Allow to override Ardour button text padding
This commit is contained in:
parent
88ff1fa192
commit
3d6ecaad79
@ -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 ()
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user