diff --git a/libs/widgets/ardour_button.cc b/libs/widgets/ardour_button.cc index 8f9c668aa8..87ba831b04 100644 --- a/libs/widgets/ardour_button.cc +++ b/libs/widgets/ardour_button.cc @@ -64,6 +64,7 @@ ArdourButton::ArdourButton (Element e, bool toggle) , _char_pixel_width (0) , _char_pixel_height (0) , _char_avg_pixel_width (0) + , _width_padding (1.75) , _custom_font_set (false) , _text_width (0) , _text_height (0) @@ -111,6 +112,7 @@ ArdourButton::ArdourButton (const std::string& str, Element e, bool toggle) , _char_pixel_width (0) , _char_pixel_height (0) , _char_avg_pixel_width (0) + , _width_padding (1.75) , _custom_font_set (false) , _text_width (0) , _text_height (0) @@ -691,7 +693,7 @@ ArdourButton::on_size_request (Gtk::Requisition* req) } else /*if (!_text.empty() || !_sizing_texts.empty()) */ { req->height = std::max(req->height, (int) ceil(char_pixel_height() * BASELINESTRETCH + 1.0)); - req->width += rint(1.75 * char_pixel_width()); // padding + req->width += rint(_width_padding * char_pixel_width()); // padding int sizing_text_width = 0, sizing_text_height = 0; @@ -1337,6 +1339,18 @@ ArdourButton::set_text_ellipsize (Pango::EllipsizeMode e) } } +void +ArdourButton::set_width_padding (float p) +{ + if (_width_padding == p) { + return; + } + _width_padding = p; + if (get_realized ()) { + queue_resize (); + } +} + void ArdourButton::ensure_layout () { diff --git a/libs/widgets/widgets/ardour_button.h b/libs/widgets/widgets/ardour_button.h index 6bfe00a68e..f6a1882622 100644 --- a/libs/widgets/widgets/ardour_button.h +++ b/libs/widgets/widgets/ardour_button.h @@ -102,6 +102,7 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ void set_layout_ellipsize_width (int w); void set_layout_font (const Pango::FontDescription&); void set_text_ellipsize (Pango::EllipsizeMode); + void set_width_padding (float); /* Sets the text used for size request computation. Pass an * empty string to return to the default behavior which uses @@ -171,6 +172,7 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ unsigned int _char_pixel_width; unsigned int _char_pixel_height; float _char_avg_pixel_width; + float _width_padding; bool _custom_font_set; int _text_width;