mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
port: menu classes ported
- add new members: setItemColors(), paintItemBackground() and paintItem()
(contains both) as a substitute for many double code lines in
paint()-members. These define (or manipulate) menue item colors.
(...bottom and scrollbars
- optimized painting of menu windows CMenuWidget::paint(), bottom and scrollbars
should be rendered with or without rounded corners clean now (FIXMES removed)
- CMenuOptionLanguageChooser::paint()
*set items always activ,
*make first char large in item captions
(...but here is still a lot to do)
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1013 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Branch: ni/coolstream
Commit: 4d2e019990
Author: Thilo Graf <dbt@novatux.de>
Date: 2011-01-08 (Sat, 08 Jan 2011)
Origin message was:
------------------
*port: menu classes ported
- add new members: setItemColors(), paintItemBackground() and paintItem()
(contains both) as a substitute for many double code lines in
paint()-members. These define (or manipulate) menue item colors.
(...bottom and scrollbars
- optimized painting of menu windows CMenuWidget::paint(), bottom and scrollbars
should be rendered with or without rounded corners clean now (FIXMES removed)
- CMenuOptionLanguageChooser::paint()
*set items always activ,
*make first char large in item captions
(...but here is still a lot to do)
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1013 e54a6e83-5905-42d5-8d5c-058d10e6a962
------------------
This commit was generated by Migit
This commit is contained in:
@@ -43,8 +43,6 @@
|
|||||||
#include <driver/rcinput.h>
|
#include <driver/rcinput.h>
|
||||||
#include <driver/screen_max.h>
|
#include <driver/screen_max.h>
|
||||||
|
|
||||||
#include <gui/color.h>
|
|
||||||
|
|
||||||
#include <gui/widget/stringinput.h>
|
#include <gui/widget/stringinput.h>
|
||||||
|
|
||||||
#include <global.h>
|
#include <global.h>
|
||||||
@@ -94,12 +92,62 @@ void CMenuItem::setItemButton(const std::string& icon_Name, const bool is_select
|
|||||||
iconName = icon_Name;
|
iconName = icon_Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenuItem::paintItemButton(const int startX, const int frame_height, const bool select_mode, const std::string &icon_Name)
|
void CMenuItem::setItemColors(const bool select_mode, const fb_pixel_t &def_color, const fb_pixel_t &def_bgcolor,
|
||||||
|
const fb_pixel_t &def_sel_color, const fb_pixel_t &def_sel_bgcolor,
|
||||||
|
const fb_pixel_t &def_inactiv_color, const fb_pixel_t &def_inactiv_bgcolor)
|
||||||
|
{
|
||||||
|
if (select_mode)
|
||||||
|
{
|
||||||
|
item_color = def_sel_color;
|
||||||
|
item_bgcolor = def_sel_bgcolor;
|
||||||
|
}
|
||||||
|
else if (!active)
|
||||||
|
{
|
||||||
|
item_color = def_inactiv_color;
|
||||||
|
item_bgcolor = def_inactiv_bgcolor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item_color = def_color;
|
||||||
|
item_bgcolor = def_bgcolor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMenuItem::paintItemBackground (const bool select_mode, const int &item_x, const int &item_y, const int &width, const int &height)
|
||||||
|
{
|
||||||
|
CFrameBuffer *frameBuffer = CFrameBuffer::getInstance();
|
||||||
|
|
||||||
|
if(select_mode)
|
||||||
|
frameBuffer->paintBoxRel(item_x, item_y, width, height, item_bgcolor, RADIUS_LARGE);
|
||||||
|
//else if(last)
|
||||||
|
//frameBuffer->paintBoxRel(item_x, item_y, width, height, i_bgcolor, RADIUS_LARGE, CORNER_BOTTOM); //FIXME
|
||||||
|
else
|
||||||
|
frameBuffer->paintBoxRel(item_x, item_y, width, height, item_bgcolor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMenuItem::paintItem(const bool select_mode, int &start_x, int &start_y, int &width, int &height,
|
||||||
|
const fb_pixel_t &def_color, const fb_pixel_t &def_bgcolor,
|
||||||
|
const fb_pixel_t &def_sel_color, const fb_pixel_t &def_sel_bgcolor,
|
||||||
|
const fb_pixel_t &def_inactiv_color, const fb_pixel_t &def_inactiv_bgcolor)
|
||||||
|
{
|
||||||
|
//set colors
|
||||||
|
setItemColors(select_mode, def_color, def_bgcolor,
|
||||||
|
def_sel_color, def_sel_bgcolor,
|
||||||
|
def_inactiv_color, def_inactiv_bgcolor);
|
||||||
|
|
||||||
|
//paint item background
|
||||||
|
paintItemBackground(select_mode, start_x, start_y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMenuItem::paintItemButton(const int startX, const int frame_height, const bool select_mode, const std::string &icon_Name, const bool icon_centered)
|
||||||
{
|
{
|
||||||
CFrameBuffer *frameBuffer = CFrameBuffer::getInstance();
|
CFrameBuffer *frameBuffer = CFrameBuffer::getInstance();
|
||||||
bool selected = select_mode;
|
bool selected = select_mode;
|
||||||
int height = frame_height;
|
int height = frame_height;
|
||||||
bool icon_painted = false;
|
bool icon_painted = false;
|
||||||
|
bool centered = icon_centered;
|
||||||
|
|
||||||
int w = 0;
|
int w = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
@@ -143,8 +191,12 @@ void CMenuItem::paintItemButton(const int startX, const int frame_height, const
|
|||||||
|
|
||||||
if (active && icon_w>0 && icon_h>0)
|
if (active && icon_w>0 && icon_h>0)
|
||||||
{
|
{
|
||||||
if (icon_name == NEUTRINO_ICON_BUTTON_OKAY || icon_name == NEUTRINO_ICON_BUTTON_HELP || icon_name == NEUTRINO_ICON_BUTTON_HOME)
|
//paint icon centered, if we using one of these icons. Note: overwrites parameter 'icon_centered'
|
||||||
icon_x = x+ ((icon_start_x-x)/2) - (icon_w/2);
|
if (!centered)
|
||||||
|
centered = (icon_name == NEUTRINO_ICON_BUTTON_OKAY || icon_name == NEUTRINO_ICON_BUTTON_HELP || icon_name == NEUTRINO_ICON_BUTTON_HOME);
|
||||||
|
|
||||||
|
if (centered/* || icon_name == NEUTRINO_ICON_BUTTON_OKAY || icon_name == NEUTRINO_ICON_BUTTON_HELP || icon_name == NEUTRINO_ICON_BUTTON_HOME*/)
|
||||||
|
icon_x = x+ ((icon_start_x-x)/2) - (icon_w/2); //centered
|
||||||
else
|
else
|
||||||
icon_x = icon_start_x - ((icon_w+m_icon_w)/*/2*/);
|
icon_x = icon_start_x - ((icon_w+m_icon_w)/*/2*/);
|
||||||
|
|
||||||
@@ -156,23 +208,25 @@ void CMenuItem::paintItemButton(const int startX, const int frame_height, const
|
|||||||
int number_w = 0;
|
int number_w = 0;
|
||||||
int number_x = 0;
|
int number_x = 0;
|
||||||
|
|
||||||
//paint only number if no icon was painted
|
//paint only number if no icon was painted and keyval is numeric
|
||||||
if (CRCInput::isNumeric(directKey) && !icon_painted)
|
if (CRCInput::isNumeric(directKey) && !icon_painted)
|
||||||
{
|
{
|
||||||
unsigned char color = COL_MENUCONTENT;
|
// unsigned char i_color = COL_MENUCONTENT;
|
||||||
if (selected)
|
// if (selected)
|
||||||
color = COL_MENUCONTENTSELECTED;
|
// i_color = COL_MENUCONTENTSELECTED;
|
||||||
if (!active)
|
// if (!active)
|
||||||
color = COL_MENUCONTENTINACTIVE;
|
// i_color = COL_MENUCONTENTINACTIVE;
|
||||||
|
|
||||||
number_w = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(CRCInput::getKeyName(directKey));
|
number_w = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(CRCInput::getKeyName(directKey));
|
||||||
|
|
||||||
number_x = icon_start_x - ((number_w+m_icon_w)/*/2*/);
|
number_x = icon_start_x - ((number_w+m_icon_w)/*/2*/);
|
||||||
|
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(number_x/*x + 15*/, y+ height, height, CRCInput::getKeyName(directKey), color, height);
|
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(number_x/*x + 15*/, y+ height, height, CRCInput::getKeyName(directKey), item_color, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
//paint marker icon
|
//paint marker icon, do not paint, if we have a centered icon
|
||||||
|
if (!centered)
|
||||||
|
{
|
||||||
if (selected && directKey != CRCInput::RC_nokey && selected_iconName.empty())
|
if (selected && directKey != CRCInput::RC_nokey && selected_iconName.empty())
|
||||||
{
|
{
|
||||||
int icon_offset = 2;
|
int icon_offset = 2;
|
||||||
@@ -183,6 +237,7 @@ void CMenuItem::paintItemButton(const int startX, const int frame_height, const
|
|||||||
|
|
||||||
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_RIGHT, icon_offset, y+ ((height/2- m_icon_h/2)) );
|
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_RIGHT, icon_offset, y+ ((height/2- m_icon_h/2)) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuWidget::CMenuWidget()
|
CMenuWidget::CMenuWidget()
|
||||||
@@ -225,7 +280,7 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const int /*m
|
|||||||
if (mwidth > 100)
|
if (mwidth > 100)
|
||||||
{
|
{
|
||||||
/* warn about abuse until we found all offenders... */
|
/* warn about abuse until we found all offenders... */
|
||||||
fprintf(stderr, "Warning: %s (%s) (%s) mwidth over 100%%: %d, current sreen width= %d\n", __FUNCTION__, nameString.c_str(), Icon.c_str(), mwidth);
|
fprintf(stderr, "Warning: %s (%s) (%s) mwidth over 100%%: %d\n", __FUNCTION__, nameString.c_str(), Icon.c_str(), mwidth);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -696,10 +751,13 @@ void CMenuWidget::paint()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//frameBuffer->paintBoxRel(x,y, width+sb_width,hheight, COL_MENUHEAD_PLUS_0);
|
//paint shadow and backround
|
||||||
frameBuffer->paintBoxRel(x+SHADOW_OFFSET, y+SHADOW_OFFSET, width+sb_width, height, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE); //FIXME rounded
|
int rad = RADIUS_LARGE-2;
|
||||||
frameBuffer->paintBoxRel(x, y, width+sb_width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); //FIXME rounded
|
frameBuffer->paintBoxRel(x+SHADOW_OFFSET ,y + SHADOW_OFFSET ,width + sb_width ,height + rad ,COL_MENUCONTENTDARK_PLUS_0 ,rad);
|
||||||
|
frameBuffer->paintBoxRel(x ,y ,width + sb_width ,height + rad ,COL_MENUCONTENT_PLUS_0 ,rad);
|
||||||
|
frameBuffer->paintBoxRel(x ,y ,width + sb_width ,hheight ,COL_MENUHEAD_PLUS_0 ,rad, CORNER_TOP);
|
||||||
|
|
||||||
|
//paint menu head
|
||||||
int HeadiconOffset = 0;
|
int HeadiconOffset = 0;
|
||||||
if(!(iconfile.empty())){
|
if(!(iconfile.empty())){
|
||||||
int w, h;
|
int w, h;
|
||||||
@@ -729,29 +787,31 @@ void CMenuWidget::paintItems()
|
|||||||
// Scrollbar
|
// Scrollbar
|
||||||
if(total_pages>1)
|
if(total_pages>1)
|
||||||
{
|
{
|
||||||
int sbh= ((item_height-4) / total_pages);
|
frameBuffer->paintBoxRel(x+ width,item_start_y, 15, item_height, COL_MENUCONTENT_PLUS_1, RADIUS_MIN);
|
||||||
// items box
|
frameBuffer->paintBoxRel(x+ width +2, item_start_y+ 2+ current_page*(item_height-4)/total_pages, 11, (item_height-4)/total_pages, COL_MENUCONTENT_PLUS_3, RADIUS_MIN);
|
||||||
frameBuffer->paintBoxRel(x, item_start_y, width+15, item_height+10, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
|
}
|
||||||
// scrollbar
|
frameBuffer->paintBoxRel(x,item_start_y, width,item_height, COL_MENUCONTENT_PLUS_0);
|
||||||
frameBuffer->paintBoxRel(x+ width,item_start_y, 15, item_height, COL_MENUCONTENT_PLUS_1);
|
|
||||||
frameBuffer->paintBoxRel(x+ width +2, item_start_y+ 2+ current_page* sbh, 11, sbh, COL_MENUCONTENT_PLUS_3);
|
|
||||||
} else
|
|
||||||
frameBuffer->paintBoxRel(x, item_start_y, width,item_height, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);//FIXME round
|
|
||||||
|
|
||||||
int ypos=item_start_y;
|
int ypos=item_start_y;
|
||||||
for (unsigned int count = 0; count < items.size(); count++) {
|
for (unsigned int count = 0; count < items.size(); count++)
|
||||||
|
{
|
||||||
CMenuItem* item = items[count];
|
CMenuItem* item = items[count];
|
||||||
|
|
||||||
if ((count >= page_start[current_page]) && (count < page_start[current_page + 1])) {
|
if ((count >= page_start[current_page]) &&
|
||||||
|
(count < page_start[current_page + 1]))
|
||||||
|
{
|
||||||
item->init(x, ypos, width, iconOffset);
|
item->init(x, ypos, width, iconOffset);
|
||||||
if( (item->isSelectable()) && (selected==-1) ) {
|
if( (item->isSelectable()) && (selected==-1) )
|
||||||
|
{
|
||||||
ypos = item->paint(true);
|
ypos = item->paint(true);
|
||||||
selected = count;
|
selected = count;
|
||||||
} else {
|
|
||||||
//ypos = item->paint(selected==((signed int) count), (count == items.size()-1));
|
|
||||||
ypos = item->paint(selected==((signed int) count), (count == (page_start[current_page + 1]-1)));
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
|
ypos = item->paint(selected==((signed int) count) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* x = -1 is a marker which prevents the item from being painted on setActive changes */
|
/* x = -1 is a marker which prevents the item from being painted on setActive changes */
|
||||||
item->init(-1, 0, 0, 0);
|
item->init(-1, 0, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -828,30 +888,8 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*)
|
|||||||
return menu_return::RETURN_NONE;
|
return menu_return::RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuOptionNumberChooser::paint(bool selected, bool last)
|
int CMenuOptionNumberChooser::paint(bool selected, bool /*last*/)
|
||||||
{
|
{
|
||||||
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
|
|
||||||
|
|
||||||
unsigned char color = COL_MENUCONTENT;
|
|
||||||
fb_pixel_t bgcolor = COL_MENUCONTENT_PLUS_0;
|
|
||||||
if (selected)
|
|
||||||
{
|
|
||||||
color = COL_MENUCONTENTSELECTED;
|
|
||||||
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
|
||||||
}
|
|
||||||
if (!active)
|
|
||||||
{
|
|
||||||
color = COL_MENUCONTENTINACTIVE;
|
|
||||||
bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected)
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE); //FIXME
|
|
||||||
else if(last)
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE, CORNER_BOTTOM); //FIXME
|
|
||||||
else
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor);
|
|
||||||
|
|
||||||
const char * l_option;
|
const char * l_option;
|
||||||
char option_value[11];
|
char option_value[11];
|
||||||
|
|
||||||
@@ -867,12 +905,16 @@ int CMenuOptionNumberChooser::paint(bool selected, bool last)
|
|||||||
int stringstartposName = x + offx + 10;
|
int stringstartposName = x + offx + 10;
|
||||||
int stringstartposOption = x + dx - stringwidth - 10; //+ offx
|
int stringstartposOption = x + dx - stringwidth - 10; //+ offx
|
||||||
|
|
||||||
|
//paint item
|
||||||
|
paintItem(selected, x, y, dx, height);
|
||||||
|
|
||||||
|
//paint item icon
|
||||||
paintItemButton(stringstartposName, height, selected, NEUTRINO_ICON_BUTTON_OKAY);
|
paintItemButton(stringstartposName, height, selected, NEUTRINO_ICON_BUTTON_OKAY);
|
||||||
|
|
||||||
const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName);
|
const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName);
|
||||||
|
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposName, y+height,dx- (stringstartposName - x), l_optionName, color, 0, true); // UTF-8
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposName, y+height,dx- (stringstartposName - x), l_optionName, item_color, 0, true); // UTF-8
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption - x), l_option, color, 0, true); // UTF-8
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption - x), l_option, item_color, 0, true); // UTF-8
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
@@ -1046,33 +1088,11 @@ int CMenuOptionChooser::exec(CMenuTarget*)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuOptionChooser::paint( bool selected , bool last)
|
int CMenuOptionChooser::paint( bool selected , bool /*last*/)
|
||||||
{
|
{
|
||||||
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
|
|
||||||
|
|
||||||
if(optionName != NONEXISTANT_LOCALE)
|
if(optionName != NONEXISTANT_LOCALE)
|
||||||
optionNameString = g_Locale->getText(optionName);
|
optionNameString = g_Locale->getText(optionName);
|
||||||
|
|
||||||
unsigned char color = COL_MENUCONTENT;
|
|
||||||
fb_pixel_t bgcolor = COL_MENUCONTENT_PLUS_0;
|
|
||||||
if (selected)
|
|
||||||
{
|
|
||||||
color = COL_MENUCONTENTSELECTED;
|
|
||||||
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
|
||||||
}
|
|
||||||
if (!active)
|
|
||||||
{
|
|
||||||
color = COL_MENUCONTENTINACTIVE;
|
|
||||||
bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected)
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE); //FIXME
|
|
||||||
else if(last)
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE, CORNER_BOTTOM); //FIXME
|
|
||||||
else
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor);
|
|
||||||
|
|
||||||
neutrino_locale_t option = NONEXISTANT_LOCALE;
|
neutrino_locale_t option = NONEXISTANT_LOCALE;
|
||||||
const char * l_option = NULL;
|
const char * l_option = NULL;
|
||||||
|
|
||||||
@@ -1099,10 +1119,14 @@ int CMenuOptionChooser::paint( bool selected , bool last)
|
|||||||
int stringstartposName = x + offx + 10;
|
int stringstartposName = x + offx + 10;
|
||||||
int stringstartposOption = x + dx - stringwidth - 10; //+ offx
|
int stringstartposOption = x + dx - stringwidth - 10; //+ offx
|
||||||
|
|
||||||
|
//paint item
|
||||||
|
paintItem(selected, x, y, dx, height);
|
||||||
|
|
||||||
|
//paint item icon
|
||||||
paintItemButton(stringstartposName, height, selected, NEUTRINO_ICON_BUTTON_OKAY);
|
paintItemButton(stringstartposName, height, selected, NEUTRINO_ICON_BUTTON_OKAY);
|
||||||
|
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposName, y+height,dx- (stringstartposName - x), optionNameString.c_str(), color, 0, true); // UTF-8
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposName, y+height,dx- (stringstartposName - x), optionNameString.c_str(), item_color, 0, true); // UTF-8
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption - x), l_option, color, 0, true); // UTF-8
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption - x), l_option, item_color, 0, true); // UTF-8
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
@@ -1225,28 +1249,8 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuOptionStringChooser::paint( bool selected, bool last )
|
int CMenuOptionStringChooser::paint( bool selected, bool /*last*/ )
|
||||||
{
|
{
|
||||||
CFrameBuffer *fb = CFrameBuffer::getInstance();
|
|
||||||
unsigned char color = COL_MENUCONTENT;
|
|
||||||
fb_pixel_t bgcolor = COL_MENUCONTENT_PLUS_0;
|
|
||||||
if (selected) {
|
|
||||||
color = COL_MENUCONTENTSELECTED;
|
|
||||||
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
|
||||||
}
|
|
||||||
if (!active) {
|
|
||||||
color = COL_MENUCONTENTINACTIVE;
|
|
||||||
bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected)
|
|
||||||
fb->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE); //FIXME
|
|
||||||
else if(last)
|
|
||||||
fb->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE, CORNER_BOTTOM); //FIXME
|
|
||||||
else
|
|
||||||
fb->paintBoxRel(x, y, dx, height, bgcolor);
|
|
||||||
|
|
||||||
|
|
||||||
const char * l_optionName = g_Locale->getText(optionName);
|
const char * l_optionName = g_Locale->getText(optionName);
|
||||||
int optionwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_optionName, true);
|
int optionwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_optionName, true);
|
||||||
//int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(optionValue, true);
|
//int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(optionValue, true);
|
||||||
@@ -1254,10 +1258,14 @@ int CMenuOptionStringChooser::paint( bool selected, bool last )
|
|||||||
//int stringstartposOption = x + dx - stringwidth - 10; //+ offx
|
//int stringstartposOption = x + dx - stringwidth - 10; //+ offx
|
||||||
int stringstartposOption = x + offx + 10 + 10 + optionwidth;
|
int stringstartposOption = x + offx + 10 + 10 + optionwidth;
|
||||||
|
|
||||||
|
//paint item
|
||||||
|
paintItem(selected, x, y, dx, height);
|
||||||
|
|
||||||
|
//paint item icon
|
||||||
paintItemButton(stringstartposName, height, selected, NEUTRINO_ICON_BUTTON_OKAY);
|
paintItemButton(stringstartposName, height, selected, NEUTRINO_ICON_BUTTON_OKAY);
|
||||||
|
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposName, y+height, dx- (stringstartposName - x), l_optionName, color, 0, true); // UTF-8
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposName, y+height, dx- (stringstartposName - x), l_optionName, item_color, 0, true); // UTF-8
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height, dx- (stringstartposOption - x), optionValue, color, 0, true);
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height, dx- (stringstartposOption - x), optionValue, item_color, 0, true);
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
@@ -1320,36 +1328,30 @@ int CMenuOptionLanguageChooser::exec(CMenuTarget*)
|
|||||||
return menu_return::RETURN_NONE;
|
return menu_return::RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuOptionLanguageChooser::paint( bool selected, bool last )
|
int CMenuOptionLanguageChooser::paint( bool selected, bool /*last*/ )
|
||||||
{
|
{
|
||||||
unsigned char color = COL_MENUCONTENT;
|
active = true;
|
||||||
fb_pixel_t bgcolor = COL_MENUCONTENT_PLUS_0;
|
|
||||||
if (selected)
|
|
||||||
{
|
|
||||||
color = COL_MENUCONTENTSELECTED;
|
|
||||||
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected)
|
//paint item
|
||||||
CFrameBuffer::getInstance()->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE); //FIXME
|
paintItem(selected, x, y, dx, height);
|
||||||
else if(last)
|
|
||||||
CFrameBuffer::getInstance()->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE, CORNER_BOTTOM); //FIXME
|
|
||||||
else
|
|
||||||
CFrameBuffer::getInstance()->paintBoxRel(x, y, dx, height, bgcolor);
|
|
||||||
|
|
||||||
if (!(iconName.empty()))
|
|
||||||
{
|
|
||||||
CFrameBuffer::getInstance()->paintIcon(iconName, x + 10, y, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
//int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(optionValue);
|
|
||||||
int stringstartposOption = x + offx + 10;
|
int stringstartposOption = x + offx + 10;
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption - x), optionValue, color);
|
|
||||||
|
|
||||||
|
paintItemButton(stringstartposOption, height, selected, iconName, true);
|
||||||
|
|
||||||
|
//convert first letter to large
|
||||||
|
string s_optionValue = static_cast<std::string> (optionValue);
|
||||||
|
string ts = s_optionValue.substr(0, 1);
|
||||||
|
string s(ts);
|
||||||
|
s = toupper(s_optionValue[0]);
|
||||||
|
s_optionValue.replace(0, 1, s);
|
||||||
|
|
||||||
|
//paint item string
|
||||||
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption - x), s_optionValue, item_color);
|
||||||
|
|
||||||
|
//show in vfd
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
CVFD::getInstance()->showMenuText(1, s_optionValue.c_str());
|
||||||
CVFD::getInstance()->showMenuText(1, optionValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return y+height;
|
return y+height;
|
||||||
}
|
}
|
||||||
@@ -1451,9 +1453,8 @@ const char * CMenuForwarder::getName(void)
|
|||||||
return g_Locale->getText(text);
|
return g_Locale->getText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuForwarder::paint(bool selected, bool last)
|
int CMenuForwarder::paint(bool selected, bool /*last*/)
|
||||||
{
|
{
|
||||||
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
|
|
||||||
int height = getHeight();
|
int height = getHeight();
|
||||||
const char * l_text = getName();
|
const char * l_text = getName();
|
||||||
int stringstartposX = x + offx + 10;
|
int stringstartposX = x + offx + 10;
|
||||||
@@ -1471,36 +1472,22 @@ int CMenuForwarder::paint(bool selected, bool last)
|
|||||||
CVFD::getInstance()->showMenuText(0, l_text, -1, true);
|
CVFD::getInstance()->showMenuText(0, l_text, -1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char color = COL_MENUCONTENT;
|
//paint item
|
||||||
fb_pixel_t bgcolor = COL_MENUCONTENT_PLUS_0;
|
paintItem(selected, x, y, dx, height);
|
||||||
if (selected)
|
|
||||||
{
|
|
||||||
color = COL_MENUCONTENTSELECTED;
|
|
||||||
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
|
||||||
}
|
|
||||||
else if (!active)
|
|
||||||
{
|
|
||||||
color = COL_MENUCONTENTINACTIVE;
|
|
||||||
bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected)
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE); //FIXME
|
|
||||||
else if(last)
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor, RADIUS_LARGE, CORNER_BOTTOM); //FIXME
|
|
||||||
else
|
|
||||||
frameBuffer->paintBoxRel(x, y, dx, height, bgcolor);
|
|
||||||
|
|
||||||
|
//paint icon
|
||||||
paintItemButton(stringstartposX, height, selected);
|
paintItemButton(stringstartposX, height, selected);
|
||||||
|
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposX, y+ height, dx- (stringstartposX - x), l_text, color, 0, true); // UTF-8
|
//caption
|
||||||
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposX, y+ height, dx- (stringstartposX - x), l_text, item_color, 0, true); // UTF-8
|
||||||
|
|
||||||
|
//option text
|
||||||
if (option_text != NULL)
|
if (option_text != NULL)
|
||||||
{
|
{
|
||||||
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true);
|
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true);
|
||||||
int stringstartposOption = std::max(stringstartposX + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true) + 10,
|
int stringstartposOption = std::max(stringstartposX + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true) + 10,
|
||||||
x + dx - stringwidth - 10); //+ offx
|
x + dx - stringwidth - 10); //+ offx
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption- x), option_text, color, 0, true);
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+height,dx- (stringstartposOption- x), option_text, item_color, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return y+ height;
|
return y+ height;
|
||||||
@@ -1581,21 +1568,19 @@ int CMenuSeparator::paint(bool selected, bool /*last*/)
|
|||||||
int height;
|
int height;
|
||||||
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
|
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
|
||||||
height = getHeight();
|
height = getHeight();
|
||||||
uint8_t color;
|
|
||||||
fb_pixel_t bgcolor0;
|
|
||||||
|
|
||||||
if ((type & SUB_HEAD))
|
if ((type & SUB_HEAD))
|
||||||
{
|
{
|
||||||
color = COL_MENUHEAD;
|
item_color = COL_MENUHEAD;
|
||||||
bgcolor0 = COL_MENUHEAD_PLUS_0;
|
item_bgcolor = COL_MENUHEAD_PLUS_0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
color = COL_MENUCONTENTINACTIVE;
|
item_color = COL_MENUCONTENTINACTIVE;
|
||||||
bgcolor0 = COL_MENUCONTENT_PLUS_0;
|
item_bgcolor = COL_MENUCONTENT_PLUS_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
frameBuffer->paintBoxRel(x,y, dx, height, bgcolor0);
|
frameBuffer->paintBoxRel(x,y, dx, height, item_bgcolor);
|
||||||
if ((type & LINE))
|
if ((type & LINE))
|
||||||
{
|
{
|
||||||
frameBuffer->paintHLineRel(x+10,dx-20,y+(height>>1), COL_MENUCONTENT_PLUS_3);
|
frameBuffer->paintHLineRel(x+10,dx-20,y+(height>>1), COL_MENUCONTENT_PLUS_3);
|
||||||
@@ -1620,9 +1605,9 @@ int CMenuSeparator::paint(bool selected, bool /*last*/)
|
|||||||
else /* ALIGN_CENTER */
|
else /* ALIGN_CENTER */
|
||||||
stringstartposX = x + (dx >> 1) - (stringwidth >> 1);
|
stringstartposX = x + (dx >> 1) - (stringwidth >> 1);
|
||||||
|
|
||||||
frameBuffer->paintBoxRel(stringstartposX-5, y, stringwidth+10, height, bgcolor0);
|
frameBuffer->paintBoxRel(stringstartposX-5, y, stringwidth+10, height, item_bgcolor);
|
||||||
|
|
||||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposX, y+height,dx- (stringstartposX- x) , l_text, color, 0, true); // UTF-8
|
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposX, y+height,dx- (stringstartposX- x) , l_text, item_color, 0, true); // UTF-8
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
{
|
{
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#include <driver/rcinput.h>
|
#include <driver/rcinput.h>
|
||||||
#include <system/localize.h>
|
#include <system/localize.h>
|
||||||
#include <gui/widget/icons.h>
|
#include <gui/widget/icons.h>
|
||||||
|
#include <gui/color.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -79,6 +80,9 @@ class CMenuItem
|
|||||||
protected:
|
protected:
|
||||||
int x, y, dx, offx;
|
int x, y, dx, offx;
|
||||||
bool used;
|
bool used;
|
||||||
|
unsigned char item_color ;
|
||||||
|
fb_pixel_t item_bgcolor ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool active;
|
bool active;
|
||||||
neutrino_msg_t directKey;
|
neutrino_msg_t directKey;
|
||||||
@@ -88,6 +92,7 @@ class CMenuItem
|
|||||||
std::string selected_iconName;
|
std::string selected_iconName;
|
||||||
bool show_marker;
|
bool show_marker;
|
||||||
|
|
||||||
|
|
||||||
CMenuItem()
|
CMenuItem()
|
||||||
{
|
{
|
||||||
x = -1;
|
x = -1;
|
||||||
@@ -124,7 +129,19 @@ class CMenuItem
|
|||||||
}
|
}
|
||||||
virtual void setActive(const bool Active);
|
virtual void setActive(const bool Active);
|
||||||
|
|
||||||
virtual void paintItemButton(const int startX, const int frame_height, const bool select_mode, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT);
|
virtual void paintItemButton(const int startX, const int frame_height, const bool select_mode, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT, const bool icon_centered = false);
|
||||||
|
|
||||||
|
virtual void setItemColors(const bool select_mode, const fb_pixel_t &def_color = COL_MENUCONTENT, const fb_pixel_t &def_bgcolor = COL_MENUCONTENT_PLUS_0,
|
||||||
|
const fb_pixel_t &def_sel_color = COL_MENUCONTENTSELECTED, const fb_pixel_t &def_sel_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0,
|
||||||
|
const fb_pixel_t &def_inactiv_color = COL_MENUCONTENTINACTIVE, const fb_pixel_t &def_inactiv_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0);
|
||||||
|
|
||||||
|
virtual void paintItemBackground (const bool select_mode, const int &x, const int &y, const int &width, const int &height);
|
||||||
|
|
||||||
|
virtual void paintItem(const bool select_mode, int &x, int &y, int &width, int &height ,
|
||||||
|
const fb_pixel_t &def_color = COL_MENUCONTENT, const fb_pixel_t &def_bgcolor = COL_MENUCONTENT_PLUS_0,
|
||||||
|
const fb_pixel_t &def_sel_color = COL_MENUCONTENTSELECTED, const fb_pixel_t &def_sel_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0,
|
||||||
|
const fb_pixel_t &def_inactiv_color = COL_MENUCONTENTINACTIVE, const fb_pixel_t &def_inactiv_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0);
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user