summaryrefslogtreecommitdiff
path: root/gtk2_ardour/group_tabs.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-08-30 09:48:53 +0000
committerCarl Hetherington <carl@carlh.net>2011-08-30 09:48:53 +0000
commit7d32cf3813b7145b98c86b59867092e04aa2621a (patch)
treedbb2d319f55e2c287b51a7071a236dadd6d83ca3 /gtk2_ardour/group_tabs.cc
parent9b7ae4cccc8507bc3e74e909b738a5b87a2b717b (diff)
Give route groups their own colour, settable from the route
group dialogue. Americanise spelling of color in a few places to avoid confusion. Fixes #4224. Addresses parts of #2650 and #4064. git-svn-id: svn://localhost/ardour2/branches/3.0@10030 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/group_tabs.cc')
-rw-r--r--gtk2_ardour/group_tabs.cc62
1 files changed, 62 insertions, 0 deletions
diff --git a/gtk2_ardour/group_tabs.cc b/gtk2_ardour/group_tabs.cc
index ab4dcd1923..ec80bc4291 100644
--- a/gtk2_ardour/group_tabs.cc
+++ b/gtk2_ardour/group_tabs.cc
@@ -27,12 +27,16 @@
#include "group_tabs.h"
#include "keyboard.h"
#include "i18n.h"
+#include "ardour_ui.h"
+#include "utils.h"
using namespace std;
using namespace Gtk;
using namespace ARDOUR;
using Gtkmm2ext::Keyboard;
+list<Gdk::Color> GroupTabs::_used_colors;
+
GroupTabs::GroupTabs ()
: _menu (0)
, _dragging (0)
@@ -501,3 +505,61 @@ GroupTabs::remove_group (RouteGroup* g)
{
_session->remove_route_group (*g);
}
+
+/** Set the color of the tab of a route group */
+void
+GroupTabs::set_group_color (RouteGroup* group, Gdk::Color color)
+{
+ assert (group);
+
+ GUIObjectState& gui_state = *ARDOUR_UI::instance()->gui_object_state;
+
+ char buf[64];
+ snprintf (buf, sizeof (buf), "%d:%d:%d", color.get_red(), color.get_green(), color.get_blue());
+ gui_state.set (group_gui_id (group), "color", buf);
+}
+
+/** @return the ID string to use for the GUI state of a route group */
+string
+GroupTabs::group_gui_id (RouteGroup* group)
+{
+ assert (group);
+
+ char buf[64];
+ snprintf (buf, sizeof (buf), "route_group %s", group->id().to_s().c_str ());
+
+ return buf;
+}
+
+/** @return the color to use for a route group tab */
+Gdk::Color
+GroupTabs::group_color (RouteGroup* group)
+{
+ assert (group);
+
+ GUIObjectState& gui_state = *ARDOUR_UI::instance()->gui_object_state;
+
+ string const gui_id = group_gui_id (group);
+
+ bool empty;
+ string const color = gui_state.get_string (gui_id, "color", &empty);
+ if (empty) {
+ /* no color has yet been set, so use a random one */
+ Gdk::Color const color = unique_random_color (_used_colors);
+ set_group_color (group, color);
+ return color;
+ }
+
+ Gdk::Color c;
+
+ int r, g, b;
+
+ sscanf (color.c_str(), "%d:%d:%d", &r, &g, &b);
+
+ c.set_red (r);
+ c.set_green (g);
+ c.set_blue (b);
+
+ return c;
+}
+