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:
parent
a375fdb183
commit
3301e993ad
1 changed files with 6 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue