From a76ebbcd78d02c81fca47a83b9c5ea3f8a4f5fcb Mon Sep 17 00:00:00 2001 From: Hombre Date: Sat, 11 Dec 2010 03:47:56 +0100 Subject: [PATCH] popupbutton (used for the curve editors) now use only the left mouse button ; may be enhanced later with more common GTK's widget if necessary and if possible --- rtdata/images/menuSymbol.png | Bin 270 -> 0 bytes rtgui/curveeditorgroup.cc | 2 +- rtgui/popupcommon.cc | 31 +++++++++++++++++++------------ rtgui/popupcommon.h | 4 ++-- 4 files changed, 22 insertions(+), 15 deletions(-) delete mode 100644 rtdata/images/menuSymbol.png diff --git a/rtdata/images/menuSymbol.png b/rtdata/images/menuSymbol.png deleted file mode 100644 index cee408a32b6b8477ffad0db4c1552b7a6b691326..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 270 zcmeAS@N?(olHy`uVBq!ia0vp^>_9BS!3HE91=ODbDVAa<&kznEsNqQI0P;BtJR*yM z>aT+^qm#z$3ZS55iEBhjaDG}zd16s2LwR|*US?i)adKios$PCk`s{Z$Qb0xBo-U3d z8WY#{8S))65MX)U(X9}8b5ge5f%6qEaSv?tawn{q7~|aB$Mh!RU}0m#%dXEE=d>Hb zLyw)VNS-QN@as%CPr({S2F7!S$L?8{YdFq0oX~JDDm$dq(B;$3zt!UW3s&u%!MN*d z@=de3pHAxe{>x9B@hUuV#^DV=({? K&t;ucLK6U%3u96M diff --git a/rtgui/curveeditorgroup.cc b/rtgui/curveeditorgroup.cc index 051a36d23..848a6ada1 100644 --- a/rtgui/curveeditorgroup.cc +++ b/rtgui/curveeditorgroup.cc @@ -215,7 +215,7 @@ void CurveEditorGroup::newLine() { int j = numberOfPackedCurve; for (int i = (int)(curveEditors.size())-1; i >= j; i--) { - headerBox->pack_end (*curveEditors[i]->curveType, Gtk::PACK_EXPAND_WIDGET, 2); + headerBox->pack_end (*curveEditors[i]->curveType->buttonGroup, Gtk::PACK_EXPAND_WIDGET, 2); numberOfPackedCurve++; } diff --git a/rtgui/popupcommon.cc b/rtgui/popupcommon.cc index 3f24e03ed..ee6cf6d2c 100644 --- a/rtgui/popupcommon.cc +++ b/rtgui/popupcommon.cc @@ -28,13 +28,17 @@ extern Glib::ustring argv0; PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label) { button = thisButton; hasMenu = false; - menuSymbol = 0; - imageContainer = Gtk::manage( new Gtk::HBox()); + imageContainer = Gtk::manage( new Gtk::HBox(false, 0)); + button->set_relief (Gtk::RELIEF_NORMAL); + button->set_border_width (0); button->add(*imageContainer); if (label.size()) { Gtk::Label* buttonLabel = Gtk::manage ( new Gtk::Label(label + " ") ); imageContainer->pack_start(*buttonLabel, Gtk::PACK_SHRINK, 0); } + // Create the global container and put the button in it + buttonGroup = Gtk::manage( new Gtk::HBox(false, 0)); + buttonGroup->pack_start(*button, Gtk::PACK_EXPAND_WIDGET, 0); // Create the list entry imagePaths.clear(); images.clear(); @@ -56,7 +60,6 @@ PopUpCommon::~PopUpCommon () { delete *i; } if (menu) delete menu; - if (menuSymbol) delete menuSymbol; if (buttonImage) delete buttonImage; } @@ -85,15 +88,19 @@ bool PopUpCommon::addEntry (Glib::ustring imagePath, Glib::ustring label) { imageContainer->pack_start(*buttonImage,Gtk::PACK_EXPAND_WIDGET); selected = 0; } - newItem->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &PopUpCommon::entrySelected), currPos-1)); - menu->attach (*newItem, 0, 1, currPos-1, currPos); - // When there is at least 2 choice, we add the RMB connector - if (images.size() == 2) { - button->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &PopUpCommon::showMenu) ); - menuSymbol = new Gtk::Image(safe_locale_from_utf8(argv0+"/images/menuSymbol.png")); - imageContainer->pack_start(*menuSymbol,Gtk::PACK_SHRINK, 2); + // When there is at least 1 choice, we add the arrow button + if (images.size() == 1) { + Gtk::Button* arrowButton = Gtk::manage( new Gtk::Button() ); + Gtk::Arrow* arrowObject = Gtk::manage( new Gtk::Arrow(Gtk::ARROW_DOWN, Gtk::SHADOW_NONE) ); + arrowButton->add(*arrowObject); //menuSymbol); + arrowButton->set_relief (Gtk::RELIEF_NONE); + arrowButton->set_border_width (0); + buttonGroup->pack_start(*arrowButton,Gtk::PACK_SHRINK, 0); + arrowButton->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &PopUpCommon::showMenu) ); hasMenu = true; } + newItem->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &PopUpCommon::entrySelected), currPos-1)); + menu->attach (*newItem, 0, 1, currPos-1, currPos); // The item has been created added = true; } @@ -127,7 +134,7 @@ void PopUpCommon::show() { menu->reposition(); setButtonHint(); menu->show_all(); - button->show_all(); + buttonGroup->show_all(); } void PopUpCommon::setButtonHint() { @@ -137,7 +144,7 @@ void PopUpCommon::setButtonHint() { } void PopUpCommon::showMenu(GdkEventButton* event) { - if (event->button == 3) menu->popup(event->button, event->time); + if (event->button == 1) menu->popup(event->button, event->time); } void PopUpCommon::set_tooltip_text (const Glib::ustring &text) { diff --git a/rtgui/popupcommon.h b/rtgui/popupcommon.h index 6bd8258f2..da88f7d35 100644 --- a/rtgui/popupcommon.h +++ b/rtgui/popupcommon.h @@ -31,6 +31,7 @@ class PopUpCommon { public: typedef sigc::signal type_signal_changed; type_signal_changed signal_changed(); + Gtk::HBox* buttonGroup; // this is the widget to be packed PopUpCommon (Gtk::Button* button, const Glib::ustring& label = ""); ~PopUpCommon (); @@ -45,7 +46,7 @@ private: type_signal_changed message; /* - TODO: MenuItem::get_label() seems to be buggy : it doesn't return any string, or an empty string !? + TODO: MenuItem::get_label() doesn't return any string, or an empty string !? That's why we store entries strings in sItems, but it would be nice to get ride of it... */ std::vector sItems; @@ -54,7 +55,6 @@ private: std::vector items; Glib::ustring buttonHint; Gtk::Image* buttonImage; - Gtk::Image* menuSymbol; Gtk::HBox* imageContainer; Gtk::Menu* menu; Gtk::Button* button;