allow addition of images to ArdourButtons (always centered)
git-svn-id: svn://localhost/ardour2/branches/3.0@10399 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -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 ();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ class ArdourButton : public CairoWidget
|
||||
Body = 0x2,
|
||||
Text = 0x4,
|
||||
Indicator = 0x8,
|
||||
Image = 0x16
|
||||
};
|
||||
|
||||
static Element default_elements;
|
||||
@@ -70,6 +69,8 @@ class ArdourButton : public CairoWidget
|
||||
bool on_button_press_event (GdkEventButton*);
|
||||
bool on_button_release_event (GdkEventButton*);
|
||||
|
||||
void set_image (const Glib::RefPtr<Gdk::Pixbuf>&);
|
||||
|
||||
protected:
|
||||
void render (cairo_t *);
|
||||
void on_size_request (Gtk::Requisition* req);
|
||||
@@ -81,6 +82,7 @@ class ArdourButton : public CairoWidget
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Pango::Layout> _layout;
|
||||
Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
|
||||
std::string _text;
|
||||
Element _elements;
|
||||
BindingProxy binding_proxy;
|
||||
|
||||
Reference in New Issue
Block a user