diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-06-14 11:47:25 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-06-14 11:47:25 -0400 |
commit | 0fe194c90b11e3b22ed2d166d5ceae5099a3981d (patch) | |
tree | 75e1581cef513aad89af04d14ed117c4fb13a89f /gtk2_ardour/ardour_button.cc | |
parent | 0eb509ac2e023b556a43017c0d018be972b10673 (diff) |
extend ArdourButton API to provide a new tweak for buttons with occasional text
Buttons with this tweak do not change their size request based on their text (or lack of it)
Diffstat (limited to 'gtk2_ardour/ardour_button.cc')
-rw-r--r-- | gtk2_ardour/ardour_button.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/gtk2_ardour/ardour_button.cc b/gtk2_ardour/ardour_button.cc index 0fa53c5372..aa28382823 100644 --- a/gtk2_ardour/ardour_button.cc +++ b/gtk2_ardour/ardour_button.cc @@ -541,14 +541,30 @@ ArdourButton::on_size_request (Gtk::Requisition* req) } } - if ((_elements & Text) && !_text.empty()) { - // if _layout does not exist, char_pixel_height() creates it, - req->height = std::max(req->height, (int) ceil(char_pixel_height() * BASELINESTRETCH + 1.0)); - assert (_layout); - _layout->get_pixel_size (_text_width, _text_height); - - req->width += rint(1.75 * char_pixel_width()); // padding - req->width += _text_width; + if (_elements & Text) { + + if (_tweaks & OccasionalText) { + + /* size should not change based on presence or absence + * of text. + */ + + if (!_text.empty()) { + ensure_layout (); + _layout->set_text (_text); + _layout->get_pixel_size (_text_width, _text_height); + } + + } else if (!_text.empty()) { + + //if _layout does not exist, char_pixel_height() creates it, + + req->height = std::max(req->height, (int) ceil(char_pixel_height() * BASELINESTRETCH + 1.0)); + assert (_layout); + _layout->get_pixel_size (_text_width, _text_height); + req->width += rint(1.75 * char_pixel_width()); // padding + req->width += _text_width; + } /* XXX hack (surprise). Deal with two common rotation angles */ |