mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
plugin interface
This commit is contained in:
parent
00ac852820
commit
4d7700aece
5
Makefile
5
Makefile
@ -81,12 +81,14 @@ OBJS = $(PLUGIN).o \
|
||||
libtemplate/templateview.o \
|
||||
libtemplate/templateviewelement.o \
|
||||
libtemplate/templateviewlist.o \
|
||||
libtemplate/templateviewgrid.o \
|
||||
libtemplate/templatepixmap.o \
|
||||
libtemplate/templateviewtab.o \
|
||||
libtemplate/templatefunction.o \
|
||||
libtemplate/templateloopfunction.o \
|
||||
libtemplate/xmlparser.o \
|
||||
views/view.o \
|
||||
views/viewgrid.o \
|
||||
views/viewhelpers.o \
|
||||
views/displaychannelview.o \
|
||||
views/displaymenurootview.o \
|
||||
@ -100,7 +102,8 @@ OBJS = $(PLUGIN).o \
|
||||
views/displayreplayview.o \
|
||||
views/displayreplayonpauseview.o \
|
||||
views/displayvolumeview.o \
|
||||
views/displayaudiotracksview.o
|
||||
views/displayaudiotracksview.o \
|
||||
views/displaypluginview.o
|
||||
|
||||
### The main target:
|
||||
|
||||
|
70
config.c
70
config.c
@ -288,23 +288,77 @@ cString cDesignerConfig::GetSkinRessourcePath(void) {
|
||||
return cString::sprintf("%s%s", *skinPath, osdSkin.c_str());
|
||||
}
|
||||
|
||||
void cDesignerConfig::AddPlugin(string name, map < int, string > &menus) {
|
||||
plugins.insert(pair< string, map < int, string > >(name, menus));
|
||||
void cDesignerConfig::AddPluginMenus(string name, map< int, string > menus) {
|
||||
pluginMenus.insert(pair< string, map < int, string > >(name, menus));
|
||||
}
|
||||
|
||||
void cDesignerConfig::InitPluginIterator(void) {
|
||||
plugIt = plugins.begin();
|
||||
void cDesignerConfig::AddPluginViews(string name,
|
||||
map< int, string > views,
|
||||
map< int, map <int, string> > viewElements,
|
||||
map< int, map <int, string> > viewGrids) {
|
||||
pluginViews.insert(pair< string, map < int, string > >(name, views));
|
||||
pluginViewElements.insert(pair< string, map< int, map <int, string> > >(name, viewElements));
|
||||
pluginViewGrids.insert(pair< string, map< int, map <int, string> > >(name, viewGrids));
|
||||
}
|
||||
|
||||
void cDesignerConfig::InitPluginMenuIterator(void) {
|
||||
plugMenuIt = pluginMenus.begin();
|
||||
}
|
||||
|
||||
map <int,string> *cDesignerConfig::GetPluginTemplates(string &name) {
|
||||
if (plugIt == plugins.end())
|
||||
if (plugMenuIt == pluginMenus.end())
|
||||
return NULL;
|
||||
name = plugIt->first;
|
||||
map <int,string> *templates = &plugIt->second;
|
||||
plugIt++;
|
||||
name = plugMenuIt->first;
|
||||
map <int,string> *templates = &plugMenuIt->second;
|
||||
plugMenuIt++;
|
||||
return templates;
|
||||
}
|
||||
|
||||
void cDesignerConfig::InitPluginViewIterator(void) {
|
||||
plugViewIt = pluginViews.begin();
|
||||
}
|
||||
|
||||
map <int,string> *cDesignerConfig::GetPluginViews(string &name) {
|
||||
if (plugViewIt == pluginViews.end())
|
||||
return NULL;
|
||||
name = plugViewIt->first;
|
||||
map <int,string> *views = &plugViewIt->second;
|
||||
plugViewIt++;
|
||||
return views;
|
||||
}
|
||||
|
||||
int cDesignerConfig::GetPluginViewElementID(string pluginName, string viewElementName, int viewID) {
|
||||
map < string, map< int, map <int, string> > >::iterator hit = pluginViewElements.find(pluginName);
|
||||
if (hit == pluginViewElements.end())
|
||||
return -1;
|
||||
map< int, map <int, string> >::iterator hit2 = (hit->second).find(viewID);
|
||||
if (hit2 == (hit->second).end())
|
||||
return -1;
|
||||
|
||||
map <int, string> viewElements = hit2->second;
|
||||
for (map <int, string>::iterator it = viewElements.begin(); it != viewElements.end(); it++) {
|
||||
if (!(it->second).compare(viewElementName))
|
||||
return it->first;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int cDesignerConfig::GetPluginViewGridID(string pluginName, string viewGridName, int viewID) {
|
||||
map < string, map< int, map <int, string> > >::iterator hit = pluginViewGrids.find(pluginName);
|
||||
if (hit == pluginViewGrids.end())
|
||||
return -1;
|
||||
map< int, map <int, string> >::iterator hit2 = (hit->second).find(viewID);
|
||||
if (hit2 == (hit->second).end())
|
||||
return -1;
|
||||
|
||||
map <int, string> viewGrids = hit2->second;
|
||||
for (map <int, string>::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
|
||||
if (!(it->second).compare(viewGridName))
|
||||
return it->first;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
cString cDesignerConfig::CheckSlashAtEnd(std::string path) {
|
||||
try {
|
||||
if (!(path.at(path.size()-1) == '/'))
|
||||
|
17
config.h
17
config.h
@ -28,8 +28,12 @@ private:
|
||||
string fontSml;
|
||||
string osdLanguage;
|
||||
cGlobals *tmplGlobals;
|
||||
map < string, map < int, string > > plugins;
|
||||
map < string, map < int, string > >::iterator plugIt;
|
||||
map < string, map < int, string > > pluginMenus;
|
||||
map < string, map < int, string > >::iterator plugMenuIt;
|
||||
map < string, map < int, string > > pluginViews;
|
||||
map < string, map < int, string > >::iterator plugViewIt;
|
||||
map < string, map< int, map <int, string> > > pluginViewElements;
|
||||
map < string, map< int, map <int, string> > > pluginViewGrids;
|
||||
map < string, cSkinSetup* > skinSetups;
|
||||
map < string, cSkinSetup* >::iterator setupIt;
|
||||
vector < pair <string, int> > skinSetupParameters;
|
||||
@ -67,9 +71,14 @@ public:
|
||||
void SetOsdLanguage(void) { osdLanguage = Setup.OSDLanguage; };
|
||||
bool OsdLanguageChanged(void);
|
||||
cString GetSkinRessourcePath(void);
|
||||
void AddPlugin(string name, map < int, string > &menus);
|
||||
void InitPluginIterator(void);
|
||||
void AddPluginMenus(string name, map< int, string > menus);
|
||||
void AddPluginViews(string name, map< int, string > views, map< int, map <int, string> > viewElements, map< int, map <int, string> > viewGrids);
|
||||
void InitPluginMenuIterator(void);
|
||||
map <int,string> *GetPluginTemplates(string &name);
|
||||
void InitPluginViewIterator(void);
|
||||
map <int,string> *GetPluginViews(string &name);
|
||||
int GetPluginViewElementID(string pluginName, string viewElementName, int viewID);
|
||||
int GetPluginViewGridID(string pluginName, string viewGridName, int viewID);
|
||||
cString skinPath;
|
||||
cString logoPath;
|
||||
cString epgImagePath;
|
||||
|
60
designer.c
60
designer.c
@ -107,6 +107,22 @@ cSkinDisplayMessage *cSkinDesigner::DisplayMessage(void) {
|
||||
return displayMessage;
|
||||
}
|
||||
|
||||
cSkinDisplayPlugin *cSkinDesigner::DisplayPlugin(string pluginName, int viewID) {
|
||||
currentMenu = NULL;
|
||||
if (useBackupSkin)
|
||||
return NULL;
|
||||
Init();
|
||||
cSkinDisplayPlugin *displayPlugin = NULL;
|
||||
map< string, map <int, cTemplate*> >::iterator hit = pluginTemplates.find(pluginName);
|
||||
if (hit == pluginTemplates.end())
|
||||
return NULL;
|
||||
map <int, cTemplate*>::iterator hit2 = (hit->second).find(viewID);
|
||||
if (hit2 == (hit->second).end())
|
||||
return NULL;
|
||||
return new cSkinDisplayPlugin(hit2->second);
|
||||
}
|
||||
|
||||
|
||||
void cSkinDesigner::Reload(void) {
|
||||
dsyslog("skindesigner: forcing full reload of templates");
|
||||
if (cOsd::IsOpen()) {
|
||||
@ -236,6 +252,13 @@ void cSkinDesigner::DeleteTemplates(void) {
|
||||
delete audiotracksTemplate;
|
||||
audiotracksTemplate = NULL;
|
||||
}
|
||||
for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs !=pluginTemplates.end(); plugs++) {
|
||||
map <int, cTemplate*> plugTpls = plugs->second;
|
||||
for (map <int, cTemplate*>::iterator tpl = plugTpls.begin(); tpl != plugTpls.end(); tpl++) {
|
||||
delete tpl->second;
|
||||
}
|
||||
}
|
||||
pluginTemplates.clear();
|
||||
}
|
||||
|
||||
bool cSkinDesigner::LoadTemplates(void) {
|
||||
@ -316,6 +339,33 @@ bool cSkinDesigner::LoadTemplates(void) {
|
||||
}
|
||||
audiotracksTemplate->Translate();
|
||||
|
||||
config.InitPluginViewIterator();
|
||||
map <int,string> *plugViews = NULL;
|
||||
string plugName;
|
||||
while ( plugViews = config.GetPluginViews(plugName) ) {
|
||||
for (map <int,string>::iterator v = plugViews->begin(); v != plugViews->end(); v++) {
|
||||
stringstream templateName;
|
||||
templateName << "plug-" << plugName << "-" << v->second.c_str();
|
||||
cTemplate *plgTemplate = new cTemplate(vtDisplayPlugin, plugName, v->first);
|
||||
plgTemplate->SetGlobals(globals);
|
||||
ok = plgTemplate->ReadFromXML(templateName.str());
|
||||
if (!ok) {
|
||||
esyslog("skindesigner: error reading plugin %s template", plugName.c_str());
|
||||
DeleteTemplates();
|
||||
return false;
|
||||
}
|
||||
plgTemplate->Translate();
|
||||
map< string, map <int, cTemplate*> >::iterator hit = pluginTemplates.find(plugName);
|
||||
if (hit == pluginTemplates.end()) {
|
||||
map <int, cTemplate*> plugTemplates;
|
||||
plugTemplates.insert(pair<int, cTemplate*>(v->first, plgTemplate));
|
||||
pluginTemplates.insert(pair<string, map <int, cTemplate*> >(plugName, plugTemplates));
|
||||
} else {
|
||||
(hit->second).insert(pair<int, cTemplate*>(v->first, plgTemplate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dsyslog("skindesigner: templates successfully validated and parsed");
|
||||
return true;
|
||||
}
|
||||
@ -327,6 +377,11 @@ void cSkinDesigner::CacheTemplates(void) {
|
||||
replayTemplate->PreCache();
|
||||
volumeTemplate->PreCache();
|
||||
audiotracksTemplate->PreCache();
|
||||
for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs != pluginTemplates.end(); plugs++) {
|
||||
for (map <int, cTemplate*>::iterator plugTplts = plugs->second.begin(); plugTplts != plugs->second.end(); plugTplts++) {
|
||||
(plugTplts->second)->PreCache();
|
||||
}
|
||||
}
|
||||
dsyslog("skindesigner: templates cached");
|
||||
fontManager->CacheFonts(channelTemplate);
|
||||
fontManager->CacheFonts(menuTemplate);
|
||||
@ -344,6 +399,11 @@ void cSkinDesigner::CacheTemplates(void) {
|
||||
replayTemplate->CacheImages();
|
||||
volumeTemplate->CacheImages();
|
||||
audiotracksTemplate->CacheImages();
|
||||
for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs != pluginTemplates.end(); plugs++) {
|
||||
for (map <int, cTemplate*>::iterator plugTplts = plugs->second.begin(); plugTplts != plugs->second.end(); plugTplts++) {
|
||||
(plugTplts->second)->CacheImages();
|
||||
}
|
||||
}
|
||||
imgCache->Debug(false);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ private:
|
||||
cTemplate *replayTemplate;
|
||||
cTemplate *volumeTemplate;
|
||||
cTemplate *audiotracksTemplate;
|
||||
map< string, map <int, cTemplate*> > pluginTemplates;
|
||||
cSDDisplayMenu *currentMenu;
|
||||
void Init(void);
|
||||
void ReloadCaches(void);
|
||||
@ -42,6 +43,7 @@ public:
|
||||
virtual cSkinDisplayVolume *DisplayVolume(void);
|
||||
virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
|
||||
virtual cSkinDisplayMessage *DisplayMessage(void);
|
||||
virtual cSkinDisplayPlugin *DisplayPlugin(string pluginName, int viewID);
|
||||
void ActivateBackupSkin(void) { useBackupSkin = true; };
|
||||
void Reload(void);
|
||||
void ListAvailableFonts(void);
|
||||
|
@ -1,7 +1,97 @@
|
||||
#include "displayplugin.h"
|
||||
|
||||
cDisplayPlugin::cDisplayPlugin(cTemplate *menuTemplate) {
|
||||
cSkinDisplayPlugin::cSkinDisplayPlugin(cTemplate *pluginTemplate) {
|
||||
if (!pluginTemplate) {
|
||||
doOutput = false;
|
||||
return;
|
||||
} else {
|
||||
doOutput = true;
|
||||
}
|
||||
initial = true;
|
||||
pluginView = new cDisplayPluginView(pluginTemplate->GetRootView());
|
||||
if (!pluginView->createOsd()) {
|
||||
doOutput = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cDisplayPlugin::~cDisplayPlugin() {
|
||||
cSkinDisplayPlugin::~cSkinDisplayPlugin(void) {
|
||||
if (pluginView) {
|
||||
delete pluginView;
|
||||
pluginView = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::SetViewElementIntTokens(map<string,int> *intTokens) {
|
||||
if (pluginView)
|
||||
pluginView->SetIntTokens(intTokens);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::SetViewElementStringTokens(map<string,string> *stringTokens) {
|
||||
if (pluginView)
|
||||
pluginView->SetStringTokens(stringTokens);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens) {
|
||||
if (pluginView)
|
||||
pluginView->SetLoopTokens(loopTokens);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::DisplayViewElement(int id) {
|
||||
if (!doOutput) {
|
||||
return;
|
||||
}
|
||||
pluginView->DisplayViewElement(id);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::InitGrids(int viewGridID) {
|
||||
if (!doOutput) {
|
||||
return;
|
||||
}
|
||||
pluginView->InitGrids(viewGridID);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::SetGrid(int viewGridID, long gridID,
|
||||
double x, double y, double width, double height,
|
||||
map<string,int> *intTokens, map<string,string> *stringTokens) {
|
||||
if (!doOutput) {
|
||||
return;
|
||||
}
|
||||
pluginView->SetGrid(viewGridID, gridID, x, y, width, height, intTokens, stringTokens);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::SetGridCurrent(int viewGridID, long gridID, bool current) {
|
||||
if (!doOutput) {
|
||||
return;
|
||||
}
|
||||
pluginView->SetGridCurrent(viewGridID, gridID, current);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::DeleteGrid(int viewGridID, long gridID) {
|
||||
if (!doOutput) {
|
||||
return;
|
||||
}
|
||||
pluginView->DeleteGrid(viewGridID, gridID);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::DisplayGrids(int viewGridID) {
|
||||
if (!doOutput) {
|
||||
return;
|
||||
}
|
||||
pluginView->DisplayGrids(viewGridID);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::ClearGrids(int viewGridID) {
|
||||
if (!doOutput) {
|
||||
return;
|
||||
}
|
||||
pluginView->ClearGrids(viewGridID);
|
||||
}
|
||||
|
||||
void cSkinDisplayPlugin::Flush(void) {
|
||||
if (initial) {
|
||||
pluginView->DoStart();
|
||||
initial = false;
|
||||
}
|
||||
pluginView->Flush();
|
||||
}
|
@ -2,12 +2,28 @@
|
||||
#define __DISPLAYPLUGIN_H
|
||||
|
||||
#include "libtemplate/template.h"
|
||||
#include "views/displaypluginview.h"
|
||||
|
||||
class cDisplayPlugin {
|
||||
class cSkinDisplayPlugin {
|
||||
private:
|
||||
bool doOutput;
|
||||
bool initial;
|
||||
cDisplayPluginView *pluginView;
|
||||
public:
|
||||
cDisplayPlugin(cTemplate *pluginTemplate);
|
||||
virtual ~cDisplayPlugin();
|
||||
cSkinDisplayPlugin(void) {};
|
||||
cSkinDisplayPlugin(cTemplate *pluginTemplate);
|
||||
virtual ~cSkinDisplayPlugin(void);
|
||||
virtual void DisplayViewElement(int id);
|
||||
virtual void SetViewElementIntTokens(map<string,int> *intTokens);
|
||||
virtual void SetViewElementStringTokens(map<string,string> *stringTokens);
|
||||
virtual void SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens);
|
||||
virtual void InitGrids(int viewGridID);
|
||||
virtual void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens);
|
||||
virtual void SetGridCurrent(int viewGridID, long gridID, bool current);
|
||||
virtual void DeleteGrid(int viewGridID, long gridID);
|
||||
virtual void DisplayGrids(int viewGridID);
|
||||
virtual void ClearGrids(int viewGridID);
|
||||
virtual void Flush(void);
|
||||
};
|
||||
|
||||
#endif //__DISPLAYPLUGIN_H
|
||||
|
24
dtd/displayplugin.dtd
Normal file
24
dtd/displayplugin.dtd
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml encoding="UTF-8"?>
|
||||
|
||||
<!ENTITY % functions SYSTEM "functions.dtd">
|
||||
|
||||
<!ELEMENT displayplugin (viewelement|grid)* >
|
||||
<!ATTLIST displayplugin
|
||||
x CDATA #REQUIRED
|
||||
y CDATA #REQUIRED
|
||||
width CDATA #REQUIRED
|
||||
height CDATA #REQUIRED
|
||||
fadetime CDATA #IMPLIED
|
||||
scaletvx CDATA #IMPLIED
|
||||
scaletvy CDATA #IMPLIED
|
||||
scaletvwidth CDATA #IMPLIED
|
||||
scaletvheight CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT viewelement (area|areascroll)*>
|
||||
<!ATTLIST viewelement
|
||||
name CDATA #REQUIRED
|
||||
debug CDATA #IMPLIED
|
||||
>
|
||||
|
||||
%functions;
|
@ -27,6 +27,16 @@
|
||||
debug (true|false) #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT grid (area|areascroll)*>
|
||||
<!ATTLIST grid
|
||||
x CDATA #REQUIRED
|
||||
y CDATA #REQUIRED
|
||||
width CDATA #REQUIRED
|
||||
height CDATA #REQUIRED
|
||||
name CDATA #REQUIRED
|
||||
debug (true|false) #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT loop (drawtext|drawtextbox|drawimage|drawrectangle|drawellipse|drawslope)+>
|
||||
<!ATTLIST loop
|
||||
x CDATA #REQUIRED
|
||||
|
@ -195,6 +195,13 @@ void cPixmapContainer::SetLayer(int num, int Layer) {
|
||||
pixmaps[num]->SetLayer(Layer);
|
||||
}
|
||||
|
||||
void cPixmapContainer::SetViewPort(int num, const cRect &rect) {
|
||||
cMutexLock MutexLock(&mutex);
|
||||
if (!pixmaps[num])
|
||||
return;
|
||||
pixmaps[num]->SetViewPort(rect);
|
||||
}
|
||||
|
||||
int cPixmapContainer::Width(int num) {
|
||||
if (checkRunning && !Running())
|
||||
return 0;
|
||||
|
@ -42,6 +42,7 @@ protected:
|
||||
void SetAlpha(int num, int Alpha);
|
||||
void SetTransparency(int num, int Transparency);
|
||||
void SetLayer(int num, int Layer);
|
||||
void SetViewPort(int num, const cRect &rect);
|
||||
int Width(int num);
|
||||
int Height(int num);
|
||||
int DrawportWidth(int num);
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
// --- cTemplate -------------------------------------------------------------
|
||||
|
||||
cTemplate::cTemplate(eViewType viewType) {
|
||||
cTemplate::cTemplate(eViewType viewType, string pluginName, int viewID) {
|
||||
globals = NULL;
|
||||
rootView = NULL;
|
||||
this->viewType = viewType;
|
||||
CreateView();
|
||||
CreateView(pluginName, viewID);
|
||||
}
|
||||
|
||||
cTemplate::~cTemplate() {
|
||||
@ -21,8 +21,8 @@ cTemplate::~cTemplate() {
|
||||
/*******************************************************************
|
||||
* Public Functions
|
||||
*******************************************************************/
|
||||
bool cTemplate::ReadFromXML(void) {
|
||||
std::string xmlFile;
|
||||
bool cTemplate::ReadFromXML(string xmlfile) {
|
||||
string xmlFile;
|
||||
switch (viewType) {
|
||||
case vtDisplayChannel:
|
||||
xmlFile = "displaychannel.xml";
|
||||
@ -42,6 +42,9 @@ bool cTemplate::ReadFromXML(void) {
|
||||
case vtDisplayAudioTracks:
|
||||
xmlFile = "displayaudiotracks.xml";
|
||||
break;
|
||||
case vtDisplayPlugin:
|
||||
xmlFile = xmlfile;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -56,7 +59,7 @@ bool cTemplate::ReadFromXML(void) {
|
||||
//read additional plugin templates
|
||||
bool ok = true;
|
||||
if (viewType == vtDisplayMenu) {
|
||||
config.InitPluginIterator();
|
||||
config.InitPluginMenuIterator();
|
||||
map <int,string> *plugTemplates = NULL;
|
||||
string plugName;
|
||||
while ( plugTemplates = config.GetPluginTemplates(plugName) ) {
|
||||
@ -119,7 +122,7 @@ void cTemplate::Debug(void) {
|
||||
* Private Functions
|
||||
*******************************************************************/
|
||||
|
||||
void cTemplate::CreateView(void) {
|
||||
void cTemplate::CreateView(string pluginName, int viewID) {
|
||||
switch (viewType) {
|
||||
case vtDisplayChannel:
|
||||
rootView = new cTemplateViewChannel();
|
||||
@ -138,7 +141,10 @@ void cTemplate::CreateView(void) {
|
||||
break;
|
||||
case vtDisplayMessage:
|
||||
rootView = new cTemplateViewMessage();
|
||||
break;
|
||||
break;
|
||||
case vtDisplayPlugin:
|
||||
rootView = new cTemplateViewPlugin(pluginName, viewID);
|
||||
break;
|
||||
default:
|
||||
esyslog("skindesigner: unknown view %d", viewType);
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ enum eViewType {
|
||||
vtDisplayReplay,
|
||||
vtDisplayVolume,
|
||||
vtDisplayAudioTracks,
|
||||
vtDisplayMessage
|
||||
vtDisplayMessage,
|
||||
vtDisplayPlugin
|
||||
};
|
||||
|
||||
class cTemplate {
|
||||
@ -37,13 +38,13 @@ private:
|
||||
protected:
|
||||
cGlobals *globals;
|
||||
cTemplateView *rootView;
|
||||
void CreateView(void);
|
||||
void CreateView(string pluginName, int viewID);
|
||||
void GetUsedFonts(cTemplateView *view, vector< pair<string, int> > &usedFonts);
|
||||
void CacheImages(cTemplateView *view);
|
||||
public:
|
||||
cTemplate(eViewType viewType);
|
||||
cTemplate(eViewType viewType, string pluginName = "", int viewID = -1);
|
||||
virtual ~cTemplate(void);
|
||||
bool ReadFromXML(void);
|
||||
bool ReadFromXML(string xmlfile = "");
|
||||
void SetGlobals(cGlobals *globals);
|
||||
cTemplateView *GetRootView(void) { return rootView; };
|
||||
void Translate(void);
|
||||
|
@ -53,6 +53,28 @@ void cTemplatePixmap::SetY(int y) {
|
||||
parameters->SetYManually(y);
|
||||
}
|
||||
|
||||
void cTemplatePixmap::SetWidthPercent(double width) {
|
||||
int absWidth = containerWidth * width;
|
||||
cString pWidth = cString::sprintf("%d", absWidth);
|
||||
parameters->SetWidthManually(*pWidth);
|
||||
}
|
||||
|
||||
void cTemplatePixmap::SetHeightPercent(double height) {
|
||||
int absHeight = containerHeight * height;
|
||||
cString pHeight = cString::sprintf("%d", absHeight);
|
||||
parameters->SetHeightManually(*pHeight);
|
||||
}
|
||||
|
||||
void cTemplatePixmap::SetXPercent(double x) {
|
||||
int absX = containerX + containerWidth * x;
|
||||
parameters->SetXManually(absX);
|
||||
}
|
||||
|
||||
void cTemplatePixmap::SetYPercent(double y) {
|
||||
int absY = containerY + containerHeight * y;
|
||||
parameters->SetYManually(absY);
|
||||
}
|
||||
|
||||
void cTemplatePixmap::ClearDynamicParameters(void) {
|
||||
parameters->ClearDynamicParameters();
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ public:
|
||||
void SetHeight(int height);
|
||||
void SetX(int x);
|
||||
void SetY(int y);
|
||||
void SetWidthPercent(double width);
|
||||
void SetHeightPercent(double height);
|
||||
void SetXPercent(double x);
|
||||
void SetYPercent(double y);
|
||||
void SetContainer(int x, int y, int w, int h);
|
||||
void SetGlobals(cGlobals *globals) { this->globals = globals; };
|
||||
void AddFunction(string name, vector<pair<string, string> > ¶ms);
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "../config.h"
|
||||
#include "templateview.h"
|
||||
|
||||
// --- cTemplateView -------------------------------------------------------------
|
||||
@ -22,6 +23,10 @@ cTemplateView::~cTemplateView() {
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
for (vector < cTemplateViewTab* >::iterator it = viewTabs.begin(); it != viewTabs.end(); it++) {
|
||||
delete *it;
|
||||
}
|
||||
@ -61,8 +66,9 @@ void cTemplateView::SetContainer(int x, int y, int width, int height) {
|
||||
|
||||
cTemplateViewElement *cTemplateView::GetViewElement(eViewElement ve) {
|
||||
map < eViewElement, cTemplateViewElement* >::iterator hit = viewElements.find(ve);
|
||||
if (hit == viewElements.end())
|
||||
if (hit == viewElements.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return hit->second;
|
||||
}
|
||||
|
||||
@ -78,6 +84,14 @@ cTemplateViewElement *cTemplateView::GetNextViewElement(void) {
|
||||
return viewElement;
|
||||
}
|
||||
|
||||
cTemplateViewGrid *cTemplateView::GetViewGrid(int gridID) {
|
||||
map < int, cTemplateViewGrid* >::iterator hit = viewGrids.find(gridID);
|
||||
if (hit == viewGrids.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return hit->second;
|
||||
}
|
||||
|
||||
cTemplateViewList *cTemplateView::GetViewList(eViewList vl) {
|
||||
map < eViewList, cTemplateViewList* >::iterator hit = viewLists.find(vl);
|
||||
if (hit == viewLists.end())
|
||||
@ -224,7 +238,14 @@ bool cTemplateView::ValidViewList(const char *viewList) {
|
||||
set<string>::iterator hit = viewListsAllowed.find(viewList);
|
||||
if (hit == viewListsAllowed.end())
|
||||
return false;
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cTemplateView::ValidViewGrid(const char *viewGrid) {
|
||||
set<string>::iterator hit = viewGridsAllowed.find(viewGrid);
|
||||
if (hit == viewGridsAllowed.end())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cTemplateView::ValidFunction(const char *func) {
|
||||
@ -428,6 +449,14 @@ void cTemplateView::PreCache(bool isSubview) {
|
||||
pixOffset += viewElement->GetNumPixmaps();
|
||||
}
|
||||
|
||||
//Cache ViewGrids
|
||||
for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
|
||||
cTemplateViewGrid *viewGrid = it->second;
|
||||
viewGrid->SetGlobals(globals);
|
||||
viewGrid->SetContainer(0, 0, osdWidth, osdHeight);
|
||||
viewGrid->CalculateParameters();
|
||||
viewGrid->CalculatePixmapParameters();
|
||||
}
|
||||
|
||||
//Cache ViewLists
|
||||
for (map < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) {
|
||||
@ -486,6 +515,12 @@ void cTemplateView::Debug(void) {
|
||||
viewList->Debug();
|
||||
}
|
||||
|
||||
for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
|
||||
esyslog("skindesigner: ++++++++ ViewGrid %d:", it->first);
|
||||
cTemplateViewGrid *viewGrid = it->second;
|
||||
viewGrid->Debug();
|
||||
}
|
||||
|
||||
for (vector<cTemplateViewTab*>::iterator tab = viewTabs.begin(); tab != viewTabs.end(); tab++) {
|
||||
esyslog("skindesigner: ++++++++ ViewTab");
|
||||
(*tab)->Debug();
|
||||
@ -516,6 +551,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
|
||||
attributes.insert("debug");
|
||||
attributes.insert("delay");
|
||||
attributes.insert("fadetime");
|
||||
attributes.insert("name");
|
||||
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
|
||||
|
||||
name = "area";
|
||||
@ -1095,7 +1131,6 @@ void cTemplateViewMenu::SetViewElements(void) {
|
||||
}
|
||||
|
||||
void cTemplateViewMenu::SetViewLists(void) {
|
||||
viewListsAllowed.insert("timerlist");
|
||||
viewListsAllowed.insert("menuitems");
|
||||
}
|
||||
|
||||
@ -1210,9 +1245,6 @@ string cTemplateViewMenu::GetViewElementName(eViewElement ve) {
|
||||
string cTemplateViewMenu::GetViewListName(eViewList vl) {
|
||||
string name;
|
||||
switch (vl) {
|
||||
case vlTimerList:
|
||||
name = "Timer List";
|
||||
break;
|
||||
case vlMenuItem:
|
||||
name = "Menu Item";
|
||||
break;
|
||||
@ -1335,9 +1367,7 @@ void cTemplateViewMenu::AddPixmap(string sViewElement, cTemplatePixmap *pix, vec
|
||||
void cTemplateViewMenu::AddViewList(string sViewList, cTemplateViewList *viewList) {
|
||||
|
||||
eViewList vl = vlUndefined;
|
||||
if (!sViewList.compare("timerlist")) {
|
||||
vl = vlTimerList;
|
||||
} else if (!sViewList.compare("menuitems")) {
|
||||
if (!sViewList.compare("menuitems")) {
|
||||
vl = vlMenuItem;
|
||||
}
|
||||
|
||||
@ -1797,3 +1827,108 @@ void cTemplateViewAudioTracks::AddViewList(string sViewList, cTemplateViewList *
|
||||
viewList->SetGlobals(globals);
|
||||
viewLists.insert(pair< eViewList, cTemplateViewList*>(vl, viewList));
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* cTemplateViewPlugin
|
||||
************************************************************************************/
|
||||
|
||||
cTemplateViewPlugin::cTemplateViewPlugin(string pluginName, int viewID) {
|
||||
this->pluginName = pluginName;
|
||||
this->viewID = viewID;
|
||||
viewName = "displayplugin";
|
||||
//definition of allowed parameters for class itself
|
||||
set<string> attributes;
|
||||
attributes.insert("x");
|
||||
attributes.insert("y");
|
||||
attributes.insert("width");
|
||||
attributes.insert("height");
|
||||
attributes.insert("fadetime");
|
||||
attributes.insert("scaletvx");
|
||||
attributes.insert("scaletvy");
|
||||
attributes.insert("scaletvwidth");
|
||||
attributes.insert("scaletvheight");
|
||||
funcsAllowed.insert(pair< string, set<string> >(viewName, attributes));
|
||||
|
||||
attributes.clear();
|
||||
attributes.insert("x");
|
||||
attributes.insert("y");
|
||||
attributes.insert("width");
|
||||
attributes.insert("height");
|
||||
attributes.insert("name");
|
||||
funcsAllowed.insert(pair< string, set<string> >("grid", attributes));
|
||||
|
||||
viewElementsAllowed.insert("viewelement");
|
||||
viewGridsAllowed.insert("grid");
|
||||
}
|
||||
|
||||
cTemplateViewPlugin::~cTemplateViewPlugin() {
|
||||
}
|
||||
|
||||
void cTemplateViewPlugin::AddPixmap(string sViewElement, cTemplatePixmap *pix, vector<pair<string, string> > &viewElementattributes) {
|
||||
eViewElement ve = veUndefined;
|
||||
string viewElementName = "";
|
||||
bool found = false;
|
||||
for (vector<pair<string, string> >::iterator it = viewElementattributes.begin(); it != viewElementattributes.end(); it++) {
|
||||
if (!(it->first).compare("name")) {
|
||||
viewElementName = it->second;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
esyslog("skindesigner: no name defined for plugin %s viewelement", pluginName.c_str());
|
||||
}
|
||||
|
||||
int viewElementID = config.GetPluginViewElementID(pluginName, viewElementName, viewID);
|
||||
|
||||
if (viewElementID == -1) {
|
||||
esyslog("skindesigner: %s: unknown ViewElement in displayplugin: %s", pluginName.c_str(), viewElementName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
pix->SetGlobals(globals);
|
||||
|
||||
ve = (eViewElement)viewElementID;
|
||||
map < eViewElement, cTemplateViewElement* >::iterator hit = viewElements.find(ve);
|
||||
if (hit == viewElements.end()) {
|
||||
cTemplateViewElement *viewElement = new cTemplateViewElement();
|
||||
viewElement->SetParameters(viewElementattributes);
|
||||
viewElement->AddPixmap(pix);
|
||||
viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement));
|
||||
} else {
|
||||
(hit->second)->AddPixmap(pix);
|
||||
}
|
||||
}
|
||||
|
||||
void cTemplateViewPlugin::AddPixmapGrid(cTemplatePixmap *pix, vector<pair<string, string> > &gridAttributes) {
|
||||
string gridName = "";
|
||||
bool found = false;
|
||||
for (vector<pair<string, string> >::iterator it = gridAttributes.begin(); it != gridAttributes.end(); it++) {
|
||||
if (!(it->first).compare("name")) {
|
||||
gridName = it->second;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
esyslog("skindesigner: no name defined for plugin %s grid", pluginName.c_str());
|
||||
}
|
||||
int gridID = config.GetPluginViewGridID(pluginName, gridName, viewID);
|
||||
|
||||
if (gridID == -1) {
|
||||
esyslog("skindesigner: %s: unknown Grid in displayplugin: %s", pluginName.c_str(), gridName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
pix->SetGlobals(globals);
|
||||
|
||||
map < int, cTemplateViewGrid* >::iterator hit = viewGrids.find(gridID);
|
||||
if (hit == viewGrids.end()) {
|
||||
cTemplateViewGrid *viewGrid = new cTemplateViewGrid();
|
||||
viewGrid->SetParameters(gridAttributes);
|
||||
viewGrid->AddPixmap(pix);
|
||||
viewGrids.insert(pair< int, cTemplateViewGrid*>(gridID, viewGrid));
|
||||
} else {
|
||||
(hit->second)->AddPixmap(pix);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "templateviewelement.h"
|
||||
#include "templateviewlist.h"
|
||||
#include "templateviewgrid.h"
|
||||
#include "templatepixmap.h"
|
||||
#include "templateviewtab.h"
|
||||
#include "templatefunction.h"
|
||||
@ -50,6 +51,7 @@ protected:
|
||||
//basic view data structures
|
||||
map < eViewElement, cTemplateViewElement* > viewElements;
|
||||
map < eViewList, cTemplateViewList* > viewLists;
|
||||
map < int, cTemplateViewGrid* > viewGrids;
|
||||
map < eSubView, cTemplateView* > subViews;
|
||||
vector< cTemplateViewTab* > viewTabs;
|
||||
map < string, map< int, cTemplateView*> > pluginViews;
|
||||
@ -62,6 +64,7 @@ protected:
|
||||
set<string> subViewsAllowed;
|
||||
set<string> viewElementsAllowed;
|
||||
set<string> viewListsAllowed;
|
||||
set<string> viewGridsAllowed;
|
||||
map < string, set < string > > funcsAllowed;
|
||||
void SetFunctionDefinitions(void);
|
||||
public:
|
||||
@ -73,6 +76,7 @@ public:
|
||||
virtual void AddSubView(string sSubView, cTemplateView *subView) {};
|
||||
virtual void AddPluginView(string plugName, int templNo, cTemplateView *plugView) {};
|
||||
virtual void AddPixmap(string sViewElement, cTemplatePixmap *pix, vector<pair<string, string> > &viewElementattributes) {};
|
||||
virtual void AddPixmapGrid(cTemplatePixmap *pix, vector<pair<string, string> > &gridAttributes) {};
|
||||
virtual void AddViewList(string sViewList, cTemplateViewList *viewList) {};
|
||||
virtual void AddViewTab(cTemplateViewTab *viewTab) {};
|
||||
//Setter Functions
|
||||
@ -83,6 +87,8 @@ public:
|
||||
cTemplateViewElement *GetViewElement(eViewElement ve);
|
||||
void InitViewElementIterator(void);
|
||||
cTemplateViewElement *GetNextViewElement(void);
|
||||
//access view grids
|
||||
cTemplateViewGrid *GetViewGrid(int gridID);
|
||||
//access list elements
|
||||
cTemplateViewList *GetViewList(eViewList vl);
|
||||
void InitViewListIterator(void);
|
||||
@ -110,7 +116,8 @@ public:
|
||||
//Checks for parsing template XML files
|
||||
bool ValidSubView(const char *subView);
|
||||
bool ValidViewElement(const char *viewElement);
|
||||
bool ValidViewList(const char *viewList);
|
||||
bool ValidViewList(const char *viewList);
|
||||
bool ValidViewGrid(const char *viewGrid);
|
||||
bool ValidFunction(const char *func);
|
||||
bool ValidAttribute(const char *func, const char *att);
|
||||
//Caching
|
||||
@ -204,4 +211,17 @@ public:
|
||||
void AddViewList(string sViewList, cTemplateViewList *viewList);
|
||||
};
|
||||
|
||||
// --- cTemplateViewAudioTracks -------------------------------------------------------------
|
||||
|
||||
class cTemplateViewPlugin : public cTemplateView {
|
||||
private:
|
||||
string pluginName;
|
||||
int viewID;
|
||||
public:
|
||||
cTemplateViewPlugin(string pluginName, int viewID);
|
||||
virtual ~cTemplateViewPlugin(void);
|
||||
void AddPixmap(string viewElement, cTemplatePixmap *pix, vector<pair<string, string> > &viewElementattributes);
|
||||
void AddPixmapGrid(cTemplatePixmap *pix, vector<pair<string, string> > &gridAttributes);
|
||||
};
|
||||
|
||||
#endif //__TEMPLATEVIEW_H
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
virtual ~cTemplateViewElement(void);
|
||||
void SetParameters(vector<pair<string, string> > ¶ms);
|
||||
bool CalculateParameters(void);
|
||||
bool CalculatePixmapParameters(void);
|
||||
virtual bool CalculatePixmapParameters(void);
|
||||
bool CalculatePixmapParametersList(int orientation, int numElements);
|
||||
int GetNumericParameter(eParamType type);
|
||||
void AddPixmap(cTemplatePixmap *pix) { viewPixmaps.push_back(pix); };
|
||||
|
29
libtemplate/templateviewgrid.c
Normal file
29
libtemplate/templateviewgrid.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include "templateviewgrid.h"
|
||||
#include "../config.h"
|
||||
#include "../libcore/helpers.h"
|
||||
|
||||
cTemplateViewGrid::cTemplateViewGrid(void) : cTemplateViewElement() {
|
||||
}
|
||||
|
||||
cTemplateViewGrid::~cTemplateViewGrid(void) {
|
||||
}
|
||||
|
||||
bool cTemplateViewGrid::CalculatePixmapParameters(void) {
|
||||
bool paramsValid = true;
|
||||
int gridX = parameters->GetNumericParameter(ptX);
|
||||
int gridY = parameters->GetNumericParameter(ptY);
|
||||
int gridWidth = parameters->GetNumericParameter(ptWidth);
|
||||
int gridHeight = parameters->GetNumericParameter(ptHeight);
|
||||
|
||||
for (vector<cTemplatePixmap*>::iterator pix = viewPixmaps.begin(); pix != viewPixmaps.end(); pix++) {
|
||||
(*pix)->SetContainer(gridX, gridY, gridWidth, gridHeight);
|
||||
(*pix)->SetGlobals(globals);
|
||||
paramsValid = paramsValid && (*pix)->CalculateParameters();
|
||||
}
|
||||
return paramsValid;
|
||||
}
|
||||
|
||||
void cTemplateViewGrid::Debug(void) {
|
||||
esyslog("skindesigner: --- Grid: ");
|
||||
cTemplateViewElement::Debug();
|
||||
}
|
25
libtemplate/templateviewgrid.h
Normal file
25
libtemplate/templateviewgrid.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __TEMPLATEVIEWGRID_H
|
||||
#define __TEMPLATEVIEWGRID_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
#include "templateviewelement.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// --- cTemplateViewGrid -------------------------------------------------------------
|
||||
|
||||
class cTemplateViewGrid : public cTemplateViewElement {
|
||||
private:
|
||||
public:
|
||||
cTemplateViewGrid(void);
|
||||
~cTemplateViewGrid(void);
|
||||
bool CalculatePixmapParameters(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
#endif //__TEMPLATEVIEWGRID_H
|
@ -19,10 +19,6 @@ using namespace std;
|
||||
|
||||
enum eViewList {
|
||||
vlUndefined,
|
||||
//DisplayChannel ViewLists
|
||||
vlDvbDeviceInfoList,
|
||||
//DisplayMenu ViewLists
|
||||
vlTimerList,
|
||||
vlMenuItem
|
||||
};
|
||||
|
||||
|
@ -195,6 +195,11 @@ bool cXmlParser::ParseView(void) {
|
||||
ParseViewElement(node->name, node->xmlChildrenNode, attribs);
|
||||
} else if (view->ValidViewList((const char*)node->name)) {
|
||||
ParseViewList(node);
|
||||
} else if (view->ValidViewGrid((const char*)node->name)) {
|
||||
xmlAttrPtr attr = node->properties;
|
||||
vector<pair<string, string> > attribs;
|
||||
ParseAttributes(attr, node, attribs);
|
||||
ParseGrid(node->xmlChildrenNode, attribs);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -844,6 +849,42 @@ void cXmlParser::ParseViewTab(xmlNodePtr parentNode, cTemplateView *subView) {
|
||||
subView->AddViewTab(viewTab);
|
||||
}
|
||||
|
||||
void cXmlParser::ParseGrid(xmlNodePtr node, vector<pair<string, string> > &attributes) {
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
while (node != NULL) {
|
||||
|
||||
if (node->type != XML_ELEMENT_NODE) {
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (xmlStrcmp(node->name, (const xmlChar *) "area") && xmlStrcmp(node->name, (const xmlChar *) "areascroll")) {
|
||||
esyslog("skindesigner: invalid tag \"%s\"", node->name);
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
xmlAttrPtr attr = node->properties;
|
||||
vector<pair<string, string> > attribs;
|
||||
ParseAttributes(attr, node, attribs);
|
||||
|
||||
cTemplatePixmap *pix = new cTemplatePixmap();
|
||||
if (!xmlStrcmp(node->name, (const xmlChar *) "areascroll")) {
|
||||
pix->SetScrolling();
|
||||
}
|
||||
pix->SetParameters(attribs);
|
||||
ParseFunctionCalls(node->xmlChildrenNode, pix);
|
||||
view->AddPixmapGrid(pix, attributes);
|
||||
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
void cXmlParser::ParseFunctionCalls(xmlNodePtr node, cTemplatePixmap *pix) {
|
||||
if (!node)
|
||||
return;
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "templateview.h"
|
||||
#include "templateviewlist.h"
|
||||
#include "templateviewgrid.h"
|
||||
#include "templateviewtab.h"
|
||||
#include "../libcore/skinsetup.h"
|
||||
|
||||
@ -43,6 +44,7 @@ private:
|
||||
void ParseViewElement(const xmlChar * viewElement, xmlNodePtr node, vector<pair<string, string> > &attributes, cTemplateView *subView = NULL);
|
||||
void ParseViewList(xmlNodePtr parentNode, cTemplateView *subView = NULL);
|
||||
void ParseViewTab(xmlNodePtr parentNode, cTemplateView *subView);
|
||||
void ParseGrid(xmlNodePtr node, vector<pair<string, string> > &attributes);
|
||||
void ParseFunctionCalls(xmlNodePtr node, cTemplatePixmap *pix);
|
||||
void ParseLoopFunctionCalls(xmlNodePtr node, cTemplateLoopFunction *loopFunc);
|
||||
bool ParseAttributes(xmlAttrPtr attr, xmlNodePtr node, vector<pair<string, string> > &attribs);
|
||||
|
82
services.h
82
services.h
@ -13,55 +13,67 @@ using namespace std;
|
||||
// Data structure for service "RegisterPlugin"
|
||||
class RegisterPlugin {
|
||||
public:
|
||||
RegisterPlugin(void) {
|
||||
name = "";
|
||||
};
|
||||
void SetMenu(int key, string templateName) {
|
||||
menus.insert(pair<int, string>(key, templateName));
|
||||
}
|
||||
RegisterPlugin(void) {
|
||||
name = "";
|
||||
};
|
||||
void SetMenu(int key, string templateName) {
|
||||
menus.insert(pair<int, string>(key, templateName));
|
||||
}
|
||||
void SetView(int key, string templateName) {
|
||||
views.insert(pair<int, string>(key, templateName));
|
||||
}
|
||||
void SetViewElement(int view, int viewElement, string name) {
|
||||
map< int, map<int, string> >::iterator hit = viewElements.find(view);
|
||||
if (hit == viewElements.end()) {
|
||||
map<int, string> vE;
|
||||
vE.insert(pair<int, string >(viewElement, name));
|
||||
viewElements.insert(pair<int, map < int, string > >(view, vE));
|
||||
} else {
|
||||
(hit->second).insert(pair<int, string >(viewElement, name));
|
||||
}
|
||||
}
|
||||
void SetViewGrid(int view, int viewGrid, string name) {
|
||||
map< int, map<int, string> >::iterator hit = viewGrids.find(view);
|
||||
if (hit == viewGrids.end()) {
|
||||
map<int, string> vG;
|
||||
vG.insert(pair<int, string >(viewGrid, name));
|
||||
viewGrids.insert(pair<int, map < int, string > >(view, vG));
|
||||
} else {
|
||||
(hit->second).insert(pair<int, string >(viewGrid, name));
|
||||
}
|
||||
}
|
||||
// in
|
||||
string name; //name of plugin
|
||||
map< int, string > menus; //menus as key -> templatename hashmap
|
||||
string name; //name of plugin
|
||||
map< int, string > menus; //menus as key -> templatename hashmap
|
||||
map< int, string> views; //standalone views as key -> templatename hashmap
|
||||
map< int, map <int, string> > viewElements; //viewelements as key -> (viewelement, viewelementname) hashmap
|
||||
map< int, map <int, string> > viewGrids; //viewgrids as key -> (viewgrid, viewgridname) hashmap
|
||||
//out
|
||||
};
|
||||
|
||||
// Data structure for service "GetDisplayMenu"
|
||||
class GetDisplayMenu {
|
||||
public:
|
||||
GetDisplayMenu(void) {
|
||||
displayMenu = NULL;
|
||||
};
|
||||
GetDisplayMenu(void) {
|
||||
displayMenu = NULL;
|
||||
};
|
||||
// in
|
||||
//out
|
||||
cSDDisplayMenu *displayMenu;
|
||||
cSDDisplayMenu *displayMenu;
|
||||
};
|
||||
|
||||
// Data structure for service "RegisterStandalonePlugin"
|
||||
/*
|
||||
class RegisterStandalonePlugin {
|
||||
public:
|
||||
RegisterStandalonePlugin(void) {
|
||||
name = "";
|
||||
rootView = "";
|
||||
};
|
||||
void SetMenu(int key, string templateName) {
|
||||
menus.insert(pair<int, string>(key, templateName));
|
||||
}
|
||||
// in
|
||||
string name; //name of plugin
|
||||
string rootView; //name of plugin
|
||||
map< int, string > menus; //menus as key -> templatename hashmap
|
||||
//out
|
||||
};
|
||||
*/
|
||||
// Data structure for service "GetDisplayPlugin"
|
||||
class GetDisplayPlugin {
|
||||
public:
|
||||
GetDisplayPlugin(void) {
|
||||
displayPlugin = NULL;
|
||||
};
|
||||
GetDisplayPlugin(void) {
|
||||
pluginName = "";
|
||||
viewID = -1;
|
||||
displayPlugin = NULL;
|
||||
};
|
||||
// in
|
||||
string pluginName;
|
||||
int viewID;
|
||||
//out
|
||||
cDisplayPlugin *displayPlugin;
|
||||
cSkinDisplayPlugin *displayPlugin;
|
||||
};
|
||||
#endif //__SKINDESIGNERSERVICES_H
|
||||
#endif //__SKINDESIGNERSERVICES_H
|
||||
|
@ -162,13 +162,17 @@ bool cPluginSkinDesigner::Service(const char *Id, void *Data) {
|
||||
return false;
|
||||
|
||||
if (strcmp(Id, "RegisterPlugin") == 0) {
|
||||
RegisterPlugin* call = (RegisterPlugin*) Data;
|
||||
if (call->menus.size() < 1) {
|
||||
esyslog("skindesigner: error - plugin without menus registered");
|
||||
RegisterPlugin *call = (RegisterPlugin*) Data;
|
||||
if (call->menus.size() < 1 && call->views.size() < 1) {
|
||||
esyslog("skindesigner: error - plugin without menus or views registered");
|
||||
return false;
|
||||
}
|
||||
config.AddPlugin(call->name, call->menus);
|
||||
dsyslog("skindesigner: plugin %s has registered %ld templates", call->name.c_str(), call->menus.size());
|
||||
config.AddPluginMenus(call->name, call->menus);
|
||||
config.AddPluginViews(call->name, call->views, call->viewElements, call->viewGrids);
|
||||
if (call->menus.size() > 0)
|
||||
dsyslog("skindesigner: plugin %s has registered %ld menus", call->name.c_str(), call->menus.size());
|
||||
if (call->views.size() > 0)
|
||||
dsyslog("skindesigner: plugin %s has registered %ld views", call->name.c_str(), call->views.size());
|
||||
return true;
|
||||
} else if (strcmp(Id, "GetDisplayMenu") == 0) {
|
||||
GetDisplayMenu* call = (GetDisplayMenu*) Data;
|
||||
@ -184,6 +188,22 @@ bool cPluginSkinDesigner::Service(const char *Id, void *Data) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (strcmp(Id, "GetDisplayPlugin") == 0) {
|
||||
GetDisplayPlugin* call = (GetDisplayPlugin*) Data;
|
||||
if (call->pluginName.size() == 0 || call->viewID < 0)
|
||||
return false;
|
||||
cSkin *current = Skins.Current();
|
||||
for (vector<cSkinDesigner*>::iterator skin = skins.begin(); skin != skins.end(); skin++) {
|
||||
if (*skin == current) {
|
||||
cSkinDisplayPlugin *displayPlugin = (*skin)->DisplayPlugin(call->pluginName, call->viewID);
|
||||
if (displayPlugin) {
|
||||
call->displayPlugin = displayPlugin;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -12,6 +12,7 @@
|
||||
<color name="clrYellow">FFE2DA00</color>
|
||||
<color name="clrBlue">FF007FE2</color>
|
||||
<color name="clrWhite">FFFFFFFF</color>
|
||||
<color name="clrBlack">FF000000</color>
|
||||
<color name="clrGray">FF999999</color>
|
||||
<color name="clrRedTrans">55FF0000</color>
|
||||
<color name="clrBlackTrans">99000000</color>
|
||||
|
15
skins/blackhole/xmlfiles/plug-tvguideng-detail.xml
Normal file
15
skins/blackhole/xmlfiles/plug-tvguideng-detail.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE displayplugin SYSTEM "../../../dtd/displayplugin.dtd">
|
||||
|
||||
<displayplugin x="0" y="0" width="100%" height="100%" fadetime="0" scaletvx="55%" scaletvy="30%" scaletvwidth="40%" scaletvheight="40%">
|
||||
|
||||
<viewelement name="background">
|
||||
<area x="0" y="0" width="100%" height="30%" layer="1">
|
||||
<fill color="{clrRed}" />
|
||||
</area>
|
||||
<area x="0" y="0" width="100%" height="30%" layer="2">
|
||||
<drawtext align="center" valign="center" font="{regular}" fontsize="20%" color="{clrWhite}" text="{backtext} {zahl}" />
|
||||
</area>
|
||||
</viewelement>
|
||||
|
||||
</displayplugin>
|
72
skins/blackhole/xmlfiles/plug-tvguideng-root.xml
Normal file
72
skins/blackhole/xmlfiles/plug-tvguideng-root.xml
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE displayplugin SYSTEM "../../../dtd/displayplugin.dtd">
|
||||
|
||||
<displayplugin x="0" y="0" width="100%" height="100%" fadetime="0" scaletvx="70%" scaletvy="0" scaletvwidth="30%" scaletvheight="15%">
|
||||
|
||||
<viewelement name="background">
|
||||
<area x="0" y="20%" width="100%" height="65%" layer="1">
|
||||
<fill color="{clrGray}" />
|
||||
</area>
|
||||
</viewelement>
|
||||
|
||||
<viewelement name="header">
|
||||
<area x="0" y="0" width="70%" height="15%" layer="1">
|
||||
<fill color="{clrRed}" />
|
||||
</area>
|
||||
<area x="0" y="0" width="70%" height="20%" layer="2">
|
||||
<drawtext align="center" valign="center" font="{regular}" fontsize="50%" color="{clrWhite}" text="{headertext}" />
|
||||
</area>
|
||||
</viewelement>
|
||||
|
||||
<viewelement name="footer">
|
||||
<area x="0" y="85%" width="100%" height="15%" layer="1">
|
||||
<fill color="{clrBlue}" />
|
||||
</area>
|
||||
<area x="0" y="85%" width="100%" height="15%" layer="2">
|
||||
<drawtext align="center" valign="center" font="{regular}" fontsize="60%" color="{clrWhite}" text="{footertext}" />
|
||||
</area>
|
||||
</viewelement>
|
||||
|
||||
<viewelement name="datetimeline">
|
||||
<area x="0" y="15%" width="15%" height="5%" layer="1">
|
||||
<fill color="{clrBlack}" />
|
||||
</area>
|
||||
<area x="0" y="15%" width="15%" height="5%" layer="2">
|
||||
<drawtext align="center" valign="center" font="{regular}" fontsize="80%" color="{clrWhite}" text="{date}" />
|
||||
</area>
|
||||
</viewelement>
|
||||
|
||||
<grid debug="true" name="timeline" x="15%" y="15%" width="85%" height="5%">
|
||||
<area layer="1">
|
||||
<fill condition="{fullhour}" color="{clrWhite}" />
|
||||
<fill condition="not{fullhour}" color="{clrBlack}" />
|
||||
</area>
|
||||
<area layer="2">
|
||||
<drawtext condition="{fullhour}" x="5%" valign="center" font="{light}" fontsize="80%" color="{clrBlack}" text="{timestring}" />
|
||||
<drawtext condition="not{fullhour}" x="5%" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{timestring}" />
|
||||
</area>
|
||||
</grid>
|
||||
|
||||
<grid debug="true" name="channels" x="0" y="20%" width="15%" height="65%">
|
||||
<area layer="1">
|
||||
<fill color="{clrYellow}" />
|
||||
</area>
|
||||
<area layer="2">
|
||||
<drawtext x="1%" valign="center" width="98%" font="{light}" fontsize="40%" color="{clrWhite}" text="{number} {name}" />
|
||||
</area>
|
||||
</grid>
|
||||
|
||||
<grid name="schedules" x="15%" y="20%" width="85%" height="65%">
|
||||
<area layer="1">
|
||||
<fill condition="{color}++not{current}" color="{clrBlue}" />
|
||||
<fill condition="not{color}++not{current}" color="{clrGreen}" />
|
||||
<fill condition="{current}" color="{clrRed}" />
|
||||
</area>
|
||||
<area layer="2">
|
||||
<drawtext condition="not{dummy}" x="1%" y="5%" width="98%" font="{light}" fontsize="30%" color="{clrWhite}" text="{start} - {stop}" />
|
||||
<drawtext condition="not{dummy}" x="1%" y="50%" width="98%" font="{light}" fontsize="30%" color="{clrWhite}" text="{title}" />
|
||||
<drawtext condition="{dummy}" x="1%" valign="center" width="98%" font="{light}" fontsize="40%" color="{clrWhite}" text="{title}" />
|
||||
</area>
|
||||
</grid>
|
||||
|
||||
</displayplugin>
|
83
views/displaypluginview.c
Normal file
83
views/displaypluginview.c
Normal file
@ -0,0 +1,83 @@
|
||||
#define __STL_CONFIG_H
|
||||
#include "displaypluginview.h"
|
||||
|
||||
cDisplayPluginView::cDisplayPluginView(cTemplateView *tmplView) : cView(tmplView) {
|
||||
intTokens = NULL;
|
||||
stringTokens = NULL;
|
||||
loopTokens = NULL;
|
||||
DeleteOsdOnExit();
|
||||
SetFadeTime(tmplView->GetNumericParameter(ptFadeTime));
|
||||
}
|
||||
|
||||
cDisplayPluginView::~cDisplayPluginView() {
|
||||
CancelSave();
|
||||
FadeOut();
|
||||
}
|
||||
|
||||
bool cDisplayPluginView::createOsd(void) {
|
||||
cRect osdSize = tmplView->GetOsdSize();
|
||||
bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
|
||||
cOsd::OsdTop() + osdSize.Y(),
|
||||
osdSize.Width(),
|
||||
osdSize.Height());
|
||||
return ok;
|
||||
}
|
||||
|
||||
void cDisplayPluginView::DisplayViewElement(int id) {
|
||||
if (!intTokens || !stringTokens || !loopTokens)
|
||||
return;
|
||||
DrawViewElement((eViewElement)id, stringTokens, intTokens, loopTokens);
|
||||
}
|
||||
|
||||
void cDisplayPluginView::InitGrids(int viewGridID) {
|
||||
map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
|
||||
if (hit != viewGrids.end()) {
|
||||
delete hit->second;
|
||||
viewGrids.erase(hit);
|
||||
}
|
||||
cTemplateViewGrid *tmplGrid = tmplView->GetViewGrid(viewGridID);
|
||||
cViewGrid *grid = new cViewGrid(tmplGrid);
|
||||
viewGrids.insert(pair< int, cViewGrid* >(viewGridID, grid));
|
||||
}
|
||||
|
||||
void cDisplayPluginView::SetGrid(int viewGridID, long gridID,
|
||||
double x, double y, double width, double height,
|
||||
map<string,int> *intTokens, map<string,string> *stringTokens) {
|
||||
map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
|
||||
if (hit != viewGrids.end())
|
||||
(hit->second)->SetGrid(gridID, x, y, width, height, intTokens, stringTokens);
|
||||
}
|
||||
|
||||
void cDisplayPluginView::SetGridCurrent(int viewGridID, long gridID, bool current) {
|
||||
map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
|
||||
if (hit != viewGrids.end())
|
||||
(hit->second)->SetCurrent(gridID, current);
|
||||
}
|
||||
|
||||
void cDisplayPluginView::DeleteGrid(int viewGridID, long gridID) {
|
||||
map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
|
||||
if (hit == viewGrids.end())
|
||||
return;
|
||||
(hit->second)->Delete(gridID);
|
||||
}
|
||||
|
||||
void cDisplayPluginView::DisplayGrids(int viewGridID) {
|
||||
map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
|
||||
if (hit == viewGrids.end())
|
||||
return;
|
||||
(hit->second)->Render();
|
||||
}
|
||||
|
||||
void cDisplayPluginView::ClearGrids(int viewGridID) {
|
||||
map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
|
||||
if (hit == viewGrids.end())
|
||||
return;
|
||||
(hit->second)->Clear();
|
||||
}
|
||||
|
||||
void cDisplayPluginView::Action(void) {
|
||||
SetInitFinished();
|
||||
FadeIn();
|
||||
DoFlush();
|
||||
cView::Action();
|
||||
}
|
33
views/displaypluginview.h
Normal file
33
views/displaypluginview.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef __DISPLAYPLUGINVIEW_H
|
||||
#define __DISPLAYPLUGINVIEW_H
|
||||
|
||||
#include <vdr/thread.h>
|
||||
#include "../libtemplate/template.h"
|
||||
#include "view.h"
|
||||
#include "viewgrid.h"
|
||||
|
||||
class cDisplayPluginView : public cView {
|
||||
private:
|
||||
map<string,int> *intTokens;
|
||||
map<string,string> *stringTokens;
|
||||
map<string,vector<map<string,string> > > *loopTokens;
|
||||
map< int, cViewGrid* > viewGrids;
|
||||
virtual void Action(void);
|
||||
public:
|
||||
cDisplayPluginView(cTemplateView *tmplView);
|
||||
virtual ~cDisplayPluginView();
|
||||
bool createOsd(void);
|
||||
void SetIntTokens(map<string,int> *intTokens) { this->intTokens = intTokens; };
|
||||
void SetStringTokens(map<string,string> *stringTokens) { this->stringTokens = stringTokens; };
|
||||
void SetLoopTokens(map<string,vector<map<string,string> > > *loopTokens) { this->loopTokens = loopTokens; };
|
||||
void DisplayViewElement(int id);
|
||||
void InitGrids(int viewGridID);
|
||||
void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens);
|
||||
void SetGridCurrent(int viewGridID, long gridID, bool current);
|
||||
void DeleteGrid(int viewGridID, long gridID);
|
||||
void DisplayGrids(int viewGridID);
|
||||
void ClearGrids(int viewGridID);
|
||||
void DoStart(void) { Start(); };
|
||||
void Flush(void) { DoFlush(); };
|
||||
};
|
||||
#endif //__DISPLAYPLUGINVIEW_H
|
129
views/view.c
129
views/view.c
@ -837,3 +837,132 @@ void cViewListItem::SetListElementPosition(cTemplatePixmap *pix) {
|
||||
pix->SetY(y);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* cGrid
|
||||
************************************************************************/
|
||||
|
||||
cGrid::cGrid(cTemplateViewElement *tmplGrid) : cView(tmplGrid) {
|
||||
dirty = true;
|
||||
moved = true;
|
||||
resized = true;
|
||||
current = false;
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
width = 0.0;
|
||||
height = 0.0;
|
||||
}
|
||||
|
||||
cGrid::~cGrid() {
|
||||
|
||||
}
|
||||
|
||||
void cGrid::Set(double x, double y, double width, double height,
|
||||
map <string,int> *intTokens, map <string,string> *stringTokens) {
|
||||
if ((width != this->width) || (height != this->height)) {
|
||||
resized = true;
|
||||
dirty = false;
|
||||
} else {
|
||||
resized = false;
|
||||
}
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
moved = true;
|
||||
if (intTokens) {
|
||||
this->intTokens = *intTokens;
|
||||
SetCurrent(current);
|
||||
dirty = true;
|
||||
}
|
||||
if (stringTokens) {
|
||||
this->stringTokens = *stringTokens;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void cGrid::SetCurrent(bool current) {
|
||||
this->current = current;
|
||||
if (!resized)
|
||||
dirty = true;
|
||||
intTokens.erase("current");
|
||||
intTokens.insert(pair<string,int>("current", current));
|
||||
}
|
||||
|
||||
void cGrid::Move(void) {
|
||||
tmplItem->InitIterator();
|
||||
cTemplatePixmap *pix = NULL;
|
||||
int pixCurrent = 0;
|
||||
|
||||
while(pix = tmplItem->GetNextPixmap()) {
|
||||
PositionPixmap(pix);
|
||||
cRect pixViewPort = pix->GetPixmapSize();
|
||||
SetViewPort(pixCurrent, pixViewPort);
|
||||
pixCurrent++;
|
||||
}
|
||||
dirty = false;
|
||||
resized = false;
|
||||
moved = false;
|
||||
}
|
||||
|
||||
void cGrid::Draw(void) {
|
||||
if (tmplItem->DebugTokens()) {
|
||||
DebugTokens("Grid", &stringTokens, &intTokens);
|
||||
}
|
||||
|
||||
tmplItem->InitIterator();
|
||||
cTemplatePixmap *pix = NULL;
|
||||
int pixCurrent = 0;
|
||||
|
||||
while(pix = tmplItem->GetNextPixmap()) {
|
||||
PositionPixmap(pix);
|
||||
if (!PixmapExists(pixCurrent)) {
|
||||
pix->ParseDynamicParameters(&intTokens, true);
|
||||
} else {
|
||||
pix->ParseDynamicParameters(&intTokens, false);
|
||||
}
|
||||
if (!PixmapExists(pixCurrent) && pix->Ready() && pix->DoExecute() && !pix->Scrolling()) {
|
||||
CreateViewPixmap(pixCurrent, pix);
|
||||
}
|
||||
//if pixmap still not valid, skip
|
||||
if (!pix->Ready() && !pix->Scrolling()) {
|
||||
pixCurrent++;
|
||||
continue;
|
||||
}
|
||||
//if condition for pixmap set, check if cond is true
|
||||
if (!pix->DoExecute()) {
|
||||
pixCurrent++;
|
||||
continue;
|
||||
}
|
||||
|
||||
pix->ClearDynamicFunctionParameters();
|
||||
pix->ParseDynamicFunctionParameters(&stringTokens, &intTokens);
|
||||
//pix->Debug();
|
||||
DrawPixmap(pixCurrent, pix);
|
||||
pixCurrent++;
|
||||
}
|
||||
dirty = false;
|
||||
resized = false;
|
||||
moved = false;
|
||||
}
|
||||
|
||||
void cGrid::Clear(void) {
|
||||
int pixMax = NumPixmaps();
|
||||
for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
|
||||
Fill(pixCurrent, clrTransparent);
|
||||
}
|
||||
}
|
||||
|
||||
void cGrid::DeletePixmaps(void) {
|
||||
int pixMax = NumPixmaps();
|
||||
for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
|
||||
DestroyPixmap(pixCurrent);
|
||||
}
|
||||
}
|
||||
|
||||
void cGrid::PositionPixmap(cTemplatePixmap *pix) {
|
||||
pix->SetXPercent(x);
|
||||
pix->SetYPercent(y);
|
||||
pix->SetWidthPercent(width);
|
||||
pix->SetHeightPercent(height);
|
||||
pix->CalculateParameters();
|
||||
}
|
||||
|
27
views/view.h
27
views/view.h
@ -70,4 +70,31 @@ public:
|
||||
void ClearListItem(void);
|
||||
};
|
||||
|
||||
class cGrid : public cView {
|
||||
protected:
|
||||
bool dirty;
|
||||
bool moved;
|
||||
bool resized;
|
||||
bool current;
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
map <string,string> stringTokens;
|
||||
map <string,int> intTokens;
|
||||
void PositionPixmap(cTemplatePixmap *pix);
|
||||
public:
|
||||
cGrid(cTemplateViewElement *tmplGrid);
|
||||
virtual ~cGrid();
|
||||
bool Dirty(void) { return dirty; };
|
||||
bool Moved(void) { return moved; };
|
||||
bool Resized(void) { return resized; };
|
||||
void Set(double x, double y, double width, double height, map <string,int> *intTokens, map <string,string> *stringTokens);
|
||||
void SetCurrent(bool current);
|
||||
void Move(void);
|
||||
void Draw(void);
|
||||
void Clear(void);
|
||||
void DeletePixmaps(void);
|
||||
};
|
||||
|
||||
#endif //__VIEW_H
|
74
views/viewgrid.c
Normal file
74
views/viewgrid.c
Normal file
@ -0,0 +1,74 @@
|
||||
#include "viewgrid.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
cViewGrid::cViewGrid(cTemplateViewGrid *tmplGrid) {
|
||||
this->tmplGrid = tmplGrid;
|
||||
}
|
||||
|
||||
cViewGrid::~cViewGrid() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
void cViewGrid::SetGrid(long gridID,
|
||||
double x, double y, double width, double height,
|
||||
map<string,int> *intTokens, map<string,string> *stringTokens) {
|
||||
map < long, cGrid* >::iterator hit = grids.find(gridID);
|
||||
cGrid *grid;
|
||||
if (hit == grids.end()) {
|
||||
grid = new cGrid(tmplGrid);
|
||||
grid->Set(x, y, width, height, intTokens, stringTokens);
|
||||
grids.insert(pair<long,cGrid*>(gridID, grid));
|
||||
} else {
|
||||
(hit->second)->Set(x, y, width, height, intTokens, stringTokens);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewGrid::SetCurrent(long gridID, bool current) {
|
||||
esyslog("skindesigner: setting %ld to current %d", gridID, current);
|
||||
map<long,cGrid*>::iterator hit = grids.find(gridID);
|
||||
if (hit != grids.end())
|
||||
(hit->second)->SetCurrent(current);
|
||||
}
|
||||
|
||||
void cViewGrid::Delete(long gridID) {
|
||||
map<long,cGrid*>::iterator hit = grids.find(gridID);
|
||||
if (hit == grids.end())
|
||||
return;
|
||||
esyslog("skindesigner: deleting grid %ld", gridID);
|
||||
delete (hit->second);
|
||||
grids.erase(gridID);
|
||||
}
|
||||
|
||||
void cViewGrid::Clear(void) {
|
||||
for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++)
|
||||
delete it->second;
|
||||
grids.clear();
|
||||
}
|
||||
|
||||
void cViewGrid::Render(void) {
|
||||
esyslog("skindesigner: rendering %ld grids", grids.size());
|
||||
for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
|
||||
cGrid *grid = it->second;
|
||||
if (grid->Dirty()) {
|
||||
if (grid->Moved()) {
|
||||
grid->DeletePixmaps();
|
||||
}
|
||||
esyslog("skindesigner: rendering grid %ld", it->first);
|
||||
grid->Draw();
|
||||
} else if (grid->Resized()) {
|
||||
esyslog("skindesigner: resizing grid %ld", it->first);
|
||||
grid->DeletePixmaps();
|
||||
grid->Draw();
|
||||
} else if (grid->Moved()) {
|
||||
esyslog("skindesigner: moving grid %ld", it->first);
|
||||
grid->Move();
|
||||
} else {
|
||||
esyslog("skindesigner: skipping grid %ld", it->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewGrid::Debug(void) {
|
||||
|
||||
}
|
26
views/viewgrid.h
Normal file
26
views/viewgrid.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef __VIEWGRID_H
|
||||
#define __VIEWGRID_H
|
||||
|
||||
#include "string"
|
||||
#include "map"
|
||||
#include "view.h"
|
||||
#include "../libtemplate/templateviewgrid.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class cViewGrid {
|
||||
private:
|
||||
cTemplateViewGrid *tmplGrid;
|
||||
map < long, cGrid* > grids;
|
||||
public:
|
||||
cViewGrid(cTemplateViewGrid *tmplGrid);
|
||||
virtual ~cViewGrid();
|
||||
void SetGrid(long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens);
|
||||
void SetCurrent(long gridID, bool current);
|
||||
void Delete(long gridID);
|
||||
void Clear(void);
|
||||
void Render(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
#endif //__DISPLAYMENULISTVIEW_H
|
Loading…
Reference in New Issue
Block a user