introduced cViewElement

This commit is contained in:
louis 2015-03-22 12:52:10 +01:00
parent 21b70b426d
commit fcf90375fa
10 changed files with 236 additions and 232 deletions

View File

@ -228,3 +228,5 @@ Version 0.3.1
Version 0.3.2 Version 0.3.2
- fixed crash if number of dvb devices changes

View File

@ -92,6 +92,7 @@ OBJS = $(PLUGIN).o \
views/viewgrid.o \ views/viewgrid.o \
views/viewhelpers.o \ views/viewhelpers.o \
views/displaychannelview.o \ views/displaychannelview.o \
views/displaychannelviewelements.o \
views/displaymenurootview.o \ views/displaymenurootview.o \
views/displaymenuview.o \ views/displaymenuview.o \
views/displaymenulistview.o \ views/displaymenulistview.o \

View File

@ -196,7 +196,7 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices detached="true" delay="100" fadetime="300"> <devices detached="true" delay="500" fadetime="500">
<area condition="{showdevices}" x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1"> <area condition="{showdevices}" x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>

View File

@ -2,6 +2,7 @@
#include <vdr/menu.h> #include <vdr/menu.h>
#include "../services/scraper2vdr.h" #include "../services/scraper2vdr.h"
#include "displaychannelview.h" #include "displaychannelview.h"
#include "displaychannelviewelements.h"
#include "../libcore/timers.h" #include "../libcore/timers.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
@ -438,9 +439,15 @@ void cDisplayChannelView::DrawDevices(bool initial) {
} }
if (DetachViewElement(veDevices)) { if (DetachViewElement(veDevices)) {
esyslog("skindesigner: start new thread for devices"); cViewElement *viewElement = GetViewElement(veDevices);
if (!viewElement) {
viewElement = new cViewElementDevices(tmplView->GetViewElement(veDevices));
AddViewElement(veDevices, viewElement);
viewElement->Start();
} else {
viewElement->Render();
} }
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens; map < string, vector< map< string, string > > > deviceLoopTokens;
@ -456,6 +463,8 @@ void cDisplayChannelView::DrawDevices(bool initial) {
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens); DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
} }
}
void cDisplayChannelView::ClearDevices(void) { void cDisplayChannelView::ClearDevices(void) {
ClearViewElement(veDevices); ClearViewElement(veDevices);
} }

View File

@ -0,0 +1,23 @@
#include "displaychannelviewelements.h"
cViewElementDevices::cViewElementDevices(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
init = true;
}
void cViewElementDevices::Render(void) {
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
if (init)
InitDevices();
bool changed = SetDevices(init, &intTokens, &devices);
init = false;
if (!changed)
return;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
Clear();
Draw(&deviceLoopTokens);
}

View File

