Make preferredWidth max from un- and focused width

This is notably an issue if the focused font differs from the unfocused
font (eg. is bold or bigger)

Updating the value with the state leads to ugly judder (nasty when minimizing
a window through the iconbar) and not handling this causes random button
widths (depending on whether the button was focused when checking the value)
This commit is contained in:
Thomas Lübking 2016-10-02 14:32:47 +02:00
parent a375fdb183
commit 3301e993ad

View file

@ -288,7 +288,13 @@ bool IconButton::setOrientation(FbTk::Orientation orient) {
}
unsigned int IconButton::preferredWidth() const {
IconButton *that = const_cast<IconButton*>(this);
that->setFont(that->m_theme.focusedTheme()->text().font());
unsigned int r = TextButton::preferredWidth();
that->setFont(that->m_theme.unfocusedTheme()->text().font());
unsigned int r2 = TextButton::preferredWidth();
that->setFont(that->m_theme->text().font());
r = std::max(r, r2);
if (m_icon_pixmap.drawable())
r += m_icon_window.width() + 1;
return r;