mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CMenuWidget: rework cc modules implementation
- don't create header instance on every widget paint. - remove parameters from hide(), not needed anymore - add signal/slot OnBeforePaint(), OnAfterHide() - try to fix infoclock handling - add member ResetModules() - allow separator to paint with gradient
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
#include <driver/screen_max.h>
|
#include <driver/screen_max.h>
|
||||||
#include <gui/pluginlist.h>
|
#include <gui/pluginlist.h>
|
||||||
#include <gui/widget/stringinput.h>
|
#include <gui/widget/stringinput.h>
|
||||||
|
#include <gui/infoclock.h>
|
||||||
|
|
||||||
|
|
||||||
#include <driver/fade.h>
|
#include <driver/fade.h>
|
||||||
@@ -547,7 +548,7 @@ CMenuWidget::CMenuWidget()
|
|||||||
preselected = -1;
|
preselected = -1;
|
||||||
details_line = NULL;
|
details_line = NULL;
|
||||||
info_box = NULL;
|
info_box = NULL;
|
||||||
show_details_line = true;
|
header = NULL;
|
||||||
nextShortcut = 1;
|
nextShortcut = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,10 +573,10 @@ void CMenuWidget::Init(const std::string &Icon, const int mwidth, const mn_widge
|
|||||||
mglobal = CMenuGlobal::getInstance(); //create CMenuGlobal instance only here
|
mglobal = CMenuGlobal::getInstance(); //create CMenuGlobal instance only here
|
||||||
frameBuffer = CFrameBuffer::getInstance();
|
frameBuffer = CFrameBuffer::getInstance();
|
||||||
iconfile = Icon;
|
iconfile = Icon;
|
||||||
details_line = new CComponentsDetailLine();
|
details_line = NULL;
|
||||||
show_details_line = true;
|
|
||||||
info_box = new CComponentsInfoBox();
|
info_box = NULL;
|
||||||
|
header = NULL;
|
||||||
//handle select values
|
//handle select values
|
||||||
if(w_index > MN_WIDGET_ID_MAX){
|
if(w_index > MN_WIDGET_ID_MAX){
|
||||||
//error
|
//error
|
||||||
@@ -632,8 +633,26 @@ void CMenuWidget::move(int xoff, int yoff)
|
|||||||
CMenuWidget::~CMenuWidget()
|
CMenuWidget::~CMenuWidget()
|
||||||
{
|
{
|
||||||
resetWidget(true);
|
resetWidget(true);
|
||||||
delete details_line;
|
ResetModules();
|
||||||
delete info_box;
|
}
|
||||||
|
|
||||||
|
void CMenuWidget::ResetModules()
|
||||||
|
{
|
||||||
|
if (header){
|
||||||
|
header->hide();
|
||||||
|
delete header;
|
||||||
|
header = NULL;
|
||||||
|
}
|
||||||
|
if (details_line){
|
||||||
|
details_line->hide();
|
||||||
|
delete details_line;
|
||||||
|
details_line = NULL;
|
||||||
|
}
|
||||||
|
if (info_box){
|
||||||
|
info_box->kill();
|
||||||
|
delete info_box;
|
||||||
|
info_box = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenuWidget::addItem(CMenuItem* menuItem, const bool defaultselected)
|
void CMenuWidget::addItem(CMenuItem* menuItem, const bool defaultselected)
|
||||||
@@ -1039,6 +1058,10 @@ void CMenuWidget::hide()
|
|||||||
if(savescreen && background)
|
if(savescreen && background)
|
||||||
restoreScreen();//FIXME
|
restoreScreen();//FIXME
|
||||||
else {
|
else {
|
||||||
|
if (header)
|
||||||
|
header->kill();
|
||||||
|
if (info_box)
|
||||||
|
info_box->kill();
|
||||||
frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height + fbutton_height);
|
frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height + fbutton_height);
|
||||||
//paintHint(-1);
|
//paintHint(-1);
|
||||||
}
|
}
|
||||||
@@ -1050,6 +1073,9 @@ void CMenuWidget::hide()
|
|||||||
items[count]->init(-1, 0, 0, 0);
|
items[count]->init(-1, 0, 0, 0);
|
||||||
hint_painted = false;
|
hint_painted = false;
|
||||||
washidden = true;
|
washidden = true;
|
||||||
|
if (CInfoClock::getInstance()->isRun())
|
||||||
|
CInfoClock::getInstance()->enableInfoClock(!CInfoClock::getInstance()->isBlocked());
|
||||||
|
OnAfterHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenuWidget::checkHints()
|
void CMenuWidget::checkHints()
|
||||||
@@ -1193,14 +1219,28 @@ void CMenuWidget::initSelectable()
|
|||||||
|
|
||||||
void CMenuWidget::paint()
|
void CMenuWidget::paint()
|
||||||
{
|
{
|
||||||
|
OnBeforePaint();
|
||||||
|
if (header){
|
||||||
|
if ((bool)header->getCornerRadius() != (bool)g_settings.rounded_corners) //ensure reset if corner mode was changed
|
||||||
|
ResetModules();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CInfoClock::getInstance()->isRun())
|
||||||
|
CInfoClock::getInstance()->disableInfoClock();
|
||||||
calcSize();
|
calcSize();
|
||||||
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 /*, nameString.c_str()*/);
|
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 /*, nameString.c_str()*/);
|
||||||
|
|
||||||
// paint head
|
// paint head
|
||||||
CComponentsHeader header(x, y, width + sb_width, hheight, getName(), iconfile);
|
if (header == NULL){
|
||||||
header.setShadowOnOff(CC_SHADOW_ON);
|
header = new CComponentsHeader(x, y, width + sb_width, hheight, getName(), iconfile);
|
||||||
header.setOffset(10);
|
header->enableShadow(CC_SHADOW_RIGHT);
|
||||||
header.paint(CC_SAVE_SCREEN_NO);
|
header->setOffset(10);
|
||||||
|
}
|
||||||
|
header->setColorBody(COL_MENUHEAD_PLUS_0);
|
||||||
|
header->setColorShadow(COL_MENUCONTENTDARK_PLUS_0);
|
||||||
|
header->setCaptionColor(COL_MENUHEAD_TEXT);
|
||||||
|
header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0);
|
||||||
|
header->paint(CC_SAVE_SCREEN_NO);
|
||||||
|
|
||||||
// paint body shadow
|
// paint body shadow
|
||||||
frameBuffer->paintBoxRel(x+SHADOW_OFFSET, y + hheight + SHADOW_OFFSET, width + sb_width, height - hheight + RADIUS_LARGE + (fbutton_count ? fbutton_height : 0), COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
|
frameBuffer->paintBoxRel(x+SHADOW_OFFSET, y + hheight + SHADOW_OFFSET, width + sb_width, height - hheight + RADIUS_LARGE + (fbutton_count ? fbutton_height : 0), COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
|
||||||
@@ -1220,9 +1260,9 @@ void CMenuWidget::setMenuPos(const int& menu_width)
|
|||||||
int scr_y = frameBuffer->getScreenY();
|
int scr_y = frameBuffer->getScreenY();
|
||||||
int scr_w = frameBuffer->getScreenWidth();
|
int scr_w = frameBuffer->getScreenWidth();
|
||||||
int scr_h = frameBuffer->getScreenHeight();
|
int scr_h = frameBuffer->getScreenHeight();
|
||||||
|
|
||||||
int real_h = full_height + fbutton_height + hint_height;
|
int real_h = full_height + fbutton_height + hint_height;
|
||||||
|
int x_old = x;
|
||||||
|
int y_old = y;
|
||||||
//configured positions
|
//configured positions
|
||||||
switch(g_settings.menu_pos)
|
switch(g_settings.menu_pos)
|
||||||
{
|
{
|
||||||
@@ -1254,6 +1294,8 @@ void CMenuWidget::setMenuPos(const int& menu_width)
|
|||||||
x = /*offx +*/ scr_x + scr_w - menu_width - 10;
|
x = /*offx +*/ scr_x + scr_w - menu_width - 10;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (x_old != x || y_old != y)
|
||||||
|
ResetModules();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenuWidget::paintItems()
|
void CMenuWidget::paintItems()
|
||||||
@@ -1364,23 +1406,21 @@ void CMenuWidget::enableSaveScreen(bool enable)
|
|||||||
|
|
||||||
void CMenuWidget::paintHint(int pos)
|
void CMenuWidget::paintHint(int pos)
|
||||||
{
|
{
|
||||||
if (!g_settings.show_menu_hints)
|
if (!g_settings.show_menu_hints){
|
||||||
|
ResetModules(); //ensure clean up on changed setting
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pos < 0 && !hint_painted)
|
if (pos < 0 && !hint_painted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_box->enableGradient(g_settings.theme.menu_Hint_gradient != 0);
|
|
||||||
info_box->set2ndColor(COL_INFOBAR_SHADOW_PLUS_1); // COL_INFOBAR_SHADOW_PLUS_1 is default footer color
|
|
||||||
|
|
||||||
|
|
||||||
if (hint_painted) {
|
if (hint_painted) {
|
||||||
/* clear detailsline line */
|
/* clear detailsline line */
|
||||||
if (details_line)
|
if (details_line)
|
||||||
savescreen ? details_line->hide() : details_line->kill();
|
details_line->hide();
|
||||||
/* clear info box */
|
/* clear info box */
|
||||||
if ((info_box) && (pos < 0))
|
if ((info_box) && (pos < 0))
|
||||||
savescreen ? info_box->hide(true) : info_box->kill();
|
savescreen ? info_box->hide() : info_box->kill();
|
||||||
hint_painted = false;
|
hint_painted = false;
|
||||||
}
|
}
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
@@ -1390,7 +1430,7 @@ void CMenuWidget::paintHint(int pos)
|
|||||||
|
|
||||||
if (!item->hintIcon && item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) {
|
if (!item->hintIcon && item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) {
|
||||||
if (info_box) {
|
if (info_box) {
|
||||||
savescreen ? info_box->hide(false) : info_box->kill();
|
savescreen ? info_box->hide() : info_box->kill();
|
||||||
hint_painted = false;
|
hint_painted = false;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -1413,35 +1453,38 @@ void CMenuWidget::paintHint(int pos)
|
|||||||
int imarkh = iheight/2+1;
|
int imarkh = iheight/2+1;
|
||||||
|
|
||||||
//init details line
|
//init details line
|
||||||
if (details_line){
|
if (details_line == NULL)
|
||||||
details_line->setXPos(xpos);
|
details_line = new CComponentsDetailLine();
|
||||||
details_line->setYPos(ypos1a);
|
|
||||||
details_line->setYPosDown(ypos2a);
|
details_line->setXPos(xpos);
|
||||||
details_line->setHMarkTop(imarkh);
|
details_line->setYPos(ypos1a);
|
||||||
details_line->setHMarkDown(markh);
|
details_line->setYPosDown(ypos2a);
|
||||||
details_line->syncSysColors();
|
details_line->setHMarkTop(imarkh);
|
||||||
}
|
details_line->setHMarkDown(markh);
|
||||||
|
details_line->syncSysColors();
|
||||||
|
|
||||||
//init infobox
|
//init infobox
|
||||||
std::string str = item->hintText.empty() ? g_Locale->getText(item->hint) : item->hintText;
|
std::string str = item->hintText.empty() ? g_Locale->getText(item->hint) : item->hintText;
|
||||||
if (info_box){
|
if (info_box == NULL)
|
||||||
info_box->setDimensionsAll(x, ypos2, iwidth, hint_height);
|
info_box = new CComponentsInfoBox();
|
||||||
info_box->setFrameThickness(2);
|
|
||||||
info_box->removeLineBreaks(str);
|
info_box->setDimensionsAll(x, ypos2, iwidth, hint_height);
|
||||||
info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT], COL_MENUCONTENT_TEXT);
|
info_box->setFrameThickness(2);
|
||||||
info_box->setCorner(RADIUS_LARGE);
|
info_box->removeLineBreaks(str);
|
||||||
info_box->syncSysColors();
|
info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT], COL_MENUCONTENT_TEXT);
|
||||||
info_box->setColorBody(COL_MENUCONTENTDARK_PLUS_0);
|
info_box->setCorner(RADIUS_LARGE);
|
||||||
info_box->setShadowOnOff(CC_SHADOW_ON);
|
info_box->setColorAll(COL_MENUCONTENT_PLUS_6, COL_MENUCONTENTDARK_PLUS_0, COL_MENUCONTENTDARK_PLUS_0);
|
||||||
info_box->setPicture(item->hintIcon ? item->hintIcon : "");
|
info_box->enableShadow();
|
||||||
}
|
info_box->setPicture(item->hintIcon ? item->hintIcon : "");
|
||||||
|
info_box->enableColBodyGradient(g_settings.theme.menu_Hint_gradient, COL_INFOBAR_SHADOW_PLUS_1, g_settings.theme.menu_Hint_gradient_direction);// COL_INFOBAR_SHADOW_PLUS_1 is default footer color
|
||||||
|
|
||||||
//paint result
|
//paint result
|
||||||
if (show_details_line)
|
if (details_line)
|
||||||
details_line->paint(savescreen);
|
details_line->paint();
|
||||||
info_box->paint(savescreen);
|
if (info_box)
|
||||||
|
info_box->paint(savescreen);
|
||||||
|
|
||||||
hint_painted = true;
|
hint_painted = info_box ? info_box->isPainted() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string & action)
|
void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string & action)
|
||||||
@@ -1564,7 +1607,7 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*)
|
|||||||
|
|
||||||
// give the observer a chance to modify the value
|
// give the observer a chance to modify the value
|
||||||
paint(true);
|
paint(true);
|
||||||
|
OnAfterChangeOption();
|
||||||
if (wantsRepaint)
|
if (wantsRepaint)
|
||||||
res = menu_return::RETURN_REPAINT;
|
res = menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
@@ -2254,8 +2297,8 @@ int CMenuSeparator::paint(bool selected)
|
|||||||
frameBuffer->paintBoxRel(x,y, dx, height, item_bgcolor);
|
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);
|
int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF;
|
||||||
frameBuffer->paintHLineRel(x+10,dx-20,y+(height>>1)+1, COL_MENUCONTENT_PLUS_1);
|
paintBoxRel(x+10, y+(height>>1), dx-20, 2, COL_MENUCONTENT_PLUS_3, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light);
|
||||||
}
|
}
|
||||||
if ((type & STRING))
|
if ((type & STRING))
|
||||||
{
|
{
|
||||||
|
@@ -308,7 +308,7 @@ class CAbstractMenuOptionChooser : public CMenuItem
|
|||||||
optionValue = NULL;
|
optionValue = NULL;
|
||||||
}
|
}
|
||||||
~CAbstractMenuOptionChooser(){}
|
~CAbstractMenuOptionChooser(){}
|
||||||
|
sigc::signal<void> OnAfterChangeOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser
|
class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser
|
||||||
@@ -444,7 +444,7 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser
|
|||||||
int getWidth(void);
|
int getWidth(void);
|
||||||
void setOptions(const struct keyval * const Options, const unsigned Number_Of_Options);
|
void setOptions(const struct keyval * const Options, const unsigned Number_Of_Options);
|
||||||
void setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options);
|
void setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options);
|
||||||
sigc::signal<void> OnAfterChangeOption;
|
|
||||||
int paint(bool selected);
|
int paint(bool selected);
|
||||||
|
|
||||||
int exec(CMenuTarget* parent);
|
int exec(CMenuTarget* parent);
|
||||||
@@ -497,7 +497,7 @@ class CMenuGlobal
|
|||||||
static CMenuGlobal* getInstance();
|
static CMenuGlobal* getInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMenuWidget : public CMenuTarget
|
class CMenuWidget : public CMenuTarget, public CComponentsSignals
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
mn_widget_id_t widget_index;
|
mn_widget_id_t widget_index;
|
||||||
@@ -505,7 +505,7 @@ class CMenuWidget : public CMenuTarget
|
|||||||
CComponentsDetailLine *details_line;
|
CComponentsDetailLine *details_line;
|
||||||
CComponentsInfoBox *info_box;
|
CComponentsInfoBox *info_box;
|
||||||
int hint_height;
|
int hint_height;
|
||||||
bool show_details_line;
|
CComponentsHeader *header;
|
||||||
protected:
|
protected:
|
||||||
std::string nameString;
|
std::string nameString;
|
||||||
neutrino_locale_t name;
|
neutrino_locale_t name;
|
||||||
@@ -562,7 +562,7 @@ class CMenuWidget : public CMenuTarget
|
|||||||
CMenuWidget(const std::string &Name, const std::string & Icon = "", const int mwidth = 30, const mn_widget_id_t &w_index = NO_WIDGET_ID);
|
CMenuWidget(const std::string &Name, const std::string & Icon = "", const int mwidth = 30, const mn_widget_id_t &w_index = NO_WIDGET_ID);
|
||||||
CMenuWidget(const neutrino_locale_t Name, const std::string & Icon = "", const int mwidth = 30, const mn_widget_id_t &w_index = NO_WIDGET_ID);
|
CMenuWidget(const neutrino_locale_t Name, const std::string & Icon = "", const int mwidth = 30, const mn_widget_id_t &w_index = NO_WIDGET_ID);
|
||||||
~CMenuWidget();
|
~CMenuWidget();
|
||||||
|
void ResetModules();
|
||||||
virtual void addItem(CMenuItem* menuItem, const bool defaultselected = false);
|
virtual void addItem(CMenuItem* menuItem, const bool defaultselected = false);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -610,7 +610,7 @@ class CMenuWidget : public CMenuTarget
|
|||||||
};
|
};
|
||||||
void addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string &action);
|
void addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string &action);
|
||||||
void setFooter(const struct button_label *_fbutton_label, const int _fbutton_count, bool repaint = false);
|
void setFooter(const struct button_label *_fbutton_label, const int _fbutton_count, bool repaint = false);
|
||||||
void suppressDetailsLine(bool suppress = true){show_details_line = suppress ? false : true;};
|
|
||||||
void setNextShortcut(int sc) { nextShortcut = sc; };
|
void setNextShortcut(int sc) { nextShortcut = sc; };
|
||||||
int getNextShortcut() { return nextShortcut; };
|
int getNextShortcut() { return nextShortcut; };
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user