From db598f3d89b27bef694c217a11e13cc002cc8ec6 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Wed, 27 Mar 2019 20:03:52 +0100 Subject: Allow add LPE with one click --- src/ui/dialog/livepatheffect-add.cpp | 40 ++++++++++++++++++++++++++++++++---- src/ui/dialog/livepatheffect-add.h | 2 ++ 2 files changed, 38 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index 452138aa0..02578efab 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -120,6 +120,14 @@ LivePathEffectAdd::LivePathEffectAdd() LPESelectorEffect->signal_button_press_event().connect( sigc::bind, const LivePathEffect::EnumEffectData *>( sigc::mem_fun(*this, &LivePathEffectAdd::apply), builder_effect, &converter.data(i))); + Gtk::EventBox *LPESelectorEffectEventExpander; + builder_effect->get_widget("LPESelectorEffectEventExpander", LPESelectorEffectEventExpander); + LPESelectorEffectEventExpander->signal_button_press_event().connect( + sigc::bind>(sigc::mem_fun(*this, &LivePathEffectAdd::expand), builder_effect)); + LPESelectorEffectEventExpander->signal_enter_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffect->gobj()))); + LPESelectorEffectEventExpander->signal_leave_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffect->gobj()))); Gtk::Label *LPEName; builder_effect->get_widget("LPEName", LPEName); const Glib::ustring label = converter.get_label(data->id); @@ -219,10 +227,25 @@ void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child) Gtk::Box *box = dynamic_cast(eventbox->get_child()); if (box) { std::vector contents = box->get_children(); - Gtk::Box *actions = dynamic_cast(contents[4]); + Gtk::Box *actions = dynamic_cast(contents[5]); if (actions) { actions->set_visible(false); } + Gtk::EventBox *expander = dynamic_cast(contents[4]); + if (expander) { + expander->set_visible(true); + } + } + } + } + Gtk::EventBox *eventbox = dynamic_cast(child->get_child()); + if (eventbox) { + Gtk::Box *box = dynamic_cast(eventbox->get_child()); + if (box) { + std::vector contents = box->get_children(); + Gtk::EventBox *expander = dynamic_cast(contents[4]); + if (expander) { + expander->set_visible(false); } } } @@ -313,15 +336,13 @@ bool LivePathEffectAdd::show_fav_toggler(GdkEventButton *evt) reload_effect_list(); return true; } - bool LivePathEffectAdd::apply(GdkEventButton *evt, Glib::RefPtr builder_effect, const LivePathEffect::EnumEffectData *to_add) { _to_add = to_add; Gtk::EventBox *LPESelectorEffect; builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); - if (!LPESelectorEffect->get_parent()->get_style_context()->has_class("lpeactive") || - LPESelectorEffect->get_parent()->get_style_context()->has_class("lpedisabled")) { + if (LPESelectorEffect->get_parent()->get_style_context()->has_class("lpedisabled")) { Gtk::FlowBoxChild *child = dynamic_cast(LPESelectorEffect->get_parent()); if (child) { on_activate(child); @@ -334,6 +355,17 @@ bool LivePathEffectAdd::apply(GdkEventButton *evt, Glib::RefPtr bu return true; } +bool LivePathEffectAdd::expand(GdkEventButton *evt, Glib::RefPtr builder_effect) +{ + Gtk::EventBox *LPESelectorEffect; + builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); + Gtk::FlowBoxChild *child = dynamic_cast(LPESelectorEffect->get_parent()); + if (child) { + on_activate(child); + } + return true; +} + bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child) diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h index 938eb768a..a605967a0 100644 --- a/src/ui/dialog/livepatheffect-add.h +++ b/src/ui/dialog/livepatheffect-add.h @@ -71,6 +71,7 @@ class LivePathEffectAdd { bool fav_toggler(GdkEventButton *evt, Glib::RefPtr builder_effect); bool apply(GdkEventButton *evt, Glib::RefPtr builder_effect, const LivePathEffect::EnumEffectData *to_add); + bool expand(GdkEventButton *evt, Glib::RefPtr builder_effect); bool show_fav_toggler(GdkEventButton *evt); bool mouseover(GdkEventCrossing *evt, GtkWidget *wdg); bool mouseout(GdkEventCrossing *evt, GtkWidget *wdg); @@ -134,3 +135,4 @@ private: End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +expand \ No newline at end of file -- cgit v1.2.3