version 0.3.0

This commit is contained in:
louis
2015-03-12 17:28:35 +01:00
parent 45cb6c1663
commit 44680b6ce8
180 changed files with 7675 additions and 1150 deletions

View File

@@ -18,6 +18,9 @@ bool cDisplayMessageView::createOsd(void) {
cOsd::OsdTop() + osdSize.Y(),
osdSize.Width(),
osdSize.Height());
if (!ok) {
DeleteOsdOnExit(false);
}
return ok;
}

View File

@@ -1,17 +1,26 @@
#define __STL_CONFIG_H
#include "displaypluginview.h"
cDisplayPluginView::cDisplayPluginView(cTemplateView *tmplView) : cView(tmplView) {
cDisplayPluginView::cDisplayPluginView(cTemplateView *tmplView, bool isRootView) : cView(tmplView) {
init = true;
tabInit = true;
tabScrolled = true;
hidden = false;
intTokens = NULL;
stringTokens = NULL;
loopTokens = NULL;
DeleteOsdOnExit();
currentTmplTab = NULL;
tabView = NULL;
if (isRootView)
DeleteOsdOnExit();
SetFadeTime(tmplView->GetNumericParameter(ptFadeTime));
}
cDisplayPluginView::~cDisplayPluginView() {
CancelSave();
FadeOut();
if (tabView)
delete tabView;
}
bool cDisplayPluginView::createOsd(void) {
@@ -23,10 +32,49 @@ bool cDisplayPluginView::createOsd(void) {
return ok;
}
void cDisplayPluginView::Deactivate(bool hide) {
Stop();
if (!hide)
return;
HidePixmaps();
for (map< int, cViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
cViewGrid *viewGrid = it->second;
viewGrid->Hide();
}
hidden = true;
}
void cDisplayPluginView::Activate(void) {
if (tvScaled) {
cDevice::PrimaryDevice()->ScaleVideo(scalingWindow);
}
if (hidden) {
ShowPixmaps();
for (map< int, cViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
cViewGrid *viewGrid = it->second;
viewGrid->Show();
}
}
Start();
}
void cDisplayPluginView::CleanViewElement(int id) {
if (ViewElementScrolls((eViewElement)id)) {
currentlyScrolling = false;
if (Running())
Stop();
DestroyViewElement((eViewElement)id);
} else {
ClearViewElement((eViewElement)id);
}
}
void cDisplayPluginView::DisplayViewElement(int id) {
if (!intTokens || !stringTokens || !loopTokens)
return;
DrawViewElement((eViewElement)id, stringTokens, intTokens, loopTokens);
if (!init && ViewElementScrolls((eViewElement)id))
Start();
}
void cDisplayPluginView::InitGrids(int viewGridID) {
@@ -75,9 +123,162 @@ void cDisplayPluginView::ClearGrids(int viewGridID) {
(hit->second)->Clear();
}
void cDisplayPluginView::SetTabIntTokens(map<string,int> *intTokens) {
tabIntTokens = *intTokens;
}
void cDisplayPluginView::SetTabStringTokens(map<string,string> *stringTokens) {
tabStringTokens = *stringTokens;
}
void cDisplayPluginView::SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens) {
tabLoopTokens = *loopTokens;
}
void cDisplayPluginView::SetTabs(void) {
tmplView->InitViewTabIterator();
cTemplateViewTab *tmplTab = NULL;
while(tmplTab = tmplView->GetNextViewTab()) {
tmplTab->ParseDynamicParameters(&tabIntTokens, true);
tmplTab->ClearDynamicFunctionParameters();
tmplTab->ParseDynamicFunctionParameters(&tabStringTokens, &tabIntTokens);
if (tmplTab->DoExecute()) {
activeTabs.push_back(tmplTab);
}
}
atIt = activeTabs.begin();
}
void cDisplayPluginView::TabLeft(void) {
if (activeTabs.size() > 1) {
currentTmplTab = GetPrevTab();
delete tabView;
tabView = NULL;
tabScrolled = true;
} else {
tabScrolled = tabView->KeyLeft();
}
}
void cDisplayPluginView::TabRight(void) {
if (activeTabs.size() > 1) {
currentTmplTab = GetNextTab();
delete tabView;
tabView = NULL;
tabScrolled = true;
} else {
tabScrolled = tabView->KeyRight();
}
}
void cDisplayPluginView::TabUp(void) {
tabScrolled = tabView->KeyUp();
}
void cDisplayPluginView::TabDown(void) {
tabScrolled = tabView->KeyDown();
}
void cDisplayPluginView::DisplayTab(void) {
if (tabInit) {
currentTmplTab = *atIt;
tabInit = false;
}
if (!tabView) {
tabView = new cDisplayMenuTabView(currentTmplTab);
tabView->SetTokens(&tabIntTokens, &tabStringTokens, &tabLoopTokens);
tabView->CreateTab();
tabView->Start();
DrawTabLabels();
}
if (tabScrolled) {
DrawScrollbar();
}
}
cTemplateViewTab *cDisplayPluginView::GetPrevTab(void) {
if (atIt == activeTabs.begin()) {
atIt = activeTabs.end();
}
atIt--;
return *atIt;
}
cTemplateViewTab *cDisplayPluginView::GetNextTab(void) {
atIt++;
if (atIt == activeTabs.end()) {
atIt = activeTabs.begin();
}
return *atIt;
}
void cDisplayPluginView::DrawScrollbar(void) {
map < string, string > scrollbarStringTokens;
map < string, int > scrollbarIntTokens;
int barTop = 0;
int barHeight = 0;
tabView->GetScrollbarPosition(barTop, barHeight);
scrollbarIntTokens.insert(pair<string,int>("height", barHeight));
scrollbarIntTokens.insert(pair<string,int>("offset", barTop));
ClearViewElement((eViewElement)pveScrollbar);
DrawViewElement((eViewElement)pveScrollbar, &scrollbarStringTokens, &scrollbarIntTokens);
}
void cDisplayPluginView::DrawTabLabels(void) {
if (!ViewElementImplemented((eViewElement)pveTablabels)) {
return;
}
map < string, string > labelStringTokens;
map < string, int > labelIntTokens;
map < string, vector< map< string, string > > > labelLoopTokens;
string labelPrev = "";
string labelPrevTemp = "";
string labelCurrent = "";
string labelNext = "";
bool wasCurrent = false;
vector< map< string, string > > tabLabels;
for (list<cTemplateViewTab*>::iterator it = activeTabs.begin(); it != activeTabs.end(); it++) {
cTemplateViewTab *tab = *it;
map< string, string > tabLabel;
tabLabel.insert(pair< string, string >("tabs[title]", tab->GetName()));
if (wasCurrent) {
labelNext = tab->GetName();
}
if (tab == currentTmplTab) {
wasCurrent = true;
labelCurrent = tab->GetName();
labelPrev = labelPrevTemp;
tabLabel.insert(pair< string, string >("tabs[current]", "1"));
} else {
wasCurrent = false;
tabLabel.insert(pair< string, string >("tabs[current]", "0"));
}
labelPrevTemp = tab->GetName();
tabLabels.push_back(tabLabel);
}
if (labelNext.size() == 0 && activeTabs.size() > 0) {
cTemplateViewTab *firstTab = activeTabs.front();
labelNext = firstTab->GetName();
}
if (labelPrev.size() == 0 && activeTabs.size() > 0) {
cTemplateViewTab *lastTab = activeTabs.back();
labelPrev = lastTab->GetName();
}
labelStringTokens.insert(pair< string, string >("currenttab", labelCurrent));
labelStringTokens.insert(pair< string, string >("nexttab", labelNext));
labelStringTokens.insert(pair< string, string >("prevtab", labelPrev));
labelLoopTokens.insert(pair< string, vector< map< string, string > > >("tabs", tabLabels));
ClearViewElement((eViewElement)pveTablabels);
DrawViewElement((eViewElement)pveTablabels, &labelStringTokens, &labelIntTokens, &labelLoopTokens);
}
void cDisplayPluginView::Action(void) {
SetInitFinished();
FadeIn();
DoFlush();
cView::Action();
}
}

View File

@@ -1,25 +1,45 @@
#ifndef __DISPLAYPLUGINVIEW_H
#define __DISPLAYPLUGINVIEW_H
#include <list>
#include <vdr/thread.h>
#include "../libtemplate/template.h"
#include "view.h"
#include "viewgrid.h"
#include "displaymenutabview.h"
class cDisplayPluginView : public cView {
private:
bool init;
bool tabInit;
bool tabScrolled;
bool hidden;
map<string,int> *intTokens;
map<string,string> *stringTokens;
map<string,vector<map<string,string> > > *loopTokens;
map< int, cViewGrid* > viewGrids;
map<string,int> tabIntTokens;
map<string,string> tabStringTokens;
map<string,vector<map<string,string> > > tabLoopTokens;
cTemplateViewTab *currentTmplTab;
list<cTemplateViewTab*> activeTabs;
list<cTemplateViewTab*>::iterator atIt;
cDisplayMenuTabView *tabView;
cTemplateViewTab *GetPrevTab(void);
cTemplateViewTab *GetNextTab(void);
void DrawScrollbar(void);
void DrawTabLabels(void);
virtual void Action(void);
public:
cDisplayPluginView(cTemplateView *tmplView);
cDisplayPluginView(cTemplateView *tmplView, bool isRootView);
virtual ~cDisplayPluginView();
bool createOsd(void);
void Deactivate(bool hide);
void Activate(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 CleanViewElement(int id);
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);
@@ -27,7 +47,16 @@ public:
void DeleteGrid(int viewGridID, long gridID);
void DisplayGrids(int viewGridID);
void ClearGrids(int viewGridID);
void DoStart(void) { Start(); };
void SetTabIntTokens(map<string,int> *intTokens);
void SetTabStringTokens(map<string,string> *stringTokens);
void SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens);
void SetTabs(void);
void TabLeft(void);
void TabRight(void);
void TabUp(void);
void TabDown(void);
void DisplayTab(void);
void DoStart(void) { init = false; Start(); };
void Flush(void) { DoFlush(); };
};
#endif //__DISPLAYPLUGINVIEW_H

