2015-04-01 10:14:26 +02:00
|
|
|
#include <vdr/player.h>
|
2014-09-27 09:25:14 +02:00
|
|
|
#include "displaymenu.h"
|
|
|
|
#include "libcore/helpers.h"
|
|
|
|
|
|
|
|
cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) {
|
2015-01-18 12:03:06 +01:00
|
|
|
textAreaFont = NULL;
|
|
|
|
rootView = NULL;
|
2014-09-27 09:25:14 +02:00
|
|
|
doOutput = true;
|
|
|
|
state = vsInit;
|
2014-11-15 09:47:22 +01:00
|
|
|
pluginMenu = -1;
|
|
|
|
pluginName = "";
|
|
|
|
pluginMenuType = mtUnknown;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (!menuTemplate) {
|
|
|
|
doOutput = false;
|
2015-03-12 17:28:35 +01:00
|
|
|
dsyslog("skindesigner: displayMenu no valid template - aborting");
|
2014-09-27 09:25:14 +02:00
|
|
|
return;
|
2015-07-12 09:24:58 +02:00
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
rootView = new cDisplayMenuRootView(menuTemplate->GetRootView());
|
|
|
|
if (!rootView->createOsd()) {
|
|
|
|
doOutput = false;
|
|
|
|
return;
|
|
|
|
}
|
2015-04-01 10:14:26 +02:00
|
|
|
SetCurrentRecording();
|
2015-04-11 16:21:33 +02:00
|
|
|
rootView->DrawDebugGrid();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cSDDisplayMenu::~cSDDisplayMenu() {
|
2015-01-18 12:03:06 +01:00
|
|
|
if (rootView)
|
|
|
|
delete rootView;
|
2014-10-15 18:04:12 +02:00
|
|
|
if (textAreaFont)
|
|
|
|
delete textAreaFont;
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::Scroll(bool Up, bool Page) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->KeyInput(Up, Page);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cSDDisplayMenu::MaxItems(void) {
|
|
|
|
if (!doOutput)
|
|
|
|
return 0;
|
|
|
|
int maxItems = rootView->GetMaxItems();
|
|
|
|
return maxItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::Clear(void) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetMenuCategory(eMenuCategory MenuCat) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetMenu(MenuCat, (state == vsInit) ? true : false);
|
|
|
|
cSkinDisplayMenu::SetMenuCategory(MenuCat);
|
|
|
|
if (state != vsInit)
|
|
|
|
state = vsMenuInit;
|
|
|
|
}
|
|
|
|
|
2015-03-31 16:08:42 +02:00
|
|
|
void cSDDisplayMenu::SetMenuSortMode(eMenuSortMode MenuSortMode) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetSortMode(MenuSortMode);
|
|
|
|
}
|
|
|
|
|
2014-11-15 09:47:22 +01:00
|
|
|
void cSDDisplayMenu::SetPluginMenu(string name, int menu, int type, bool init) {
|
|
|
|
pluginName = name;
|
|
|
|
pluginMenu = menu;
|
|
|
|
pluginMenuType = (ePluginMenuType)type;
|
|
|
|
rootView->SetPluginMenu(pluginName, pluginMenu, pluginMenuType);
|
|
|
|
if (!init) {
|
|
|
|
rootView->SetMenu(mcPlugin, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cSDDisplayMenu::SetTitle(const char *Title) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetTitle(Title);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetButtonTexts(Red, Green, Yellow, Blue);
|
|
|
|
if (state != vsInit && MenuCategory() != mcMain)
|
|
|
|
state = vsMenuInit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetMessage(eMessageType Type, const char *Text) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetMessage(Type, Text);
|
|
|
|
rootView->DoFlush();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cSDDisplayMenu::SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch) {
|
|
|
|
if (!doOutput)
|
|
|
|
return true;
|
|
|
|
if (!rootView->SubViewAvailable())
|
|
|
|
return false;
|
2014-10-18 09:11:11 +02:00
|
|
|
if (config.blockFlush)
|
|
|
|
rootView->LockFlush();
|
2015-01-10 10:10:31 +01:00
|
|
|
bool isFav = false;
|
|
|
|
if (MenuCategory() == mcSchedule && Channel) {
|
|
|
|
isFav = true;
|
|
|
|
rootView->SetEpgSearchFavorite();
|
|
|
|
}
|
2014-11-01 10:23:34 +01:00
|
|
|
const cChannel *channel = Channel;
|
2015-01-11 14:46:33 +01:00
|
|
|
if (MenuCategory() == mcSchedule) {
|
|
|
|
if (!channel) {
|
|
|
|
channel = rootView->GetChannel();
|
|
|
|
}
|
|
|
|
if (!channel && Event) {
|
|
|
|
channel = Channels.GetByChannelID(Event->ChannelID());
|
|
|
|
}
|
|
|
|
rootView->SetChannel(channel);
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
2015-01-10 10:10:31 +01:00
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
cDisplayMenuListView *list = rootView->GetListView();
|
|
|
|
if (!list)
|
|
|
|
return false;
|
2015-05-14 12:09:44 +02:00
|
|
|
list->AddSchedulesMenuItem(Index, Event, channel, TimerMatch, MenuCategory(), isFav, Current, Selectable, "");
|
2014-09-27 09:25:14 +02:00
|
|
|
if (state == vsIdle)
|
|
|
|
state = vsMenuUpdate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cSDDisplayMenu::SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable) {
|
|
|
|
if (!doOutput)
|
|
|
|
return true;
|
|
|
|
if (!rootView->SubViewAvailable())
|
|
|
|
return false;
|
2014-10-18 09:11:11 +02:00
|
|
|
if (config.blockFlush)
|
|
|
|
rootView->LockFlush();
|
2014-09-27 09:25:14 +02:00
|
|
|
cDisplayMenuListView *list = rootView->GetListView();
|
|
|
|
if (!list)
|
|
|
|
return false;
|
|
|
|
list->AddTimersMenuItem(Index, Timer, Current, Selectable);
|
|
|
|
if (state == vsIdle)
|
|
|
|
state = vsMenuUpdate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cSDDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider) {
|
|
|
|
if (!doOutput)
|
|
|
|
return true;
|
|
|
|
if (!rootView->SubViewAvailable())
|
|
|
|
return false;
|
2014-10-18 09:11:11 +02:00
|
|
|
if (config.blockFlush)
|
|
|
|
rootView->LockFlush();
|
2014-09-27 09:25:14 +02:00
|
|
|
cDisplayMenuListView *list = rootView->GetListView();
|
|
|
|
if (!list)
|
|
|
|
return false;
|
|
|
|
list->AddChannelsMenuItem(Index, Channel, WithProvider, Current, Selectable);
|
|
|
|
if (state == vsIdle)
|
|
|
|
state = vsMenuUpdate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cSDDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New) {
|
|
|
|
if (!doOutput)
|
|
|
|
return true;
|
|
|
|
if (!rootView->SubViewAvailable())
|
|
|
|
return false;
|
2014-10-18 09:11:11 +02:00
|
|
|
if (config.blockFlush)
|
|
|
|
rootView->LockFlush();
|
2014-09-27 09:25:14 +02:00
|
|
|
cDisplayMenuListView *list = rootView->GetListView();
|
|
|
|
if (!list)
|
|
|
|
return false;
|
2015-06-05 17:32:24 +02:00
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
list->AddRecordingMenuItem(Index, Recording, Level, Total, New, Current, Selectable);
|
|
|
|
if (state == vsIdle)
|
|
|
|
state = vsMenuUpdate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-15 09:47:22 +01:00
|
|
|
bool cSDDisplayMenu::SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable) {
|
|
|
|
if (!doOutput)
|
|
|
|
return true;
|
|
|
|
if (!rootView->SubViewAvailable())
|
|
|
|
return false;
|
|
|
|
if (config.blockFlush)
|
|
|
|
rootView->LockFlush();
|
|
|
|
cDisplayMenuListView *list = rootView->GetListView();
|
|
|
|
if (!list)
|
|
|
|
return false;
|
|
|
|
list->AddPluginMenuItem(stringTokens, intTokens, loopTokens, Index, Current, Selectable);
|
|
|
|
if (state == vsIdle)
|
|
|
|
state = vsMenuUpdate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cSDDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
2015-06-04 10:57:25 +02:00
|
|
|
//esyslog("skindesigner: %s %d - %s", Current ? "----->" : "", Index, Text);
|
2014-09-27 09:25:14 +02:00
|
|
|
cDisplayMenuListView *list = rootView->GetListView();
|
|
|
|
if (!list) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-18 09:11:11 +02:00
|
|
|
if (config.blockFlush)
|
|
|
|
rootView->LockFlush();
|
2014-09-27 09:25:14 +02:00
|
|
|
eMenuCategory cat = MenuCategory();
|
2014-10-25 12:47:00 +02:00
|
|
|
if (cat == mcMain && rootView->SubViewAvailable()) {
|
2015-04-05 16:56:15 +02:00
|
|
|
string plugName = list->AddMainMenuItem(Index, Text, Current, Selectable);
|
|
|
|
if (Current) {
|
|
|
|
rootView->SetSelectedPluginMainMenu(plugName);
|
|
|
|
}
|
2014-10-25 12:47:00 +02:00
|
|
|
} else if (cat == mcSetup && rootView->SubViewAvailable()) {
|
2014-09-27 09:25:14 +02:00
|
|
|
list->AddSetupMenuItem(Index, Text, Current, Selectable);
|
2015-05-14 12:09:44 +02:00
|
|
|
} else if ((cat == mcSchedule || cat == mcScheduleNow || cat == mcScheduleNext) && rootView->SubViewAvailable()) {
|
2015-06-05 07:19:51 +02:00
|
|
|
list->AddSchedulesMenuItem(Index, NULL, NULL, tmNone, MenuCategory(), false, Current, Selectable, Text ? Text : "");
|
2014-09-27 09:25:14 +02:00
|
|
|
} else {
|
2014-12-06 11:17:15 +01:00
|
|
|
rootView->CorrectDefaultMenu();
|
2014-09-27 09:25:14 +02:00
|
|
|
string *tabTexts = new string[MaxTabs];
|
|
|
|
for (int i=0; i<MaxTabs; i++) {
|
|
|
|
const char *s = GetTabbedText(Text, i);
|
|
|
|
if (s) {
|
2015-01-12 12:34:19 +01:00
|
|
|
if (strlen(s) == 0)
|
|
|
|
tabTexts[i] = " ";
|
|
|
|
else
|
|
|
|
tabTexts[i] = s;
|
2014-09-27 09:25:14 +02:00
|
|
|
} else {
|
|
|
|
tabTexts[i] = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list->AddDefaultMenuItem(Index, tabTexts, Current, Selectable);
|
|
|
|
SetEditableWidth( rootView->GetListViewWidth() / 2);
|
|
|
|
}
|
|
|
|
if (state == vsIdle)
|
|
|
|
state = vsMenuUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetTabs(int Tab1, int Tab2, int Tab3, int Tab4, int Tab5) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetTabs(Tab1, Tab2, Tab3, Tab4, Tab5);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cSDDisplayMenu::GetTextAreaWidth(void) const {
|
|
|
|
int areaWidth = rootView->GetTextAreaWidth();
|
|
|
|
return areaWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
const cFont *cSDDisplayMenu::GetTextAreaFont(bool FixedFont) const {
|
2014-10-15 18:04:12 +02:00
|
|
|
if (textAreaFont)
|
|
|
|
return textAreaFont;
|
|
|
|
textAreaFont = rootView->GetTextAreaFont();
|
|
|
|
return textAreaFont;
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetScrollbar(int Total, int Offset) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->RenderMenuScrollBar(Total, Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetEvent(const cEvent *Event) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetDetailedViewEvent(Event);
|
|
|
|
state = vsMenuDetail;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetRecording(const cRecording *Recording) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetDetailedViewRecording(Recording);
|
|
|
|
state = vsMenuDetail;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSDDisplayMenu::SetText(const char *Text, bool FixedFont) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
|
|
|
rootView->SetDetailedViewText(Text);
|
|
|
|
state = vsMenuDetail;
|
|
|
|
}
|
|
|
|
|
2014-11-15 09:47:22 +01:00
|
|
|
bool cSDDisplayMenu::SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens) {
|
|
|
|
if (!doOutput)
|
|
|
|
return true;
|
|
|
|
bool tmplOk = rootView->SetDetailedViewPlugin(stringTokens, intTokens, loopTokens);
|
|
|
|
state = vsMenuDetail;
|
|
|
|
return tmplOk;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cSDDisplayMenu::Flush(void) {
|
|
|
|
if (!doOutput)
|
|
|
|
return;
|
2014-10-11 12:13:15 +02:00
|
|
|
bool doFlush = false;
|
2014-09-27 09:25:14 +02:00
|
|
|
if (state == vsInit) {
|
|
|
|
rootView->Start();
|
|
|
|
rootView->RenderMenuItems();
|
2014-10-11 12:13:15 +02:00
|
|
|
doFlush = true;
|
2014-09-27 09:25:14 +02:00
|
|
|
} else if (state == vsMenuInit) {
|
|
|
|
rootView->Render();
|
|
|
|
rootView->RenderMenuItems();
|
2014-10-11 12:13:15 +02:00
|
|
|
doFlush = true;
|
2014-09-27 09:25:14 +02:00
|
|
|
} else if (state == vsMenuUpdate) {
|
|
|
|
rootView->RenderMenuItems();
|
2014-10-11 12:13:15 +02:00
|
|
|
doFlush = true;
|
2014-09-27 09:25:14 +02:00
|
|
|
} else if (state == vsMenuDetail) {
|
2014-10-11 12:13:15 +02:00
|
|
|
rootView->OpenFlush();
|
2014-09-27 09:25:14 +02:00
|
|
|
rootView->Render();
|
|
|
|
rootView->DoFlush();
|
|
|
|
rootView->RenderDetailView();
|
|
|
|
rootView->DoFlush();
|
2014-10-11 12:13:15 +02:00
|
|
|
}
|
2015-01-06 06:07:48 +01:00
|
|
|
|
|
|
|
if (rootView->RenderDynamicElements()) {
|
|
|
|
doFlush = true;
|
|
|
|
}
|
|
|
|
|
2014-10-11 12:13:15 +02:00
|
|
|
if (doFlush) {
|
2014-10-18 09:11:11 +02:00
|
|
|
if (config.blockFlush)
|
|
|
|
rootView->OpenFlush();
|
2014-10-11 12:13:15 +02:00
|
|
|
rootView->DoFlush();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
state = vsIdle;
|
|
|
|
}
|
2015-04-01 10:14:26 +02:00
|
|
|
|
|
|
|
void cSDDisplayMenu::SetCurrentRecording(void) {
|
|
|
|
cControl *control = cControl::Control();
|
|
|
|
if (!control) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const cRecording *recording = control->GetRecording();
|
|
|
|
if (!recording) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
string recFileName = "";
|
|
|
|
if (recording->FileName()) {
|
|
|
|
recFileName = recording->FileName();
|
|
|
|
}
|
|
|
|
rootView->SetCurrentRecording(recFileName);
|
|
|
|
}
|