Allow multiple sizing texts for ArdourButton/Dropdown

A widget's style (font) is only set after the widget has been
packed and inherits relevant information from the top-level window.

`set_size_request_to_display_given_text()` produces incorrect
results when it is called for widgets without a top-level
(here ARDOUR_UI::setup_windows() _main_window.add(), changes the
font from "Sans 11" to "Sans 9" for ArdourDropdowns).

`set_size_request_to_display_given_text()` must subscribe to
`signal_style_changed()`, however in case of ArdourButton UI-scaling
of elements also needs to be taken into account. It is preferable
to allow for multiple sizing-texts directly.
This commit is contained in:
Robin Gareus 2022-09-20 02:35:26 +02:00
parent d1bf8428fc
commit 8508b3dba4
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 33 additions and 23 deletions

View file

@ -106,8 +106,8 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ
/* Sets the text used for size request computation. Pass an
* empty string to return to the default behavior which uses
* the currently displayed text for measurement. */
void set_sizing_text (const std::string&);
const std::string& get_sizing_text () {return _sizing_text;}
void set_sizing_text (std::string const&);
void set_sizing_texts (std::vector<std::string> const&);
sigc::signal<void, GdkEventButton*> signal_led_clicked;
sigc::signal<void> signal_clicked;
@ -156,7 +156,7 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ
Glib::RefPtr<Pango::Layout> _layout;
Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
std::string _text;
std::string _sizing_text;
std::vector<std::string> _sizing_texts;
bool _markup;
Element _elements;
ArdourIcon::Icon _icon;