Add menu.hilite.font and menu.hilite.justify style resources
This commit is contained in:
parent
9d25ea54a1
commit
71f75c70ae
4 changed files with 39 additions and 20 deletions
|
@ -328,6 +328,8 @@ Everything you need to make your menu look pretty.
|
|||
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>
|
||||
|
|
|
@ -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<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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<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;
|
||||
|
|
Loading…
Reference in a new issue