get meter color from gtkrc style file
This commit is contained in:
parent
b70057f576
commit
e469ce0961
@ -200,10 +200,14 @@ static inline float mtr_col_and_fract(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void set_bg_color(Gtk::Widget& w, cairo_t* cr, MeterType type) {
|
static void set_bg_color(Gtk::Widget& w, cairo_t* cr, MeterType type) {
|
||||||
// TODO use "meterstrip*" stype
|
float r,g,b;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case MeterVU:
|
case MeterVU:
|
||||||
cairo_set_source_rgb (cr, 1.0, 1.0, 0.85);
|
if (rgba_p_from_style("meterstripVU", &r, &g, &b, "bg")) {
|
||||||
|
cairo_set_source_rgb (cr, r, g, b);
|
||||||
|
} else {
|
||||||
|
cairo_set_source_rgb (cr, 1.0, 1.0, 0.85);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MeterIEC1DIN:
|
case MeterIEC1DIN:
|
||||||
case MeterIEC1NOR:
|
case MeterIEC1NOR:
|
||||||
@ -211,7 +215,11 @@ static void set_bg_color(Gtk::Widget& w, cairo_t* cr, MeterType type) {
|
|||||||
case MeterIEC2EBU:
|
case MeterIEC2EBU:
|
||||||
case MeterK14:
|
case MeterK14:
|
||||||
case MeterK20:
|
case MeterK20:
|
||||||
cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
|
if (rgba_p_from_style("meterstripPPM", &r, &g, &b, "bg")) {
|
||||||
|
cairo_set_source_rgb (cr, r, g, b);
|
||||||
|
} else {
|
||||||
|
cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -223,13 +231,21 @@ static void set_bg_color(Gtk::Widget& w, cairo_t* cr, MeterType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void set_fg_color(Gtk::Widget& w, MeterType type, Gdk::Color * c) {
|
static void set_fg_color(Gtk::Widget& w, MeterType type, Gdk::Color * c) {
|
||||||
// TODO use "meterstrip*" stype
|
float r,g,b;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case MeterVU:
|
case MeterVU:
|
||||||
c->set_rgb_p(0.0, 0.0, 0.0);
|
if (rgba_p_from_style("meterstripVU", &r, &g, &b)) {
|
||||||
|
c->set_rgb_p(r, g, b);
|
||||||
|
} else {
|
||||||
|
c->set_rgb_p(0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
c->set_rgb_p(1.0, 1.0, 1.0);
|
if (rgba_p_from_style("meterstripPPM", &r, &g, &b)) {
|
||||||
|
c->set_rgb_p(r, g, b);
|
||||||
|
} else {
|
||||||
|
c->set_rgb_p(1.0, 1.0, 1.0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +301,53 @@ rgba_from_style (string style, uint32_t r, uint32_t g, uint32_t b, uint32_t a, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
canvas_item_visible (ArdourCanvas::Item* item)
|
canvas_item_visible (ArdourCanvas::Item* item)
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,8 @@ Pango::FontDescription get_font_for_style (std::string widgetname);
|
|||||||
|
|
||||||
uint32_t rgba_from_style (std::string, uint32_t, uint32_t, uint32_t, uint32_t, std::string = "fg", int = Gtk::STATE_NORMAL, bool = true);
|
uint32_t rgba_from_style (std::string, uint32_t, uint32_t, uint32_t, uint32_t, std::string = "fg", int = Gtk::STATE_NORMAL, bool = true);
|
||||||
|
|
||||||
|
bool rgba_p_from_style (std::string, float*, float*, float*, std::string = "fg", int = Gtk::STATE_NORMAL);
|
||||||
|
|
||||||
void decorate (Gtk::Window& w, Gdk::WMDecoration d);
|
void decorate (Gtk::Window& w, Gdk::WMDecoration d);
|
||||||
|
|
||||||
bool canvas_item_visible (ArdourCanvas::Item* item);
|
bool canvas_item_visible (ArdourCanvas::Item* item);
|
||||||
|
Loading…
Reference in New Issue
Block a user