diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-01-31 23:52:45 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-02-18 21:18:27 +0000 |
| commit | 6b001ac073b436c9b19441a3f31256f3a2bb7241 (patch) | |
| tree | c1f687ee3c3dea0c5f33455ac9066801330fbdfd /src | |
| parent | improving enum position (diff) | |
| download | inkscape-6b001ac073b436c9b19441a3f31256f3a2bb7241.tar.gz inkscape-6b001ac073b436c9b19441a3f31256f3a2bb7241.zip | |
Add info popup
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.cpp | 86 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.h | 5 |
2 files changed, 50 insertions, 41 deletions
diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index 886dbb38f..e72ca745d 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -26,7 +26,7 @@ namespace Dialog { LivePathEffectAdd::LivePathEffectAdd() : converter(Inkscape::LivePathEffect::LPETypeConverter) { - const std::string req_widgets[] = { "LPEDialogSelector", "LPESelector", "LPESelectorFlowBox" }; + add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK ); Glib::ustring gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add.ui"); try { _builder = Gtk::Builder::create_from_file(gladefile); @@ -34,62 +34,36 @@ LivePathEffectAdd::LivePathEffectAdd() g_warning("Glade file loading failed for filter effect dialog"); return; } - - Gtk::Object *test; - for (std::string w : req_widgets) { - _builder->get_widget(w, test); - if (!test) { - g_warning("Required widget %s does not exist", w.c_str()); - return; - } - } _builder->get_widget("LPEDialogSelector", _LPEDialogSelector); - /** - * Initialize Effect list - */ _builder->get_widget("LPESelectorFlowBox", _LPESelectorFlowBox); + _builder->get_widget("LPESelectorEffectInfo", _LPESelectorEffectInfo); _builder->get_widget("LPEFilter", _LPEFilter); _builder->get_widget("LPEInfo", _LPEInfo); _LPEFilter->signal_search_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_search)); - const std::string le_widgets[] = { "LPESelectorEffect", "LPEName", "LPEDescription" }; - Glib::ustring le_gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add-effect.ui"); + Glib::ustring effectgladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add-effect.ui"); for (int i = 0; i < static_cast<int>(converter._length); ++i) { - + Glib::RefPtr<Gtk::Builder> builder_effect; try { - _builder = Gtk::Builder::create_from_file(le_gladefile); + builder_effect = Gtk::Builder::create_from_file(effectgladefile); } catch (const Glib::Error &ex) { g_warning("Glade file loading failed for filter effect dialog"); return; } - - Gtk::Object *test; - for (std::string w : le_widgets) { - _builder->get_widget(w, test); - if (!test) { - g_warning("Required widget %s does not exist", w.c_str()); - return; - } - } const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *data = &converter.data(i); Gtk::Label *LPEName; - _builder->get_widget("LPEName", LPEName); - Glib::ustring newid = "LPEName_" + Glib::ustring::format(i); - (*LPEName).set_name(newid); - (*LPEName).set_text(converter.get_label(data->id).c_str()); + builder_effect->get_widget("LPEName", LPEName); + LPEName->set_text(converter.get_label(data->id).c_str()); Gtk::Label *LPEDescription; - _builder->get_widget("LPEDescription", LPEDescription); - newid = "LPEDescription_" + Glib::ustring::format(i); - (*LPEDescription).set_name(newid); - (*LPEDescription).set_text(converter.get_description(data->id)); + builder_effect->get_widget("LPEDescription", LPEDescription); + LPEDescription->set_text(converter.get_description(data->id)); Gtk::Image *LPEIcon; - _builder->get_widget("LPEIcon", LPEIcon); - newid = "LPEIcon_" + Glib::ustring::format(i); - (*LPEIcon).set_name(newid); - (*LPEIcon).set_from_icon_name(converter.get_icon(data->id), Gtk::BuiltinIconSize(Gtk::ICON_SIZE_DIALOG)); + builder_effect->get_widget("LPEIcon", LPEIcon); + LPEIcon->set_from_icon_name(converter.get_icon(data->id), Gtk::BuiltinIconSize(Gtk::ICON_SIZE_DIALOG)); + Gtk::EventBox *LPESelectorEffectInfoLauncher; + builder_effect->get_widget("LPESelectorEffectInfoLauncher", LPESelectorEffectInfoLauncher); + LPESelectorEffectInfoLauncher->signal_button_press_event().connect(sigc::bind<Glib::RefPtr<Gtk::Builder> >(sigc::mem_fun(*this, &LivePathEffectAdd::pop_description), builder_effect)); Gtk::Box *LPESelectorEffect; - _builder->get_widget("LPESelectorEffect", LPESelectorEffect); - newid = "LPESelectorEffect" + Glib::ustring::format(i); - (*LPESelectorEffect).set_name(newid); + builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); _LPESelectorFlowBox->insert(*LPESelectorEffect, i); } _visiblelpe = _LPESelectorFlowBox->get_children().size(); @@ -121,6 +95,36 @@ void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child) child->show_all_children(); } +bool LivePathEffectAdd::pop_description(GdkEventButton* evt, Glib::RefPtr<Gtk::Builder> builder_effect) +{ + Gtk::EventBox *LPESelectorEffectInfoLauncher; + builder_effect->get_widget("LPESelectorEffectInfoLauncher", LPESelectorEffectInfoLauncher); + _LPESelectorEffectInfo->set_relative_to(*LPESelectorEffectInfoLauncher->get_children()[0]); + + Gtk::Label *LPEName; + builder_effect->get_widget("LPEName", LPEName); + Gtk::Label *LPEDescription; + builder_effect->get_widget("LPEDescription", LPEDescription); + Gtk::Image *LPEIcon; + builder_effect->get_widget("LPEIcon", LPEIcon); + + Gtk::Image *LPESelectorEffectInfoIcon; + _builder->get_widget("LPESelectorEffectInfoIcon", LPESelectorEffectInfoIcon); + LPESelectorEffectInfoIcon->set_from_icon_name(LPEIcon->get_icon_name(), Gtk::IconSize(60)); + + Gtk::Label *LPESelectorEffectInfoName; + _builder->get_widget("LPESelectorEffectInfoName", LPESelectorEffectInfoName); + LPESelectorEffectInfoName->set_text(LPEName->get_text()); + + Gtk::Label *LPESelectorEffectInfoDescription; + _builder->get_widget("LPESelectorEffectInfoDescription", LPESelectorEffectInfoDescription); + LPESelectorEffectInfoDescription->set_text(LPEDescription->get_text()); + + _LPESelectorEffectInfo->show(); + + return true; +} + bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child) { if (_LPEFilter->get_text().length() < 4) { diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h index 4127553ac..d6369a314 100644 --- a/src/ui/dialog/livepatheffect-add.h +++ b/src/ui/dialog/livepatheffect-add.h @@ -15,7 +15,10 @@ #include "live_effects/effect-enum.h" #include <gtkmm/box.h> #include <gtkmm/builder.h> +#include <gtkmm/image.h> +#include <gtkmm/eventbox.h> #include <gtkmm/dialog.h> +#include <gtkmm/popover.h> #include <gtkmm/flowbox.h> #include <gtkmm/flowboxchild.h> #include <gtkmm/label.h> @@ -53,6 +56,7 @@ public: bool on_filter(Gtk::FlowBoxChild *child); void on_search(); void on_activate(Gtk::FlowBoxChild *child); + bool pop_description(GdkEventButton* evt, Glib::RefPtr<Gtk::Builder> builder_effect); /** * Add button was clicked */ @@ -72,6 +76,7 @@ private: Gtk::Dialog *_LPEDialogSelector; Glib::RefPtr<Gtk::Builder> _builder; Gtk::FlowBox *_LPESelectorFlowBox; + Gtk::Popover *_LPESelectorEffectInfo; Gtk::SearchEntry *_LPEFilter; Gtk::Label *_LPEInfo; Gtk::Box *_LPESelector; |
