summaryrefslogtreecommitdiff
path: root/gtk2_ardour/group_tabs.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-09 23:28:32 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-09 23:29:00 -0400
commitce08ec0de0b0b077d9b28533c23886607991d144 (patch)
tree031a01c89075fbf90733da202ce8b19f6f048a6c /gtk2_ardour/group_tabs.cc
parent438179d278559bcb41a8abdadfb5e6b2e1e89d2d (diff)
substantial changes in color management, involving a reduction in the use of Gdk::Color and more consistent logic for region coloring.
Group tabs now also get the text drawn in an appropriately contrast-y color
Diffstat (limited to 'gtk2_ardour/group_tabs.cc')
-rw-r--r--gtk2_ardour/group_tabs.cc46
1 files changed, 29 insertions, 17 deletions
diff --git a/gtk2_ardour/group_tabs.cc b/gtk2_ardour/group_tabs.cc
index 05e8438709..9dd9dd51e3 100644
--- a/gtk2_ardour/group_tabs.cc
+++ b/gtk2_ardour/group_tabs.cc
@@ -28,6 +28,7 @@
#include "keyboard.h"
#include "i18n.h"
#include "ardour_ui.h"
+#include "rgb_macros.h"
#include "utils.h"
using namespace std;
@@ -535,19 +536,30 @@ GroupTabs::remove_group (RouteGroup* g)
/** Set the color of the tab of a route group */
void
-GroupTabs::set_group_color (RouteGroup* group, Gdk::Color color)
+GroupTabs::set_group_color (RouteGroup* group, uint32_t color)
{
assert (group);
+ uint32_t r, g, b, a;
+
+ UINT_TO_RGBA (color, &r, &g, &b, &a);
/* Hack to disallow black route groups; force a dark grey instead */
- if (color.get_red() == 0 && color.get_green() == 0 && color.get_blue() == 0) {
- color.set_grey_p (0.1);
+
+ if (r == 0 && g == 0 && b == 0) {
+ r = 25;
+ g = 25;
+ b = 25;
}
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());
+
+ /* for historical reasons the colors must be stored as 16 bit color
+ * values. Ugh.
+ */
+
+ snprintf (buf, sizeof (buf), "%d:%d:%d", (r<<8), (g<<8), (b<<8));
gui_state.set_property (group_gui_id (group), "color", buf);
/* the group color change notification */
@@ -577,35 +589,35 @@ GroupTabs::group_gui_id (RouteGroup* group)
}
/** @return the color to use for a route group tab */
-Gdk::Color
+uint32_t
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;
+ uint32_t c = gdk_color_to_rgba (unique_random_color (_used_colors));
+ set_group_color (group, c);
+ return c;
}
- Gdk::Color c;
-
int r, g, b;
+ /* for historical reasons, colors are stored as 16 bit values.
+ */
+
sscanf (color.c_str(), "%d:%d:%d", &r, &g, &b);
- c.set_red (r);
- c.set_green (g);
- c.set_blue (b);
-
- return c;
+ r /= 256;
+ g /= 256;
+ b /= 256;
+
+ return RGBA_TO_UINT (r, g, b, 255);
}
void