summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/menunode.cc37
-rw-r--r--src/menunode.h28
-rw-r--r--src/pluginmenuitem.cc14
-rw-r--r--src/pluginmenuitem.h19
-rw-r--r--src/submenuitem.cc6
-rw-r--r--src/submenuitem.h12
-rw-r--r--src/submenuprovider.cc164
-rw-r--r--src/submenuprovider.h36
-rw-r--r--src/vdrmenuitem.cc14
-rw-r--r--src/vdrmenuitem.h19
10 files changed, 220 insertions, 129 deletions
diff --git a/src/menunode.cc b/src/menunode.cc
new file mode 100644
index 0000000..ab862e6
--- /dev/null
+++ b/src/menunode.cc
@@ -0,0 +1,37 @@
+#include "menunode.h"
+
+MenuNode::~MenuNode()
+{
+ while (!_childs.empty())
+ {
+ delete _childs.back();
+ _childs.pop_back();
+ }
+}
+
+MenuNode* MenuNode::Parent()
+{
+ return _parent;
+}
+
+MenuNodeList& MenuNode::Childs()
+{
+ return _childs;
+}
+
+MenuNode* MenuNode::AddChild(MenuNode* child)
+{
+ _childs.push_back(child);
+ child->SetParent(this);
+ return child;
+}
+
+void MenuNode::SetParent(MenuNode* parent)
+{
+ _parent = parent;
+}
+
+SubMenuPatch::MainMenuItem* MenuNode::CreateMainMenuItem()
+{
+ return NULL;
+}
diff --git a/src/menunode.h b/src/menunode.h
new file mode 100644
index 0000000..73dbb4c
--- /dev/null
+++ b/src/menunode.h
@@ -0,0 +1,28 @@
+#ifndef ___MENUNODE_H
+#define ___MENUNODE_H
+
+#include <vector>
+#include <vdr/submenupatch.h>
+
+class MenuNode;
+
+typedef std::vector<MenuNode*> MenuNodeList;
+
+class MenuNode
+{
+ private:
+ MenuNode* _parent;
+ MenuNodeList _childs;
+
+ protected:
+ void SetParent(MenuNode* parent);
+
+ public:
+ virtual ~MenuNode();
+ MenuNode* Parent();
+ MenuNodeList& Childs();
+ MenuNode* AddChild(MenuNode* child);
+ virtual SubMenuPatch::MainMenuItem* CreateMainMenuItem();
+};
+
+#endif
diff --git a/src/pluginmenuitem.cc b/src/pluginmenuitem.cc
new file mode 100644
index 0000000..d44d747
--- /dev/null
+++ b/src/pluginmenuitem.cc
@@ -0,0 +1,14 @@
+#include "pluginmenuitem.h"
+#include <vdr/submenupatch.h>
+
+PluginMenuItem::PluginMenuItem(const char* pluginMainMenuEntry, int pluginIndex)
+{
+ _pluginMainMenuEntry = pluginMainMenuEntry;
+ _pluginIndex = pluginIndex;
+}
+
+SubMenuPatch::MainMenuItem* PluginMenuItem::CreateMainMenuItem()
+{
+ return SubMenuPatch::MainMenuItem::CreatePluginMenuItem(
+ _pluginMainMenuEntry, _pluginIndex);
+}
diff --git a/src/pluginmenuitem.h b/src/pluginmenuitem.h
new file mode 100644
index 0000000..069abce
--- /dev/null
+++ b/src/pluginmenuitem.h
@@ -0,0 +1,19 @@
+#ifndef ___PLUGINMENUITEM_H
+#define ___PLUGINMENUITEM_H
+
+#include "menunode.h"
+#include <vdr/osdbase.h>
+#include <vdr/submenupatch.h>
+
+class PluginMenuItem: public MenuNode
+{
+ private:
+ const char* _pluginMainMenuEntry;
+ int _pluginIndex;
+
+ public:
+ PluginMenuItem(const char* pluginMainMenuEntry, int pluginIndex);
+ SubMenuPatch::MainMenuItem* CreateMainMenuItem();
+};
+
+#endif
diff --git a/src/submenuitem.cc b/src/submenuitem.cc
new file mode 100644
index 0000000..fa7d43f
--- /dev/null
+++ b/src/submenuitem.cc
@@ -0,0 +1,6 @@
+#include "submenuitem.h"
+
+SubMenuItem::SubMenuItem(const char* itemText)
+ :VdrMenuItem(itemText, osUser1)
+{
+}
diff --git a/src/submenuitem.h b/src/submenuitem.h
new file mode 100644
index 0000000..00c4b2e
--- /dev/null
+++ b/src/submenuitem.h
@@ -0,0 +1,12 @@
+#ifndef ___SUBMENUITEM_H
+#define ___SUBMENUITEM_H
+
+#include "vdrmenuitem.h"
+
+class SubMenuItem: public VdrMenuItem
+{
+ public:
+ SubMenuItem(const char* itemText);
+};
+
+#endif
diff --git a/src/submenuprovider.cc b/src/submenuprovider.cc
index b3c7c67..cf6b34c 100644
--- a/src/submenuprovider.cc
+++ b/src/submenuprovider.cc
@@ -1,140 +1,88 @@
#include "submenuprovider.h"
+#include "submenuitem.h"
+#include "vdrmenuitem.h"
+#include "pluginmenuitem.h"
#include <vdr/plugin.h>
-#include <iostream>
-
-//using namespace std;
SubMenuProvider::SubMenuProvider()
{
- _MenuIndex=0;
- _nextMenuIndex=0;
- CreateTestMenus();
+ CreateTestMenus();
+ _currentMenu = &_rootMenuNode;
}
void SubMenuProvider::CreateTestMenus()
{
- // Mainmenu
- _myOsdItems[0].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("A custom sub menu1"), osUser1)));
- _myOsdItems[0].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("A custom sub menu2"), osUser1)));
- _myOsdItems[0].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("Setup"), osSetup)));
- if (Commands.Count())
- _myOsdItems[0].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("Commands"), osCommands)));
-
- _MenuSwitch[0][0][ENTER] = 1;
- _MenuSwitch[0][0][LEAVE] = 0;
-
- _MenuSwitch[0][1][ENTER] = 2;
- _MenuSwitch[0][1][LEAVE] = 0;
-
- _MenuSwitch[0][2][ENTER] = 0;
- _MenuSwitch[0][2][LEAVE] = 0;
-
- _MenuSwitch[0][3][ENTER] = 0;
- _MenuSwitch[0][3][LEAVE] = 0;
-
- // Submenu 1
- _myOsdItems[1].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("Schedule"), osSchedule)));
- _myOsdItems[1].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("Channels"), osChannels)));
- _myOsdItems[1].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("Timers"), osTimers)));
- _myOsdItems[1].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("Recordings"), osRecordings)));
- _myOsdItems[1].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("A custom sub sub menu1"), osUser1)));
-
- _MenuSwitch[1][0][ENTER] = 1;
- _MenuSwitch[1][0][LEAVE] = 0;
-
- _MenuSwitch[1][1][ENTER] = 1;
- _MenuSwitch[1][1][LEAVE] = 0;
-
- _MenuSwitch[1][2][ENTER] = 1;
- _MenuSwitch[1][2][LEAVE] = 0;
-
- _MenuSwitch[1][3][ENTER] = 1;
- _MenuSwitch[1][3][LEAVE] = 0;
-
- _MenuSwitch[1][4][ENTER] = 3;
- _MenuSwitch[1][4][LEAVE] = 0;
-
- // Submenu 2
- int MenuItemCount = 0;
- for (int i = 0; ; i++)
- {
- cPlugin *p = cPluginManager::GetPlugin(i);
- if (p)
- {
- const char *item = p->MainMenuEntry();
- if (item)
- {
- _myOsdItems[2].push_back(MainMenuItem::CreatePluginMenuItem(item, i));
- _MenuSwitch[2][MenuItemCount][ENTER] = 2;
- _MenuSwitch[2][MenuItemCount][LEAVE] = 0;
- MenuItemCount++;
- }
- }
- else
- break;
- }
-
- // Sub Sub Menu 1
- _myOsdItems[3].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("a Test Item"), osContinue)));
- _myOsdItems[3].push_back(MainMenuItem::CreateCustomMenuItem(new cOsdItem(tr("Channels"), osChannels)));
- _MenuSwitch[3][0][ENTER] = 3;
- _MenuSwitch[3][0][LEAVE] = 1;
- _MenuSwitch[3][0][ENTER] = 3;
- _MenuSwitch[3][0][LEAVE] = 1;
+ MenuNode* subMenu1 =_rootMenuNode.AddChild(new SubMenuItem("Custom menu 1"));
+ subMenu1->AddChild(new VdrMenuItem(tr("Schedule"), osSchedule));
+ subMenu1->AddChild(new VdrMenuItem(tr("Channels"), osChannels));
+ MenuNode* subMenu1_1 = subMenu1->AddChild(new SubMenuItem("Custom menu 1.1"));
+ subMenu1_1->AddChild(new VdrMenuItem(tr("Timers"), osTimers));
+ subMenu1_1->AddChild(new VdrMenuItem(tr("Recordings"), osRecordings));
+ MenuNode* subMenu2 =_rootMenuNode.AddChild(new SubMenuItem("Custom menu 2"));
+ //plugins
+ for (int i = 0; ; i++)
+ {
+ cPlugin *p = cPluginManager::GetPlugin(i);
+ if (p)
+ {
+ const char *item = p->MainMenuEntry();
+ if (item)
+ {
+ subMenu2->AddChild(new PluginMenuItem(item, i));
+ }
+ }
+ else
+ break;
+ }
}
MainMenuItemsList* SubMenuProvider::MainMenuItems()
{
- isyslog("Call MainMenuItems() - _MenuIndex=%d - _nextMenuIndex=%d", _MenuIndex, _nextMenuIndex);
-
- ResetMainMenuItemsList();
-
- _osdItems=_myOsdItems[_nextMenuIndex];
- _MenuIndex=_nextMenuIndex;
+ ResetMainMenuItemsList();
+
+ for (MenuNodeList::iterator i = _currentMenu->Childs().begin();
+ i != _currentMenu->Childs().end(); i++)
+ {
+ _currentMainMenuItems.push_back((*i)->CreateMainMenuItem());
+ }
- return &_osdItems;
+ return &_currentMainMenuItems;
}
void SubMenuProvider::ResetMainMenuItemsList()
{
- for( MainMenuItemsList::iterator i = _osdItems.begin(); i != _osdItems.end(); i++)
+
+ for( MainMenuItemsList::iterator i = _currentMainMenuItems.begin();
+ i != _currentMainMenuItems.end(); i++)
{
delete *i;
}
- _osdItems.clear();
+ _currentMainMenuItems.clear();
+
}
void SubMenuProvider::EnterSubMenu(cOsdItem* item)
{
- isyslog("Call EnterSubMenu() - _MenuIndex=%d", _MenuIndex);
-
- unsigned int itemIndex;
-
- for(itemIndex=0; itemIndex < _osdItems.size(); itemIndex++)
+ for(unsigned int itemIndex=0; itemIndex < _currentMainMenuItems.size(); itemIndex++)
+ {
+ MainMenuItem* menuItem = _currentMainMenuItems.at(itemIndex);
+ if (menuItem->IsCustomMenuItem() && (menuItem->CustomMenuItem() == item))
{
- MainMenuItem* menuItem = _osdItems.at(itemIndex);
- if (menuItem->IsCustomMenuItem() && (menuItem->CustomMenuItem() == item))
- {
- break;
- }
+ _currentMenu = _currentMenu->Childs().at(itemIndex);
+ break;
}
- isyslog("_MenuSwitch[%d][%d][ENTER]=%d",_MenuIndex,itemIndex,_MenuSwitch[_MenuIndex][itemIndex][ENTER]);
- _nextMenuIndex = _MenuSwitch[_MenuIndex][itemIndex][ENTER];
+ }
}
bool SubMenuProvider::LeaveSubMenu()
{
- isyslog("Call LeaveSubMenu() - _MenuIndex=%d", _MenuIndex);
-
- if (_MenuIndex != _MenuSwitch[_MenuIndex][0][LEAVE])
- {
- _nextMenuIndex = _MenuSwitch[_MenuIndex][0][LEAVE];
- isyslog("LeaveSubMenu() - return true");
- return true;
- }
- else
- {
- isyslog("LeaveSubMenu() - return false");
- return false;
- }
+ if (_currentMenu->Parent())
+ {
+ _currentMenu = _currentMenu->Parent();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
diff --git a/src/submenuprovider.h b/src/submenuprovider.h
index 6cdbd83..095482b 100644
--- a/src/submenuprovider.h
+++ b/src/submenuprovider.h
@@ -2,32 +2,26 @@
#define ___SUBMENUPROVIDER_H
#include <vdr/submenupatch.h>
+#include "menunode.h"
using namespace SubMenuPatch;
-const unsigned int ENTER = 0;
-const unsigned int LEAVE = 1;
-
class SubMenuProvider: public ISubMenuProvider
{
- private:
- MainMenuItemsList _osdItems; // Enthält das aktuelle MenüItem
- MainMenuItemsList _myOsdItems[5]; // Enthält alle verfügbaren Menüs
-
- int _MenuIndex; // Enthält den Index des aktuellen Menüs
- int _nextMenuIndex; // Enthält den Index des nächsten Menüs
- int _MenuSwitch[5][20][2]; // Speichert die Zuodnung
- // erster Wert MenuIndex | zweiter Wert MenuItemIndex | dritter wert 0=Enter, 1=Leave
-
- public:
- SubMenuProvider();
- virtual MainMenuItemsList* MainMenuItems();
- virtual void EnterSubMenu(cOsdItem* item);
- virtual bool LeaveSubMenu();
-
- private:
- void ResetMainMenuItemsList();
- void CreateTestMenus();
+ private:
+ MenuNode _rootMenuNode;
+ MenuNode* _currentMenu;
+ MainMenuItemsList _currentMainMenuItems;
+
+ public:
+ SubMenuProvider();
+ virtual MainMenuItemsList* MainMenuItems();
+ virtual void EnterSubMenu(cOsdItem* item);
+ virtual bool LeaveSubMenu();
+
+ private:
+ void ResetMainMenuItemsList();
+ void CreateTestMenus();
};
#endif
diff --git a/src/vdrmenuitem.cc b/src/vdrmenuitem.cc
new file mode 100644
index 0000000..2a5aba9
--- /dev/null
+++ b/src/vdrmenuitem.cc
@@ -0,0 +1,14 @@
+#include "vdrmenuitem.h"
+#include <vdr/submenupatch.h>
+
+VdrMenuItem::VdrMenuItem(const char* itemText, eOSState itemState)
+{
+ _itemText = itemText;
+ _itemState = itemState;
+}
+
+SubMenuPatch::MainMenuItem* VdrMenuItem::CreateMainMenuItem()
+{
+ return SubMenuPatch::MainMenuItem::CreateCustomMenuItem(
+ new cOsdItem(_itemText, _itemState));
+}
diff --git a/src/vdrmenuitem.h b/src/vdrmenuitem.h
new file mode 100644
index 0000000..730b2b3
--- /dev/null
+++ b/src/vdrmenuitem.h
@@ -0,0 +1,19 @@
+#ifndef ___VDRMENUITEM_H
+#define ___VDRMENUITEM_H
+
+#include "menunode.h"
+#include <vdr/osdbase.h>
+#include <vdr/submenupatch.h>
+
+class VdrMenuItem: public MenuNode
+{
+ private:
+ const char* _itemText;
+ eOSState _itemState;
+
+ public:
+ VdrMenuItem(const char* itemText, eOSState itemState);
+ SubMenuPatch::MainMenuItem* CreateMainMenuItem();
+};
+
+#endif