Fix size-request that rely on Pango::Layout

A Pango::Layout created by Gtk::Widget::get_pango_context ()
does not have any font set. The Font is inherited from the
layout's context.

The actual font is set when the layout is used in
on_expose_event() via get_window ()->create_cairo_context ().

In some cases we rely on the font-size to calculate the widget's
size before rendering. At this point in time there is no drawing
context from which to inherit the style.

Furthermore, even after a call to `ensure_style()` in the c'tor
of a Widget get_font() simply returns the default value.

All Widgets that rely an Pango::Layout font size during
size-requests have to explicitly set the font.

This fixes various overlarge buttons with the initial default layout.
This commit is contained in:
Robin Gareus
2021-01-30 02:18:56 +01:00
parent d42b09f1d3
commit 2abf9c66a4
3 changed files with 26 additions and 11 deletions

View File

@@ -165,9 +165,11 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ
void set_text_internal ();
void recalc_char_pixel_geometry ();
unsigned int _char_pixel_width;
unsigned int _char_pixel_height;
float _char_avg_pixel_width;
float _char_avg_pixel_width;
bool _custom_font_set;
int _text_width;
int _text_height;