From 71f75c70ae4e47ba0a58590aeb17152fc648edf7 Mon Sep 17 00:00:00 2001 From: "Vladimir A. Pavlov" Date: Fri, 27 Jul 2012 21:32:35 +0400 Subject: Add menu.hilite.font and menu.hilite.justify style resources --- doc/asciidoc/fluxbox-style.txt | 2 ++ src/FbTk/MenuItem.cc | 32 ++++++++++++++++++-------------- src/FbTk/MenuTheme.cc | 14 ++++++++++++-- src/FbTk/MenuTheme.hh | 11 +++++++---- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/doc/asciidoc/fluxbox-style.txt b/doc/asciidoc/fluxbox-style.txt index 71af67f..a5cfeb6 100644 --- a/doc/asciidoc/fluxbox-style.txt +++ b/doc/asciidoc/fluxbox-style.txt @@ -328,6 +328,8 @@ Everything you need to make your menu look pretty. menu.hilite: menu.hilite.color: menu.hilite.colorTo: + menu.hilite.font: + menu.hilite.justify: <{left|center|right}> menu.hilite.pixmap: menu.hilite.textColor: menu.itemHeight: diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index c1357fb..c128c57 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -49,20 +49,20 @@ void MenuItem::drawLine(FbDrawable &draw, 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 @@ void MenuItem::drawLine(FbDrawable &draw, // 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 @@ void MenuItem::draw(FbDrawable &draw, 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 @@ void MenuItem::draw(FbDrawable &draw, 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 @@ void MenuItem::setIcon(const std::string &filename, int screen_num) { } unsigned int MenuItem::height(const FbTk::ThemeProxy &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 &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; } diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc index 28bcc35..db54483 100644 --- a/src/FbTk/MenuTheme.cc +++ b/src/FbTk/MenuTheme.cc @@ -48,7 +48,9 @@ MenuTheme::MenuTheme(int screen_num): 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 @@ MenuTheme::MenuTheme(int screen_num): 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 @@ void MenuTheme::reconfigTheme() { 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 @@ bool MenuTheme::fallback(ThemeItem_base &item) { 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; diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh index d39b5df..e217e7c 100644 --- a/src/FbTk/MenuTheme.hh +++ b/src/FbTk/MenuTheme.hh @@ -76,9 +76,12 @@ public: 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 @@ public: ///@{ 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 @@ public: private: ThemeItem t_text, f_text, h_text, d_text, u_text; ThemeItem title, frame, hilite; - ThemeItem titlefont, framefont; - ThemeItem framefont_justify, titlefont_justify; + ThemeItem titlefont, framefont, hilitefont; + ThemeItem framefont_justify, hilitefont_justify, titlefont_justify; ThemeItem bullet_pos; ThemeItem m_bullet; ThemeItem m_shapeplace; -- cgit v0.11.2