mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
Preparing the menu classes for Lua Part #1
- Remove CNonLocalizedMenuSeparator - Add overloaded function CMenuSeparator for non local THX Martii
This commit is contained in:
@@ -491,7 +491,7 @@ int CPersonalizeGui::ShowMenuOptions(const int& widget)
|
|||||||
CMenuSeparator * pm_subhead = new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING);
|
CMenuSeparator * pm_subhead = new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING);
|
||||||
string s_sh = g_Locale->getText(LOCALE_PERSONALIZE_ACCESS);
|
string s_sh = g_Locale->getText(LOCALE_PERSONALIZE_ACCESS);
|
||||||
s_sh += ": " + mn_name;
|
s_sh += ": " + mn_name;
|
||||||
pm_subhead->setString(s_sh);
|
pm_subhead->setName(s_sh);
|
||||||
|
|
||||||
pm->addItem(pm_subhead);
|
pm->addItem(pm_subhead);
|
||||||
pm->addIntroItems();
|
pm->addIntroItems();
|
||||||
|
@@ -194,7 +194,7 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
}
|
}
|
||||||
//updates_lists.push_back(url.substr(startpos, endpos - startpos));
|
//updates_lists.push_back(url.substr(startpos, endpos - startpos));
|
||||||
|
|
||||||
SelectionWidget.addItem(new CNonLocalizedMenuSeparator(updates_lists.rbegin()->c_str(), LOCALE_FLASHUPDATE_SELECTIMAGE));
|
SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_lists.rbegin()->c_str()));
|
||||||
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20))
|
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20))
|
||||||
{
|
{
|
||||||
std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME);
|
std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME);
|
||||||
|
@@ -63,7 +63,11 @@ CMenuItem::CMenuItem()
|
|||||||
used = false;
|
used = false;
|
||||||
icon_frame_w = 10;
|
icon_frame_w = 10;
|
||||||
hint = NONEXISTANT_LOCALE;
|
hint = NONEXISTANT_LOCALE;
|
||||||
|
name = NONEXISTANT_LOCALE;
|
||||||
|
nameString = "";
|
||||||
isStatic = false;
|
isStatic = false;
|
||||||
|
marked = false;
|
||||||
|
inert = 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)
|
||||||
@@ -87,6 +91,20 @@ void CMenuItem::setActive(const bool Active)
|
|||||||
paint();
|
paint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMenuItem::setMarked(const bool Marked)
|
||||||
|
{
|
||||||
|
marked = Marked;
|
||||||
|
if (used && x != -1)
|
||||||
|
paint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMenuItem::setInert(const bool Inert)
|
||||||
|
{
|
||||||
|
inert = Inert;
|
||||||
|
if (used && x != -1)
|
||||||
|
paint();
|
||||||
|
}
|
||||||
|
|
||||||
void CMenuItem::setItemButton(const std::string& icon_Name, const bool is_select_button)
|
void CMenuItem::setItemButton(const std::string& icon_Name, const bool is_select_button)
|
||||||
{
|
{
|
||||||
if (is_select_button)
|
if (is_select_button)
|
||||||
@@ -102,11 +120,16 @@ void CMenuItem::initItemColors(const bool select_mode)
|
|||||||
item_color = COL_MENUCONTENTSELECTED_TEXT;
|
item_color = COL_MENUCONTENTSELECTED_TEXT;
|
||||||
item_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
item_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
||||||
}
|
}
|
||||||
else if (!active)
|
else if (!active || inert)
|
||||||
{
|
{
|
||||||
item_color = COL_MENUCONTENTINACTIVE_TEXT;
|
item_color = COL_MENUCONTENTINACTIVE_TEXT;
|
||||||
item_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
|
item_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
|
||||||
}
|
}
|
||||||
|
else if (marked)
|
||||||
|
{
|
||||||
|
item_color = COL_MENUCONTENT_TEXT;
|
||||||
|
item_bgcolor = COL_MENUCONTENT_PLUS_1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item_color = COL_MENUCONTENT_TEXT;
|
item_color = COL_MENUCONTENT_TEXT;
|
||||||
@@ -281,6 +304,13 @@ void CMenuItem::paintItemButton(const bool select_mode, const int &item_height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *CMenuItem::getName(void)
|
||||||
|
{
|
||||||
|
if (name != NONEXISTANT_LOCALE)
|
||||||
|
return g_Locale->getText(name);
|
||||||
|
return nameString.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
//small helper class to manage values e.g.: handling needed but deallocated widget objects
|
//small helper class to manage values e.g.: handling needed but deallocated widget objects
|
||||||
CMenuGlobal::CMenuGlobal()
|
CMenuGlobal::CMenuGlobal()
|
||||||
{
|
{
|
||||||
@@ -1151,10 +1181,10 @@ void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------
|
||||||
CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn)
|
CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name1, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn)
|
||||||
{
|
{
|
||||||
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||||
optionName = name;
|
optionName = name1;
|
||||||
active = Active;
|
active = Active;
|
||||||
optionValue = OptionValue;
|
optionValue = OptionValue;
|
||||||
|
|
||||||
@@ -1933,30 +1963,38 @@ CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, boo
|
|||||||
directKey = CRCInput::RC_nokey;
|
directKey = CRCInput::RC_nokey;
|
||||||
iconName = "";
|
iconName = "";
|
||||||
type = Type;
|
type = Type;
|
||||||
text = Text;
|
name = Text;
|
||||||
|
nameString = "";
|
||||||
isStatic = IsStatic;
|
isStatic = IsStatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMenuSeparator::CMenuSeparator(const int Type, const std::string Text, bool IsStatic)
|
||||||
|
{
|
||||||
|
directKey = CRCInput::RC_nokey;
|
||||||
|
iconName = "";
|
||||||
|
type = Type;
|
||||||
|
name = NONEXISTANT_LOCALE;
|
||||||
|
nameString = Text;
|
||||||
|
isStatic = IsStatic;
|
||||||
|
}
|
||||||
|
|
||||||
int CMenuSeparator::getHeight(void) const
|
int CMenuSeparator::getHeight(void) const
|
||||||
{
|
{
|
||||||
if (separator_text.empty() && text == NONEXISTANT_LOCALE)
|
if (nameString.empty() && name == NONEXISTANT_LOCALE)
|
||||||
return 10;
|
return 10;
|
||||||
else
|
|
||||||
return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * CMenuSeparator::getString(void)
|
void CMenuSeparator::setName(const std::string& t)
|
||||||
{
|
{
|
||||||
if (!separator_text.empty())
|
name = NONEXISTANT_LOCALE;
|
||||||
return separator_text.c_str();
|
nameString = t;
|
||||||
else
|
|
||||||
return g_Locale->getText(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenuSeparator::setString(const std::string& s_text)
|
void CMenuSeparator::setName(const neutrino_locale_t t)
|
||||||
{
|
{
|
||||||
separator_text = s_text;
|
name = t;
|
||||||
|
nameString = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuSeparator::getWidth(void)
|
int CMenuSeparator::getWidth(void)
|
||||||
@@ -1964,11 +2002,9 @@ int CMenuSeparator::getWidth(void)
|
|||||||
int w = 0;
|
int w = 0;
|
||||||
if (type & LINE)
|
if (type & LINE)
|
||||||
w = 30; /* 15 pixel left and right */
|
w = 30; /* 15 pixel left and right */
|
||||||
if ((type & STRING) && text != NONEXISTANT_LOCALE)
|
const char *l_name = getName();
|
||||||
{
|
if ((type & STRING) && *l_name)
|
||||||
const char *l_text = getString();
|
w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true);
|
||||||
w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true);
|
|
||||||
}
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1996,11 +2032,11 @@ int CMenuSeparator::paint(bool selected)
|
|||||||
}
|
}
|
||||||
if ((type & STRING))
|
if ((type & STRING))
|
||||||
{
|
{
|
||||||
const char * l_text = getString();
|
const char * l_name = getName();
|
||||||
|
|
||||||
if (text != NONEXISTANT_LOCALE || strlen(l_text) != 0)
|
if (*l_name)
|
||||||
{
|
{
|
||||||
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true); // UTF-8
|
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true); // UTF-8
|
||||||
|
|
||||||
/* if no alignment is specified, align centered */
|
/* if no alignment is specified, align centered */
|
||||||
if (type & ALIGN_LEFT)
|
if (type & ALIGN_LEFT)
|
||||||
@@ -2012,7 +2048,7 @@ int CMenuSeparator::paint(bool selected)
|
|||||||
|
|
||||||
frameBuffer->paintBoxRel(name_start_x-5, y, stringwidth+10, height, item_bgcolor);
|
frameBuffer->paintBoxRel(name_start_x-5, y, stringwidth+10, height, item_bgcolor);
|
||||||
|
|
||||||
paintItemCaption(selected, height, l_text);
|
paintItemCaption(selected, height, l_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return y+ height;
|
return y+ height;
|
||||||
|
@@ -45,6 +45,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
}
|
||||||
|
|
||||||
#define NO_WIDGET_ID -1
|
#define NO_WIDGET_ID -1
|
||||||
|
|
||||||
typedef int mn_widget_id_t;
|
typedef int mn_widget_id_t;
|
||||||
@@ -90,9 +96,16 @@ class CMenuItem
|
|||||||
fb_pixel_t item_color, item_bgcolor;
|
fb_pixel_t item_color, item_bgcolor;
|
||||||
|
|
||||||
void initItemColors(const bool select_mode);
|
void initItemColors(const bool select_mode);
|
||||||
|
lua_State *luaState;
|
||||||
|
std::string luaAction;
|
||||||
|
std::string luaId;
|
||||||
|
neutrino_locale_t name;
|
||||||
|
std::string nameString;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool active;
|
bool active;
|
||||||
|
bool marked;
|
||||||
|
bool inert;
|
||||||
bool isStatic;
|
bool isStatic;
|
||||||
neutrino_msg_t directKey;
|
neutrino_msg_t directKey;
|
||||||
neutrino_msg_t msg;
|
neutrino_msg_t msg;
|
||||||
@@ -100,6 +113,7 @@ class CMenuItem
|
|||||||
std::string selected_iconName;
|
std::string selected_iconName;
|
||||||
std::string iconName_Info_right;
|
std::string iconName_Info_right;
|
||||||
std::string hintIcon;
|
std::string hintIcon;
|
||||||
|
std::string hintText;
|
||||||
neutrino_locale_t hint;
|
neutrino_locale_t hint;
|
||||||
|
|
||||||
CMenuItem();
|
CMenuItem();
|
||||||
@@ -130,6 +144,8 @@ class CMenuItem
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
virtual void setActive(const bool Active);
|
virtual void setActive(const bool Active);
|
||||||
|
virtual void setMarked(const bool Marked);
|
||||||
|
virtual void setInert(const bool Inert);
|
||||||
|
|
||||||
virtual void paintItemButton(const bool select_mode, const int &item_height, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT);
|
virtual void paintItemButton(const bool select_mode, const int &item_height, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT);
|
||||||
|
|
||||||
@@ -144,16 +160,19 @@ class CMenuItem
|
|||||||
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);
|
||||||
|
|
||||||
virtual int isMenueOptionChooser(void) const{return 0;}
|
virtual int isMenueOptionChooser(void) const{return 0;}
|
||||||
void setHint(std::string icon, neutrino_locale_t text) { hintIcon = icon; hint = text; }
|
void setHint(const std::string icon, const neutrino_locale_t text) { hintIcon = icon; hint = text; }
|
||||||
|
void setHint(const std::string icon, const std::string text) { hintIcon = icon; hintText = text; }
|
||||||
|
|
||||||
|
void setLua(lua_State *_luaState, std::string &_luaAction, std::string &_luaId) { luaState = _luaState; luaAction = _luaAction; luaId = _luaId; };
|
||||||
|
|
||||||
|
virtual const char *getName();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMenuSeparator : public CMenuItem
|
class CMenuSeparator : public CMenuItem
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
std::string separator_text;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
neutrino_locale_t text;
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -168,30 +187,15 @@ class CMenuSeparator : public CMenuItem
|
|||||||
|
|
||||||
|
|
||||||
CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE, bool IsStatic = false);
|
CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE, bool IsStatic = false);
|
||||||
|
CMenuSeparator(const int Type, const std::string Text, bool IsStatic = false);
|
||||||
virtual ~CMenuSeparator(){}
|
virtual ~CMenuSeparator(){}
|
||||||
|
|
||||||
int paint(bool selected=false);
|
int paint(bool selected=false);
|
||||||
int getHeight(void) const;
|
int getHeight(void) const;
|
||||||
int getWidth(void);
|
int getWidth(void);
|
||||||
|
|
||||||
virtual const char * getString(void);
|
void setName(const std::string& text);
|
||||||
void setString(const std::string& text);
|
void setName(const neutrino_locale_t text);
|
||||||
};
|
|
||||||
|
|
||||||
class CNonLocalizedMenuSeparator : public CMenuSeparator
|
|
||||||
{
|
|
||||||
const char * the_text;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CNonLocalizedMenuSeparator(const char * ptext, const neutrino_locale_t Text1) : CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, Text1)
|
|
||||||
{
|
|
||||||
the_text = ptext;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual const char * getString(void)
|
|
||||||
{
|
|
||||||
return the_text;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMenuForwarder : public CMenuItem
|
class CMenuForwarder : public CMenuItem
|
||||||
|
Reference in New Issue
Block a user