Adding a symbol to the pop up (toggle) button class. CMake you project.
This commit is contained in:
BIN
rtdata/images/menuSymbol.png
Normal file
BIN
rtdata/images/menuSymbol.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 270 B |
@@ -40,11 +40,10 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup) {
|
||||
group = ceGroup;
|
||||
|
||||
if (group && text.size())
|
||||
curveType = Gtk::manage (new PopUpToggleButton(text + ":", true));
|
||||
curveType = Gtk::manage (new PopUpToggleButton(text + ":"));
|
||||
else
|
||||
curveType = Gtk::manage (new PopUpToggleButton());
|
||||
|
||||
curveType->set_image_position(Gtk::POS_RIGHT);
|
||||
// Order set in the same order than "enum CurveType". Shouldn't change, for compatibility reason
|
||||
curveType->addEntry(argv0+"/images/curveType-linear.png", M("CURVEEDITOR_LINEAR")); // 0 Linear
|
||||
curveType->addEntry(argv0+"/images/curveType-spline.png", M("CURVEEDITOR_CUSTOM")); // 1 Spline
|
||||
|
@@ -210,7 +210,6 @@ void CurveEditorGroup::newLine() {
|
||||
curve_reset->signal_clicked().connect( sigc::mem_fun(*this, &CurveEditorGroup::curveResetPressed) );
|
||||
|
||||
headerBox->pack_end (*curve_reset, Gtk::PACK_SHRINK, 0);
|
||||
curve_reset->signal_clicked().connect( sigc::mem_fun(*this, &CurveEditorGroup::curveResetPressed) );
|
||||
}
|
||||
|
||||
int j = numberOfPackedCurve;
|
||||
|
@@ -28,10 +28,8 @@
|
||||
*
|
||||
* Parameters:
|
||||
* label = label displayed in the button
|
||||
* imRight = 0: the image is displayed at the left of the label (default)
|
||||
* 1: the image is displayed at the right of the label
|
||||
*/
|
||||
PopUpButton::PopUpButton (const Glib::ustring& label, bool imgRight) : Gtk::Button(), PopUpCommon(this, label, imgRight) { }
|
||||
PopUpButton::PopUpButton (const Glib::ustring& label) : Gtk::Button(), PopUpCommon(this, label) { }
|
||||
|
||||
void PopUpButton::show() {
|
||||
PopUpCommon::show();
|
||||
|
@@ -27,7 +27,7 @@
|
||||
class PopUpButton : public Gtk::Button, public PopUpCommon {
|
||||
|
||||
public:
|
||||
PopUpButton (const Glib::ustring& label = "", bool imgRight=false);
|
||||
PopUpButton (const Glib::ustring& label = "");
|
||||
void show ();
|
||||
void set_tooltip_text (const Glib::ustring &text);
|
||||
};
|
||||
|
@@ -23,15 +23,18 @@
|
||||
#include <popupcommon.h>
|
||||
#include <safegtk.h>
|
||||
|
||||
PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label, bool imgRight) {
|
||||
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());
|
||||
button->add(*imageContainer);
|
||||
if (label.size()) {
|
||||
hasText = true;
|
||||
button->set_label(label + " ");
|
||||
Gtk::Label* buttonLabel = Gtk::manage ( new Gtk::Label(label + " ") );
|
||||
imageContainer->pack_start(*buttonLabel, Gtk::PACK_SHRINK, 0);
|
||||
}
|
||||
else
|
||||
hasText = false;
|
||||
// Create the list entry
|
||||
imagePaths.clear();
|
||||
images.clear();
|
||||
@@ -41,7 +44,6 @@ PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label, b
|
||||
menu = 0;
|
||||
buttonImage = 0;
|
||||
buttonHint = "";
|
||||
imageRight = imgRight; // By default, image is on the left in the menu
|
||||
}
|
||||
|
||||
PopUpCommon::~PopUpCommon () {
|
||||
@@ -54,6 +56,7 @@ PopUpCommon::~PopUpCommon () {
|
||||
delete *i;
|
||||
}
|
||||
if (menu) delete menu;
|
||||
if (menuSymbol) delete menuSymbol;
|
||||
if (buttonImage) delete buttonImage;
|
||||
}
|
||||
|
||||
@@ -79,13 +82,7 @@ bool PopUpCommon::addEntry (Glib::ustring imagePath, Glib::ustring label) {
|
||||
// Create the image for the button
|
||||
buttonImage = new Gtk::Image(imagePath);
|
||||
// Use the first image by default
|
||||
if (hasText) {
|
||||
button->set_image_position(imageRight ? Gtk::POS_RIGHT : Gtk::POS_LEFT);
|
||||
button->set_image(*buttonImage);
|
||||
}
|
||||
else {
|
||||
button->add(*buttonImage);
|
||||
}
|
||||
imageContainer->pack_start(*buttonImage,Gtk::PACK_EXPAND_WIDGET);
|
||||
selected = 0;
|
||||
}
|
||||
newItem->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &PopUpCommon::entrySelected), currPos-1));
|
||||
@@ -93,6 +90,8 @@ bool PopUpCommon::addEntry (Glib::ustring imagePath, Glib::ustring label) {
|
||||
// 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);
|
||||
hasMenu = true;
|
||||
}
|
||||
// The item has been created
|
||||
@@ -128,7 +127,7 @@ void PopUpCommon::show() {
|
||||
menu->reposition();
|
||||
setButtonHint();
|
||||
menu->show_all();
|
||||
button->show();
|
||||
button->show_all();
|
||||
}
|
||||
|
||||
void PopUpCommon::setButtonHint() {
|
||||
|
@@ -32,7 +32,7 @@ public:
|
||||
typedef sigc::signal<void, int> type_signal_changed;
|
||||
type_signal_changed signal_changed();
|
||||
|
||||
PopUpCommon (Gtk::Button* button, const Glib::ustring& label = "", bool imgRight=false);
|
||||
PopUpCommon (Gtk::Button* button, const Glib::ustring& label = "");
|
||||
~PopUpCommon ();
|
||||
bool addEntry (Glib::ustring imagePath, Glib::ustring label);
|
||||
bool setSelected (int entryNum);
|
||||
@@ -54,11 +54,11 @@ private:
|
||||
std::vector<Gtk::ImageMenuItem*> items;
|
||||
Glib::ustring buttonHint;
|
||||
Gtk::Image* buttonImage;
|
||||
Gtk::Image* menuSymbol;
|
||||
Gtk::HBox* imageContainer;
|
||||
Gtk::Menu* menu;
|
||||
Gtk::Button* button;
|
||||
int selected;
|
||||
bool hasText;
|
||||
bool imageRight;
|
||||
bool hasMenu;
|
||||
|
||||
void showMenu(GdkEventButton* event);
|
||||
|
@@ -28,10 +28,8 @@
|
||||
*
|
||||
* Parameters:
|
||||
* label = label displayed in the button
|
||||
* imRight = 0: the image is displayed at the left of the label (default)
|
||||
* 1: the image is displayed at the right of the label
|
||||
*/
|
||||
PopUpToggleButton::PopUpToggleButton (const Glib::ustring& label, bool imgRight) : Gtk::ToggleButton(), PopUpCommon(this, label, imgRight) { }
|
||||
PopUpToggleButton::PopUpToggleButton (const Glib::ustring& label) : Gtk::ToggleButton(), PopUpCommon(this, label) { }
|
||||
|
||||
void PopUpToggleButton::show() {
|
||||
PopUpCommon::show();
|
||||
|
@@ -27,7 +27,7 @@
|
||||
class PopUpToggleButton : public Gtk::ToggleButton, public PopUpCommon {
|
||||
|
||||
public:
|
||||
PopUpToggleButton (const Glib::ustring& label = "", bool imgRight=false);
|
||||
PopUpToggleButton (const Glib::ustring& label = "");
|
||||
void show ();
|
||||
void set_tooltip_text (const Glib::ustring &text);
|
||||
};
|
||||
|
Reference in New Issue
Block a user