@ -0,0 +1,17 @@
#ifndef __DISPLAYCHANNELVIEWELEMENTS_H
#define __DISPLAYCHANNELVIEWELEMENTS_H
#include "../libtemplate/template.h"
#include "view.h"
#include "viewhelpers.h"
class cViewElementDevices : public cViewElement, public cViewHelpers {
private:
bool init;
public:
cViewElementDevices(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDevices() {};
void Render(void);
};
#endif //__DISPLAYCHANNELVIEWELEMENTS_H

View File

@ -5,13 +5,10 @@
#include "displaymenuitemcurrentview.h" #include "displaymenuitemcurrentview.h"
cDisplayMenuItemCurrentView::cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent) : cView(tmplCurrent) { cDisplayMenuItemCurrentView::cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent) : cViewElement(tmplCurrent) {
delay = tmplItem->GetNumericParameter(ptDelay);
SetFadeTime(tmplItem->GetNumericParameter(ptFadeTime));
} }
cDisplayMenuItemCurrentView::~cDisplayMenuItemCurrentView() { cDisplayMenuItemCurrentView::~cDisplayMenuItemCurrentView() {
CancelSave();
} }
void cDisplayMenuItemCurrentView::SetPosMenuItem(cRect &pos) { void cDisplayMenuItemCurrentView::SetPosMenuItem(cRect &pos) {
@ -65,13 +62,6 @@ cDisplayMenuItemCurrentMainView::cDisplayMenuItemCurrentMainView(cTemplateViewEl
this->icon = icon; this->icon = icon;
} }
cDisplayMenuItemCurrentMainView::~cDisplayMenuItemCurrentMainView() {
}
void cDisplayMenuItemCurrentMainView::Prepare(void) {
}
void cDisplayMenuItemCurrentMainView::Render(void) { void cDisplayMenuItemCurrentMainView::Render(void) {
stringTokens.insert(pair<string,string>("number", number)); stringTokens.insert(pair<string,string>("number", number));
stringTokens.insert(pair<string,string>("label", label)); stringTokens.insert(pair<string,string>("label", label));
@ -80,26 +70,6 @@ void cDisplayMenuItemCurrentMainView::Render(void) {
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens);
} }
void cDisplayMenuItemCurrentMainView::Clear(void) {
}
void cDisplayMenuItemCurrentMainView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}
/************************************************************* /*************************************************************
* cDisplayMenuItemCurrentSchedulesView * cDisplayMenuItemCurrentSchedulesView
*************************************************************/ *************************************************************/
@ -113,13 +83,6 @@ cDisplayMenuItemCurrentSchedulesView::cDisplayMenuItemCurrentSchedulesView(cTemp
this->isEpgSearchFav = isEpgSearchFav; this->isEpgSearchFav = isEpgSearchFav;
} }
cDisplayMenuItemCurrentSchedulesView::~cDisplayMenuItemCurrentSchedulesView() {
}
void cDisplayMenuItemCurrentSchedulesView::Prepare(void) {
}
void cDisplayMenuItemCurrentSchedulesView::Render(void) { void cDisplayMenuItemCurrentSchedulesView::Render(void) {
intTokens.insert(pair<string,int>("whatson", (cat == mcSchedule)&&(!isEpgSearchFav) ? true: false)); intTokens.insert(pair<string,int>("whatson", (cat == mcSchedule)&&(!isEpgSearchFav) ? true: false));
intTokens.insert(pair<string,int>("whatsonnow", (cat == mcScheduleNow) ? true: false)); intTokens.insert(pair<string,int>("whatsonnow", (cat == mcScheduleNow) ? true: false));
@ -184,26 +147,6 @@ void cDisplayMenuItemCurrentSchedulesView::Render(void) {
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} }
void cDisplayMenuItemCurrentSchedulesView::Clear(void) {
}
void cDisplayMenuItemCurrentSchedulesView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}
void cDisplayMenuItemCurrentSchedulesView::ReadSchedules(vector< map<string,string> > *schedulesTokens) { void cDisplayMenuItemCurrentSchedulesView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
if (!event) if (!event)
return; return;
@ -236,13 +179,6 @@ cDisplayMenuItemCurrentChannelView::cDisplayMenuItemCurrentChannelView(cTemplate
this->channel = channel; this->channel = channel;
} }
cDisplayMenuItemCurrentChannelView::~cDisplayMenuItemCurrentChannelView() {
}
void cDisplayMenuItemCurrentChannelView::Prepare(void) {
}
void cDisplayMenuItemCurrentChannelView::Render(void) { void cDisplayMenuItemCurrentChannelView::Render(void) {
if (!channel) if (!channel)
return; return;
@ -342,26 +278,6 @@ void cDisplayMenuItemCurrentChannelView::Render(void) {
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} }
void cDisplayMenuItemCurrentChannelView::Clear(void) {
}
void cDisplayMenuItemCurrentChannelView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}
void cDisplayMenuItemCurrentChannelView::ReadSchedules(vector< map<string,string> > *schedulesTokens) { void cDisplayMenuItemCurrentChannelView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
cSchedulesLock schedulesLock; cSchedulesLock schedulesLock;
const cSchedules *schedules = cSchedules::Schedules(schedulesLock); const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
@ -398,13 +314,6 @@ cDisplayMenuItemCurrentTimerView::cDisplayMenuItemCurrentTimerView(cTemplateView
this->timer = timer; this->timer = timer;
} }
cDisplayMenuItemCurrentTimerView::~cDisplayMenuItemCurrentTimerView() {
}
void cDisplayMenuItemCurrentTimerView::Prepare(void) {
}
void cDisplayMenuItemCurrentTimerView::Render(void) { void cDisplayMenuItemCurrentTimerView::Render(void) {
if (!timer) if (!timer)
return; return;
@ -491,26 +400,6 @@ void cDisplayMenuItemCurrentTimerView::Render(void) {
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens);
} }
void cDisplayMenuItemCurrentTimerView::Clear(void) {
}
void cDisplayMenuItemCurrentTimerView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}
/************************************************************* /*************************************************************
* cDisplayMenuItemCurrentRecordingView * cDisplayMenuItemCurrentRecordingView
*************************************************************/ *************************************************************/
@ -523,13 +412,6 @@ cDisplayMenuItemCurrentRecordingView::cDisplayMenuItemCurrentRecordingView(cTemp
this->newRecs = newRecs; this->newRecs = newRecs;
} }
cDisplayMenuItemCurrentRecordingView::~cDisplayMenuItemCurrentRecordingView() {
}
void cDisplayMenuItemCurrentRecordingView::Prepare(void) {
}
void cDisplayMenuItemCurrentRecordingView::Render(void) { void cDisplayMenuItemCurrentRecordingView::Render(void) {
if (!recording) if (!recording)
return; return;
@ -658,26 +540,6 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} }
void cDisplayMenuItemCurrentRecordingView::Clear(void) {
}
void cDisplayMenuItemCurrentRecordingView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}
/************************************************************* /*************************************************************
* cDisplayMenuItemCurrentPluginView * cDisplayMenuItemCurrentPluginView
*************************************************************/ *************************************************************/
@ -691,34 +553,7 @@ cDisplayMenuItemCurrentPluginView::cDisplayMenuItemCurrentPluginView(cTemplateVi
loopTokens = pluginLoopTokens; loopTokens = pluginLoopTokens;
} }
cDisplayMenuItemCurrentPluginView::~cDisplayMenuItemCurrentPluginView() {
}
void cDisplayMenuItemCurrentPluginView::Prepare(void) {
}
void cDisplayMenuItemCurrentPluginView::Render(void) { void cDisplayMenuItemCurrentPluginView::Render(void) {
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} }
void cDisplayMenuItemCurrentPluginView::Clear(void) {
}
void cDisplayMenuItemCurrentPluginView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}

