added category indicator token to default menus

This commit is contained in:
louis 2015-04-05 16:56:15 +02:00
parent 7bc7304d84
commit 3a53ab95b6
14 changed files with 139 additions and 21 deletions

View File

@ -276,3 +276,5 @@ Version 0.4.0
its own datetime display its own datetime display
- adapted Makefiles to work also in a LCLBLD environment - adapted Makefiles to work also in a LCLBLD environment
- reverted Makefile changes in parts - reverted Makefile changes in parts
- added category indicator token to default menus

View File

@ -202,7 +202,10 @@ void cSDDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Sel
rootView->LockFlush(); rootView->LockFlush();
eMenuCategory cat = MenuCategory(); eMenuCategory cat = MenuCategory();
if (cat == mcMain && rootView->SubViewAvailable()) { if (cat == mcMain && rootView->SubViewAvailable()) {
list->AddMainMenuItem(Index, Text, Current, Selectable); string plugName = list->AddMainMenuItem(Index, Text, Current, Selectable);
if (Current) {
rootView->SetSelectedPluginMainMenu(plugName);
}
} else if (cat == mcSetup && rootView->SubViewAvailable()) { } else if (cat == mcSetup && rootView->SubViewAvailable()) {
list->AddSetupMenuItem(Index, Text, Current, Selectable); list->AddSetupMenuItem(Index, Text, Current, Selectable);
} else { } else {

View File

@ -188,7 +188,7 @@ cImage *cImageCache::GetIcon(eImageType type, string name, int width, int height
return NULL; return NULL;
} }
string cImageCache::GetIconName(string label, eMenuCategory cat) { string cImageCache::GetIconName(string label, eMenuCategory cat, string plugName) {
//if cat is set, use standard menu entries //if cat is set, use standard menu entries
switch (cat) { switch (cat) {
case mcSchedule: case mcSchedule:
@ -267,6 +267,9 @@ string cImageCache::GetIconName(string label, eMenuCategory cat) {
} }
} catch (...) {} } catch (...) {}
//check for Plugins //check for Plugins
if (plugName.size() > 0) {
return *cString::sprintf("pluginicons/%s", plugName.c_str());
}
for (int i = 0; ; i++) { for (int i = 0; ; i++) {
cPlugin *p = cPluginManager::GetPlugin(i); cPlugin *p = cPluginManager::GetPlugin(i);
if (p) { if (p) {

View File

@ -25,7 +25,7 @@ public:
//icons //icons
void CacheIcon(eImageType type, string path, int width, int height); void CacheIcon(eImageType type, string path, int width, int height);
cImage *GetIcon(eImageType type, string name, int width, int height); cImage *GetIcon(eImageType type, string name, int width, int height);
string GetIconName(string label, eMenuCategory cat = mcUndefined); string GetIconName(string label, eMenuCategory cat = mcUndefined, string plugName = "");
bool MenuIconExists(string name); bool MenuIconExists(string name);
//skinparts //skinparts
void CacheSkinpart(string path, int width, int height); void CacheSkinpart(string path, int width, int height);

View File

@ -637,6 +637,11 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("mode"); attributes.insert("mode");
funcsAllowed.insert(pair< string, set<string> >(name, attributes)); funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "listelement";
attributes.clear();
attributes.insert("debug");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "area"; name = "area";
attributes.clear(); attributes.clear();
attributes.insert("debug"); attributes.insert("debug");
@ -1147,6 +1152,7 @@ cTemplateViewMenu::cTemplateViewMenu(void) {
//definition of allowed parameters for currentitems viewlist //definition of allowed parameters for currentitems viewlist
attributes.clear(); attributes.clear();
attributes.insert("debug");
attributes.insert("delay"); attributes.insert("delay");
attributes.insert("fadetime"); attributes.insert("fadetime");
funcsAllowed.insert(pair< string, set<string> >("currentelement", attributes)); funcsAllowed.insert(pair< string, set<string> >("currentelement", attributes));

View File

@ -59,6 +59,7 @@
<drawimage condition="not{current}" imagetype="skinpart" path="menubutton" x="0" y="0" width="100%" height="100%"/> <drawimage condition="not{current}" imagetype="skinpart" path="menubutton" x="0" y="0" width="100%" height="100%"/>
<drawimage condition="{current}" imagetype="skinpart" path="menubuttonactive" x="0" y="0" width="100%" height="100%"/> <drawimage condition="{current}" imagetype="skinpart" path="menubuttonactive" x="0" y="0" width="100%" height="100%"/>
</area> </area>
<areascroll scrollelement="column1" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" x="1%" width="{column1width}" layer="3"> <areascroll scrollelement="column1" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" x="1%" width="{column1width}" layer="3">
<drawtext name="column1" x="{column1x}" width="{column1width}" valign="center" font="{regular}" fontsize="90%" color="{clrWhite}" text="{column1}" /> <drawtext name="column1" x="{column1x}" width="{column1width}" valign="center" font="{regular}" fontsize="90%" color="{clrWhite}" text="{column1}" />
</areascroll> </areascroll>

View File

@ -113,7 +113,7 @@
<!-- IMPORTANT: menuitemwidth and determinatefont have to be defined here. menuitemwidth defines the total width of the <!-- IMPORTANT: menuitemwidth and determinatefont have to be defined here. menuitemwidth defines the total width of the
default menu items, determinatefont the function which sets the actual font to use. With that it is possible to determinate default menu items, determinatefont the function which sets the actual font to use. With that it is possible to determinate
the correct column widths --> the correct column widths -->
<menuitems x="0" y="10%" orientation="vertical" width="100%" height="82%" align="center" menuitemwidth="94%" determinatefont="column1" numlistelements="16"> <menuitems x="0" y="10%" orientation="vertical" width="94%" height="82%" align="center" menuitemwidth="94%" determinatefont="column1" numlistelements="16">
<!-- Available Variables default menu listelement: <!-- Available Variables default menu listelement:
{nummenuitem} number of item in list, starts with 1 {nummenuitem} number of item in list, starts with 1
{column1} text of column1 {column1} text of column1
@ -140,18 +140,48 @@
{column6width} proposed width of column6 {column6width} proposed width of column6
{columnscroll} number of column which should have scrollable text {columnscroll} number of column which should have scrollable text
{current} true if column is currently selected {current} true if column is currently selected
{separator} true if column is a list separator {separator} true if column is a list separator
A dynamic token is set to indicate the current menu category or the plugin which is currently running.
With that it is possible to display different default menus with an individual style.
If a setup menu is diplayed, the token
{setup} is set to true
For the commands menu
{commands} is set to true
If a plugin is running, a token called as the name of the plugin is set to true
{pluginname} is set to true
--> -->
<listelement> <listelement>
<area x="0" width="95%" layer="2"> <area x="0" condition="not{separator}" width="100%" layer="2">
<fill condition="not{current}" color="{clrTransparent}" /> <fill condition="not{current}" color="{clrTransparent}" />
<fill condition="{current}" color="{clrTransBlueLight}" /> <fill condition="{current}" color="{clrTransBlueLight}" />
</area> </area>
<areascroll scrollelement="column1" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" x="1%" width="{column1width}" layer="3"> <!-- Separators -->
<area x="0" condition="{separator}" width="100%" layer="2">
<fill color="{clrDarkGray}" />
</area>
<area x="1%" condition="{separator}" width="98%" layer="3">
<drawtext align="left" valign="center" font="{light}" fontsize="90%" width="98%" color="{clrWhite}" text="{column1}" />
</area>
<!-- Setup Menus -->
<areascroll condition="not{separator} ++ {setup} ++ {column2set}" scrollelement="column1" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" x="1%" width="59%" layer="3">
<drawtext name="column1" x="0" width="99%" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{column1}" />
</areascroll>
<area x="60%" condition="not{separator} ++ {setup} ++ {column2set}" width="39%" layer="3">
<drawtext align="right" valign="center" font="{light}" fontsize="90%" width="99%" color="{clrWhite}" text="{column2}" />
</area>
<area x="1%" condition="not{separator} ++ {setup} ++ not{column2set}" width="98%" layer="3">
<drawtext align="left" valign="center" font="{light}" fontsize="90%" width="99%" color="{clrWhite}" text="{column1}" />
</area>
<!-- Default Menus -->
<areascroll condition="not{separator} ++ not{setup}" scrollelement="column1" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" x="1%" width="{column1width}" layer="3">
<drawtext name="column1" x="{column1x}" width="{column1width}" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{column1}" /> <drawtext name="column1" x="{column1x}" width="{column1width}" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{column1}" />
</areascroll> </areascroll>
<area x="1%" width="100%" layer="3"> <area condition="not{separator} ++ not{setup}" x="1%" width="100%" layer="3">
<drawtext condition="{column2set}" x="{column2x}" valign="center" font="{light}" fontsize="90%" width="{column2width}" color="{clrWhite}" text="{column2}" /> <drawtext condition="{column2set}" x="{column2x}" valign="center" font="{light}" fontsize="90%" width="{column2width}" color="{clrWhite}" text="{column2}" />
<drawtext condition="{column3set}" x="{column3x}" valign="center" font="{light}" fontsize="90%" width="{column3width}" color="{clrWhite}" text="{column3}" /> <drawtext condition="{column3set}" x="{column3x}" valign="center" font="{light}" fontsize="90%" width="{column3width}" color="{clrWhite}" text="{column3}" />
<drawtext condition="{column4set}" x="{column4x}" valign="center" font="{light}" fontsize="90%" width="{column4width}" color="{clrWhite}" text="{column4}" /> <drawtext condition="{column4set}" x="{column4x}" valign="center" font="{light}" fontsize="90%" width="{column4width}" color="{clrWhite}" text="{column4}" />

View File

@ -28,7 +28,16 @@
{column5width} proposed width of column5 {column5width} proposed width of column5
{column6width} proposed width of column6 {column6width} proposed width of column6
{current} true if column is currently selected {current} true if column is currently selected
{separator} true if column is a list separator {separator} true if column is a list separator
A dynamic token is set to indicate the current menu category or the plugin which is currently running.
With that it is possible to display different default menus with an individual style.
If a setup menu is diplayed, the token
{setup} is set to true
For the commands menu
{commands} is set to true
If a plugin is running, a token called as the name of the plugin is set to true
{pluginname} is set to true
--> -->
<listelement> <listelement>
</listelement> </listelement>

View File

@ -106,6 +106,7 @@ cDisplayMenuItemDefaultView::cDisplayMenuItemDefaultView(cTemplateViewList *tmpl
this->tabs = tabs; this->tabs = tabs;
this->tabWidths = tabWidths; this->tabWidths = tabWidths;
maxTabs = cSkinDisplayMenu::MaxTabs; maxTabs = cSkinDisplayMenu::MaxTabs;
menuCategory = "";
} }
cDisplayMenuItemDefaultView::~cDisplayMenuItemDefaultView() { cDisplayMenuItemDefaultView::~cDisplayMenuItemDefaultView() {
@ -138,6 +139,9 @@ void cDisplayMenuItemDefaultView::SetTokens(void) {
intTokens.insert(pair<string,int>("current", current)); intTokens.insert(pair<string,int>("current", current));
intTokens.insert(pair<string,int>("separator", !selectable)); intTokens.insert(pair<string,int>("separator", !selectable));
intTokens.insert(pair<string,int>("nummenuitem", num+1)); intTokens.insert(pair<string,int>("nummenuitem", num+1));
if (menuCategory.size() > 0) {
intTokens.insert(pair<string,int>(menuCategory, 1));
}
} }
void cDisplayMenuItemDefaultView::Prepare(void) { void cDisplayMenuItemDefaultView::Prepare(void) {
@ -173,6 +177,10 @@ cDisplayMenuItemMainView::cDisplayMenuItemMainView(cTemplateViewList *tmplList,
number = ""; number = "";
label = ""; label = "";
icon = ""; icon = "";
isPlugin = false;
plugName = "";
SplitMenuText();
CheckPlugins();
} }
cDisplayMenuItemMainView::~cDisplayMenuItemMainView() { cDisplayMenuItemMainView::~cDisplayMenuItemMainView() {
@ -193,8 +201,11 @@ void cDisplayMenuItemMainView::SetTokens(void) {
void cDisplayMenuItemMainView::Prepare(void) { void cDisplayMenuItemMainView::Prepare(void) {
ArrangeContainer(); ArrangeContainer();
SplitMenuText(); if (isPlugin) {
icon = imgCache->GetIconName(label); icon = imgCache->GetIconName(label, mcUnknown, plugName);
} else {
icon = imgCache->GetIconName(label);
}
} }
@ -214,6 +225,12 @@ void cDisplayMenuItemMainView::Render(void) {
dirty = false; dirty = false;
} }
string cDisplayMenuItemMainView::GetPluginName(void) {
if (!isPlugin)
return "";
return plugName;
}
void cDisplayMenuItemMainView::Debug(void) { void cDisplayMenuItemMainView::Debug(void) {
esyslog("skindesigner: Main Menu Item ---------------"); esyslog("skindesigner: Main Menu Item ---------------");
cDisplayMenuItemView::Debug(); cDisplayMenuItemView::Debug();
@ -266,6 +283,24 @@ void cDisplayMenuItemMainView::SplitMenuText(void) {
} }
} }
void cDisplayMenuItemMainView::CheckPlugins(void) {
for (int i = 0; ; i++) {
cPlugin *p = cPluginManager::GetPlugin(i);
if (p) {
const char *mainMenuEntry = p->MainMenuEntry();
if (mainMenuEntry) {
string plugMainEntry = mainMenuEntry;
if (label.substr(0, plugMainEntry.size()) == plugMainEntry) {
isPlugin = true;
plugName = p->Name() ? p->Name() : "";
return;
}
}
} else
break;
}
}
/************************************************************* /*************************************************************
* cDisplayMenuItemSchedulesView * cDisplayMenuItemSchedulesView
*************************************************************/ *************************************************************/

View File

@ -42,11 +42,13 @@ private:
int *tabWidths; int *tabWidths;
string *tabTexts; string *tabTexts;
int maxTabs; int maxTabs;
string menuCategory;
public: public:
cDisplayMenuItemDefaultView(cTemplateViewList *tmplList, string *tabTexts, int *tabs, int *tabWidths, bool current, bool selectable); cDisplayMenuItemDefaultView(cTemplateViewList *tmplList, string *tabTexts, int *tabs, int *tabWidths, bool current, bool selectable);
virtual ~cDisplayMenuItemDefaultView(); virtual ~cDisplayMenuItemDefaultView();
void SetTabTexts(string *tabTexts); void SetTabTexts(string *tabTexts);
void SetTokens(void); void SetTokens(void);
void SetMenuCategory(string cat) { menuCategory = cat; };
void Prepare(void); void Prepare(void);
void Render(void); void Render(void);
void Debug(void); void Debug(void);
@ -54,17 +56,21 @@ public:
class cDisplayMenuItemMainView: public cDisplayMenuItemView { class cDisplayMenuItemMainView: public cDisplayMenuItemView {
private: private:
bool isPlugin;
string plugName;
string text; string text;
string number; string number;
string label; string label;
string icon; string icon;
void SplitMenuText(void); void SplitMenuText(void);
void CheckPlugins(void);
public: public:
cDisplayMenuItemMainView(cTemplateViewList *tmplList, string itemText, bool current, bool selectable); cDisplayMenuItemMainView(cTemplateViewList *tmplList, string itemText, bool current, bool selectable);
virtual ~cDisplayMenuItemMainView(); virtual ~cDisplayMenuItemMainView();
void SetTokens(void); void SetTokens(void);
void Prepare(void); void Prepare(void);
void Render(void); void Render(void);
string GetPluginName(void);
void Debug(void); void Debug(void);
}; };

View File

@ -2,7 +2,7 @@
#include "displaymenulistview.h" #include "displaymenulistview.h"
cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int count) { cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int count, eMenuCategory cat, string currentPlug) {
oneColumn = true; oneColumn = true;
this->tmplList = tmplList; this->tmplList = tmplList;
if (count < 0) { if (count < 0) {
@ -15,6 +15,8 @@ cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int coun
intTokens.insert(pair<string,int>("numelements", count)); intTokens.insert(pair<string,int>("numelements", count));
tmplList->CalculateListParameters(&intTokens); tmplList->CalculateListParameters(&intTokens);
} }
this->cat = cat;
this->currentPlug = currentPlug;
menuItems = new cDisplayMenuItemView*[itemCount]; menuItems = new cDisplayMenuItemView*[itemCount];
for (int i=0; i<itemCount; i++) for (int i=0; i<itemCount; i++)
menuItems[i] = NULL; menuItems[i] = NULL;
@ -111,19 +113,24 @@ void cDisplayMenuListView::AddDefaultMenuItem(int index, string *tabTexts, bool
break; break;
} }
} }
cDisplayMenuItemView *item = new cDisplayMenuItemDefaultView(tmplList, tabTexts, tabs, tabWidths, current, selectable); cDisplayMenuItemDefaultView *item = new cDisplayMenuItemDefaultView(tmplList, tabTexts, tabs, tabWidths, current, selectable);
item->SetMenuCategory(GetDefaultMenuCategory());
menuItems[index] = item; menuItems[index] = item;
} }
void cDisplayMenuListView::AddMainMenuItem(int index, const char *itemText, bool current, bool selectable) { string cDisplayMenuListView::AddMainMenuItem(int index, const char *itemText, bool current, bool selectable) {
if (index >= itemCount) if (index >= itemCount)
return; return "";
if (menuItems[index]) { if (menuItems[index]) {
menuItems[index]->SetCurrent(current); cDisplayMenuItemMainView *menuItem = dynamic_cast<cDisplayMenuItemMainView*>(menuItems[index]);
return; if (!menuItem)
return "";
menuItem->SetCurrent(current);
return menuItem->GetPluginName();
} }
cDisplayMenuItemView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable); cDisplayMenuItemMainView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable);
menuItems[index] = item; menuItems[index] = item;
return item->GetPluginName();
} }
void cDisplayMenuListView::AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable) { void cDisplayMenuListView::AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable) {
@ -241,3 +248,13 @@ void cDisplayMenuListView::Debug(void) {
} }
} }
} }
string cDisplayMenuListView::GetDefaultMenuCategory(void) {
if (cat == mcSchedule || cat == mcScheduleNow || cat == mcScheduleNext)
return "schedule";
else if (cat >= mcPluginSetup && cat <= mcSetupPlugins)
return "setup";
else if (cat == mcCommand)
return "commands";
return currentPlug;
}

