all repos — fluxbox @ 71f75c70ae4e47ba0a58590aeb17152fc648edf7

custom fork of the fluxbox windowmanager

Add menu.hilite.font and menu.hilite.justify style resources
Vladimir A. Pavlov pv4@bk.ru
commit

71f75c70ae4e47ba0a58590aeb17152fc648edf7

parent

9d25ea54a1a21c252622232e0ec959f500e638f3

4 files changed, 39 insertions(+), 20 deletions(-)

jump to
M doc/asciidoc/fluxbox-style.txtdoc/asciidoc/fluxbox-style.txt

@@ -328,6 +328,8 @@ menu.frame.textColor: <color>

menu.hilite: <texture type> menu.hilite.color: <color> menu.hilite.colorTo: <color> + menu.hilite.font: <font> + menu.hilite.justify: <{left|center|right}> menu.hilite.pixmap: <filename> menu.hilite.textColor: <color> menu.itemHeight: <integer>
M src/FbTk/MenuItem.ccsrc/FbTk/MenuItem.cc

@@ -49,20 +49,20 @@

unsigned int height = theme->itemHeight(); int bevelW = theme->bevelWidth(); - int font_top = (height - theme->frameFont().height())/2; - int underline_height = font_top + theme->frameFont().ascent() + 2; + int font_top = (height - theme->hiliteFont().height())/2; + int underline_height = font_top + theme->hiliteFont().ascent() + 2; int bottom = height - bevelW - 1; text_y += bottom > underline_height ? underline_height : bottom; - int text_w = theme->frameFont().textWidth(label()); + int text_w = theme->hiliteFont().textWidth(label()); const FbString& visual = m_label.visual(); BiDiString search_string(FbString(visual, 0, size > visual.size() ? visual.size() : size)); - int search_string_w = theme->frameFont().textWidth(search_string); + int search_string_w = theme->hiliteFont().textWidth(search_string); // pay attention to the text justification - switch(theme->frameFontJustify()) { + switch(theme->hiliteFontJustify()) { case FbTk::LEFT: text_x += bevelW + height + 1; break;

@@ -76,7 +76,7 @@ }

// avoid drawing an ugly dot if (size != 0) - draw.drawLine(theme->frameUnderlineGC().gc(), + draw.drawLine(theme->hiliteUnderlineGC().gc(), text_x, text_y, text_x + search_string_w, text_y); }

@@ -152,16 +152,17 @@ if (draw_background) {

const GContext &tgc = (highlight ? theme->hiliteTextGC() : (isEnabled() ? theme->frameTextGC() : theme->disableTextGC() ) ); + const Font& font = (highlight ? theme->hiliteFont() : theme->frameFont()); // // Text // int text_y = y, text_x = x; - int text_w = theme->frameFont().textWidth(label()); + int text_w = font.textWidth(label()); - int height_offset = theme->itemHeight() - (theme->frameFont().height() + 2*theme->bevelWidth()); - text_y = y + theme->bevelWidth() + theme->frameFont().ascent() + height_offset/2; + int height_offset = theme->itemHeight() - (font.height() + 2*theme->bevelWidth()); + text_y = y + theme->bevelWidth() + font.ascent() + height_offset/2; - switch(theme->frameFontJustify()) { + switch(highlight ? theme->hiliteFontJustify() : theme->frameFontJustify()) { case FbTk::LEFT: text_x = x + theme->bevelWidth() + height + 1; break;

@@ -174,7 +175,7 @@ text_x = x + ((width + 1 - text_w) / 2);

break; } - theme->frameFont().drawText(draw, theme->screenNum(), tgc.gc(), label(), text_x, text_y); + font.drawText(draw, theme->screenNum(), tgc.gc(), label(), text_x, text_y); } GC gc = (highlight) ? theme->hiliteTextGC().gc() :