View File

@ -4,12 +4,9 @@
#include "../libtemplate/template.h" #include "../libtemplate/template.h"
#include "view.h" #include "view.h"
class cDisplayMenuItemCurrentView : public cView { class cDisplayMenuItemCurrentView : public cViewElement {
private: private:
protected: protected:
int delay;
map < string, string > stringTokens;
map < string, int > intTokens;
cRect posMenuItem; cRect posMenuItem;
void SetTokensPosMenuItem(void); void SetTokensPosMenuItem(void);
void SetScraperPoster(const cEvent *event, const cRecording *recording=NULL); void SetScraperPoster(const cEvent *event, const cRecording *recording=NULL);
@ -17,9 +14,6 @@ public:
cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent); cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent);
virtual ~cDisplayMenuItemCurrentView(); virtual ~cDisplayMenuItemCurrentView();
void SetPosMenuItem(cRect &pos); void SetPosMenuItem(cRect &pos);
virtual void Prepare(void) {};
virtual void Render(void) {};
virtual void Clear(void) {};
}; };
class cDisplayMenuItemCurrentMainView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentMainView: public cDisplayMenuItemCurrentView {
@ -27,13 +21,10 @@ private:
string number; string number;
string label; string label;
string icon; string icon;
void Action(void);
public: public:
cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon); cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon);
virtual ~cDisplayMenuItemCurrentMainView(); virtual ~cDisplayMenuItemCurrentMainView() {};
void Prepare(void);
void Render(void); void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentSchedulesView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentSchedulesView: public cDisplayMenuItemCurrentView {
@ -43,39 +34,30 @@ private:
eTimerMatch timerMatch; eTimerMatch timerMatch;
eMenuCategory cat; eMenuCategory cat;
bool isEpgSearchFav; bool isEpgSearchFav;
void Action(void);
void ReadSchedules(vector< map<string,string> > *schedulesTokens); void ReadSchedules(vector< map<string,string> > *schedulesTokens);
public: public:
cDisplayMenuItemCurrentSchedulesView(cTemplateViewElement *tmplCurrent, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav); cDisplayMenuItemCurrentSchedulesView(cTemplateViewElement *tmplCurrent, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav);
virtual ~cDisplayMenuItemCurrentSchedulesView(); virtual ~cDisplayMenuItemCurrentSchedulesView() {};
void Prepare(void);
void Render(void); void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentChannelView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentChannelView: public cDisplayMenuItemCurrentView {
private: private:
const cChannel *channel; const cChannel *channel;
void Action(void);
void ReadSchedules(vector< map<string,string> > *schedulesTokens); void ReadSchedules(vector< map<string,string> > *schedulesTokens);
public: public:
cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel); cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel);
virtual ~cDisplayMenuItemCurrentChannelView(); virtual ~cDisplayMenuItemCurrentChannelView() {};
void Prepare(void);
void Render(void); void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentTimerView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentTimerView: public cDisplayMenuItemCurrentView {
private: private:
const cTimer *timer; const cTimer *timer;
void Action(void);
public: public:
cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer); cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer);
virtual ~cDisplayMenuItemCurrentTimerView(); virtual ~cDisplayMenuItemCurrentTimerView() {};
void Prepare(void);
void Render(void); void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentRecordingView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentRecordingView: public cDisplayMenuItemCurrentView {
@ -84,25 +66,19 @@ private:
int level; int level;
int total; int total;
int newRecs; int newRecs;
void Action(void);
public: public:
cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs); cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs);
virtual ~cDisplayMenuItemCurrentRecordingView(); virtual ~cDisplayMenuItemCurrentRecordingView() {};
void Prepare(void);
void Render(void); void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentPluginView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentPluginView: public cDisplayMenuItemCurrentView {
private: private:
map<string,vector<map<string,string> > > loopTokens; map<string,vector<map<string,string> > > loopTokens;
void Action(void);
public: public:
cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens, map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens); cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens, map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens);
virtual ~cDisplayMenuItemCurrentPluginView(); virtual ~cDisplayMenuItemCurrentPluginView() {};
void Prepare(void);
void Render(void); void Render(void);
void Clear(void);
}; };
#endif //__DISPLAYMENUITEMCURRENTVIEW_H #endif //__DISPLAYMENUITEMCURRENTVIEW_H

