2014-09-27 09:25:14 +02:00
|
|
|
#include <vdr/menu.h>
|
|
|
|
#include "displaymenulistview.h"
|
|
|
|
|
|
|
|
|
2015-04-05 16:56:15 +02:00
|
|
|
cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int count, eMenuCategory cat, string currentPlug) {
|
2014-09-27 09:25:14 +02:00
|
|
|
oneColumn = true;
|
|
|
|
this->tmplList = tmplList;
|
|
|
|
if (count < 0) {
|
|
|
|
//if count is not set, the fixed number of items is configured in the template
|
|
|
|
itemCount = tmplList->GetNumericParameter(ptNumElements);
|
|
|
|
} else {
|
|
|
|
//else use the actual numbers of elements
|
|
|
|
itemCount = count;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
intTokens.insert(pair<string,int>("numelements", count));
|
|
|
|
tmplList->CalculateListParameters(&intTokens);
|
|
|
|
}
|
2015-04-05 16:56:15 +02:00
|
|
|
this->cat = cat;
|
|
|
|
this->currentPlug = currentPlug;
|
2014-09-27 09:25:14 +02:00
|
|
|
menuItems = new cDisplayMenuItemView*[itemCount];
|
|
|
|
for (int i=0; i<itemCount; i++)
|
|
|
|
menuItems[i] = NULL;
|
|
|
|
tabs = new int[cSkinDisplayMenu::MaxTabs];
|
|
|
|
for (int i=0; i<cSkinDisplayMenu::MaxTabs; i++)
|
|
|
|
tabs[i] = 0;
|
|
|
|
tabWidths = new int[cSkinDisplayMenu::MaxTabs];
|
|
|
|
for (int i=0; i<cSkinDisplayMenu::MaxTabs; i++)
|
|
|
|
tabWidths[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayMenuListView::~cDisplayMenuListView() {
|
|
|
|
Clear();
|
|
|
|
delete[] menuItems;
|
|
|
|
delete[] tabs;
|
|
|
|
delete[] tabWidths;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
|
|
|
|
|
|
|
|
int menuItemWidth = 1920;
|
|
|
|
int averageFontWidth = 20;
|
|
|
|
if (tmplList) {
|
|
|
|
menuItemWidth = tmplList->GetMenuItemWidth();
|
|
|
|
averageFontWidth = tmplList->GetAverageFontWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tab1) {
|
|
|
|
tabs[0] = 0;
|
|
|
|
tabWidths[0] = menuItemWidth;
|
|
|
|
} else {
|
|
|
|
tabs[0] = 0;
|
|
|
|
if (!tab2) {
|
|
|
|
tabs[1] = menuItemWidth/2;
|
|
|
|
tabWidths[0] = tabs[1];
|
|
|
|
tabWidths[1] = tabs[1];
|
|
|
|
} else {
|
|
|
|
tabs[0] = 0;
|
|
|
|
tabs[1] = tab1 ? tabs[0] + tab1 : 0;
|
|
|
|
tabs[2] = tab2 ? tabs[1] + tab2 : 0;
|
|
|
|
tabs[3] = tab3 ? tabs[2] + tab3 : 0;
|
|
|
|
tabs[4] = tab4 ? tabs[3] + tab4 : 0;
|
|
|
|
tabs[5] = tab5 ? tabs[4] + tab5 : 0;
|
|
|
|
for (int i = 1; i < cSkinDisplayMenu::MaxTabs; i++)
|
|
|
|
tabs[i] *= averageFontWidth;
|
|
|
|
|
|
|
|
for (int i = 0; i < cSkinDisplayMenu::MaxTabs; i++) {
|
|
|
|
if (i == cSkinDisplayMenu::MaxTabs - 1) {
|
|
|
|
tabWidths[i] = menuItemWidth - tabs[i];
|
|
|
|
} else {
|
|
|
|
tabWidths[i] = tabs[i+1] - tabs[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int cDisplayMenuListView::GetListWidth(void) {
|
|
|
|
if (tmplList) {
|
|
|
|
return tmplList->GetMenuItemWidth();
|
|
|
|
}
|
|
|
|
return 1920;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cDisplayMenuListView::Clear(void) {
|
|
|
|
for (int i=0; i<itemCount; i++) {
|
2015-07-15 19:08:05 +02:00
|
|
|
Lock();
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[i]) {
|
|
|
|
delete menuItems[i];
|
|
|
|
menuItems[i] = NULL;
|
|
|
|
}
|
2015-07-15 19:08:05 +02:00
|
|
|
Unlock();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
oneColumn = true;
|
|
|
|
for (int i=0; i<cSkinDisplayMenu::MaxTabs; i++) {
|
|
|
|
tabs[i] = 0;
|
|
|
|
tabWidths[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::AddDefaultMenuItem(int index, string *tabTexts, bool current, bool selectable) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
|
|
|
cDisplayMenuItemDefaultView *menuItem = dynamic_cast<cDisplayMenuItemDefaultView*>(menuItems[index]);
|
|
|
|
if (!menuItem)
|
|
|
|
return;
|
|
|
|
menuItem->SetCurrent(current);
|
|
|
|
menuItem->SetTabTexts(tabTexts);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i=1; i<cSkinDisplayMenu::MaxTabs; i++) {
|
|
|
|
if (tabTexts[i].size() > 0) {
|
|
|
|
oneColumn = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-04-05 16:56:15 +02:00
|
|
|
cDisplayMenuItemDefaultView *item = new cDisplayMenuItemDefaultView(tmplList, tabTexts, tabs, tabWidths, current, selectable);
|
|
|
|
item->SetMenuCategory(GetDefaultMenuCategory());
|
2014-09-27 09:25:14 +02:00
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
2015-04-05 16:56:15 +02:00
|
|
|
string cDisplayMenuListView::AddMainMenuItem(int index, const char *itemText, bool current, bool selectable) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
2015-04-05 16:56:15 +02:00
|
|
|
return "";
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
2015-04-05 16:56:15 +02:00
|
|
|
cDisplayMenuItemMainView *menuItem = dynamic_cast<cDisplayMenuItemMainView*>(menuItems[index]);
|
|
|
|
if (!menuItem)
|
|
|
|
return "";
|
|
|
|
menuItem->SetCurrent(current);
|
|
|
|
return menuItem->GetPluginName();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
2015-04-05 16:56:15 +02:00
|
|
|
cDisplayMenuItemMainView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable);
|
2014-09-27 09:25:14 +02:00
|
|
|
menuItems[index] = item;
|
2015-04-05 16:56:15 +02:00
|
|
|
return item->GetPluginName();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
|
|
|
menuItems[index]->SetCurrent(current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cDisplayMenuItemView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable);
|
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::AddSchedulesMenuItem(int index, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch,
|
2015-05-14 12:09:44 +02:00
|
|
|
eMenuCategory cat, bool isEpgSearchFav, bool current, bool selectable, string dayseparator) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
|
|
|
menuItems[index]->SetCurrent(current);
|
|
|
|
return;
|
|
|
|
}
|
2015-05-14 12:09:44 +02:00
|
|
|
cDisplayMenuItemView *item = new cDisplayMenuItemSchedulesView(tmplList, event, channel, timerMatch, cat, isEpgSearchFav, current, selectable, dayseparator);
|
2014-09-27 09:25:14 +02:00
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::AddChannelsMenuItem(int index, const cChannel *channel, bool withProvider, bool current, bool selectable) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
|
|
|
menuItems[index]->SetCurrent(current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cDisplayMenuItemView *item = new cDisplayMenuItemChannelsView(tmplList, channel, withProvider, current, selectable);
|
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::AddTimersMenuItem(int index, const cTimer *timer, bool current, bool selectable) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
|
|
|
menuItems[index]->SetCurrent(current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cDisplayMenuItemView *item = new cDisplayMenuItemTimersView(tmplList, timer, current, selectable);
|
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::AddRecordingMenuItem(int index, const cRecording *recording, int level, int total, int isNew, bool current, bool selectable) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
|
|
|
menuItems[index]->SetCurrent(current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cDisplayMenuItemView *item = new cDisplayMenuItemRecordingView(tmplList, recording, level, total, isNew, current, selectable);
|
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
2014-11-15 09:47:22 +01:00
|
|
|
void cDisplayMenuListView::AddPluginMenuItem(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int index, bool current, bool selectable) {
|
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
|
|
|
if (menuItems[index]) {
|
|
|
|
menuItems[index]->SetCurrent(current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cDisplayMenuItemView *item = new cDisplayMenuItemPluginView(tmplList, stringTokens, intTokens, loopTokens, index, current, selectable);
|
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cDisplayMenuListView::AddTracksMenuItem(int index, const char *title, bool current, bool selectable) {
|
2014-11-02 11:41:41 +01:00
|
|
|
if (index >= itemCount)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[index]) {
|
|
|
|
menuItems[index]->SetCurrent(current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cDisplayMenuItemView *item = new cDisplayMenuItemTrackView(tmplList, title, current, selectable, itemCount);
|
|
|
|
menuItems[index] = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::Render(void) {
|
|
|
|
if (tabs[1] && oneColumn) {
|
|
|
|
tabs[0] = 0;
|
|
|
|
tabWidths[0] = tmplList->GetMenuItemWidth();
|
|
|
|
for (int i=1; i<cSkinDisplayMenu::MaxTabs; i++) {
|
|
|
|
tabs[i] = 0;
|
|
|
|
tabWidths[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int current = -1;
|
|
|
|
for (int i=0; i<itemCount; i++) {
|
2015-07-16 18:08:22 +02:00
|
|
|
Lock();
|
2014-09-27 09:25:14 +02:00
|
|
|
if (menuItems[i] && menuItems[i]->Dirty()) {
|
|
|
|
menuItems[i]->Clear();
|
|
|
|
menuItems[i]->SetNumber(i);
|
|
|
|
menuItems[i]->Prepare();
|
|
|
|
menuItems[i]->SetTokens();
|
|
|
|
menuItems[i]->Render();
|
|
|
|
if (menuItems[i]->Current()) {
|
|
|
|
current = i;
|
|
|
|
} else {
|
|
|
|
menuItems[i]->Stop();
|
|
|
|
}
|
|
|
|
}
|
2015-07-16 18:08:22 +02:00
|
|
|
Unlock();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
if (current > -1) {
|
|
|
|
menuItems[current]->Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuListView::Debug(void) {
|
|
|
|
for (int i=0; i<itemCount; i++) {
|
|
|
|
esyslog("skindesigner: item %d", i);
|
|
|
|
if (menuItems[i]) {
|
|
|
|
menuItems[i]->Debug();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-05 16:56:15 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|