all repos — fluxbox @ ca452a58867b4ceaacb35c823902c89f2f6b6b83

custom fork of the fluxbox windowmanager

ignore font for empty title height calculation

and align calculation on init and reconfigure

As a result, if a menu has no label, the title height is determined
only by menu.titleHeight (and the border sizes), not by the unused font.
Thomas Lübking thomas.luebking@gmail.com
commit

ca452a58867b4ceaacb35c823902c89f2f6b6b83

parent

ea306493f95abd04cfa5b7653e3ad30a74b1985f

3 files changed, 23 insertions(+), 22 deletions(-)

jump to
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -158,7 +158,7 @@ event_mask ^= FocusChangeMask;

event_mask |= EnterWindowMask | LeaveWindowMask; int w = width(); - int th = theme()->titleHeight(); + int th = theme()->titleHeight(!m_title.label.logical().empty()); int fh = std::max(m_frame.height, m_frame.height); //create menu title

@@ -395,7 +395,7 @@ int bevel = theme()->bevelWidth();

int bw = theme()->borderWidth(); int ih = theme()->itemHeight(); unsigned int iw = 1; - int th = theme()->titleHeight(); + int th = theme()->titleHeight(!m_title.label.logical().empty()); int tbw = m_title.win.borderWidth(); int w = static_cast<int>(width()); size_t l = m_items.size();

@@ -668,7 +668,7 @@ break;

} // difference between height based on font, and style-set height - int height_offset = theme()->titleHeight() - (font.height() + 2*dx); + int height_offset = theme()->titleHeight(!m_title.label.logical().empty()) - (font.height() + 2*dx); font.drawText(drawable, screenNumber(), theme()->titleTextGC().gc(), m_title.label, dx, font.ascent() + dx + height_offset/2); // position }

@@ -707,10 +707,10 @@

int bw = m_window.borderWidth(); int h = static_cast<int>(height()); int title_bw = m_title.win.borderWidth(); - int title_height = (m_title.visible ? theme()->titleHeight() + title_bw : 0); + int title_height = (m_title.visible ? theme()->titleHeight(!m_title.label.logical().empty()) + title_bw : 0); int subm_title_height = (item->submenu()->m_title.visible) ? - item->submenu()->theme()->titleHeight() + bw : 0; + item->submenu()->theme()->titleHeight(!m_title.label.logical().empty()) + bw : 0; int subm_height = static_cast<int>(item->submenu()->height()); int subm_width = static_cast<int>(item->submenu()->width()); int subm_bw = item->submenu()->fbwindow().borderWidth();
M src/FbTk/MenuTheme.ccsrc/FbTk/MenuTheme.cc

@@ -86,14 +86,14 @@ *m_shapeplace = FbTk::Shape::NONE;

ThemeManager::instance().loadTheme(*this); - m_real_item_height = std::max(*m_item_height, - std::max(frameFont().height() + 2*bevelWidth(), - hiliteFont().height() + 2*bevelWidth())); - m_real_title_height = std::max(*m_title_height, - titleFont().height() + 2*bevelWidth()); - - m_real_item_height = m_real_item_height == 0 ? 1 : m_real_item_height; - m_real_title_height = m_real_title_height == 0 ? 1 : m_real_title_height; + if (*m_title_height < 1) + *m_title_height = 1; + const unsigned int pad = 2*bevelWidth(); + m_real_item_height = std::max(std::max(pad + 1, *m_item_height), + std::max(frameFont().height() + pad, + hiliteFont().height() + pad)); + m_real_title_height = std::max(std::max(pad + 1, *m_title_height), + titleFont().height() + pad); t_text_gc.setForeground(*t_text); f_text_gc.setForeground(*f_text);

@@ -115,15 +115,14 @@ *m_bevel_width = 20;

if (*m_border_width > 20) *m_border_width = 20; - m_real_item_height = std::max(*m_item_height, - std::max(frameFont().height() + 2*bevelWidth(), - hiliteFont().height() + 2*bevelWidth())); - m_real_title_height = std::max(*m_title_height, - titleFont().height() + 2*bevelWidth()); + + const unsigned int pad = 2*bevelWidth(); + m_real_item_height = std::max(std::max(pad + 1, *m_item_height), + std::max(frameFont().height() + pad, + hiliteFont().height() + pad)); + m_real_title_height = std::max(std::max(pad + 1, *m_title_height), + titleFont().height() + pad); - unsigned int minsize = 2*bevelWidth()+1; - m_real_item_height = m_real_item_height < minsize ? minsize: m_real_item_height; - m_real_title_height = m_real_title_height == minsize ? minsize : m_real_title_height; unsigned int item_pm_height = itemHeight(); m_bullet_pixmap->scale(item_pm_height, item_pm_height);
M src/FbTk/MenuTheme.hhsrc/FbTk/MenuTheme.hh

@@ -104,7 +104,9 @@ ///@}

BulletType bullet() const { return *m_bullet; } Justify bulletPos() const { return *bullet_pos; } - unsigned int titleHeight() const { return m_real_title_height; } + unsigned int titleHeight(bool fontConstrained = false) const { + return fontConstrained ? m_real_title_height : *m_title_height; + } unsigned int itemHeight() const { return m_real_item_height; } unsigned int borderWidth() const { return *m_border_width; } unsigned int bevelWidth() const { return *m_bevel_width; }