colorchooser: display selected color in menue, based on patch (c) martii <m4rtii@gmx.de>

Origin commit data
------------------
Commit: 5d95016b37
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2013-07-12 (Fri, 12 Jul 2013)
This commit is contained in:
[CST] Focus
2013-07-12 16:31:23 +04:00
parent 2e542cb8ca
commit b18668f8a3
2 changed files with 26 additions and 8 deletions

View File

@@ -125,7 +125,7 @@ void CMenuItem::paintItemBackground (const bool select_mode, const int &item_hei
frameBuffer->paintBoxRel(x, y, dx, item_height, item_bgcolor, RADIUS_LARGE); frameBuffer->paintBoxRel(x, y, dx, item_height, item_bgcolor, RADIUS_LARGE);
} }
void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, const char * left_text, const char * right_text) void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, const char * left_text, const char * right_text, const fb_pixel_t right_bgcol)
{ {
if (select_mode) if (select_mode)
{ {
@@ -152,11 +152,20 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height,
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height, _dx- (name_start_x - x), left_text, item_color, 0, true); // UTF-8 g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height, _dx- (name_start_x - x), left_text, item_color, 0, true); // UTF-8
//right text //right text
if (right_text != NULL) if (right_text || right_bgcol)
{ {
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text, true); int stringwidth = 0;
if (right_text)
stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text, true);
int stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text, true) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx int stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text, true) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height,dx- (stringstartposOption- x), right_text, item_color, 0, true); if (right_bgcol) {
if (!right_text)
stringstartposOption -= 60;
CFrameBuffer::getInstance()->paintBoxRel(stringstartposOption, y + 1, dx - stringstartposOption + x - 1, item_height - 2, right_bgcol, RADIUS_LARGE);
CFrameBuffer::getInstance()->paintBoxFrame(stringstartposOption, y + 1, dx - stringstartposOption + x - 1, item_height - 2, 1, COL_MENUCONTENT_PLUS_6, RADIUS_LARGE);
}
if (right_text)
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height,dx- (stringstartposOption- x), right_text, item_color, 0, true);
} }
} }
@@ -1732,9 +1741,14 @@ int CMenuForwarder::getWidth(void)
else if (option_string) else if (option_string)
option_text = option_string->c_str(); option_text = option_string->c_str();
fb_pixel_t bgcol = 0;
if (jumpTarget)
bgcol = jumpTarget->getColor();
if (option_text != NULL) if (option_text != NULL)
tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true); tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true);
else if (bgcol)
tw += 10 + 60;
return tw; return tw;
} }
@@ -1773,6 +1787,9 @@ int CMenuForwarder::paint(bool selected)
const char * l_text = getName(); const char * l_text = getName();
const char * option_text = getOption(); const char * option_text = getOption();
fb_pixel_t bgcol = 0;
if (jumpTarget)
bgcol = jumpTarget->getColor();
//paint item //paint item
prepareItem(selected, height); prepareItem(selected, height);
@@ -1781,7 +1798,7 @@ int CMenuForwarder::paint(bool selected)
paintItemButton(selected, height); paintItemButton(selected, height);
//caption //caption
paintItemCaption(selected, height, l_text, option_text); paintItemCaption(selected, height, l_text, option_text, bgcol);
return y+ height; return y+ height;
} }

View File

@@ -80,6 +80,7 @@ class CMenuTarget
virtual ~CMenuTarget(){} virtual ~CMenuTarget(){}
virtual void hide(){} virtual void hide(){}
virtual int exec(CMenuTarget* parent, const std::string & actionKey) = 0; virtual int exec(CMenuTarget* parent, const std::string & actionKey) = 0;
virtual fb_pixel_t getColor(void) { return 0; }
}; };
class CMenuItem class CMenuItem
@@ -139,7 +140,7 @@ class CMenuItem
virtual void setItemButton(const std::string& icon_Name, const bool is_select_button = false); virtual void setItemButton(const std::string& icon_Name, const bool is_select_button = false);
virtual void paintItemCaption(const bool select_mode, const int &item_height, const char * left_text=NULL, const char * right_text=NULL); virtual void paintItemCaption(const bool select_mode, const int &item_height, const char * left_text=NULL, const char * right_text=NULL, const fb_pixel_t right_bgcol=0);
virtual void paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text=NULL, const char * right_text=NULL); virtual void paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text=NULL, const char * right_text=NULL);