13
0

micro tweaks to ArdourButton corners

This commit is contained in:
Ben Loftis 2014-09-02 15:16:37 -05:00
parent 5d5d859c2a
commit bc16da5b5a

View File

@ -218,9 +218,16 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
_diameter = std::min (get_width(), get_height());
}
// draw edge (filling a rect underneath, rather than stroking a border on top, allows the corners to be lighter-weight.
if ((_elements & (Body|Edge)) == (Body|Edge)) {
rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
cairo_fill(cr);
}
// background fill
if ((_elements & Body)==Body) {
rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius-1.5);
if (active_state() == Gtkmm2ext::ImplicitActive && !((_elements & Indicator)==Indicator)) {
ArdourCanvas::set_source_rgba (cr, fill_inactive_color);
cairo_fill (cr);
@ -235,36 +242,28 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
cairo_fill (cr);
}
//show the "convex" or "concave" gradient
if (!_flat_buttons) {
if ( active_state() == Gtkmm2ext::ExplicitActive && !((_elements & Indicator)==Indicator) ) {
//concave
cairo_set_source (cr, concave_pattern);
Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
cairo_fill (cr);
} else {
cairo_set_source (cr, convex_pattern);
Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
cairo_fill (cr);
}
}
// indicator border on top of gradient
// IMPLICIT ACTIVE: draw a border of the active color
if ((_elements & Body)==Body) {
if (active_state() == Gtkmm2ext::ImplicitActive && !((_elements & Indicator)==Indicator)) {
cairo_set_line_width (cr, 3.0);
rounded_function (cr, 1.5, 1.5, get_width() - 3, get_height() - 3, _corner_radius);
cairo_set_line_width (cr, 2.0);
rounded_function (cr, 2, 2, get_width() - 4, get_height() - 4, _corner_radius-2);
ArdourCanvas::set_source_rgba (cr, fill_active_color);
cairo_stroke (cr);
}
}
// draw edge
if ((_elements & (Body|Edge)) == (Body|Edge)) {
rounded_function (cr, .5, .5, get_width() - 1, get_height() - 1, _corner_radius);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
cairo_set_line_width (cr, 1.0);
cairo_stroke(cr);
//show the "convex" or "concave" gradient
if (!_flat_buttons) {
if ( active_state() == Gtkmm2ext::ExplicitActive && !((_elements & Indicator)==Indicator) ) {
//concave
cairo_set_source (cr, concave_pattern);
Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius-1.5);
cairo_fill (cr);
} else {
cairo_set_source (cr, convex_pattern);
Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius-1.5);
cairo_fill (cr);
}
}
//Pixbuf, if any
@ -295,11 +294,11 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
const double x = get_width() * .5;
const double y = get_height() * .5;
cairo_arc (cr, x, y, get_height () *.2 , 0, 2 * M_PI);
cairo_set_source_rgba (cr, .95, .44, .44, 1.); // #f46f6f
cairo_fill(cr);
cairo_set_source_rgba (cr, .0, .0, .0, 1.);
cairo_set_line_width(cr, 1);
cairo_stroke_preserve (cr);
cairo_set_source_rgba (cr, .95, .44, .44, 1.); // #f46f6f
cairo_fill(cr);
}
int text_margin;
@ -421,7 +420,7 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
// a transparent gray layer to indicate insensitivity
if ((visual_state() & Gtkmm2ext::Insensitive)) {
rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius-1.5);
cairo_set_source_rgba (cr, 0.505, 0.517, 0.525, 0.6);
cairo_fill (cr);
}
@ -430,7 +429,7 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
if (ARDOUR::Config->get_widget_prelight()
&& !((visual_state() & Gtkmm2ext::Insensitive))) {
if (_hovering) {
rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius-1.5);
cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.2);
cairo_fill (cr);
}