summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-03-10 23:51:39 +0100
committerRobin Gareus <robin@gareus.org>2017-03-11 00:33:43 +0100
commit05dfc1fdc1e0c0e41dadfacbfb5c1076f8a7364a (patch)
tree7a2264db527fb700a4cf0a80fc24931f73917023 /gtk2_ardour
parent7a709f23f13c7485200cbd67dd3adb4e1a268359 (diff)
Update color stripable color-picker(s)
* consistent behavior (Route, VCA) * non-modal * a single color picker for each RouteUI/VCA at most * fix bug: VCA picker staying around even when VCA was deleted
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/route_ui.cc10
-rw-r--r--gtk2_ardour/route_ui.h4
-rw-r--r--gtk2_ardour/stripable_colorpicker.cc71
-rw-r--r--gtk2_ardour/stripable_colorpicker.h40
-rw-r--r--gtk2_ardour/vca_master_strip.cc26
-rw-r--r--gtk2_ardour/vca_master_strip.h4
-rw-r--r--gtk2_ardour/wscript1
7 files changed, 123 insertions, 33 deletions
diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc
index 1802425a5a..c8c48f257e 100644
--- a/gtk2_ardour/route_ui.cc
+++ b/gtk2_ardour/route_ui.cc
@@ -243,6 +243,8 @@ RouteUI::reset ()
delete mute_menu;
mute_menu = 0;
+ _color_picker.reset ();
+
denormal_menu_item = 0;
}
@@ -1604,13 +1606,7 @@ RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check)
void
RouteUI::choose_color ()
{
- bool picked;
- Gdk::Color c (gdk_color_from_rgba (_route->presentation_info().color()));
- Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &c);
-
- if (picked) {
- set_color (gdk_color_to_rgba (color));
- }
+ _color_picker.popup (_route);
}
/** Set the route's own color. This may not be used for display if
diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h
index 6f53b7232d..7e4dd2e968 100644
--- a/gtk2_ardour/route_ui.h
+++ b/gtk2_ardour/route_ui.h
@@ -26,6 +26,7 @@
#include "pbd/signals.h"
#include <gtkmm/textview.h>
+#include <gtkmm/colorselection.h>
#include "gtkmm2ext/widget_state.h"
@@ -40,6 +41,7 @@
#include "axis_view.h"
#include "selectable.h"
+#include "stripable_colorpicker.h"
#include "window_manager.h"
namespace ARDOUR {
@@ -336,6 +338,8 @@ private:
std::vector<ArdourButton*> _invert_buttons;
Gtk::Menu* _invert_menu;
+ StripableColorDialog _color_picker;
+
static void set_showing_sends_to (boost::shared_ptr<ARDOUR::Route>);
static boost::weak_ptr<ARDOUR::Route> _showing_sends_to;
diff --git a/gtk2_ardour/stripable_colorpicker.cc b/gtk2_ardour/stripable_colorpicker.cc
new file mode 100644
index 0000000000..6b92a94dc6
--- /dev/null
+++ b/gtk2_ardour/stripable_colorpicker.cc
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2017 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 "stripable_colorpicker.h"
+#include "utils.h"
+
+using namespace Gtk;
+using namespace ARDOUR_UI_UTILS;
+
+StripableColorDialog::StripableColorDialog ()
+{
+ signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit));
+}
+
+StripableColorDialog::~StripableColorDialog ()
+{
+ reset ();
+}
+
+void
+StripableColorDialog::reset ()
+{
+ hide ();
+ _stripable.reset ();
+}
+
+void
+StripableColorDialog::popup (boost::shared_ptr<ARDOUR::Stripable> s)
+{
+ if (_stripable == s) {
+ /* keep modified color */
+ present ();
+ return;
+ }
+
+ _stripable = s;
+
+ get_colorsel()->set_has_opacity_control (false);
+ get_colorsel()->set_has_palette (true);
+
+ Gdk::Color c = gdk_color_from_rgba (_stripable->presentation_info().color ());
+
+ get_colorsel()->set_previous_color (c);
+ get_colorsel()->set_current_color (c);
+
+ present ();
+}
+
+void
+StripableColorDialog::finish_color_edit (int response)
+{
+ if (_stripable && response == RESPONSE_OK) {
+ _stripable->presentation_info().set_color (gdk_color_to_rgba (get_colorsel()->get_current_color()));
+ }
+ reset ();
+}
diff --git a/gtk2_ardour/stripable_colorpicker.h b/gtk2_ardour/stripable_colorpicker.h
new file mode 100644
index 0000000000..79b7ffcf62
--- /dev/null
+++ b/gtk2_ardour/stripable_colorpicker.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef __gtkardour_stripable_colorpicker_h__
+#define __gtkardour_stripable_colorpicker_h__
+
+#include <boost/shared_ptr.hpp>
+#include <gtkmm/colorselection.h>
+#include "ardour/stripable.h"
+
+class StripableColorDialog : public Gtk::ColorSelectionDialog
+{
+public:
+ StripableColorDialog ();
+ ~StripableColorDialog ();
+ void reset ();
+ void popup (boost::shared_ptr<ARDOUR::Stripable> s);
+
+private:
+ void finish_color_edit (int response);
+
+ boost::shared_ptr<ARDOUR::Stripable> _stripable;
+};
+
+#endif
diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc
index 5e96010c3c..2d6088fbdf 100644
--- a/gtk2_ardour/vca_master_strip.cc
+++ b/gtk2_ardour/vca_master_strip.cc
@@ -17,7 +17,6 @@
*/
#include <gtkmm/stock.h>
-#include <gtkmm/colorselection.h>
#include "pbd/convert.h"
@@ -526,30 +525,7 @@ VCAMasterStrip::state_id () const
void
VCAMasterStrip::start_color_edit ()
{
- Gtk::ColorSelectionDialog* color_dialog = new Gtk::ColorSelectionDialog;
-
- color_dialog->get_colorsel()->set_has_opacity_control (false);
- color_dialog->get_colorsel()->set_has_palette (true);
-
- Gdk::Color c = gdk_color_from_rgba (_vca->presentation_info().color ());
-
- color_dialog->get_colorsel()->set_previous_color (c);
- color_dialog->get_colorsel()->set_current_color (c);
-
- color_dialog->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &VCAMasterStrip::finish_color_edit), color_dialog));
- color_dialog->present ();
-}
-
-void
-VCAMasterStrip::finish_color_edit (int response, Gtk::ColorSelectionDialog* dialog)
-{
- switch (response) {
- case RESPONSE_OK:
- _vca->presentation_info().set_color (gdk_color_to_rgba (dialog->get_colorsel()->get_current_color()));
- break;
- }
-
- delete_when_idle (dialog);
+ _color_picker.popup (_vca);
}
bool
diff --git a/gtk2_ardour/vca_master_strip.h b/gtk2_ardour/vca_master_strip.h
index 6cc728ea52..0694b15e23 100644
--- a/gtk2_ardour/vca_master_strip.h
+++ b/gtk2_ardour/vca_master_strip.h
@@ -23,11 +23,13 @@
#include <gtkmm/box.h>
#include <gtkmm/menuitem.h>
+#include <gtkmm/colorselection.h>
#include "ardour_button.h"
#include "axis_view.h"
#include "control_slave_ui.h"
#include "gain_meter.h"
+#include "stripable_colorpicker.h"
namespace ARDOUR {
class GainControl;
@@ -107,7 +109,7 @@ class VCAMasterStrip : public AxisView, public Gtk::EventBox
void update_bottom_padding ();
void start_color_edit ();
- void finish_color_edit (int, Gtk::ColorSelectionDialog*);
+ StripableColorDialog _color_picker;
};
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
index 2e3ff2e6be..7accf20fe5 100644
--- a/gtk2_ardour/wscript
+++ b/gtk2_ardour/wscript
@@ -243,6 +243,7 @@ gtk2_ardour_sources = [
'stereo_panner_editor.cc',
'streamview.cc',
'strip_silence_dialog.cc',
+ 'stripable_colorpicker.cc',
'sys_ex.cc',
'tape_region_view.cc',
'tempo_curve.cc',