View File

@@ -16,7 +16,7 @@ cView::cView(cTemplateView *tmplView) : cPixmapContainer(tmplView->GetNumPixmaps
Init();
}
cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem->GetNumPixmaps()) {
cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem ? tmplItem->GetNumPixmaps() : 0) {
this->tmplItem = tmplItem;
tmplView = NULL;
tmplTab = NULL;
@@ -164,6 +164,23 @@ void cView::ClearViewElement(eViewElement ve) {
}
}
void cView::DestroyViewElement(eViewElement ve) {
if (!tmplView)
return;
cTemplateViewElement *viewElement = tmplView->GetViewElement(ve);
if (!viewElement)
return;
int pixCurrent = viewElement->GetPixOffset();
if (pixCurrent < 0)
return;
cTemplatePixmap *pix = NULL;
viewElement->InitIterator();
while(pix = viewElement->GetNextPixmap()) {
DestroyPixmap(pixCurrent);
pixCurrent++;
}
}
void cView::ActivateScrolling(void) {
if (veScroll == veUndefined)
return;
@@ -192,6 +209,22 @@ bool cView::ViewElementImplemented(eViewElement ve) {
return tmplView->GetNumPixmapsViewElement(ve);
}
bool cView::ViewElementScrolls(eViewElement ve) {
if (scrollingPix < 0)
return false;
if (!tmplView)
return false;
cTemplateViewElement *viewElement = tmplView->GetViewElement(ve);
if (!viewElement)
return false;
int pixStart = viewElement->GetPixOffset();
int numPixmaps = viewElement->GetNumPixmaps();
if ( (scrollingPix >= pixStart) && (scrollingPix < (pixStart + numPixmaps)) )
return true;
return false;
}
void cView::CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size) {
cRect pixSize;
if (size) {
@@ -236,6 +269,9 @@ void cView::DrawPixmap(int num, cTemplatePixmap *pix, map < string, vector< map<
case ftDrawText:
DoDrawText(num, func);
break;
case ftDrawTextVertical:
DoDrawTextVertical(num, func);
break;
case ftDrawTextBox: {
int floating = func->GetNumericParameter(ptFloat);
if (floating > flNone) {
@@ -438,6 +474,53 @@ void cView::DoDrawText(int num, cTemplateFunction *func, int x0, int y0) {
DrawText(num, pos, text.c_str(), clr, clrBack, fontName, fontSize);
}
void cView::DoDrawTextVertical(int num, cTemplateFunction *func, int x0, int y0) {
string fontName = func->GetFontName();
int fontSize = func->GetNumericParameter(ptFontSize);
tColor clr = func->GetColorParameter(ptColor);
tColor clrBack = clrTransparent;
string text = func->GetText(false);
cImage *textVertical = imgCache->GetVerticalText(text, clr, fontName, fontSize);
if (!textVertical)
return;
//align has to be set here because here we know the image size
int x = 0;
int y = 0;
int align = func->GetNumericParameter(ptAlign);
if (align == alCenter) {
int containerWidth = func->GetContainerWidth();
x = (containerWidth - textVertical->Width()) / 2;
} else if (align == alLeft) {
x = 0;
} else if (align = alRight) {
int containerWidth = func->GetContainerWidth();
x = (containerWidth - textVertical->Width());
} else {
x = func->GetNumericParameter(ptX);
}
int valign = func->GetNumericParameter(ptValign);
if (valign == alCenter) {
int containerHeight = func->GetContainerHeight();
y = (containerHeight - textVertical->Height()) / 2;
} else if (align == alTop) {
y = 0;
} else if (align = alBottom) {
int containerHeight = func->GetContainerHeight();
y = (containerHeight - textVertical->Height());
} else {
y = func->GetNumericParameter(ptY);
}
if (x < 0) x = 0;
x += x0;
if (y < 0) y = func->GetContainerHeight() - textVertical->Height() - 5;
y += y0;
cPoint pos(x,y);
DrawImage(num, pos, *textVertical);
}
void cView::DoDrawTextBox(int num, cTemplateFunction *func, int x0, int y0) {
string text = func->GetText(false);
if (text.size() < 3)
@@ -858,17 +941,22 @@ 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)) {
this->width = width;
this->height = height;
resized = true;
dirty = false;
} else {
resized = false;
}
this->x = x;
this->y = y;
this->width = width;
this->height = height;
moved = true;
if (this->x != x || this->y != y) {
this->x = x;
this->y = y;
moved = true;
} else {
moved = false;
}
if (intTokens) {
this->intTokens = *intTokens;
SetCurrent(current);
@@ -889,6 +977,8 @@ void cGrid::SetCurrent(bool current) {
}
void cGrid::Move(void) {
if (!tmplItem)
return;
tmplItem->InitIterator();
cTemplatePixmap *pix = NULL;
int pixCurrent = 0;
@@ -905,6 +995,8 @@ void cGrid::Move(void) {
}
void cGrid::Draw(void) {
if (!tmplItem)
return;
if (tmplItem->DebugTokens()) {
DebugTokens("Grid", &stringTokens, &intTokens);
}

View File

@@ -13,6 +13,7 @@ private:
void Init(void);
void DoFill(int num, cTemplateFunction *func);
void DoDrawText(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
void DoDrawTextVertical(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
void DoDrawTextBox(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
void DoDrawFloatingTextBox(int num, cTemplateFunction *func);
void DoDrawRectangle(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
@@ -40,7 +41,9 @@ protected:
int scrollSpeed;
void DrawViewElement(eViewElement ve, map <string,string> *stringTokens = NULL, map <string,int> *intTokens = NULL, map < string, vector< map< string, string > > > *loopTokens = NULL);
void ClearViewElement(eViewElement ve);
void DestroyViewElement(eViewElement ve);
bool ViewElementImplemented(eViewElement ve);
bool ViewElementScrolls(eViewElement ve);
void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL);
void CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize);
void DrawPixmap(int num, cTemplatePixmap *pix, map < string, vector< map< string, string > > > *loopTokens = NULL, bool flushPerLoop = false);

View File

@@ -25,7 +25,6 @@ void cViewGrid::SetGrid(long gridID,
}
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);
@@ -35,7 +34,6 @@ 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);
}
@@ -47,28 +45,43 @@ void cViewGrid::Clear(void) {
}
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();
grid->Move();
}
esyslog("skindesigner: rendering grid %ld", it->first);
grid->Clear();
//esyslog("skindesigner: rendering grid %ld", it->first);
grid->Draw();
} else if (grid->Resized()) {
esyslog("skindesigner: resizing grid %ld", it->first);
//esyslog("skindesigner: resizing grid %ld", it->first);
grid->DeletePixmaps();
grid->Draw();
} else if (grid->Moved()) {
esyslog("skindesigner: moving grid %ld", it->first);
grid->Move();
//esyslog("skindesigner: moving grid %ld", it->first);
grid->Move();
} else {
esyslog("skindesigner: skipping grid %ld", it->first);
//esyslog("skindesigner: skipping grid %ld", it->first);
}
}
}
void cViewGrid::Hide(void) {
for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
cGrid *grid = it->second;
grid->HidePixmaps();
}
}
void cViewGrid::Show(void) {
for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
cGrid *grid = it->second;
grid->ShowPixmaps();
}
}
void cViewGrid::Debug(void) {
}

View File

@@ -20,6 +20,8 @@ public:
void Delete(long gridID);
void Clear(void);
void Render(void);
void Hide(void);
void Show(void);
void Debug(void);
};