diff options
author | Robin Gareus <robin@gareus.org> | 2018-01-30 15:21:45 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2018-01-30 15:21:45 +0100 |
commit | f979463cfe5d8b939a1c87119e6d711de6d8902e (patch) | |
tree | 76507fcffcc710969688d97194184bd01c596597 | |
parent | e6b8a0d95bbdc091fcef0713197a9985263bb631 (diff) |
Add ArdourDropdown API for use as dumb text dropdown.
-rw-r--r-- | libs/widgets/ardour_dropdown.cc | 13 | ||||
-rw-r--r-- | libs/widgets/widgets/ardour_dropdown.h | 5 |
2 files changed, 18 insertions, 0 deletions
diff --git a/libs/widgets/ardour_dropdown.cc b/libs/widgets/ardour_dropdown.cc index 6be0ab84d6..e54213df0e 100644 --- a/libs/widgets/ardour_dropdown.cc +++ b/libs/widgets/ardour_dropdown.cc @@ -28,6 +28,7 @@ #include "pbd/stacktrace.h" #include "gtkmm2ext/utils.h" +#include "gtkmm2ext/menu_elems.h" #include "gtkmm2ext/rgb_macros.h" #include "gtkmm2ext/gui_thread.h" @@ -162,3 +163,15 @@ ArdourDropdown::disable_scrolling() { _scrolling_disabled = true; } + +void +ArdourDropdown::append_text_item (std::string const& text) { + using namespace Gtkmm2ext; + AddMenuElem (MenuElemNoMnemonic (text, sigc::bind (sigc::mem_fun (*this, &ArdourDropdown::default_text_handler), text))); +} + +void +ArdourDropdown::default_text_handler (std::string const& text) { + set_text (text); + StateChanged (); /* EMIT SIGNAL */ +} diff --git a/libs/widgets/widgets/ardour_dropdown.h b/libs/widgets/widgets/ardour_dropdown.h index 93e866d011..bb878c8570 100644 --- a/libs/widgets/widgets/ardour_dropdown.h +++ b/libs/widgets/widgets/ardour_dropdown.h @@ -49,6 +49,11 @@ public: Gtk::Menu_Helpers::MenuList& items () { return _menu.items (); } + void append_text_item (std::string const& text); + +protected: + void default_text_handler (std::string const& text); + private: Gtk::Menu _menu; |