summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorDoug McLain <doug@nostar.net>2006-01-06 15:06:33 +0000
committerDoug McLain <doug@nostar.net>2006-01-06 15:06:33 +0000
commit1186b1d881fac3d1d1b55954b84b958c988501c4 (patch)
treedaebae62a81cd7f88a4c04335a47c569d94d17ed /gtk2_ardour/utils.cc
parentbd21c474e547d49338ea0efd452895de1e147cd5 (diff)
modified rgba_from_style() so that it can be used to retrieve any attribute from any style, return rgb or rgba, then used to to remove hard coding of colors in transport buttons and whole_file region names. Theme changes too
git-svn-id: svn://localhost/trunk/ardour2@245 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc45
1 files changed, 31 insertions, 14 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 012d184fef..1c4fc2a452 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -39,6 +39,7 @@
using namespace std;
using namespace Gtk;
using namespace sigc;
+using namespace Glib;
string
short_version (string orig, string::size_type target_length)
@@ -480,7 +481,7 @@ pane_handler (GdkEventButton* ev, Gtk::Paned* pane)
return FALSE;
}
uint32_t
-rgba_from_style (string style, uint32_t r, uint32_t g, uint32_t b, uint32_t a)
+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.
@@ -502,21 +503,39 @@ rgba_from_style (string style, uint32_t r, uint32_t g, uint32_t b, uint32_t a)
GtkRcStyle* waverc = foo.get_style()->gobj()->rc_style;
if (waverc) {
- r = waverc->fg[Gtk::STATE_NORMAL].red / 257;
- g = waverc->fg[Gtk::STATE_NORMAL].green / 257;
- b = waverc->fg[Gtk::STATE_NORMAL].blue / 257;
-
- /* what a hack ... "a" is for "active" */
-
- a = waverc->fg[GTK_STATE_ACTIVE].red / 257;
-
+ if (attr == "fg") {
+ r = waverc->fg[state].red / 257;
+ g = waverc->fg[state].green / 257;
+ b = waverc->fg[state].blue / 257;
+ /* what a hack ... "a" is for "active" */
+ if (state == Gtk::STATE_NORMAL && rgba) {
+ a = waverc->fg[GTK_STATE_ACTIVE].red / 257;
+ }
+ } else if (attr == "bg") {
+ r = g = b = 0;
+ r = waverc->bg[state].red / 257;
+ g = waverc->bg[state].green / 257;
+ b = waverc->bg[state].blue / 257;
+ } else if (attr == "base") {
+ r = waverc->base[state].red / 257;
+ g = waverc->base[state].green / 257;
+ b = waverc->base[state].blue / 257;
+ } else if (attr == "text") {
+ r = waverc->text[state].red / 257;
+ g = waverc->text[state].green / 257;
+ b = waverc->text[state].blue / 257;
+ }
} else {
warning << string_compose (_("missing RGBA style for \"%1\""), style) << endl;
}
window->remove ();
- return (uint32_t) RGBA_TO_UINT(r,g,b,a);
+ if (state == Gtk::STATE_NORMAL && rgba) {
+ return (uint32_t) RGBA_TO_UINT(r,g,b,a);
+ } else {
+ return (uint32_t) RGB_TO_UINT(r,g,b);
+ }
}
bool
@@ -526,9 +545,7 @@ canvas_item_visible (ArdourCanvas::Item* item)
}
void
-set_color (Gdk::Color& c, gint r, gint g, gint b)
+set_color (Gdk::Color& c, int rgb)
{
- c.set_red(65535);
- c.set_green(0);
- c.set_blue(0);
+ c.set_rgb((rgb >> 16)*256, ((rgb & 0xff00) >> 8)*256, (rgb & 0xff)*256);
}