From 3301e993ada9fc794dcbba65e8ee28c1ebe5621a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sun, 2 Oct 2016 14:32:47 +0200 Subject: 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) --- src/IconButton.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/IconButton.cc b/src/IconButton.cc index d8205fb..a4cd8af 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -288,7 +288,13 @@ bool IconButton::setOrientation(FbTk::Orientation orient) { } unsigned int IconButton::preferredWidth() const { + IconButton *that = const_cast(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; -- cgit v0.11.2