From 35407c7fe88ae5f55c73eace540c6ed1de37856c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 14 Mar 2017 17:03:14 +0100 Subject: [PATCH] Update stripable color on the fly --- gtk2_ardour/stripable_colorpicker.cc | 15 ++++++++++++++- gtk2_ardour/stripable_colorpicker.h | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/stripable_colorpicker.cc b/gtk2_ardour/stripable_colorpicker.cc index 2e341f4d7e..b9c4990cfe 100644 --- a/gtk2_ardour/stripable_colorpicker.cc +++ b/gtk2_ardour/stripable_colorpicker.cc @@ -74,6 +74,7 @@ StripableColorDialog::reset () _stripable->set_active_color_picker (0); } _stripable.reset (); + _color_changed_connection.disconnect (); } void @@ -91,15 +92,17 @@ StripableColorDialog::popup (boost::shared_ptr s) _stripable = s; _stripable->set_active_color_picker (this); + _initial_color = _stripable->presentation_info().color (); set_title (string_compose (_("Color Selection: %1"), s->name())); get_colorsel()->set_has_opacity_control (false); get_colorsel()->set_has_palette (true); - Gdk::Color c = gdk_color_from_rgba (_stripable->presentation_info().color ()); + Gdk::Color c = gdk_color_from_rgba (_initial_color); get_colorsel()->set_previous_color (c); get_colorsel()->set_current_color (c); + _color_changed_connection = get_colorsel()->signal_color_changed().connect (sigc::mem_fun (*this, &StripableColorDialog::color_changed)); present (); } @@ -109,6 +112,16 @@ 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())); + } else { + _stripable->presentation_info().set_color (_initial_color); } reset (); } + +void +StripableColorDialog::color_changed () +{ + if (_stripable) { + _stripable->presentation_info().set_color (gdk_color_to_rgba (get_colorsel()->get_current_color())); + } +} diff --git a/gtk2_ardour/stripable_colorpicker.h b/gtk2_ardour/stripable_colorpicker.h index d05d67e974..952640da70 100644 --- a/gtk2_ardour/stripable_colorpicker.h +++ b/gtk2_ardour/stripable_colorpicker.h @@ -34,8 +34,12 @@ public: private: void initialize_color_palette (); void finish_color_edit (int response); + void color_changed (); boost::shared_ptr _stripable; + ARDOUR::PresentationInfo::color_t _initial_color; + + sigc::connection _color_changed_connection; static bool palette_initialized;