menue.cpp/h: re add SUB_HEAD option with some samples inside test menu

This commit is contained in:
2019-04-03 15:35:29 +02:00
parent eceefe6f27
commit 8eb418617b
3 changed files with 28 additions and 4 deletions

View File

@@ -1127,7 +1127,7 @@ int CTestMenu::showTestMenu()
char rev[255]; char rev[255];
sprintf(rev, "Test menu, System revision %d %s", system_rev, system_rev == 0 ? "WARNING - INVALID" : ""); sprintf(rev, "Test menu, System revision %d %s", system_rev, system_rev == 0 ? "WARNING - INVALID" : "");
CMenuWidget w_test(rev /*"Test menu"*/, NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU); CMenuWidget w_test(rev /*"Test menu"*/, NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU);
w_test.addIntroItems(); w_test.addIntroItems("Subhead");
w_test.addItem(new CMenuForwarder("Shell Window Test", true, NULL, this, "shellwindow")); w_test.addItem(new CMenuForwarder("Shell Window Test", true, NULL, this, "shellwindow"));
//hardware //hardware
@@ -1156,6 +1156,18 @@ int CTestMenu::showTestMenu()
//restart gui //restart gui
w_test.addItem(new CMenuForwarder(LOCALE_SERVICEMENU_RESTART , true, NULL, CNeutrinoApp::getInstance(), "restart", CRCInput::RC_standby)); w_test.addItem(new CMenuForwarder(LOCALE_SERVICEMENU_RESTART , true, NULL, CNeutrinoApp::getInstance(), "restart", CRCInput::RC_standby));
w_test.addItem(GenericMenuSeparatorLine);
w_test.addItem(new CMenuSeparator(CMenuSeparator::STRING, "String Separator"));
w_test.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, "String Line Separator"));
w_test.addItem(new CMenuSeparator(CMenuSeparator::SUB_HEAD, "Sub Title"));
w_test.addItem(new CMenuSeparator(CMenuSeparator::SUB_HEAD | CMenuSeparator::ALIGN_LEFT, "Sub Title L"));
w_test.addItem(new CMenuSeparator(CMenuSeparator::SUB_HEAD | CMenuSeparator::ALIGN_RIGHT, "Sub Title R"));
//footer buttons //footer buttons
static const struct button_label footerButtons[2] = { static const struct button_label footerButtons[2] = {
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_COLORCHOOSER_RED }, { NEUTRINO_ICON_BUTTON_RED, LOCALE_COLORCHOOSER_RED },

View File

@@ -2476,13 +2476,24 @@ int CMenuSeparator::paint(bool selected)
height = getHeight(); height = getHeight();
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
if ((type & SUB_HEAD))
{
item_color = COL_MENUHEAD_TEXT;
item_bgcolor = g_settings.theme.menu_Head_gradient ? COL_MENUCONTENT_PLUS_0 : COL_MENUHEAD_PLUS_0;
}
else
{
item_color = COL_MENUCONTENTINACTIVE_TEXT;
item_bgcolor = COL_MENUCONTENT_PLUS_0;
}
frameBuffer->paintBoxRel(x, y, dx, height, item_bgcolor); frameBuffer->paintBoxRel(x, y, dx, height, item_bgcolor);
if ((type & LINE)) if ((type & LINE))
{ {
int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF; int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF;
paintBoxRel(x+OFFSET_INNER_MID, y+(height>>1), dx-2*OFFSET_INNER_MID, 1, COL_MENUCONTENT_PLUS_1, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light); paintBoxRel(x+OFFSET_INNER_MID, y+(height>>1), dx-2*OFFSET_INNER_MID, 1, COL_MENUCONTENT_PLUS_1, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light);
} }
if ((type & STRING)) if ((type & STRING) | (type & SUB_HEAD))
{ {
const char * l_name = getName(); const char * l_name = getName();
@@ -2494,7 +2505,7 @@ int CMenuSeparator::paint(bool selected)
/* if no alignment is specified, align centered */ /* if no alignment is specified, align centered */
if (type & ALIGN_LEFT) if (type & ALIGN_LEFT)
name_start_x = x + (2*OFFSET_INNER_MID + iconwidth); name_start_x = x + (!(type & SUB_HEAD) ? name_start_x : 2*OFFSET_INNER_MID + iconwidth);
else if (type & ALIGN_RIGHT) else if (type & ALIGN_RIGHT)
name_start_x = x + dx - stringwidth - 2*OFFSET_INNER_MID; name_start_x = x + dx - stringwidth - 2*OFFSET_INNER_MID;
else /* ALIGN_CENTER */ else /* ALIGN_CENTER */
@@ -2505,6 +2516,7 @@ int CMenuSeparator::paint(bool selected)
paintItemCaption(selected); paintItemCaption(selected);
} }
} }
return y+ height; return y+ height;
} }

View File

@@ -230,7 +230,7 @@ class CMenuSeparator : public CMenuItem
ALIGN_CENTER = 4, ALIGN_CENTER = 4,
ALIGN_LEFT = 8, ALIGN_LEFT = 8,
ALIGN_RIGHT = 16, ALIGN_RIGHT = 16,
SUB_HEAD = 0 //32 deprecated and invalid, only here for compatibility //TODO: remove global SUB_HEAD = 32 // description "SUB_HEAD" seems is misleading
}; };