View File

@ -11,13 +11,13 @@ cView::cView(cTemplateView *tmplView) : cPixmapContainer(tmplView->GetNumPixmaps
if (tvScaled) { if (tvScaled) {
cDevice::PrimaryDevice()->ScaleVideo(scalingWindow); cDevice::PrimaryDevice()->ScaleVideo(scalingWindow);
} }
tmplItem = NULL; tmplViewElement = NULL;
tmplTab = NULL; tmplTab = NULL;
Init(); Init();
} }
cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem ? tmplItem->GetNumPixmaps() : 0) { cView::cView(cTemplateViewElement *tmplViewElement) : cPixmapContainer(tmplViewElement ? tmplViewElement->GetNumPixmaps() : 0) {
this->tmplItem = tmplItem; this->tmplViewElement = tmplViewElement;
tmplView = NULL; tmplView = NULL;
tmplTab = NULL; tmplTab = NULL;
tvScaled = false; tvScaled = false;
@ -27,7 +27,7 @@ cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem ? tmplI
cView::cView(cTemplateViewTab *tmplTab) : cPixmapContainer(1) { cView::cView(cTemplateViewTab *tmplTab) : cPixmapContainer(1) {
this->tmplTab = tmplTab; this->tmplTab = tmplTab;
tmplView = NULL; tmplView = NULL;
tmplItem = NULL; tmplViewElement = NULL;
tvScaled = false; tvScaled = false;
Init(); Init();
} }
@ -36,6 +36,9 @@ cView::~cView() {
if (tvScaled) { if (tvScaled) {
cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
} }
for (map<eViewElement,cViewElement*>::iterator dVeIt = detachedViewElements.begin(); dVeIt != detachedViewElements.end(); dVeIt++) {
delete dVeIt->second;
}
} }
void cView::Init(void) { void cView::Init(void) {
@ -72,9 +75,9 @@ void cView::Stop(void) {
void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) { void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) {
//setting correct ViewElement, depending which constructor was used //setting correct ViewElement, depending which constructor was used
cTemplateViewElement *viewElement; cTemplateViewElement *viewElement = NULL;
if (tmplItem && (ve == veMenuCurrentItemDetail || ve == veOnPause)) { if (tmplViewElement) {
viewElement = tmplItem; viewElement = tmplViewElement;
} else if (tmplView) { } else if (tmplView) {
viewElement = tmplView->GetViewElement(ve); viewElement = tmplView->GetViewElement(ve);
} }
@ -235,6 +238,17 @@ bool cView::ViewElementScrolls(eViewElement ve) {
return false; return false;
} }
cViewElement *cView::GetViewElement(eViewElement ve) {
map < eViewElement, cViewElement* >::iterator hit = detachedViewElements.find(ve);
if (hit == detachedViewElements.end())
return NULL;
cViewElement *viewElement = hit->second;
return viewElement;
}
void cView::AddViewElement(eViewElement ve, cViewElement *viewElement) {
detachedViewElements.insert(pair< eViewElement, cViewElement* >(ve, viewElement));
}
void cView::CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size) { void cView::CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size) {
cRect pixSize; cRect pixSize;
@ -815,6 +829,112 @@ void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) {
} }
} }
/***********************************************************************
* cViewElement
************************************************************************/
cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
delay = tmplViewElement->GetNumericParameter(ptDelay);
SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
}
cViewElement::~cViewElement() {
CancelSave();
}
void cViewElement::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}
void cViewElement::Draw(map < string, vector< map< string, string > > > *loopTokens) {
if (!tmplViewElement)
return;
if (tmplViewElement->DebugTokens()) {
DebugTokens("viewelement", &stringTokens, &intTokens, loopTokens);
}
//iterate through pixmaps of viewelement
int pixCurrent = 0;
tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL;
while(pix = tmplViewElement->GetNextPixmap()) {
//reset Template
pix->ClearDynamicParameters();
//create Pixmap if already fully parsed
if (!PixmapExists(pixCurrent) && pix->Ready() && pix->DoExecute() && !pix->Scrolling()) {
CreateViewPixmap(pixCurrent, pix);
}
//check if pixmap needs dynamic parameters
if ((!pix->Ready() || !pix->DoExecute()) && !pix->Scrolling()) {
//parse dynamic parameters and initiate functions
pix->ParseDynamicParameters(&intTokens, true);
if (pix->Ready() && pix->DoExecute()) {
CreateViewPixmap(pixCurrent, pix);
}
} else {
//parse dynamic parameters but not initiate functions
pix->ParseDynamicParameters(&intTokens, false);
}
//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;
}
//parse dynamic tokens of pixmap functions
pix->ClearDynamicFunctionParameters();
pix->ParseDynamicFunctionParameters(&stringTokens, &intTokens);
if (!PixmapExists(pixCurrent) && pix->Scrolling()) {
cSize drawportSize;
scrolling = pix->CalculateDrawPortSize(drawportSize, loopTokens);
if (scrolling) {
/*
CreateScrollingPixmap(pixCurrent, pix, drawportSize);
pix->SetScrollingTextWidth();
veScroll = ve;
scrollingPix = pixCurrent;
scrollOrientation = pix->GetNumericParameter(ptOrientation);
scrollMode = pix->GetNumericParameter(ptScrollMode);
scrollDelay = pix->GetNumericParameter(ptDelay);
scrollSpeed = pix->GetNumericParameter(ptScrollSpeed);
*/
} else {
CreateViewPixmap(pixCurrent, pix);
}
}
if (pix->DoDebug()) {
pix->Debug();
}
DrawPixmap(pixCurrent, pix, loopTokens);
pixCurrent++;
}
}
void cViewElement::Clear(void) {
int pixMax = NumPixmaps();
for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
Fill(pixCurrent, clrTransparent);
}
}
/*********************************************************************** /***********************************************************************
* cViewListItem * cViewListItem
************************************************************************/ ************************************************************************/
@ -832,18 +952,18 @@ cViewListItem::~cViewListItem() {
cRect cViewListItem::DrawListItem(map <string,string> *stringTokens, map <string,int> *intTokens) { cRect cViewListItem::DrawListItem(map <string,string> *stringTokens, map <string,int> *intTokens) {
cRect posItem; cRect posItem;
if (!tmplItem) if (!tmplViewElement)
return posItem; return posItem;
if (tmplItem->DebugTokens()) { if (tmplViewElement->DebugTokens()) {
DebugTokens("ListItem", stringTokens, intTokens); DebugTokens("ListItem", stringTokens, intTokens);
} }
tmplItem->InitIterator(); tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
int pixCurrent = 0; int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) { while(pix = tmplViewElement->GetNextPixmap()) {
SetListElementPosition(pix); SetListElementPosition(pix);
if (pixCurrent == 0) { if (pixCurrent == 0) {
posItem = pix->GetPixmapSize(); posItem = pix->GetPixmapSize();
@ -988,13 +1108,13 @@ void cGrid::SetCurrent(bool current) {
} }
void cGrid::Move(void) { void cGrid::Move(void) {
if (!tmplItem) if (!tmplViewElement)
return; return;
tmplItem->InitIterator(); tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
int pixCurrent = 0; int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) { while(pix = tmplViewElement->GetNextPixmap()) {
PositionPixmap(pix); PositionPixmap(pix);
cRect pixViewPort = pix->GetPixmapSize(); cRect pixViewPort = pix->GetPixmapSize();
SetViewPort(pixCurrent, pixViewPort); SetViewPort(pixCurrent, pixViewPort);
@ -1006,17 +1126,17 @@ void cGrid::Move(void) {
} }
void cGrid::Draw(void) { void cGrid::Draw(void) {
if (!tmplItem) if (!tmplViewElement)
return; return;
if (tmplItem->DebugTokens()) { if (tmplViewElement->DebugTokens()) {
DebugTokens("Grid", &stringTokens, &intTokens); DebugTokens("Grid", &stringTokens, &intTokens);
} }
tmplItem->InitIterator(); tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
int pixCurrent = 0; int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) { while(pix = tmplViewElement->GetNextPixmap()) {
PositionPixmap(pix); PositionPixmap(pix);
if (!PixmapExists(pixCurrent)) { if (!PixmapExists(pixCurrent)) {
pix->ParseDynamicParameters(&intTokens, true); pix->ParseDynamicParameters(&intTokens, true);

View File

@ -8,6 +8,8 @@
using namespace std; using namespace std;
class cViewElement;
class cView : public cPixmapContainer { class cView : public cPixmapContainer {
private: private:
void Init(void); void Init(void);
@ -23,8 +25,10 @@ private:
void ActivateScrolling(void); void ActivateScrolling(void);
protected: protected:
cTemplateView *tmplView; cTemplateView *tmplView;
cTemplateViewElement *tmplItem; cTemplateViewElement *tmplViewElement;
cTemplateViewTab *tmplTab; cTemplateViewTab *tmplTab;
//detached viewelements
map < eViewElement, cViewElement* > detachedViewElements;
//scaling window //scaling window
cRect scalingWindow; cRect scalingWindow;
bool tvScaled; bool tvScaled;
@ -45,6 +49,8 @@ protected:
bool ExecuteViewElement(eViewElement ve); bool ExecuteViewElement(eViewElement ve);
bool DetachViewElement(eViewElement ve); bool DetachViewElement(eViewElement ve);
bool ViewElementScrolls(eViewElement ve); bool ViewElementScrolls(eViewElement ve);
cViewElement *GetViewElement(eViewElement ve);
void AddViewElement(eViewElement ve, cViewElement *viewElement);
void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL); void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL);
void CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize); 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); void DrawPixmap(int num, cTemplatePixmap *pix, map < string, vector< map< string, string > > > *loopTokens = NULL, bool flushPerLoop = false);
@ -53,12 +59,27 @@ protected:
virtual void Action(void); virtual void Action(void);
public: public:
cView(cTemplateView *tmplView); cView(cTemplateView *tmplView);
cView(cTemplateViewElement *tmplItem); cView(cTemplateViewElement *tmplViewElement);
cView(cTemplateViewTab *tmplTab); cView(cTemplateViewTab *tmplTab);
virtual ~cView(); virtual ~cView();
virtual void Stop(void); virtual void Stop(void);
}; };
class cViewElement : public cView {
private:
protected:
int delay;
map < string, string > stringTokens;
map < string, int > intTokens;
void Action(void);
void Draw(map < string, vector< map< string, string > > > *loopTokens = NULL);
public:
cViewElement(cTemplateViewElement *tmplViewElement);
virtual ~cViewElement();
virtual void Render(void) {};
void Clear(void);
};
class cViewListItem : public cView { class cViewListItem : public cView {
protected: protected:
int pos; int pos;