more color work, including removing rgba{_p_}_from_style()

This commit is contained in:
Paul Davis 2014-12-08 10:13:27 -05:00
parent 8455ebce90
commit aff8a806a2
11 changed files with 78 additions and 238 deletions

View file

@ -263,111 +263,6 @@ ARDOUR_UI_UTILS::get_font_for_style (string widgetname)
return Pango::FontDescription (pfd); /* make a copy */
}
uint32_t
ARDOUR_UI_UTILS::rgba_from_style (string style, uint32_t r, uint32_t g, uint32_t b, uint32_t a, string attr, int state, bool rgba)
{
/* In GTK+2, styles aren't set up correctly if the widget is not
attached to a toplevel window that has a screen pointer.
*/
static Gtk::Window* window = 0;
if (window == 0) {
window = new Window (WINDOW_TOPLEVEL);
}
Gtk::Label foo;
window->add (foo);
foo.set_name (style);
foo.ensure_style ();
GtkRcStyle* rc = foo.get_style()->gobj()->rc_style;
if (rc) {
if (attr == "fg") {
r = rc->fg[state].red / 257;
g = rc->fg[state].green / 257;
b = rc->fg[state].blue / 257;
/* what a hack ... "a" is for "active" */
if (state == Gtk::STATE_NORMAL && rgba) {
a = rc->fg[GTK_STATE_ACTIVE].red / 257;
}
} else if (attr == "bg") {
r = rc->bg[state].red / 257;
g = rc->bg[state].green / 257;
b = rc->bg[state].blue / 257;
} else if (attr == "base") {
r = rc->base[state].red / 257;
g = rc->base[state].green / 257;
b = rc->base[state].blue / 257;
} else if (attr == "text") {
r = rc->text[state].red / 257;
g = rc->text[state].green / 257;
b = rc->text[state].blue / 257;
}
} else {
warning << string_compose (_("missing RGBA style for \"%1\""), style) << endl;
}
window->remove ();
if (state == Gtk::STATE_NORMAL && rgba) {
return (uint32_t) RGBA_TO_UINT(r,g,b,a);
} else {
return (uint32_t) RGBA_TO_UINT(r,g,b,255);
}
}
bool
ARDOUR_UI_UTILS::rgba_p_from_style (string style, float *r, float *g, float *b, string attr, int state)
{
static Gtk::Window* window = 0;
assert (r && g && b);
if (window == 0) {
window = new Window (WINDOW_TOPLEVEL);
}
Gtk::EventBox foo;
window->add (foo);
foo.set_name (style);
foo.ensure_style ();
GtkRcStyle* rc = foo.get_style()->gobj()->rc_style;
if (!rc) {
warning << string_compose (_("missing RGBA style for \"%1\""), style) << endl;
return false;
}
if (attr == "fg") {
*r = rc->fg[state].red / 65535.0;
*g = rc->fg[state].green / 65535.0;
*b = rc->fg[state].blue / 65535.0;
} else if (attr == "bg") {
*r = rc->bg[state].red / 65535.0;
*g = rc->bg[state].green / 65535.0;
*b = rc->bg[state].blue / 65535.0;
} else if (attr == "base") {
*r = rc->base[state].red / 65535.0;
*g = rc->base[state].green / 65535.0;
*b = rc->base[state].blue / 65535.0;
} else if (attr == "text") {
*r = rc->text[state].red / 65535.0;
*g = rc->text[state].green / 65535.0;
*b = rc->text[state].blue / 65535.0;
} else {
return false;
}
window->remove ();
return true;
}
void
ARDOUR_UI_UTILS::set_color_from_rgb (Gdk::Color& c, uint32_t rgb)
{