summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2015-02-12 18:50:58 +0100
committerlouis <louis.braun@gmx.de>2015-02-12 18:50:58 +0100
commit4d7700aecedf475038d57e10f45ab2dd4bcf806f (patch)
tree2fefc56fe77c8f4137187515a5f2b57d78425fea /views
parent00ac852820a09f676157a7b487acf51f4fe95ff4 (diff)
downloadvdr-plugin-skindesigner-4d7700aecedf475038d57e10f45ab2dd4bcf806f.tar.gz
vdr-plugin-skindesigner-4d7700aecedf475038d57e10f45ab2dd4bcf806f.tar.bz2
plugin interface
Diffstat (limited to 'views')
-rw-r--r--views/displaypluginview.c83
-rw-r--r--views/displaypluginview.h33
-rw-r--r--views/view.c129
-rw-r--r--views/view.h27
-rw-r--r--views/viewgrid.c74
-rw-r--r--views/viewgrid.h26
6 files changed, 372 insertions, 0 deletions
diff --git a/views/displaypluginview.c b/views/displaypluginview.c
new file mode 100644
index 0000000..89ff94c
--- /dev/null
+++ b/views/displaypluginview.c
@@ -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();
+}
diff --git a/views/displaypluginview.h b/views/displaypluginview.h
new file mode 100644
index 0000000..b170116
--- /dev/null
+++ b/views/displaypluginview.h
@@ -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
diff --git a/views/view.c b/views/view.c
index 2b9c4bf..1571d2e 100644
--- a/views/view.c
+++ b/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();
+}
diff --git a/views/view.h b/views/view.h
index a793c31..7b5bd9b 100644
--- a/views/view.h
+++ b/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 \ No newline at end of file
diff --git a/views/viewgrid.c b/views/viewgrid.c
new file mode 100644
index 0000000..6488ccd
--- /dev/null
+++ b/views/viewgrid.c
@@ -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) {
+
+} \ No newline at end of file
diff --git a/views/viewgrid.h b/views/viewgrid.h
new file mode 100644
index 0000000..84209c3
--- /dev/null
+++ b/views/viewgrid.h
@@ -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 \ No newline at end of file