summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_button.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-11-02 18:47:14 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-11-02 18:47:14 +0000
commit0cc9daed289a96a82171335660304a3cdc6f42c6 (patch)
tree184402f16c2267bb096b60f2c06b33949f14be79 /gtk2_ardour/ardour_button.cc
parent592bfa3616678838bb80b925d66fbadae2d20d7e (diff)
allow addition of images to ArdourButtons (always centered)
git-svn-id: svn://localhost/ardour2/branches/3.0@10399 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/ardour_button.cc')
-rw-r--r--gtk2_ardour/ardour_button.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/gtk2_ardour/ardour_button.cc b/gtk2_ardour/ardour_button.cc
index 2bc73398ae..24f678e5c5 100644
--- a/gtk2_ardour/ardour_button.cc
+++ b/gtk2_ardour/ardour_button.cc
@@ -133,6 +133,17 @@ ArdourButton::render (cairo_t* cr)
cairo_fill (cr);
}
+ if (_pixbuf) {
+
+ double x,y;
+ x = (_width - _pixbuf->get_width())/2.0;
+ y = (_height - _pixbuf->get_height())/2.0;
+
+ cairo_rectangle (cr, x, y, _pixbuf->get_width(), _pixbuf->get_height());
+ gdk_cairo_set_source_pixbuf (cr, _pixbuf->gobj(), x, y);
+ cairo_fill (cr);
+ }
+
/* text, if any */
int text_margin;
@@ -202,10 +213,11 @@ ArdourButton::render (cairo_t* cr)
}
+
/* a partially transparent gray layer to indicate insensitivity */
if ((visual_state() & Gtkmm2ext::Insensitive)) {
- cairo_rectangle (cr, 0, 0, _width, _height);
+ Gtkmm2ext::rounded_rectangle (cr, 0, 0, _width, _height, _corner_radius);
cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.5);
cairo_fill (cr);
}
@@ -541,3 +553,9 @@ ArdourButton::setup_led_rect ()
}
}
+void
+ArdourButton::set_image (const RefPtr<Gdk::Pixbuf>& img)
+{
+ _pixbuf = img;
+ queue_draw ();
+}