add Gtk::ColorButton widget to LuaDialog and add ability to change multiple route...
authorNikolaus Gullotta <nikolaus.gullotta@gmail.com>
Tue, 3 Apr 2018 20:38:54 +0000 (15:38 -0500)
committerNikolaus Gullotta <nikolaus.gullotta@gmail.com>
Fri, 1 Jun 2018 14:55:25 +0000 (09:55 -0500)
gtk2_ardour/luadialog.cc
gtk2_ardour/stripable_colorpicker.cc

index 90464d26afae4374b9b4f225f16bc18f9dc73604..943b077b7721bdafc0a4566a8b14c1de7450954f 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "ardour/dB.h"
 #include "ardour/rc_configuration.h"
+#include "gtk2_ardour/stripable_colorpicker.h"
 
 #include "gtkmm2ext/utils.h"
 
@@ -169,6 +170,34 @@ protected:
        Gtk::HSeparator _sep;
 };
 
+class LuaColorPicker : public LuaDialogWidget
+{
+public:
+       LuaColorPicker (std::string const& key)
+               : LuaDialogWidget (key, "", 0, 1)
+       {}
+
+       Gtk::Widget* widget ()
+       {
+               return &_cs;
+       }
+       void assign (luabridge::LuaRef* rv) const {
+               uint32_t rgba = ARDOUR_UI_UTILS::gdk_color_to_rgba(_cs.get_color());
+               (*rv)[_key] = rgba;
+       }
+protected:
+       Gtk::ColorButton _cs;
+};
+/*
+local a = {
+       {type = "color", key = "col", title = ""}
+}
+
+local rv = LuaDialog.Dialog("", a):run()
+
+print(rv['col'])
+*/
+
 class LuaDialogCheckbox : public LuaDialogWidget
 {
 public:
@@ -675,6 +704,8 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
                                path = i.value ()["path"].cast<std::string> ();
                        }
                        w = new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, path);
+               } else if (type == "color") {
+                       w = new LuaColorPicker (key);
                }
 
                if (w) {
index 4e8fe339d476a43f03643f3d943420980a1e77b6..66602a9f6729d95919ae523df9f3bea60a8b1317 100644 (file)
@@ -19,6 +19,7 @@
 #include "pbd/compose.h"
 #include "pbd/i18n.h"
 
+#include "public_editor.h"
 #include "stripable_colorpicker.h"
 #include "ui_config.h"
 #include "utils.h"
@@ -142,10 +143,15 @@ StripableColorDialog::popup (boost::shared_ptr<ARDOUR::Stripable> s)
 void
 StripableColorDialog::finish_color_edit (int response)
 {
+       ARDOUR::RouteList rl = PublicEditor::instance().get_selection().tracks.routelist();
+
        if (response == RESPONSE_OK) {
                ColorChanged (gdk_color_to_rgba (get_colorsel()->get_current_color())); /* EMIT SIGNAL */
        }
        if (_stripable && response == RESPONSE_OK) {
+               for (ARDOUR::RouteList::iterator i = rl.begin(); i != rl.end(); ++i) {
+                       (*i)->presentation_info().set_color (gdk_color_to_rgba (get_colorsel()->get_current_color()));
+               }
                _stripable->presentation_info().set_color (gdk_color_to_rgba (get_colorsel()->get_current_color()));
        } else if (_stripable) {
                _stripable->presentation_info().set_color (_initial_color);