13
0

allow true boxy buttons for ArdourButtons

Also add a default tweaks static member to force all buttons to a given tweak state
This commit is contained in:
Paul Davis 2024-03-20 06:48:26 -06:00
parent 46fa056da6
commit 16ed245977
2 changed files with 25 additions and 18 deletions

View File

@ -53,6 +53,7 @@ using namespace std;
ArdourButton::Element ArdourButton::default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text);
ArdourButton::Element ArdourButton::led_default_elements = ArdourButton::Element (ArdourButton::default_elements|ArdourButton::Indicator);
ArdourButton::Element ArdourButton::just_led_default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Indicator);
ArdourButton::Tweaks ArdourButton::default_tweaks = ArdourButton::Tweaks (0);
ArdourButton::ArdourButton (Element e, bool toggle)
: _markup (false)
@ -60,7 +61,7 @@ ArdourButton::ArdourButton (Element e, bool toggle)
, _icon (ArdourIcon::NoIcon)
, _icon_render_cb (0)
, _icon_render_cb_data (0)
, _tweaks (Tweaks (0))
, _tweaks (default_tweaks)
, _char_pixel_width (0)
, _char_pixel_height (0)
, _char_avg_pixel_width (0)
@ -108,7 +109,7 @@ ArdourButton::ArdourButton (const std::string& str, Element e, bool toggle)
: _markup (false)
, _elements (e)
, _icon (ArdourIcon::NoIcon)
, _tweaks (Tweaks (0))
, _tweaks (default_tweaks)
, _char_pixel_width (0)
, _char_pixel_height (0)
, _char_avg_pixel_width (0)
@ -300,7 +301,7 @@ ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
}
void (*rounded_function)(cairo_t*, double, double, double, double, double);
if (corner_radius) {
switch (_corner_mask) {
case 0x1: /* upper left only */
rounded_function = Gtkmm2ext::rounded_top_left_rectangle;
@ -317,6 +318,9 @@ ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
default:
rounded_function = Gtkmm2ext::rounded_rectangle;
}
} else {
rounded_function = Gtkmm2ext::rectangle;
}
// 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)) {

View File

@ -69,6 +69,9 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ
ForceFlat = 0x20,
};
static Tweaks default_tweaks;
static void set_default_tweaks (Tweaks t) { default_tweaks = t; }
Tweaks tweaks() const { return _tweaks; }
void set_tweaks (Tweaks);