Vkeybd: add a mod-wheel
[ardour.git] / gtk2_ardour / stripable_colorpicker.cc
index 3defed81201e12cd3399785ee384ab8d337a31cd..5a095e787dbfb6e3ccb2859865ca4c5588ca1099 100644 (file)
@@ -1,28 +1,30 @@
 /*
- * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2017-2018 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 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.
+ * 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 "pbd/compose.h"
-#include "pbd/i18n.h"
 
+#include "public_editor.h"
 #include "stripable_colorpicker.h"
 #include "ui_config.h"
 #include "utils.h"
 
+#include "pbd/i18n.h"
+
 using namespace Gtk;
 using namespace ARDOUR_UI_UTILS;
 
@@ -33,6 +35,31 @@ StripableColorDialog::StripableColorDialog ()
 {
        initialize_color_palette ();
        signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit));
+
+#ifdef __APPLE__
+       /* hide eyedropper button -- which does not work on OSX:
+        * " the problem is worse than just `not getting the color' though.
+        *   The action doesn't actually complete, and window focus is in a
+        *   `weird state' until you click inside the color-picker dialog twice;
+        *   then it all seems back to normal (but no color got picked)"
+        *
+        * the alternative is to patch gtk's source:
+        * gtk/gtkcolorsel.c  gtk_color_selection_init() which packs
+        *
+        *  top_hbox [ VBOX [ triangle || hbox [ sample-area || picker-button] ] || ... ]
+        */
+       ColorSelection* cs = get_colorsel(); // IS-A VBOX
+       if (!cs) { return ; }
+       Gtk::HBox* top_hbox = dynamic_cast<Gtk::HBox*> (cs->children()[0].get_widget());
+       if (!top_hbox) { return ; }
+       Gtk::VBox* vbox = dynamic_cast<Gtk::VBox*> (top_hbox->children()[0].get_widget());
+       if (!vbox) { return ; }
+       Gtk::HBox* hbox = dynamic_cast<Gtk::HBox*> (vbox->children()[1].get_widget());
+       if (!hbox) { return ; }
+       Gtk::Button* picker = dynamic_cast<Gtk::Button*> (hbox->children()[1].get_widget());
+       if (!picker) { return ; }
+       picker->hide ();
+#endif
 }
 
 StripableColorDialog::~StripableColorDialog ()
@@ -117,10 +144,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);