Changing active-state needs no color lookup
[ardour.git] / libs / widgets / ardour_dropdown.cc
index 6be0ab84d6f2259635f26600145d83c6f629ae81..321992d632840a8e25ed3a631e4e0b38216296b0 100644 (file)
@@ -1,21 +1,21 @@
 /*
-    Copyright (C) 2014 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2014 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.org>
+ *
* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <iostream>
 #include <cmath>
@@ -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"
 
@@ -48,7 +49,6 @@ using namespace std;
 ArdourDropdown::ArdourDropdown (Element e)
        : _scrolling_disabled(false)
 {
-//     signal_button_press_event().connect (sigc::mem_fun(*this, &ArdourDropdown::on_mouse_pressed));
        _menu.signal_size_request().connect (sigc::mem_fun(*this, &ArdourDropdown::menu_size_request));
 
        _menu.set_reserve_toggle_size(false);
@@ -162,3 +162,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 */
+}