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

This commit is contained in:
Hombre 2010-12-11 03:47:56 +01:00
parent 791fabf64b
commit a76ebbcd78
4 changed files with 22 additions and 15 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

View File

@ -215,7 +215,7 @@ void CurveEditorGroup::newLine() {
int j = numberOfPackedCurve; int j = numberOfPackedCurve;
for (int i = (int)(curveEditors.size())-1; i >= j; i--) 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++; numberOfPackedCurve++;
} }

View File

@ -28,13 +28,17 @@ extern Glib::ustring argv0;
PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label) { PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label) {
button = thisButton; button = thisButton;
hasMenu = false; hasMenu = false;
menuSymbol = 0; imageContainer = Gtk::manage( new Gtk::HBox(false, 0));
imageContainer = Gtk::manage( new Gtk::HBox()); button->set_relief (Gtk::RELIEF_NORMAL);
button->set_border_width (0);
button->add(*imageContainer); button->add(*imageContainer);
if (label.size()) { if (label.size()) {
Gtk::Label* buttonLabel = Gtk::manage ( new Gtk::Label(label + " ") ); Gtk::Label* buttonLabel = Gtk::manage ( new Gtk::Label(label + " ") );
imageContainer->pack_start(*buttonLabel, Gtk::PACK_SHRINK, 0); 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 // Create the list entry
imagePaths.clear(); imagePaths.clear();
images.clear(); images.clear();
@ -56,7 +60,6 @@ PopUpCommon::~PopUpCommon () {
delete *i; delete *i;
} }
if (menu) delete menu; if (menu) delete menu;
if (menuSymbol) delete menuSymbol;
if (buttonImage) delete buttonImage; 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); imageContainer->pack_start(*buttonImage,Gtk::PACK_EXPAND_WIDGET);
selected = 0; selected = 0;
} }
newItem->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &PopUpCommon::entrySelected), currPos-1)); // When there is at least 1 choice, we add the arrow button
menu->attach (*newItem, 0, 1, currPos-1, currPos); if (images.size() == 1) {
// When there is at least 2 choice, we add the RMB connector Gtk::Button* arrowButton = Gtk::manage( new Gtk::Button() );
if (images.size() == 2) { Gtk::Arrow* arrowObject = Gtk::manage( new Gtk::Arrow(Gtk::ARROW_DOWN, Gtk::SHADOW_NONE) );
button->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &PopUpCommon::showMenu) ); arrowButton->add(*arrowObject); //menuSymbol);
menuSymbol = new Gtk::Image(safe_locale_from_utf8(argv0+"/images/menuSymbol.png")); arrowButton->set_relief (Gtk::RELIEF_NONE);
imageContainer->pack_start(*menuSymbol,Gtk::PACK_SHRINK, 2); 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; 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 // The item has been created
added = true; added = true;
} }
@ -127,7 +134,7 @@ void PopUpCommon::show() {
menu->reposition(); menu->reposition();
setButtonHint(); setButtonHint();
menu->show_all(); menu->show_all();
button->show_all(); buttonGroup->show_all();
} }
void PopUpCommon::setButtonHint() { void PopUpCommon::setButtonHint() {
@ -137,7 +144,7 @@ void PopUpCommon::setButtonHint() {
} }
void PopUpCommon::showMenu(GdkEventButton* event) { 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) { void PopUpCommon::set_tooltip_text (const Glib::ustring &text) {

View File

@ -31,6 +31,7 @@ class PopUpCommon {
public: public:
typedef sigc::signal<void, int> type_signal_changed; typedef sigc::signal<void, int> type_signal_changed;
type_signal_changed 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 (Gtk::Button* button, const Glib::ustring& label = "");
~PopUpCommon (); ~PopUpCommon ();
@ -45,7 +46,7 @@ private:
type_signal_changed message; 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... That's why we store entries strings in sItems, but it would be nice to get ride of it...
*/ */
std::vector<Glib::ustring> sItems; std::vector<Glib::ustring> sItems;
@ -54,7 +55,6 @@ private:
std::vector<Gtk::ImageMenuItem*> items; std::vector<Gtk::ImageMenuItem*> items;
Glib::ustring buttonHint; Glib::ustring buttonHint;
Gtk::Image* buttonImage; Gtk::Image* buttonImage;
Gtk::Image* menuSymbol;
Gtk::HBox* imageContainer; Gtk::HBox* imageContainer;
Gtk::Menu* menu; Gtk::Menu* menu;
Gtk::Button* button; Gtk::Button* button;