View File

@ -8,20 +8,23 @@
class cDisplayMenuListView { class cDisplayMenuListView {
private: private:
cTemplateViewList *tmplList; cTemplateViewList *tmplList;
eMenuCategory cat;
string currentPlug;
int itemCount; int itemCount;
cDisplayMenuItemView **menuItems; cDisplayMenuItemView **menuItems;
int *tabs; int *tabs;
int *tabWidths; int *tabWidths;
bool oneColumn; bool oneColumn;
string GetDefaultMenuCategory(void);
public: public:
cDisplayMenuListView(cTemplateViewList *tmplList, int count = -1); cDisplayMenuListView(cTemplateViewList *tmplList, int count, eMenuCategory cat = mcUnknown, string currentPlug = "");
virtual ~cDisplayMenuListView(); virtual ~cDisplayMenuListView();
void Clear(void); void Clear(void);
void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5); void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
int GetMaxItems(void) { return itemCount; }; int GetMaxItems(void) { return itemCount; };
int GetListWidth(void); int GetListWidth(void);
void AddDefaultMenuItem(int index, string *tabTexts, bool current, bool selectable); void AddDefaultMenuItem(int index, string *tabTexts, bool current, bool selectable);
void AddMainMenuItem(int index, const char *itemText, bool current, bool selectable); string AddMainMenuItem(int index, const char *itemText, bool current, bool selectable);
void AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable); void AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable);
void AddSchedulesMenuItem(int index, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav, bool current, bool selectable); void AddSchedulesMenuItem(int index, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav, bool current, bool selectable);
void AddChannelsMenuItem(int index, const cChannel *channel, bool withProvider, bool current, bool selectable); void AddChannelsMenuItem(int index, const cChannel *channel, bool withProvider, bool current, bool selectable);

