*/
+#ifdef WAF_BUILD
+#include "gtk2ardour-config.h"
+#endif
+
#include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
#include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
foo.set_name (style);
foo.ensure_style ();
- GtkRcStyle* waverc = foo.get_style()->gobj()->rc_style;
+ GtkRcStyle* rc = foo.get_style()->gobj()->rc_style;
- if (waverc) {
+ if (rc) {
if (attr == "fg") {
- r = waverc->fg[state].red / 257;
- g = waverc->fg[state].green / 257;
- b = waverc->fg[state].blue / 257;
+ 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 = waverc->fg[GTK_STATE_ACTIVE].red / 257;
+ a = rc->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;
+ r = rc->bg[state].red / 257;
+ g = rc->bg[state].green / 257;
+ b = rc->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;
+ r = rc->base[state].red / 257;
+ g = rc->base[state].green / 257;
+ b = rc->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;
+ 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;
DPIReset();//Emit Signal
}
-
-
-inline guint8
-convert_color_channel (guint8 src,
- guint8 alpha)
-{
- return alpha ? ((guint (src) << 8) - src) / alpha : 0;
-}
-
-void
-convert_bgra_to_rgba (guint8 const* src,
- guint8* dst,
- int width,
- int height)
-{
- guint8 const* src_pixel = src;
- guint8* dst_pixel = dst;
-
- for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- {
- dst_pixel[0] = convert_color_channel (src_pixel[2],
- src_pixel[3]);
- dst_pixel[1] = convert_color_channel (src_pixel[1],
- src_pixel[3]);
- dst_pixel[2] = convert_color_channel (src_pixel[0],
- src_pixel[3]);
- dst_pixel[3] = src_pixel[3];
-
- dst_pixel += 4;
- src_pixel += 4;
- }
-}
-
void
resize_window_to_proportion_of_monitor (Gtk::Window* window, int max_width, int max_height)
{
window->resize (w, h);
}
-Glib::RefPtr<Gdk::Pixbuf>
-pixbuf_from_string(const string& name, Pango::FontDescription* font, int clip_width, int clip_height, Gdk::Color fg)
-{
- static Glib::RefPtr<Gdk::Pixbuf>* empty_pixbuf = 0;
-
- if (name.empty()) {
- if (empty_pixbuf == 0) {
- empty_pixbuf = new Glib::RefPtr<Gdk::Pixbuf>;
- *empty_pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
- }
- return *empty_pixbuf;
- }
-
- Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
-
- cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, clip_width, clip_height);
- cairo_t* cr = cairo_create (surface);
- cairo_text_extents_t te;
-
- cairo_set_source_rgba (cr, fg.get_red_p(), fg.get_green_p(), fg.get_blue_p(), 1.0);
- cairo_select_font_face (cr, font->get_family().c_str(),
- CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size (cr, font->get_size() / Pango::SCALE);
- cairo_text_extents (cr, name.c_str(), &te);
-
- cairo_move_to (cr, 0.5, 0.5 - te.height / 2 - te.y_bearing + clip_height / 2);
- cairo_show_text (cr, name.c_str());
-
- convert_bgra_to_rgba(cairo_image_surface_get_data (surface), buf->get_pixels(), clip_width, clip_height);
-
- cairo_destroy(cr);
- cairo_surface_destroy(surface);
-
- return buf;
-}
/** Replace _ with __ in a string; for use with menu item text to make underscores displayed correctly */
string
return o;
}
-static void
-adjustment_to_controllable (Gtk::Adjustment* adj, boost::weak_ptr<Controllable> wcont)
-{
- boost::shared_ptr<Controllable> cont = wcont.lock();
-
- if (cont) {
- double val = adj->get_value();
- if (val != cont->get_value()) {
- cont->set_value (val);
- }
- }
-}
-
-static void
-controllable_to_adjustment (Gtk::Adjustment* adj, boost::weak_ptr<Controllable> wcont)
-{
- boost::shared_ptr<Controllable> cont = wcont.lock();
-
- if (cont) {
- float val = cont->get_value();
-
- if (val != adj->get_value()) {
- adj->set_value (val);
- }
- }
-}
-
-void
-control_link (ScopedConnectionList& scl, boost::shared_ptr<Controllable> c, Gtk::Adjustment& a)
-{
- boost::weak_ptr<Controllable> wc (c);
-
- a.signal_value_changed().connect (sigc::bind (sigc::ptr_fun (adjustment_to_controllable), &a, wc));
- c->Changed.connect (scl, MISSING_INVALIDATOR, boost::bind (controllable_to_adjustment, &a, wc),
- gui_context());
-}
-int
-physical_screen_height (Glib::RefPtr<Gdk::Window> win)
-{
- GdkScreen* scr = gdk_screen_get_default();
-
- if (win) {
- GdkRectangle r;
- gint monitor = gdk_screen_get_monitor_at_window (scr, win->gobj());
- gdk_screen_get_monitor_geometry (scr, monitor, &r);
- return r.height;
- } else {
- return gdk_screen_get_height (scr);
- }
-}
-
-int
-physical_screen_width (Glib::RefPtr<Gdk::Window> win)
-{
- GdkScreen* scr = gdk_screen_get_default();
-
- if (win) {
- GdkRectangle r;
- gint monitor = gdk_screen_get_monitor_at_window (scr, win->gobj());
- gdk_screen_get_monitor_geometry (scr, monitor, &r);
- return r.width;
- } else {
- return gdk_screen_get_width (scr);
- }
-}