diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2019-05-09 14:36:55 +0000 |
|---|---|---|
| committer | Jabiertxof <jabier.arraiza@marker.es> | 2019-05-09 14:49:14 +0000 |
| commit | c22a12014210626604962233022d3148c0d63e45 (patch) | |
| tree | 82641e4006364850da4b1666a28ee8ca349ed3cb | |
| parent | Fix some symbolic icons II (diff) | |
| download | inkscape-c22a12014210626604962233022d3148c0d63e45.tar.gz inkscape-c22a12014210626604962233022d3148c0d63e45.zip | |
Add styling and options to hangle keyboard on LPE dialog
| -rw-r--r-- | share/ui/style.css | 514 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.cpp | 123 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.h | 7 |
3 files changed, 377 insertions, 267 deletions
diff --git a/share/ui/style.css b/share/ui/style.css index 037d27191..e7085c508 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -1,6 +1,6 @@ - /* GTK3 WIDGET STYLING */ + /* * Keep in order of: * General -> Specific @@ -13,6 +13,7 @@ * As of Gtk 3.20, you cannot use widget names. */ + /* Standard theme based colors. Prefer these. * * @theme_bg_color @@ -26,273 +27,315 @@ * */ + /* Our own custom shades... better not to use. * Lightest to darkest based on linear rgb. */ - @define-color bg_color0 #ffffff; /* White */ - @define-color bg_color05 #f8f8f8; /* Slightly off white */ - @define-color bg_color1 #f0f0f0; - @define-color bg_color2 #e0e0e0; - @define-color bg_color3 #d0d0d0; - @define-color bg_color4 #bbbbbb; /* 50% Gray */ - @define-color bg_color5 #a5a5a5; - @define-color bg_color6 #898989; - @define-color bg_color7 #636363; - @define-color bg_color8 #000000; /* Black */ - - /* Inkscape CSS helper - * to add a class to a widget do some thing like - * widget->get_style_context()->add_class("mycoolclass"); - * we define a bunch of helper CSS styles - * Ecah Inkscape desktop has a class in top level window - * call "dark" so you can style using 2 clases with or without - * "dark" by this way you can always know if the UI is in dark mode - * Also added some helper clases: - * ::::::: Color based - * ::::::: apply to colors - * ::::::: scope widget and all his childs - * ".colordefault" use default window color - * ".colorinverse" invert window colors - * ".colorbright" force bright colors no matter the UI is dark or bright - * ".colordark" same but dark - * ::::::: Background based - * ::::::: apply to backgrounds - * ::::::: scope widget and all his childs - * ".backgrounddefault" use default window color - * ".backgroundinverse" invert window colors - * ".backgroundbright" force bright colors no matter the UI is dark or bright - * ".backgrounddark" same but daLPESelectorButtonBoxk - * :::::::: Icon Based. - * :::::::: apply to color (foreground) - * :::::::: scope widget and all nested images - * ".iconsymbolic" Force icon symbolic - * ".iconregular" Force colorful icons - * ".iconcolordefault" Theme color default - * ".iconcolorinverse" Inverse color from theme - * ".iconcolorbright, Force clear icon - * ".iconcolordark" Force dark icon - * ".iconcolornamed" Icon in prefs selected color; - * ".iconcolornamedinverse" Icon in inverse color from prefs" - * :::::::: Combo box. - * "..combobright" Combo bright - * ".regular ..." Inkscape is in regular icon mode - * ".symbolic ..." Inkscape is in symbolic icon mode - */ - - .colordefault, - .colordefault *{ - color: @theme_fg_color; - } - - .colorinverse, - .colorinverse *{ - color: @theme_bg_color; - } - .colorbright, - .colorbright *{ - color: @theme_fg_color; - } - - .dark .colorbright, - .dark .colorbright *{ - color: @theme_bg_color; - } - .colordark, - .colordark *{ - color: @theme_bg_color; - } - .dark .colordark, - .dark .colordark *{ - color: @theme_fg_color; - } - .backgrounddefault, - .backgrounddefault *{ - background-color: @theme_bg_color; - background-image:image(@theme_bg_color); - } - .backgroundinverse, - .backgroundinverse *{ - background-color: @theme_fg_color; - background-image:image(@theme_fg_color); - } - .backgroundbright, - .backgroundbright *{ - background-color: @theme_bg_color; - background-image:image(@theme_bg_color); - } - .dark .backgroundbright, - .dark .backgroundbright *{ - background-color: @theme_fg_color; - background-image:image(@theme_fg_color); - } - .backgrounddark, - .backgrounddark *{ - background-color: @theme_fg_color; - background-image:image(@theme_fg_color); - } - .dark .backgrounddark, - .dark .backgrounddark *{ - background-color: @theme_bg_color; - background-image:image(@theme_bg_color); - } - .iconsymbolic, - .iconsymbolic image{ - -gtk-icon-style: symbolic; - } - .iconregular, - .iconregular image{ - -gtk-icon-style: regular; - } - - .combobright *{ - color: @theme_text_color; - background-color: @theme_base_color; - background-image:image(@theme_base_color); - border-radius:4px; - } - .dark .combobright *{ - color: @theme_base_color; - background-color: @theme_text_color; - background-image:image(@theme_text_color); - border-radius:4px; - } - - - /* 'GtkWidget' for Gtk <= 3.18 */ - /* 'widget' for Gtk <= 3.19.2 */ - GtkWidget, widget { - /* font-size: 12pt; */ - } - - GtkSpinButton { - padding: 0; - outline-style : none; - } - - spinbutton { - padding: 0; - outline-style : none; - } - - GtkSpinButton entry { - padding-left: 2px; - padding-right:0; - } - - spinbutton entry { - padding-left: 2px; - padding-right:0; - } - - GtkSpinButton undershoot { - outline-style : none; - } - - spinbutton undershoot { - outline-style : none; - } +@define-color bg_color0 #ffffff; + +/* White */ + +@define-color bg_color05 #f8f8f8; + +/* Slightly off white */ + +@define-color bg_color1 #f0f0f0; +@define-color bg_color2 #e0e0e0; +@define-color bg_color3 #d0d0d0; +@define-color bg_color4 #bbbbbb; + +/* 50% Gray */ + +@define-color bg_color5 #a5a5a5; +@define-color bg_color6 #898989; +@define-color bg_color7 #636363; +@define-color bg_color8 #000000; + +/* Black */ + + +/* Inkscape CSS helper + * to add a class to a widget do some thing like + * widget->get_style_context()->add_class("mycoolclass"); + * we define a bunch of helper CSS styles + * Ecah Inkscape desktop has a class in top level window + * call "dark" so you can style using 2 clases with or without + * "dark" by this way you can always know if the UI is in dark mode + * Also added some helper clases: + * ::::::: Color based + * ::::::: apply to colors + * ::::::: scope widget and all his childs + * ".colordefault" use default window color + * ".colorinverse" invert window colors + * ".colorbright" force bright colors no matter the UI is dark or bright + * ".colordark" same but dark + * ::::::: Background based + * ::::::: apply to backgrounds + * ::::::: scope widget and all his childs + * ".backgrounddefault" use default window color + * ".backgroundinverse" invert window colors + * ".backgroundbright" force bright colors no matter the UI is dark or bright + * ".backgrounddark" same but daLPESelectorButtonBoxk + * :::::::: Icon Based. + * :::::::: apply to color (foreground) + * :::::::: scope widget and all nested images + * ".iconsymbolic" Force icon symbolic + * ".iconregular" Force colorful icons + * ".iconcolordefault" Theme color default + * ".iconcolorinverse" Inverse color from theme + * ".iconcolorbright, Force clear icon + * ".iconcolordark" Force dark icon + * ".iconcolornamed" Icon in prefs selected color; + * ".iconcolornamedinverse" Icon in inverse color from prefs" + * :::::::: Combo box. + * "..combobright" Combo bright + * ".regular ..." Inkscape is in regular icon mode + * ".symbolic ..." Inkscape is in symbolic icon mode + */ + +.colordefault, +.colordefault * { + color: @theme_fg_color; +} + +.colorinverse, +.colorinverse * { + color: @theme_bg_color; +} + +.colorbright, +.colorbright * { + color: @theme_fg_color; +} + +.dark .colorbright, +.dark .colorbright * { + color: @theme_bg_color; +} + +.colordark, +.colordark * { + color: @theme_bg_color; +} + +.dark .colordark, +.dark .colordark * { + color: @theme_fg_color; +} + +.backgrounddefault, +.backgrounddefault * { + background-color: @theme_bg_color; + background-image: image(@theme_bg_color); +} + +.backgroundinverse, +.backgroundinverse * { + background-color: @theme_fg_color; + background-image: image(@theme_fg_color); +} + +.backgroundbright, +.backgroundbright * { + background-color: @theme_bg_color; + background-image: image(@theme_bg_color); +} + +.dark .backgroundbright, +.dark .backgroundbright * { + background-color: @theme_fg_color; + background-image: image(@theme_fg_color); +} + +.backgrounddark, +.backgrounddark * { + background-color: @theme_fg_color; + background-image: image(@theme_fg_color); +} + +.dark .backgrounddark, +.dark .backgrounddark * { + background-color: @theme_bg_color; + background-image: image(@theme_bg_color); +} + +.iconsymbolic, +.iconsymbolic image { + -gtk-icon-style: symbolic; +} + +.iconregular, +.iconregular image { + -gtk-icon-style: regular; +} + +.combobright * { + color: @theme_text_color; + background-color: @theme_base_color; + background-image: image(@theme_base_color); + border-radius: 4px; +} + +.dark .combobright * { + color: @theme_base_color; + background-color: @theme_text_color; + background-image: image(@theme_text_color); + border-radius: 4px; +} + + +/* 'GtkWidget' for Gtk <= 3.18 */ + + +/* 'widget' for Gtk <= 3.19.2 */ + +GtkWidget, +widget { + /* font-size: 12pt; */ +} + +GtkSpinButton { + padding: 0; + outline-style: none; +} + +spinbutton { + padding: 0; + outline-style: none; +} GtkSpinButton entry { padding-left: 2px; - padding-right:0; + padding-right: 0; } spinbutton entry { padding-left: 2px; - padding-right:0; + padding-right: 0; } GtkSpinButton undershoot { - outline-style : none; + outline-style: none; } spinbutton undershoot { - outline-style : none; -} - -.lpeactive #LPESelectorEffectFavTop{ - opacity:0; + outline-style: none; } -.lpefav{ - background-color: @theme_base_color; - padding-bottom:0; +GtkSpinButton entry { + padding-left: 2px; + padding-right: 0; } -.lpename{ - font-size:16px; - margin-bottom:5px; +spinbutton entry { + padding-left: 2px; + padding-right: 0; } -.lpeinfo{ - font-size:16px; - padding:20px; +GtkSpinButton undershoot { + outline-style: none; } -.lpedisabled{ - opacity:0.3; +spinbutton undershoot { + outline-style: none; } #LPEDialogSelector, #LPEDialogSelector .frame, #LPEDialogSelector .searchbar { - outline-width:0; - border-width:0; + outline-width: 0; + border-width: 0; } #LPESelectorFlowBox GtkFlowBoxChild, -#LPESelectorFlowBox flowboxchild{ - border-width:0px; - border-radius:6px; - margin:10px; - padding:10px; - margin-bottom:0px; - padding-bottom:10px; - outline:none; +#LPESelectorFlowBox flowboxchild { + border-width: 0px; + border-radius: 6px; + margin: 10px; + padding: 10px; + margin-bottom: 0px; + padding-bottom: 10px; + outline: none; +} + +#LPESelectorFlowBox flowboxchild * { + color: @theme_selected_bg_color; +} + +#LPESelectorFlowBox flowboxchild:selected image, +#LPESelectorFlowBox flowboxchild:selected label { + background-color: @theme_selected_bg_color; + color: @theme_selected_fg_color; + background-image: image(@theme_selected_bg_color); +} + +#LPESelectorFlowBox *:selected #LPESelectorEffectFavTop, +#LPESelectorFlowBox *:selected:focus #LPESelectorEffectFavTop { + opacity: 0; +} + +#LPESelectorFlowBox .lpename { + font-size: 16px; + margin-bottom: 5px; +} + +#LPESelectorFlowBox .lpeinfo { + font-size: 16px; + padding: 20px; +} + +#LPESelectorFlowBox .lpedisabled { + opacity: 0.3; +} + +#LPESelectorEffectInfoPop { + padding: 15px; } -#LPEExperimental image{ -color: transparent; +#LPESelectorEffectInfoName { + font-weight: bold; + padding: 15px; } -#LPESelectorEffectInfoPop{ -padding:15px; +#LPEExperimental image { + color: transparent; } -#LPESelectorEffectInfoName{ -font-weight:bold; -padding:15px; +#LPEDialogSelector .searchbar entry image, +#LPEDialogSelector .searchbar label, +#LPEDialogSelector .searchbar #LPESelectorEffectFavShowImage { + color: @theme_selected_bg_color; } -#XMLFlow .toggle{ - min-width:18px; - padding-left:6px; - padding-right:6px; - padding-top:0; - padding-bottom:0; +#XMLFlow .toggle { + min-width: 18px; + padding-left: 6px; + padding-right: 6px; + padding-top: 0; + padding-bottom: 0; } SPRuler { background-color: @theme_bg_color; - color: @theme_fg_color; + color: @theme_fg_color; } ruler-widget { background-color: @theme_bg_color; - color: @theme_fg_color; + color: @theme_fg_color; } + /* The actual canvas (Inkscape's drawing area). */ + SPCanvas { background-color: white; } -combobox window.popup scrolledwindow treeview separator { -} +combobox window.popup scrolledwindow treeview separator {} -#font_selector_family { -} +#font_selector_family {} #TextFontFamilyAction_combobox { -GtkComboBox-appears-as-list: true; @@ -304,33 +347,44 @@ combobox window.popup scrolledwindow treeview separator { padding: 0; } + /* Keep palette scrollbar from generating warnings. */ + #PreviewHolderScroller .vertical slider { min-height: 15px; } + /* Override minimum size of container children for palette. */ + #ColorItemPreview { min-height: 5px; - min-width: 5px; + min-width: 5px; } + /* Reduce width of Fill and Stroke dialog */ + #ColorModeButton { padding-left: 0; padding-right: 0; } + /* Reduce width of +/- buttons. */ -.up, .down { + +.up, +.down { padding-left: 0; padding-right: 0; } + /* InkSpinScale */ + #InkSpinScale { - background : @theme_bg_color; - border : 1px black; + background: @theme_bg_color; + border: 1px black; border-radius: 3px; padding: 0px; } @@ -341,23 +395,26 @@ combobox window.popup scrolledwindow treeview separator { border-radius: 0 3px 3px 0; box-shadow: none; padding: 0 0 0 1px; - min-height : 10px; + min-height: 10px; } + /* Hide slider */ + #InkSpinScale slider { background: none; - border: none; - outline: none; - min-width: 0px; + border: none; + outline: none; + min-width: 0px; min-height: 0px; - padding: 0px; - margin: 0px; + padding: 0px; + margin: 0px; } -#InkSpinScale slider, #InkSpinScale highlight { - border-top-right-radius : 0; - border-bottom-right-radius : 0; +#InkSpinScale slider, +#InkSpinScale highlight { + border-top-right-radius: 0; + border-bottom-right-radius: 0; } #InkSpinScale scale { @@ -369,11 +426,10 @@ combobox window.popup scrolledwindow treeview separator { } #InkSpinScale box.active { - box-shadow: 0 0 0 1px rgb(74,144,217); + box-shadow: 0 0 0 1px rgb(74, 144, 217); } #InkSpinScale spinbutton entry { - padding : 0 ; - outline-style : none; -} - + padding: 0; + outline-style: none; +}
\ No newline at end of file diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index 83761c36e..1b99e9609 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -98,9 +98,9 @@ LivePathEffectAdd::LivePathEffectAdd() _builder->get_widget("LPESelectorEffectEventFavShow", _LPESelectorEffectEventFavShow); _builder->get_widget("LPESelectorEffectInfoEventBox", _LPESelectorEffectInfoEventBox); _LPEFilter->signal_search_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_search)); - _LPESelectorFlowBox->signal_child_activated().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_activate)); _LPEDialogSelector->add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | - Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); + Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::KEY_PRESS_MASK); + _LPESelectorFlowBox->signal_set_focus_child().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_focus)); for (int i = 0; i < static_cast<int>(converter._length); ++i) { Glib::RefPtr<Gtk::Builder> builder_effect; try { @@ -118,7 +118,7 @@ LivePathEffectAdd::LivePathEffectAdd() Gtk::EventBox *LPESelectorEffectEventExpander; builder_effect->get_widget("LPESelectorEffectEventExpander", LPESelectorEffectEventExpander); LPESelectorEffectEventExpander->signal_button_press_event().connect( - sigc::bind<Glib::RefPtr<Gtk::Builder>>(sigc::mem_fun(*this, &LivePathEffectAdd::expand), builder_effect)); + sigc::bind<Glib::RefPtr<Gtk::Builder>>(sigc::mem_fun(*this, &LivePathEffectAdd::expand), builder_effect)); LPESelectorEffectEventExpander->signal_enter_notify_event().connect(sigc::bind<GtkWidget *>( sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffect->gobj()))); LPESelectorEffectEventExpander->signal_leave_notify_event().connect(sigc::bind<GtkWidget *>( @@ -179,10 +179,15 @@ LivePathEffectAdd::LivePathEffectAdd() LPESelectorEffect->signal_leave_notify_event().connect(sigc::bind<GtkWidget *>( sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffect->gobj()))); _LPESelectorFlowBox->insert(*LPESelectorEffect, i); + LPESelectorEffect->get_parent()->signal_key_press_event().connect( + sigc::bind<Glib::RefPtr<Gtk::Builder>, const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *>( + sigc::mem_fun(*this, &LivePathEffectAdd::on_press_enter), builder_effect, &converter.data(i))); LPESelectorEffect->get_parent()->get_style_context()->add_class( ("LPEIndex" + Glib::ustring::format(i)).c_str()); } + _LPESelectorFlowBox->set_activate_on_single_click(false); _visiblelpe = _LPESelectorFlowBox->get_children().size(); + _firstlpe = 0; _LPEInfo->set_visible(false); _LPESelectorEffectEventFavShow->signal_enter_notify_event().connect(sigc::bind<GtkWidget *>( sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(_LPESelectorEffectEventFavShow->gobj()))); @@ -204,50 +209,51 @@ LivePathEffectAdd::LivePathEffectAdd() window->get_size(width, height); _LPEDialogSelector->resize(std::min(width - 300, 1440), std::min(height - 300, 900)); _LPEDialogSelector->set_transient_for(*window); + _LPESelectorFlowBox->set_focus_vadjustment(_LPEScrolled->get_vadjustment()); _LPEDialogSelector->show_all_children(); } const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *LivePathEffectAdd::getActiveData() { return instance()._to_add; } -void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child) + +void LivePathEffectAdd::on_focus(Gtk::Widget *widget) { - for (auto i : _LPESelectorFlowBox->get_children()) { - Gtk::FlowBoxChild *leitem = dynamic_cast<Gtk::FlowBoxChild *>(i); - leitem->get_style_context()->remove_class("lpeactive"); - leitem->get_style_context()->remove_class("colorinverse"); - leitem->get_style_context()->remove_class("backgroundinverse"); - Gtk::EventBox *eventbox = dynamic_cast<Gtk::EventBox *>(leitem->get_child()); + Gtk::FlowBoxChild *child = dynamic_cast<Gtk::FlowBoxChild *>(widget); + if (child) { + for (auto i : _LPESelectorFlowBox->get_children()) { + Gtk::FlowBoxChild *leitem = dynamic_cast<Gtk::FlowBoxChild *>(i); + Gtk::EventBox *eventbox = dynamic_cast<Gtk::EventBox *>(leitem->get_child()); + if (eventbox) { + Gtk::Box *box = dynamic_cast<Gtk::Box *>(eventbox->get_child()); + if (box) { + std::vector<Gtk::Widget *> contents = box->get_children(); + Gtk::Box *actions = dynamic_cast<Gtk::Box *>(contents[5]); + if (actions) { + actions->set_visible(false); + } + Gtk::EventBox *expander = dynamic_cast<Gtk::EventBox *>(contents[4]); + if (expander) { + expander->set_visible(true); + } + } + } + } + Gtk::EventBox *eventbox = dynamic_cast<Gtk::EventBox *>(child->get_child()); if (eventbox) { Gtk::Box *box = dynamic_cast<Gtk::Box *>(eventbox->get_child()); if (box) { std::vector<Gtk::Widget *> contents = box->get_children(); - Gtk::Box *actions = dynamic_cast<Gtk::Box *>(contents[5]); - if (actions) { - actions->set_visible(false); - } Gtk::EventBox *expander = dynamic_cast<Gtk::EventBox *>(contents[4]); if (expander) { - expander->set_visible(true); + expander->set_visible(false); } } } - } - Gtk::EventBox *eventbox = dynamic_cast<Gtk::EventBox *>(child->get_child()); - if (eventbox) { - Gtk::Box *box = dynamic_cast<Gtk::Box *>(eventbox->get_child()); - if (box) { - std::vector<Gtk::Widget *> contents = box->get_children(); - Gtk::EventBox *expander = dynamic_cast<Gtk::EventBox *>(contents[4]); - if (expander) { - expander->set_visible(false); - } - } - } - child->get_style_context()->add_class("lpeactive"); - child->get_style_context()->add_class("colorinverse"); - child->get_style_context()->add_class("backgroundinverse"); + child->show_all_children(); + _LPESelectorFlowBox->select_child(*child); + } } bool LivePathEffectAdd::pop_description(GdkEventCrossing *evt, Glib::RefPtr<Gtk::Builder> builder_effect) @@ -303,6 +309,8 @@ bool LivePathEffectAdd::fav_toggler(GdkEventButton *evt, Glib::RefPtr<Gtk::Build LPESelectorEffectFav->set_from_icon_name("draw-star-outline", Gtk::IconSize(25)); sp_remove_fav(LPEName->get_text()); LPESelectorEffect->get_parent()->get_style_context()->remove_class("lpefav"); + LPESelectorEffect->get_parent()->get_style_context()->add_class("lpenormal"); + LPESelectorEffect->get_parent()->get_style_context()->add_class("lpe"); if (_showfavs) { reload_effect_list(); } @@ -312,6 +320,8 @@ bool LivePathEffectAdd::fav_toggler(GdkEventButton *evt, Glib::RefPtr<Gtk::Build LPESelectorEffectFav->set_from_icon_name("draw-star", Gtk::IconSize(25)); sp_add_fav(LPEName->get_text()); LPESelectorEffect->get_parent()->get_style_context()->add_class("lpefav"); + LPESelectorEffect->get_parent()->get_style_context()->remove_class("lpenormal"); + LPESelectorEffect->get_parent()->get_style_context()->add_class("lpe"); } } return true; @@ -340,7 +350,7 @@ bool LivePathEffectAdd::apply(GdkEventButton *evt, Glib::RefPtr<Gtk::Builder> bu if (LPESelectorEffect->get_parent()->get_style_context()->has_class("lpedisabled")) { Gtk::FlowBoxChild *child = dynamic_cast<Gtk::FlowBoxChild *>(LPESelectorEffect->get_parent()); if (child) { - on_activate(child); + child->grab_focus(); } return true; } @@ -350,13 +360,35 @@ bool LivePathEffectAdd::apply(GdkEventButton *evt, Glib::RefPtr<Gtk::Builder> bu return true; } +bool LivePathEffectAdd::on_press_enter(GdkEventKey *key, Glib::RefPtr<Gtk::Builder> builder_effect, + const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *to_add) +{ + if (key->keyval == 65293 || key->keyval == 65421) { + _to_add = to_add; + Gtk::EventBox *LPESelectorEffect; + builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); + if (LPESelectorEffect->get_parent()->get_style_context()->has_class("lpedisabled")) { + Gtk::FlowBoxChild *child = dynamic_cast<Gtk::FlowBoxChild *>(LPESelectorEffect->get_parent()); + if (child) { + child->grab_focus(); + } + return true; + } + _applied = true; + _LPEDialogSelector->response(Gtk::RESPONSE_APPLY); + _LPEDialogSelector->hide(); + return true; + } + return false; +} + bool LivePathEffectAdd::expand(GdkEventButton *evt, Glib::RefPtr<Gtk::Builder> builder_effect) { Gtk::EventBox *LPESelectorEffect; builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); Gtk::FlowBoxChild *child = dynamic_cast<Gtk::FlowBoxChild *>(LPESelectorEffect->get_parent()); if (child) { - on_activate(child); + child->grab_focus(); } return true; } @@ -406,12 +438,18 @@ bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child) } if (_LPEFilter->get_text().length() < 1) { _visiblelpe++; + if(_firstlpe == 0){ + _firstlpe = child->get_index(); + } return true; } if (lpename) { size_t s = lpename->get_text().uppercase().find(_LPEFilter->get_text().uppercase(), 0); if (s != -1) { _visiblelpe++; + if(_firstlpe == 0){ + _firstlpe = child->get_index(); + } return true; } } @@ -420,6 +458,9 @@ bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child) size_t s = lpedesc->get_text().uppercase().find(_LPEFilter->get_text().uppercase(), 0); if (s != -1) { _visiblelpe++; + if(_firstlpe == 0){ + _firstlpe = child->get_index(); + } return true; } } @@ -436,6 +477,7 @@ void LivePathEffectAdd::reload_effect_list() _LPEExperimental->get_style_context()->remove_class("active"); } */ _visiblelpe = 0; + _firstlpe = 0; _LPESelectorFlowBox->invalidate_filter(); if (_showfavs) { if (_visiblelpe == 0) { @@ -457,6 +499,7 @@ void LivePathEffectAdd::reload_effect_list() void LivePathEffectAdd::on_search() { _visiblelpe = 0; + _firstlpe = 0; _LPESelectorFlowBox->invalidate_filter(); if (_showfavs) { if (_visiblelpe == 0) { @@ -471,6 +514,7 @@ void LivePathEffectAdd::on_search() } _LPEInfo->set_visible(true); _LPEInfo->get_style_context()->add_class("lpeinfowarn"); + _LPESelectorFlowBox->select_child(*_LPESelectorFlowBox->get_child_at_index(_firstlpe)); } } else { if (_visiblelpe == 0) { @@ -480,6 +524,7 @@ void LivePathEffectAdd::on_search() } else { _LPEInfo->set_visible(false); _LPEInfo->get_style_context()->remove_class("lpeinfowarn"); + _LPESelectorFlowBox->select_child(*_LPESelectorFlowBox->get_child_at_index(_firstlpe)); } } } @@ -504,11 +549,14 @@ int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *chi LPESelectorEffectEventFavTop->set_visible(true); LPESelectorEffectEventFavTop->show(); child1->get_style_context()->add_class("lpefav"); - } else { + child1->get_style_context()->remove_class("lpenormal"); + } else if (!sp_has_fav(name1)) { LPESelectorEffectEventFavTop->set_visible(false); LPESelectorEffectEventFavTop->hide(); child1->get_style_context()->remove_class("lpefav"); + child1->get_style_context()->add_class("lpenormal"); } + child1->get_style_context()->add_class("lpe"); } } } @@ -528,12 +576,15 @@ int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *chi if (sp_has_fav(name2)) { LPESelectorEffectEventFavTop->set_visible(true); LPESelectorEffectEventFavTop->show(); - child1->get_style_context()->add_class("lpefav"); - } else { + child2->get_style_context()->add_class("lpefav"); + child2->get_style_context()->remove_class("lpenormal"); + } else if (!sp_has_fav(name2)) { LPESelectorEffectEventFavTop->set_visible(false); LPESelectorEffectEventFavTop->hide(); - child1->get_style_context()->remove_class("lpefav"); + child2->get_style_context()->remove_class("lpefav"); + child2->get_style_context()->add_class("lpenormal"); } + child2->get_style_context()->add_class("lpe"); } } } diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h index 4ea54f5fc..ceaa41eee 100644 --- a/src/ui/dialog/livepatheffect-add.h +++ b/src/ui/dialog/livepatheffect-add.h @@ -65,12 +65,14 @@ class LivePathEffectAdd { bool on_filter(Gtk::FlowBoxChild *child); int on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *child2); void on_search(); - void on_activate(Gtk::FlowBoxChild *child); + void on_focus(Gtk::Widget *widg); bool pop_description(GdkEventCrossing *evt, Glib::RefPtr<Gtk::Builder> builder_effect); bool hide_pop_description(GdkEventCrossing *evt); bool fav_toggler(GdkEventButton *evt, Glib::RefPtr<Gtk::Builder> builder_effect); bool apply(GdkEventButton *evt, Glib::RefPtr<Gtk::Builder> builder_effect, const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *to_add); + bool on_press_enter(GdkEventKey *key, Glib::RefPtr<Gtk::Builder> builder_effect, + const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *to_add); bool expand(GdkEventButton *evt, Glib::RefPtr<Gtk::Builder> builder_effect); bool show_fav_toggler(GdkEventButton *evt); bool mouseover(GdkEventCrossing *evt, GtkWidget *wdg); @@ -104,6 +106,7 @@ private: Gtk::Label *_LPEInfo; Gtk::Box *_LPESelector; guint _visiblelpe; + guint _firstlpe; Glib::ustring _item_type; const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *_to_add; bool _showfavs; @@ -134,4 +137,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
\ No newline at end of file +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |
