gui/widget/menue.cpp: add CMenuItem isStatic param, (c) martii <m4rtii@gmx.de>

This commit is contained in:
[CST] Focus
2013-07-05 18:06:44 +04:00
parent 7702408456
commit 8b5bbf8911
2 changed files with 48 additions and 30 deletions

View File

@@ -44,11 +44,11 @@
#include <cctype> #include <cctype>
/* the following generic menu items are integrated into multiple menus at the same time */ /* the following generic menu items are integrated into multiple menus at the same time */
CMenuSeparator CGenericMenuSeparator; CMenuSeparator CGenericMenuSeparator(0, NONEXISTANT_LOCALE, true);
CMenuSeparator CGenericMenuSeparatorLine(CMenuSeparator::LINE); CMenuSeparator CGenericMenuSeparatorLine(CMenuSeparator::LINE, NONEXISTANT_LOCALE, true);
CMenuForwarder CGenericMenuBack(LOCALE_MENU_BACK, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_LEFT); CMenuForwarder CGenericMenuBack(LOCALE_MENU_BACK, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_LEFT, NULL, true);
CMenuForwarder CGenericMenuCancel(LOCALE_MENU_CANCEL, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME); CMenuForwarder CGenericMenuCancel(LOCALE_MENU_CANCEL, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME, NULL, true);
CMenuForwarder CGenericMenuNext(LOCALE_MENU_NEXT, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME); CMenuForwarder CGenericMenuNext(LOCALE_MENU_NEXT, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME, NULL, true);
CMenuSeparator * const GenericMenuSeparator = &CGenericMenuSeparator; CMenuSeparator * const GenericMenuSeparator = &CGenericMenuSeparator;
CMenuSeparator * const GenericMenuSeparatorLine = &CGenericMenuSeparatorLine; CMenuSeparator * const GenericMenuSeparatorLine = &CGenericMenuSeparatorLine;
CMenuForwarder * const GenericMenuBack = &CGenericMenuBack; CMenuForwarder * const GenericMenuBack = &CGenericMenuBack;
@@ -64,6 +64,7 @@ CMenuItem::CMenuItem()
used = false; used = false;
icon_frame_w = 10; icon_frame_w = 10;
hint = NONEXISTANT_LOCALE; hint = NONEXISTANT_LOCALE;
isStatic = false;
} }
void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX) void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX)
@@ -196,7 +197,11 @@ void CMenuItem::paintItemButton(const bool select_mode, const int &item_height,
int icon_h = 0; int icon_h = 0;
//define icon name depends of numeric value //define icon name depends of numeric value
#ifdef MARTII
if (g_settings.menu_numbers_as_icons && icon_name.empty() && CRCInput::isNumeric(directKey))
#else
if (icon_name.empty() && CRCInput::isNumeric(directKey)) if (icon_name.empty() && CRCInput::isNumeric(directKey))
#endif
{ {
char i_name[6]; /* X +'\0' */ char i_name[6]; /* X +'\0' */
snprintf(i_name, 6, "%d", CRCInput::getNumericValue(directKey)); snprintf(i_name, 6, "%d", CRCInput::getNumericValue(directKey));
@@ -397,11 +402,7 @@ void CMenuWidget::resetWidget(bool delete_items)
{ {
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 ((item != GenericMenuSeparator) && if (!item->isStatic && delete_items) {
(item != GenericMenuSeparatorLine) &&
(item != GenericMenuBack) &&
(item != GenericMenuCancel)){
if(delete_items)
delete item; delete item;
item = NULL; item = NULL;
} }
@@ -532,6 +533,12 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &)
break; break;
} }
} }
#ifdef MARTII
if (msg == (uint32_t) g_settings.key_channelList_pageup)
msg = CRCInput::RC_page_up;
else if (msg == (uint32_t) g_settings.key_channelList_pagedown)
msg = CRCInput::RC_page_down;
#endif
} }
if (handled) if (handled)
@@ -1174,9 +1181,10 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*)
else else
(*optionValue)++; (*optionValue)++;
} }
paint(true);
if(observ) if(observ)
observ->changeNotify(optionName, optionValue); observ->changeNotify(optionName, optionValue);
// give the observer a chance to modify the value
paint(true);
return menu_return::RETURN_NONE; return menu_return::RETURN_NONE;
} }
@@ -1596,7 +1604,7 @@ int CMenuOptionLanguageChooser::paint( bool selected )
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
{ {
option = Option; option = Option;
option_string = NULL; option_string = NULL;
@@ -1607,9 +1615,10 @@ CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active,
directKey = DirectKey; directKey = DirectKey;
iconName = IconName ? IconName : ""; iconName = IconName ? IconName : "";
iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; iconName_Info_right = IconName_Info_right ? IconName_Info_right : "";
isStatic = IsStatic;
} }
CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
{ {
option = NULL; option = NULL;
option_string = &Option; option_string = &Option;
@@ -1620,6 +1629,23 @@ CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active,
directKey = DirectKey; directKey = DirectKey;
iconName = IconName ? IconName : ""; iconName = IconName ? IconName : "";
iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; iconName_Info_right = IconName_Info_right ? IconName_Info_right : "";
isStatic = IsStatic;
}
void CMenuForwarder::setOption(const char * const Option)
{
option = Option;
option_string = NULL;
if (used && x != -1)
paint();
}
void CMenuForwarder::setOption(const std::string &Option)
{
option = NULL;
option_string = &Option;
if (used && x != -1)
paint();
} }
int CMenuForwarder::getHeight(void) const int CMenuForwarder::getHeight(void) const
@@ -1627,16 +1653,6 @@ int CMenuForwarder::getHeight(void) const
return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
} }
// used gets set by the addItem() function. This is for set to paint Option string by just not calling the addItem() function.
// Without this, the changeNotifiers would become machine-dependent.
void CMenuForwarder::setOption(const char *Option)
{
option = Option;
if (used && x != -1)
paint();
}
// used gets set by the addItem() function. This is for set to paint Text from locales by just not calling the addItem() function. // used gets set by the addItem() function. This is for set to paint Text from locales by just not calling the addItem() function.
// Without this, the changeNotifiers would become machine-dependent. // Without this, the changeNotifiers would become machine-dependent.
void CMenuForwarder::setTextLocale(const neutrino_locale_t Text) void CMenuForwarder::setTextLocale(const neutrino_locale_t Text)
@@ -1767,12 +1783,13 @@ int CMenuForwarderNonLocalized::getWidth(void)
return tw; return tw;
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text) CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic)
{ {
directKey = CRCInput::RC_nokey; directKey = CRCInput::RC_nokey;
iconName = ""; iconName = "";
type = Type; type = Type;
text = Text; text = Text;
isStatic = IsStatic;
} }