@@ -324,14 +325,17 @@ screen_num));

} unsigned int MenuItem::height(const FbTk::ThemeProxy<MenuTheme> &theme) const { - return std::max(theme->frameFont().height() + 2*theme->bevelWidth(), theme->itemHeight()); + return std::max(theme->itemHeight(), + std::max(theme->frameFont().height() + 2*theme->bevelWidth(), + theme->hiliteFont().height() + 2*theme->bevelWidth())); } unsigned int MenuItem::width(const FbTk::ThemeProxy<MenuTheme> &theme) const { // textwidth + bevel width on each side of the text const unsigned int icon_width = height(theme); - const unsigned int normal = theme->frameFont().textWidth(label()) + - 2 * (theme->bevelWidth() + icon_width); + const unsigned int normal = 2 * (theme->bevelWidth() + icon_width) + + std::max(theme->frameFont().textWidth(label()), + theme->hiliteFont().textWidth(label())); return m_icon.get() == 0 ? normal : normal + icon_width; }
M src/FbTk/MenuTheme.ccsrc/FbTk/MenuTheme.cc

@@ -48,7 +48,9 @@ frame(*this, "menu.frame", "Menu.Frame"),

hilite(*this, "menu.hilite", "Menu.Hilite"), titlefont(*this, "menu.title.font", "Menu.Title.Font"), framefont(*this, "menu.frame.font", "Menu.Frame.Font"), + hilitefont(*this, "menu.hilite.font", "Menu.Hilite.Font"), framefont_justify(*this, "menu.frame.justify", "Menu.Frame.Justify"), + hilitefont_justify(*this, "menu.hilite.justify", "Menu.Hilite.Justify"), titlefont_justify(*this, "menu.title.justify", "Menu.Title.Justify"), bullet_pos(*this, "menu.bullet.position", "Menu.Bullet.Position"), m_bullet(*this, "menu.bullet", "Menu.Bullet"),

@@ -84,7 +86,9 @@ *m_shapeplace = FbTk::Shape::NONE;

ThemeManager::instance().loadTheme(*this); - m_real_item_height = std::max(*m_item_height, frameFont().height() + 2*bevelWidth()); + 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());

@@ -111,7 +115,9 @@ *m_bevel_width = 20;

if (*m_border_width > 20) *m_border_width = 20; - m_real_item_height = std::max(*m_item_height, frameFont().height() + 2*bevelWidth()); + 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());

@@ -143,6 +149,10 @@ } else if (item.name() == "menu.borderColor") {

return ThemeManager::instance().loadItem(item, "borderColor", "BorderColor"); } else if (item.name() == "menu.bevelWidth") { return ThemeManager::instance().loadItem(item, "bevelWidth", "BevelWidth"); + } else if (item.name() == "menu.hilite.font") { + return ThemeManager::instance().loadItem(item, "menu.frame.font", "Menu.Frame.Font"); + } else if (item.name() == "menu.hilite.justify") { + return ThemeManager::instance().loadItem(item, "menu.frame.justify", "Menu.Frame.Justify"); } return false;
M src/FbTk/MenuTheme.hhsrc/FbTk/MenuTheme.hh

@@ -76,9 +76,12 @@ const Font &titleFont() const { return *titlefont; }

Font &titleFont() { return *titlefont; } const Font &frameFont() const { return *framefont; } Font &frameFont() { return *framefont; } + const Font &hiliteFont() const { return *hilitefont; } + Font &hiliteFont() { return *hilitefont; } ///@} Justify frameFontJustify() const { return *framefont_justify; } + Justify hiliteFontJustify() const { return *hilitefont_justify; } Justify titleFontJustify() const { return *titlefont_justify; } /**

@@ -87,13 +90,13 @@ */

///@{ const GContext &titleTextGC() const { return t_text_gc; } const GContext &frameTextGC() const { return f_text_gc; } - const GContext &frameUnderlineGC() const { return u_text_gc; } + const GContext &hiliteUnderlineGC() const { return u_text_gc; } const GContext &hiliteTextGC() const { return h_text_gc; } const GContext &disableTextGC() const { return d_text_gc; } const GContext &hiliteGC() const { return hilite_gc; } GContext &titleTextGC() { return t_text_gc; } GContext &frameTextGC() { return f_text_gc; } - GContext &frameUnderlineGC() { return u_text_gc; } + GContext &hiliteUnderlineGC() { return u_text_gc; } GContext &hiliteTextGC() { return h_text_gc; } GContext &disableTextGC() { return d_text_gc; } GContext &hiliteGC() { return hilite_gc; }

@@ -138,8 +141,8 @@

private: ThemeItem<Color> t_text, f_text, h_text, d_text, u_text; ThemeItem<Texture> title, frame, hilite; - ThemeItem<Font> titlefont, framefont; - ThemeItem<Justify> framefont_justify, titlefont_justify; + ThemeItem<Font> titlefont, framefont, hilitefont; + ThemeItem<Justify> framefont_justify, hilitefont_justify, titlefont_justify; ThemeItem<Justify> bullet_pos; ThemeItem<BulletType> m_bullet; ThemeItem<Shape::ShapePlace> m_shapeplace;