Update size-request when font/style is set
This commit is contained in:
parent
5ef2d04cd8
commit
f76e63fd89
@ -65,15 +65,26 @@ Gtkmm2ext::get_ink_pixel_size (Glib::RefPtr<Pango::Layout> layout,
|
|||||||
height = PANGO_PIXELS(ink_rect.get_height());
|
height = PANGO_PIXELS(ink_rect.get_height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_set_size_request_to_display_given_text (Glib::RefPtr<Gtk::Style> const& sty, Gtk::Widget* w, std::string const& text,
|
||||||
|
gint hpadding, gint vpadding)
|
||||||
|
{
|
||||||
|
w->ensure_style ();
|
||||||
|
if (sty && sty->get_font() == w->get_style()->get_font()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
w->create_pango_layout (text)->get_pixel_size (width, height);
|
||||||
|
w->set_size_request(width + hpadding, height + vpadding);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, std::string const& text,
|
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, std::string const& text,
|
||||||
gint hpadding, gint vpadding)
|
gint hpadding, gint vpadding)
|
||||||
{
|
{
|
||||||
int width, height;
|
w.signal_style_changed().connect (sigc::bind (sigc::ptr_fun (_set_size_request_to_display_given_text), &w, text, hpadding, vpadding));
|
||||||
w.ensure_style ();
|
_set_size_request_to_display_given_text (Glib::RefPtr<Gtk::Style>(), &w, text, hpadding, vpadding);
|
||||||
|
|
||||||
w.create_pango_layout (text)->get_pixel_size (width, height);
|
|
||||||
w.set_size_request(width + hpadding, height + vpadding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline guint8
|
static inline guint8
|
||||||
|
Loading…
Reference in New Issue
Block a user