View File

@@ -93,6 +93,7 @@ class CMenuItem
public: public:
bool active; bool active;
bool isStatic;
neutrino_msg_t directKey; neutrino_msg_t directKey;
neutrino_msg_t msg; neutrino_msg_t msg;
std::string iconName; std::string iconName;
@@ -166,7 +167,7 @@ class CMenuSeparator : public CMenuItem
}; };
CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE); CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE, bool IsStatic = false);
virtual ~CMenuSeparator(){} virtual ~CMenuSeparator(){}
int paint(bool selected=false); int paint(bool selected=false);
@@ -208,16 +209,14 @@ class CMenuForwarder : public CMenuItem
public: public:
CMenuForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); CMenuForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false);
CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false);
virtual ~CMenuForwarder(){} virtual ~CMenuForwarder(){}
int paint(bool selected=false); int paint(bool selected=false);
int getHeight(void) const; int getHeight(void) const;
int getWidth(void); int getWidth(void);
void setOption(const char *Option);
void setTextLocale(const neutrino_locale_t Text); void setTextLocale(const neutrino_locale_t Text);
neutrino_locale_t getTextLocale(){return text;}; neutrino_locale_t getTextLocale(){return text;};
CMenuTarget* getTarget(){return jumpTarget;}; CMenuTarget* getTarget(){return jumpTarget;};
@@ -228,6 +227,8 @@ class CMenuForwarder : public CMenuItem
{ {
return active; return active;
} }
void setOption(const char * const Option);
void setOption(const std::string &Option);
}; };
class CMenuDForwarder : public CMenuForwarder class CMenuDForwarder : public CMenuForwarder