diff --git a/gtk2_ardour/axis_view.cc b/gtk2_ardour/axis_view.cc index b87e911536..cba282dff6 100644 --- a/gtk2_ardour/axis_view.cc +++ b/gtk2_ardour/axis_view.cc @@ -65,7 +65,7 @@ AxisView::~AxisView() Gdk::Color AxisView::unique_random_color() { - return ::unique_random_color (used_colors, true); + return ARDOUR_UI_UTILS::unique_palette_color (used_colors); } string diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 7e69da7815..346ad934c0 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -680,28 +680,36 @@ ARDOUR_UI_UTILS::escape_underscores (string const & s) } Gdk::Color -ARDOUR_UI_UTILS::unique_random_color (list& used_colors, bool from_palette) +ARDOUR_UI_UTILS::unique_palette_color (list& used_colors) { Gdk::Color newcolor; + string cp = UIConfiguration::instance().get_stripable_color_palette (); + Gdk::ArrayHandle_Color gc = ColorSelection::palette_from_string (cp); + std::vector c (gc); + static std::vector::size_type index = 0; - if (from_palette) { - - string cp = UIConfiguration::instance().get_stripable_color_palette (); - Gdk::ArrayHandle_Color gc = ColorSelection::palette_from_string (cp); - std::vector c (gc); - int n = random () % c.size(); - Gtkmm2ext::HSV hsv (Gtkmm2ext::gdk_color_to_rgba (c[n])); - - do { - newcolor.set_hsv (hsv.h, hsv.s, hsv.v); - hsv = random() % 1000 > 500 ? hsv.darker ((random() % 500) / 1000.0) : hsv.lighter ((random() % 500 / 1000.0)); - } while (find (used_colors.begin(), used_colors.end(), newcolor) != used_colors.end()); - - used_colors.push_back (newcolor); - - return newcolor; + if (index >= c.size()) { + index = 0; } + Gtkmm2ext::HSV hsv (Gtkmm2ext::gdk_color_to_rgba (c[index])); + index++; + + do { + newcolor.set_hsv (hsv.h, hsv.s, hsv.v); + hsv = random() % 1000 > 500 ? hsv.darker ((random() % 500) / 1000.0) : hsv.lighter ((random() % 500 / 1000.0)); + } while (find (used_colors.begin(), used_colors.end(), newcolor) != used_colors.end()); + + used_colors.push_back (newcolor); + + return newcolor; +} + +Gdk::Color +ARDOUR_UI_UTILS::unique_random_color (list& used_colors) +{ + Gdk::Color newcolor; + while (1) { double h, s, v; diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h index aa5a705eea..4827ad9115 100644 --- a/gtk2_ardour/utils.h +++ b/gtk2_ardour/utils.h @@ -98,7 +98,8 @@ void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int); std::string escape_underscores (std::string const &); -Gdk::Color unique_random_color (std::list &, bool from_palette = false); +Gdk::Color unique_palette_color (std::list &); +Gdk::Color unique_random_color (std::list &); std::string rate_as_string (float r); std::string samples_as_time_string (ARDOUR::samplecnt_t s, float r, bool show_samples = false);