View File

@ -7,6 +7,7 @@
cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) { cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) {
cat = mcUndefined; cat = mcUndefined;
selectedPluginMainMenu = "";
sortMode = msmUnknown; sortMode = msmUnknown;
sortModeLast = msmUnknown; sortModeLast = msmUnknown;
menuTitle = ""; menuTitle = "";
@ -208,7 +209,7 @@ void cDisplayMenuRootView::SetMenu(eMenuCategory menuCat, bool menuInit) {
cTemplateViewList *tmplMenuItems = subView->GetViewList(vlMenuItem); cTemplateViewList *tmplMenuItems = subView->GetViewList(vlMenuItem);
if (!tmplMenuItems) if (!tmplMenuItems)
return; return;
listView = new cDisplayMenuListView(tmplMenuItems); listView = new cDisplayMenuListView(tmplMenuItems, -1, menuCat, selectedPluginMainMenu);
} else { } else {
//Create detailed view //Create detailed view
detailView = new cDisplayMenuDetailView(subView); detailView = new cDisplayMenuDetailView(subView);

View File

@ -15,6 +15,7 @@ enum ePluginMenuType {
class cDisplayMenuRootView : public cView, public cViewHelpers { class cDisplayMenuRootView : public cView, public cViewHelpers {
private: private:
eMenuCategory cat; eMenuCategory cat;
string selectedPluginMainMenu;
eMenuSortMode sortMode; eMenuSortMode sortMode;
eMenuSortMode sortModeLast; eMenuSortMode sortModeLast;
eSubView viewType; eSubView viewType;
@ -51,6 +52,7 @@ public:
virtual ~cDisplayMenuRootView(); virtual ~cDisplayMenuRootView();
bool createOsd(void); bool createOsd(void);
void SetMenu(eMenuCategory menuCat, bool menuInit); void SetMenu(eMenuCategory menuCat, bool menuInit);
void SetSelectedPluginMainMenu(string name) { selectedPluginMainMenu = name; };
void SetSortMode(eMenuSortMode sortMode); void SetSortMode(eMenuSortMode sortMode);
void SetCurrentRecording(string rec) { currentRecording = rec; }; void SetCurrentRecording(string rec) { currentRecording = rec; };
void CorrectDefaultMenu(void); void CorrectDefaultMenu(void);