mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 15:58:31 +00:00
Version 0.8.0 beta
This commit is contained in:
347
coreengine/animation.c
Normal file
347
coreengine/animation.c
Normal file
@@ -0,0 +1,347 @@
|
||||
#include "animation.h"
|
||||
#include <math.h>
|
||||
|
||||
/******************************************************************
|
||||
* cAnimation
|
||||
******************************************************************/
|
||||
cAnimation::cAnimation(cScrollable *scrollable) : cThread("scroller") {
|
||||
this->scrollable = scrollable;
|
||||
this->detachable = NULL;
|
||||
this->fadable = NULL;
|
||||
this->shiftable = NULL;
|
||||
this->blinkable = NULL;
|
||||
waitOnWakeup = false;
|
||||
doAnimation = true;
|
||||
modeIn = false;
|
||||
blinkFunc = -1;
|
||||
}
|
||||
|
||||
cAnimation::cAnimation(cDetachable *detachable, bool wait, bool animation) : cThread("detached") {
|
||||
this->scrollable = NULL;
|
||||
this->detachable = detachable;
|
||||
this->fadable = NULL;
|
||||
this->shiftable = NULL;
|
||||
this->blinkable = NULL;
|
||||
waitOnWakeup = wait;
|
||||
doAnimation = animation;
|
||||
modeIn = false;
|
||||
blinkFunc = -1;
|
||||
}
|
||||
|
||||
cAnimation::cAnimation(cFadable *fadable, bool fadein) : cThread("fadable") {
|
||||
this->scrollable = NULL;
|
||||
this->detachable = NULL;
|
||||
this->fadable = fadable;
|
||||
this->shiftable = NULL;
|
||||
this->blinkable = NULL;
|
||||
waitOnWakeup = false;
|
||||
doAnimation = true;
|
||||
modeIn = fadein;
|
||||
blinkFunc = -1;
|
||||
}
|
||||
|
||||
cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin) : cThread("shiftable") {
|
||||
this->scrollable = NULL;
|
||||
this->detachable = NULL;
|
||||
this->fadable = NULL;
|
||||
this->shiftable = shiftable;
|
||||
this->blinkable = NULL;
|
||||
waitOnWakeup = false;
|
||||
doAnimation = true;
|
||||
modeIn = shiftin;
|
||||
shiftstart = start;
|
||||
shiftend = end;
|
||||
blinkFunc = -1;
|
||||
}
|
||||
|
||||
cAnimation::cAnimation(cBlinkable *blinkable, int func) : cThread("blinking") {
|
||||
this->scrollable = NULL;
|
||||
this->detachable = NULL;
|
||||
this->fadable = NULL;
|
||||
this->shiftable = NULL;
|
||||
this->blinkable = blinkable;
|
||||
waitOnWakeup = false;
|
||||
doAnimation = true;
|
||||
modeIn = false;
|
||||
blinkFunc = func;
|
||||
}
|
||||
|
||||
cAnimation::~cAnimation(void) {
|
||||
sleepWait.Signal();
|
||||
Cancel(2);
|
||||
}
|
||||
|
||||
void cAnimation::WakeUp(void) {
|
||||
sleepWait.Signal();
|
||||
}
|
||||
|
||||
void cAnimation::Stop(bool deletePixmaps) {
|
||||
sleepWait.Signal();
|
||||
Cancel(2);
|
||||
if (scrollable && deletePixmaps)
|
||||
scrollable->StopScrolling();
|
||||
}
|
||||
|
||||
void cAnimation::Action(void) {
|
||||
if (scrollable) {
|
||||
Scroll();
|
||||
} else if (detachable) {
|
||||
Detach();
|
||||
} else if (fadable) {
|
||||
Fade();
|
||||
} else if (shiftable) {
|
||||
Shift();
|
||||
} else if (blinkable) {
|
||||
Blink();
|
||||
}
|
||||
}
|
||||
|
||||
void cAnimation::Sleep(int duration) {
|
||||
//sleep should wake up itself, so no infinit wait allowed
|
||||
if (duration <= 0)
|
||||
return;
|
||||
sleepWait.Wait(duration);
|
||||
}
|
||||
|
||||
void cAnimation::Wait(void) {
|
||||
//wait has to be waked up from outside
|
||||
sleepWait.Wait(0);
|
||||
}
|
||||
|
||||
void cAnimation::Scroll(void) {
|
||||
int delay = scrollable->ScrollDelay();
|
||||
Sleep(delay);
|
||||
if (!Running()) return;
|
||||
|
||||
eOrientation orientation = scrollable->ScrollOrientation();
|
||||
int scrollTotal = 0;
|
||||
if (orientation == eOrientation::horizontal) {
|
||||
scrollTotal = scrollable->ScrollWidth();
|
||||
} else if (orientation == eOrientation::vertical) {
|
||||
scrollTotal = scrollable->ScrollHeight();
|
||||
}
|
||||
|
||||
eScrollMode mode = scrollable->ScrollMode();
|
||||
bool carriageReturn = (mode == eScrollMode::carriagereturn) ? true : false;
|
||||
|
||||
eScrollSpeed speed = scrollable->ScrollSpeed();
|
||||
int frameTime = 30;
|
||||
if (speed == eScrollSpeed::slow)
|
||||
frameTime = 50;
|
||||
else if (speed == eScrollSpeed::medium)
|
||||
frameTime = 30;
|
||||
else if (speed == eScrollSpeed::fast)
|
||||
frameTime = 15;
|
||||
|
||||
if (!Running()) return;
|
||||
|
||||
scrollable->StartScrolling();
|
||||
|
||||
int drawPortX = 0;
|
||||
int drawPortY = 0;
|
||||
int scrollDelta = 1;
|
||||
|
||||
bool doSleep = false;
|
||||
while (Running()) {
|
||||
if (doSleep) {
|
||||
Sleep(delay);
|
||||
doSleep = false;
|
||||
}
|
||||
if (!Running()) return;
|
||||
uint64_t now = cTimeMs::Now();
|
||||
|
||||
cPoint drawPortPoint(0,0);
|
||||
if (orientation == eOrientation::horizontal) {
|
||||
|
||||
drawPortX -= scrollDelta;
|
||||
if (abs(drawPortX) > scrollTotal) {
|
||||
Sleep(delay);
|
||||
if (carriageReturn) {
|
||||
drawPortX = 0;
|
||||
doSleep = true;
|
||||
} else {
|
||||
scrollDelta *= -1;
|
||||
drawPortX -= scrollDelta;
|
||||
}
|
||||
}
|
||||
drawPortPoint.SetX(drawPortX);
|
||||
|
||||
} else if (orientation == eOrientation::vertical) {
|
||||
|
||||
drawPortY -= scrollDelta;
|
||||
if (abs(drawPortY) > scrollTotal) {
|
||||
Sleep(delay);
|
||||
drawPortY = 0;
|
||||
doSleep = true;
|
||||
}
|
||||
drawPortPoint.SetY(drawPortY);
|
||||
|
||||
}
|
||||
|
||||
if (!Running()) return;
|
||||
scrollable->SetDrawPort(drawPortPoint);
|
||||
|
||||
if (!Running()) return;
|
||||
scrollable->Flush();
|
||||
|
||||
if (orientation == eOrientation::horizontal && !carriageReturn && (drawPortX == 0)) {
|
||||
scrollDelta *= -1;
|
||||
doSleep = true;
|
||||
}
|
||||
|
||||
int delta = cTimeMs::Now() - now;
|
||||
if (delta < frameTime)
|
||||
Sleep(frameTime - delta);
|
||||
}
|
||||
}
|
||||
|
||||
void cAnimation::Detach(void) {
|
||||
if (waitOnWakeup) {
|
||||
Wait();
|
||||
int delay = 100 + detachable->Delay();
|
||||
Sleep(delay);
|
||||
} else {
|
||||
int delay = detachable->Delay();
|
||||
Sleep(delay);
|
||||
}
|
||||
if (!Running()) return;
|
||||
detachable->ParseDetached();
|
||||
if (!Running()) return;
|
||||
detachable->RenderDetached();
|
||||
if (!Running()) return;
|
||||
detachable->Flush();
|
||||
if (!Running()) return;
|
||||
if (doAnimation) {
|
||||
detachable->StartAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void cAnimation::Fade(void) {
|
||||
int fadetime = fadable->FadeTime();
|
||||
int frametime = 1000 / FPS;
|
||||
int step = 100.0f / ((double)fadetime / (double)frametime);
|
||||
uint64_t start = cTimeMs::Now();
|
||||
int transparency = 0;
|
||||
if (modeIn) {
|
||||
transparency = 100 - step;
|
||||
} else {
|
||||
transparency = step;
|
||||
}
|
||||
//wait configured delay if not already done by detacher
|
||||
if (!fadable->Detached()) {
|
||||
int delay = fadable->Delay();
|
||||
if (delay > 0)
|
||||
Sleep(delay);
|
||||
}
|
||||
while (Running() || !modeIn) {
|
||||
uint64_t now = cTimeMs::Now();
|
||||
if (Running() || !modeIn)
|
||||
fadable->SetTransparency(transparency, !modeIn);
|
||||
if (Running() || !modeIn)
|
||||
fadable->Flush();
|
||||
int delta = cTimeMs::Now() - now;
|
||||
if ((Running() || !modeIn) && (delta < frametime)) {
|
||||
Sleep(frametime - delta);
|
||||
}
|
||||
if ((int)(now - start) > fadetime) {
|
||||
if ((Running() && modeIn) && transparency > 0) {
|
||||
fadable->SetTransparency(0);
|
||||
fadable->Flush();
|
||||
} else if (!modeIn && transparency < 100) {
|
||||
fadable->SetTransparency(100, true);
|
||||
fadable->Flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (modeIn) {
|
||||
transparency -= step;
|
||||
if (transparency < 0)
|
||||
transparency = 0;
|
||||
} else {
|
||||
transparency += step;
|
||||
if (transparency > 100)
|
||||
transparency = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cAnimation::Shift(void) {
|
||||
int shifttime = shiftable->ShiftTime();
|
||||
eShiftMode mode = (eShiftMode)shiftable->ShiftMode();
|
||||
//in shiftmode slowedDown shifting is done starting with slowratio % faster
|
||||
//at start. Then speed reduces linear to (100 - slowratio)% at end
|
||||
//for me 60 is a nice value :-)
|
||||
int slowRatio = 60;
|
||||
|
||||
int frametime = 1000 / FPS;
|
||||
int steps = (double)shifttime / (double)frametime;
|
||||
int stepXLinear = 0;
|
||||
int stepYLinear = 0;
|
||||
if (shiftstart.X() == shiftend.X()) {
|
||||
stepYLinear = (shiftend.Y() - shiftstart.Y()) / steps;
|
||||
} else if (shiftstart.Y() == shiftend.Y()) {
|
||||
stepXLinear = (shiftend.X() - shiftstart.X()) / steps;
|
||||
} else {
|
||||
stepXLinear = (shiftend.X() - shiftstart.X()) / steps;
|
||||
stepYLinear = (shiftend.Y() - shiftstart.Y()) / steps;
|
||||
}
|
||||
int stepX = stepXLinear;
|
||||
int stepY = stepYLinear;
|
||||
|
||||
cPoint pos;
|
||||
if (modeIn)
|
||||
pos = shiftstart;
|
||||
else
|
||||
pos = shiftend;
|
||||
|
||||
//wait configured delay if not already done by detacher
|
||||
if (!shiftable->Detached()) {
|
||||
int delay = shiftable->Delay();
|
||||
if (delay > 0)
|
||||
Sleep(delay);
|
||||
}
|
||||
uint64_t start = cTimeMs::Now();
|
||||
while (Running() || !modeIn) {
|
||||
uint64_t now = cTimeMs::Now();
|
||||
if (Running() || !modeIn)
|
||||
shiftable->SetPosition(pos, shiftend);
|
||||
if (Running() || !modeIn)
|
||||
shiftable->Flush();
|
||||
int delta = cTimeMs::Now() - now;
|
||||
if ((Running() || !modeIn) && (delta < frametime)) {
|
||||
cCondWait::SleepMs(frametime - delta);
|
||||
}
|
||||
if ((int)(now - start) > shifttime) {
|
||||
if ((Running() && modeIn) && pos != shiftend) {
|
||||
shiftable->SetPosition(shiftend, shiftend);
|
||||
shiftable->Flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (mode == eShiftMode::slowedDown) {
|
||||
double t = (double)(now - start) / (double)shifttime;
|
||||
double factor = 1.0f + (double)slowRatio / 100.0f - 2.0f * ((double)slowRatio / 100.0f) * t;
|
||||
stepX = stepXLinear * factor;
|
||||
stepY = stepYLinear * factor;
|
||||
}
|
||||
if (modeIn) {
|
||||
pos.Set(pos.X() + stepX, pos.Y() + stepY);
|
||||
} else {
|
||||
pos.Set(pos.X() - stepX, pos.Y() - stepY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void cAnimation::Blink(void) {
|
||||
int freq = blinkable->BlinkFreq(blinkFunc);
|
||||
bool blinkOn = false;
|
||||
while (Running()) {
|
||||
Sleep(freq);
|
||||
if (Running()) {
|
||||
blinkable->DoBlink(blinkFunc, blinkOn);
|
||||
blinkable->Flush();
|
||||
}
|
||||
blinkOn = !blinkOn;
|
||||
}
|
||||
}
|
||||
126
coreengine/animation.h
Normal file
126
coreengine/animation.h
Normal file
@@ -0,0 +1,126 @@
|
||||
#ifndef __ANIMATION_H
|
||||
#define __ANIMATION_H
|
||||
|
||||
#include <vdr/skins.h>
|
||||
#include <vdr/thread.h>
|
||||
#include "definitions.h"
|
||||
|
||||
#define FPS 50
|
||||
|
||||
/******************************************************************
|
||||
* cScrollable
|
||||
******************************************************************/
|
||||
class cScrollable {
|
||||
protected:
|
||||
cScrollable(void) {};
|
||||
~cScrollable(void) {};
|
||||
public:
|
||||
virtual int ScrollDelay(void) = 0;
|
||||
virtual int ScrollWidth(void) = 0;
|
||||
virtual int ScrollHeight(void) = 0;
|
||||
virtual eScrollMode ScrollMode(void) = 0;
|
||||
virtual eScrollSpeed ScrollSpeed(void) = 0;
|
||||
virtual eOrientation ScrollOrientation(void) = 0;
|
||||
virtual void StartScrolling(void) = 0;
|
||||
virtual void StopScrolling(void) = 0;
|
||||
virtual void SetDrawPort(cPoint &point) = 0;
|
||||
virtual void Flush(void) = 0;
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cDetachable
|
||||
******************************************************************/
|
||||
class cDetachable {
|
||||
protected:
|
||||
cDetachable(void) {};
|
||||
~cDetachable(void) {};
|
||||
public:
|
||||
virtual int Delay(void) = 0;
|
||||
virtual void ParseDetached(void) = 0;
|
||||
virtual void RenderDetached(void) = 0;
|
||||
virtual void StartAnimation(void) = 0;
|
||||
virtual void Flush(void) = 0;
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cFadable
|
||||
******************************************************************/
|
||||
class cFadable {
|
||||
protected:
|
||||
cFadable(void) {};
|
||||
~cFadable(void) {};
|
||||
public:
|
||||
virtual bool Detached(void) = 0;
|
||||
virtual int Delay(void) = 0;
|
||||
virtual int FadeTime(void) = 0;
|
||||
virtual void SetTransparency(int transparency, bool force = false) = 0;
|
||||
virtual void Flush(void) = 0;
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cShiftable
|
||||
******************************************************************/
|
||||
class cShiftable {
|
||||
protected:
|
||||
cShiftable(void) {};
|
||||
~cShiftable(void) {};
|
||||
public:
|
||||
virtual bool Detached(void) = 0;
|
||||
virtual int Delay(void) = 0;
|
||||
virtual int ShiftTime(void) = 0;
|
||||
virtual int ShiftMode(void) = 0;
|
||||
virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false) = 0;
|
||||
virtual void Flush(void) = 0;
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cBlinkable
|
||||
******************************************************************/
|
||||
class cBlinkable {
|
||||
protected:
|
||||
cBlinkable(void) {};
|
||||
~cBlinkable(void) {};
|
||||
public:
|
||||
virtual int BlinkFreq(int func) = 0;
|
||||
virtual void DoBlink(int func, bool on) = 0;
|
||||
virtual void Flush(void) = 0;
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cAnimation
|
||||
******************************************************************/
|
||||
class cAnimation : public cThread, public cListObject {
|
||||
private:
|
||||
cCondWait sleepWait;
|
||||
cScrollable *scrollable;
|
||||
cDetachable *detachable;
|
||||
cFadable *fadable;
|
||||
cShiftable *shiftable;
|
||||
cBlinkable *blinkable;
|
||||
bool waitOnWakeup;
|
||||
bool doAnimation;
|
||||
bool modeIn;
|
||||
int blinkFunc;
|
||||
cPoint shiftstart;
|
||||
cPoint shiftend;
|
||||
void Sleep(int duration);
|
||||
void Wait(void);
|
||||
void Scroll(void);
|
||||
void Detach(void);
|
||||
void Blink(void);
|
||||
protected:
|
||||
virtual void Action(void);
|
||||
public:
|
||||
cAnimation(cScrollable *scrollable);
|
||||
cAnimation(cDetachable *detachable, bool wait, bool animation);
|
||||
cAnimation(cFadable *fadable, bool fadein);
|
||||
cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin);
|
||||
cAnimation(cBlinkable *blinkable, int func);
|
||||
~cAnimation(void);
|
||||
void WakeUp(void);
|
||||
void Fade(void);
|
||||
void Shift(void);
|
||||
void Stop(bool deletePixmaps);
|
||||
};
|
||||
|
||||
#endif //__ANIMATION_H
|
||||
767
coreengine/area.c
Normal file
767
coreengine/area.c
Normal file
@@ -0,0 +1,767 @@
|
||||
#include "area.h"
|
||||
#include "../config.h"
|
||||
|
||||
/******************************************************************
|
||||
* cAreaNode
|
||||
******************************************************************/
|
||||
cAreaNode::cAreaNode(void) {
|
||||
globals = NULL;
|
||||
isTab = false;
|
||||
activeTab = false;
|
||||
}
|
||||
|
||||
cAreaNode::~cAreaNode(void) {
|
||||
}
|
||||
|
||||
void cAreaNode::SetContainer(int x, int y, int width, int height) {
|
||||
container.SetX(x);
|
||||
container.SetY(y);
|
||||
container.SetWidth(width);
|
||||
container.SetHeight(height);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cArea
|
||||
******************************************************************/
|
||||
cArea::cArea(void) {
|
||||
sdOsd = NULL;
|
||||
init = true;
|
||||
isBackgroundArea = false;
|
||||
attribs = new cAreaAttribs((int)eAreaAttribs::count);
|
||||
scrolling = false;
|
||||
isScrolling = false;
|
||||
scrollFunc = NULL;
|
||||
blinking = false;
|
||||
areaContainer = NULL;
|
||||
pix = NULL;
|
||||
}
|
||||
|
||||
cArea::cArea(const cArea &other) {
|
||||
sdOsd = other.sdOsd;
|
||||
init = true;
|
||||
isBackgroundArea = false;
|
||||
pix = NULL;
|
||||
globals = other.globals;
|
||||
attribs = new cAreaAttribs(*other.attribs);
|
||||
//area container is set from outside during cloning of areacontainer
|
||||
areaContainer = NULL;
|
||||
//scrolling is set from outside by ScrollFunc(), see below
|
||||
scrolling = other.scrolling;
|
||||
isScrolling = false;
|
||||
blinking = false;
|
||||
scrollFunc = NULL;
|
||||
|
||||
for (cFunction *func = other.functions.First(); func; func = other.functions.Next(func)) {
|
||||
if (cFuncFill *f = dynamic_cast<cFuncFill*>(func)) {
|
||||
cFuncFill *fFill = new cFuncFill(*f);
|
||||
fFill->SetOwner(this);
|
||||
functions.Add(fFill);
|
||||
} else if (cFuncDrawRectangle *f = dynamic_cast<cFuncDrawRectangle*>(func)) {
|
||||
cFuncDrawRectangle *fDrawRect = new cFuncDrawRectangle(*f);
|
||||
fDrawRect->SetOwner(this);
|
||||
functions.Add(fDrawRect);
|
||||
} else if (cFuncDrawEllipse *f = dynamic_cast<cFuncDrawEllipse*>(func)) {
|
||||
cFuncDrawEllipse *fDrawEllipse = new cFuncDrawEllipse(*f);
|
||||
fDrawEllipse->SetOwner(this);
|
||||
functions.Add(fDrawEllipse);
|
||||
} else if (cFuncDrawSlope *f = dynamic_cast<cFuncDrawSlope*>(func)) {
|
||||
cFuncDrawSlope *fDrawSlope = new cFuncDrawSlope(*f);
|
||||
fDrawSlope->SetOwner(this);
|
||||
functions.Add(fDrawSlope);
|
||||
} else if (cFuncDrawText *f = dynamic_cast<cFuncDrawText*>(func)) {
|
||||
cFuncDrawText *fDrawText = new cFuncDrawText(*f);
|
||||
fDrawText->SetOwner(this);
|
||||
functions.Add(fDrawText);
|
||||
} else if (cFuncDrawTextVertical *f = dynamic_cast<cFuncDrawTextVertical*>(func)) {
|
||||
cFuncDrawTextVertical *fDrawTextVertical = new cFuncDrawTextVertical(*f);
|
||||
fDrawTextVertical->SetOwner(this);
|
||||
functions.Add(fDrawTextVertical);
|
||||
} else if (cFuncDrawTextBox *f = dynamic_cast<cFuncDrawTextBox*>(func)) {
|
||||
cFuncDrawTextBox *fDrawTextBox = new cFuncDrawTextBox(*f);
|
||||
fDrawTextBox->SetOwner(this);
|
||||
functions.Add(fDrawTextBox);
|
||||
} else if (cFuncDrawImage *f = dynamic_cast<cFuncDrawImage*>(func)) {
|
||||
cFuncDrawImage *fDrawImage = new cFuncDrawImage(*f);
|
||||
fDrawImage->SetOwner(this);
|
||||
functions.Add(fDrawImage);
|
||||
} else {
|
||||
esyslog("skindesigner: ERROR: unknown function in area cloning!!!");
|
||||
}
|
||||
}
|
||||
|
||||
//func references have to be set from outside if already cached clone is wanted
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->CacheFuncReferences();
|
||||
}
|
||||
if (scrolling) {
|
||||
SetScrollFunc();
|
||||
}
|
||||
}
|
||||
|
||||
cArea::~cArea(void) {
|
||||
StopBlinkers();
|
||||
delete attribs;
|
||||
}
|
||||
|
||||
void cArea::SetGlobals(cGlobals *globals) {
|
||||
this->globals = globals;
|
||||
attribs->SetGlobals(globals);
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->SetGlobals(globals);
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {
|
||||
attribs->SetTokenContainer(tokenContainer);
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->SetTokenContainer(tokenContainer);
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
|
||||
attribs->SetTokenContainerDeep(tokenContainer);
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->SetTokenContainerDeep(tokenContainer);
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::SetAttributes(vector<stringpair> &attributes) {
|
||||
attribs->Set(attributes);
|
||||
}
|
||||
|
||||
bool cArea::ValidFunction(const char *func) {
|
||||
if (!strcmp(func, "fill")) return true;
|
||||
if (!strcmp(func, "drawtext")) return true;
|
||||
if (!strcmp(func, "drawtextbox")) return true;
|
||||
if (!strcmp(func, "drawtextvertical")) return true;
|
||||
if (!strcmp(func, "drawimage")) return true;
|
||||
if (!strcmp(func, "drawrectangle")) return true;
|
||||
if (!strcmp(func, "drawellipse")) return true;
|
||||
if (!strcmp(func, "drawslope")) return true;
|
||||
esyslog("skindesigner: unknown function \"%s\"", func);
|
||||
return false;
|
||||
}
|
||||
|
||||
cFunction *cArea::AddFunction(const char *name, vector<stringpair> attribs, cFuncLoop *loopFunc) {
|
||||
cFunction *f = NULL;
|
||||
if (!strcmp(name, "fill")) {
|
||||
f = new cFuncFill(this, (int)eFillAttribs::count);
|
||||
} else if (!strcmp(name, "drawrectangle")) {
|
||||
f = new cFuncDrawRectangle(this, (int)eDrawRectangleAttribs::count);
|
||||
} else if (!strcmp(name, "drawellipse")) {
|
||||
f = new cFuncDrawEllipse(this, (int)eDrawEllipseAttribs::count);
|
||||
} else if (!strcmp(name, "drawslope")) {
|
||||
f = new cFuncDrawSlope(this, (int)eDrawSlopeAttribs::count);
|
||||
} else if (!strcmp(name, "drawtext")) {
|
||||
f = new cFuncDrawText(this, (int)eDrawTextAttribs::count);
|
||||
} else if (!strcmp(name, "drawtextvertical")) {
|
||||
f = new cFuncDrawTextVertical(this, (int)eDrawTextAttribs::count);
|
||||
} else if (!strcmp(name, "drawtextbox")) {
|
||||
f = new cFuncDrawTextBox(this, (int)eDrawTextBoxAttribs::count);
|
||||
} else if (!strcmp(name, "drawimage")) {
|
||||
f = new cFuncDrawImage(this, (int)eDrawImageAttribs::count);
|
||||
} else if (!strcmp(name, "loop")) {
|
||||
f = new cFuncLoop(this, (int)eLoopAttribs::count);
|
||||
}
|
||||
if (!f) {
|
||||
esyslog("skindesigner: TODO: function \"%s\" not implemented", name);
|
||||
return NULL;
|
||||
}
|
||||
f->Set(attribs);
|
||||
if (!loopFunc)
|
||||
functions.Add(f);
|
||||
else
|
||||
loopFunc->AddFunction(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
cFunction *cArea::GetFunction(const char *name) {
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
const char *funcName = f->Name();
|
||||
if (funcName && !strcmp(funcName, name)) {
|
||||
return f;
|
||||
}
|
||||
cFuncLoop *loopFunc = dynamic_cast<cFuncLoop*>(f);
|
||||
if (loopFunc) {
|
||||
cFunction *lf = loopFunc->GetFunction(name);
|
||||
if (lf)
|
||||
return lf;
|
||||
}
|
||||
}
|
||||
if (!areaContainer)
|
||||
return NULL;
|
||||
return areaContainer->GetFunction(name);
|
||||
}
|
||||
|
||||
void cArea::SetX(int x) {
|
||||
attribs->SetX(x);
|
||||
}
|
||||
|
||||
void cArea::SetY(int y) {
|
||||
attribs->SetY(y);
|
||||
}
|
||||
|
||||
void cArea::SetWidth(int width) {
|
||||
attribs->SetWidth(width);
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::SetHeight(int height) {
|
||||
attribs->SetHeight(height);
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::Cache(void) {
|
||||
attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->Cache();
|
||||
attribs->CheckDynamic();
|
||||
isBackgroundArea = attribs->BackgroundArea();
|
||||
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
if (!attribs->Dynamic()) {
|
||||
f->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
} else {
|
||||
f->SetContainer(0, 0, -1, -1);
|
||||
}
|
||||
f->Cache();
|
||||
}
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->CacheFuncReferences();
|
||||
}
|
||||
if (scrolling) {
|
||||
SetScrollFunc();
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::Close(void) {
|
||||
StopBlinkers();
|
||||
if (pix) {
|
||||
sdOsd->DestroyPixmap(pix);
|
||||
pix = NULL;
|
||||
}
|
||||
init = true;
|
||||
}
|
||||
|
||||
void cArea::Clear(void) {
|
||||
if (!init && isBackgroundArea) {
|
||||
return;
|
||||
}
|
||||
if (pix) {
|
||||
pix->Fill(clrTransparent);
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::Hide(void) {
|
||||
StopBlinkers();
|
||||
if (pix) {
|
||||
pix->SetLayer(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::Show(void) {
|
||||
StartBlinkers();
|
||||
if (pix) {
|
||||
pix->SetLayer(attribs->Layer());
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::Render(void) {
|
||||
if (attribs->DoDebug())
|
||||
Debug();
|
||||
|
||||
if (init) {
|
||||
InitFunctions();
|
||||
init = false;
|
||||
}
|
||||
|
||||
if (!isScrolling && scrollFunc && attribs->Orientation() == (int)eOrientation::horizontal) {
|
||||
scrollFunc->Scrolling(false);
|
||||
} else if (isScrolling && scrollFunc && attribs->Orientation() == (int)eOrientation::horizontal) {
|
||||
scrollFunc->Scrolling(true);
|
||||
}
|
||||
|
||||
if (!pix) {
|
||||
if (!IsTab())
|
||||
CreatePixmap();
|
||||
else {
|
||||
int overlap = ScrollHeight();
|
||||
if (overlap > 0) {
|
||||
cRect drawport;
|
||||
drawport.SetX(0);
|
||||
drawport.SetY(0);
|
||||
drawport.SetWidth(attribs->Width());
|
||||
drawport.SetHeight(overlap + attribs->Height());
|
||||
CreatePixmap(drawport);
|
||||
} else {
|
||||
CreatePixmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
if (f->DoDebug())
|
||||
f->Debug();
|
||||
if (!f->DoExecute())
|
||||
continue;
|
||||
if (pix) {
|
||||
f->Render(pix);
|
||||
}
|
||||
}
|
||||
|
||||
StartBlinkers();
|
||||
}
|
||||
|
||||
bool cArea::Execute(void) {
|
||||
return attribs->DoExecute();
|
||||
}
|
||||
|
||||
void cArea::SetTransparency(int transparency, bool absolute) {
|
||||
if (transparency < 0 || transparency > 100)
|
||||
return;
|
||||
int alpha = (100 - transparency)*255/100;
|
||||
if (!absolute) {
|
||||
int pixTransparency = attribs->Transparency();
|
||||
if (pixTransparency > 0) {
|
||||
alpha = (100 - pixTransparency) * alpha / 100;
|
||||
}
|
||||
}
|
||||
if (pix) {
|
||||
pix->SetAlpha(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
bool cArea::Scrolling(void) {
|
||||
if (!scrolling)
|
||||
return false;
|
||||
if (!Execute())
|
||||
return false;
|
||||
if (ScrollOrientation() == eOrientation::horizontal) {
|
||||
if (!scrollFunc)
|
||||
return false;
|
||||
if (scrollFunc->X() + scrollFunc->FuncWidth() > attribs->Width())
|
||||
return true;
|
||||
} else if (ScrollOrientation() == eOrientation::vertical) {
|
||||
int maxHeight = 0;
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
int funcHeight = f->FuncY() + f->FuncHeight();
|
||||
if (funcHeight > maxHeight)
|
||||
maxHeight = funcHeight;
|
||||
}
|
||||
if (maxHeight > attribs->Height())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int cArea::ScrollWidth(void) {
|
||||
if (!scrollFunc)
|
||||
return 0;
|
||||
return scrollFunc->X() + scrollFunc->FuncWidth() + 10 - attribs->Width();
|
||||
}
|
||||
|
||||
int cArea::ScrollHeight(void) {
|
||||
int maxHeight = 0;
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
if (!f->DoExecute())
|
||||
continue;
|
||||
int funcHeight = f->FuncY() + f->FuncHeight();
|
||||
if (funcHeight > maxHeight)
|
||||
maxHeight = funcHeight;
|
||||
}
|
||||
return maxHeight - attribs->Height();
|
||||
}
|
||||
|
||||
int cArea::ScrollDelay(void) {
|
||||
return attribs->Delay();
|
||||
}
|
||||
|
||||
eScrollMode cArea::ScrollMode(void) {
|
||||
return (eScrollMode)attribs->Mode();
|
||||
}
|
||||
|
||||
eScrollSpeed cArea::ScrollSpeed(void) {
|
||||
return (eScrollSpeed)attribs->ScrollSpeed();
|
||||
}
|
||||
|
||||
eOrientation cArea::ScrollOrientation(void) {
|
||||
return (eOrientation)attribs->Orientation();
|
||||
}
|
||||
|
||||
void cArea::StartScrolling(void) {
|
||||
cRect drawport;
|
||||
drawport.SetX(0);
|
||||
drawport.SetY(0);
|
||||
if (ScrollOrientation() == eOrientation::horizontal) {
|
||||
drawport.SetWidth(ScrollWidth() + attribs->Width());
|
||||
drawport.SetHeight(attribs->Height());
|
||||
} else if (ScrollOrientation() == eOrientation::vertical) {
|
||||
drawport.SetWidth(attribs->Width());
|
||||
drawport.SetHeight(ScrollHeight() + attribs->Height() + 10);
|
||||
}
|
||||
isScrolling = true;
|
||||
CreatePixmap(drawport);
|
||||
Render();
|
||||
}
|
||||
|
||||
void cArea::StopScrolling(void) {
|
||||
isScrolling = false;
|
||||
if (pix && !(pix->ViewPort().Size() == pix->DrawPort().Size())) {
|
||||
sdOsd->DestroyPixmap(pix);
|
||||
pix = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::SetViewPort(cRect &vp) {
|
||||
if (!pix)
|
||||
return;
|
||||
pix->SetViewPort(vp);
|
||||
}
|
||||
|
||||
void cArea::SetPosition(cPoint &pos, cPoint &ref) {
|
||||
if (!pix)
|
||||
return;
|
||||
int x = (attribs->X() - ref.X()) + pos.X();
|
||||
int y = (attribs->Y() - ref.Y()) + pos.Y();
|
||||
pix->SetViewPort(cRect(x, y, pix->ViewPort().Width(), pix->ViewPort().Height()));
|
||||
}
|
||||
|
||||
void cArea::SetDrawPort(cPoint &point) {
|
||||
if (!pix)
|
||||
return;
|
||||
pix->SetDrawPortPoint(point);
|
||||
}
|
||||
|
||||
cRect cArea::ViewPort(void) {
|
||||
if (!pix)
|
||||
return cRect::Null;
|
||||
cRect vp = pix->ViewPort();
|
||||
return vp;
|
||||
}
|
||||
|
||||
cRect cArea::CoveringArea(void) {
|
||||
return ViewPort();
|
||||
}
|
||||
|
||||
cRect cArea::DrawPort(void) {
|
||||
if (!pix)
|
||||
return cRect::Null;
|
||||
cRect dp = pix->DrawPort();
|
||||
return dp;
|
||||
}
|
||||
|
||||
int cArea::BlinkFreq(int func) {
|
||||
cFunction *blinkFunc = functions.Get(func);
|
||||
if (!blinkFunc)
|
||||
return -1;
|
||||
return blinkFunc->BlinkFreq();
|
||||
}
|
||||
|
||||
void cArea::DoBlink(int func, bool on) {
|
||||
cFunction *blinker = functions.Get(func);
|
||||
if (!blinker)
|
||||
return;
|
||||
if (on) {
|
||||
if (pix) {
|
||||
blinker->Render(pix);
|
||||
}
|
||||
} else {
|
||||
cRect blinkRect = cRect(blinker->GetX((eAlign)blinker->Align(), 0, 0),
|
||||
blinker->GetY((eAlign)blinker->Valign(), 0, 0),
|
||||
blinker->FuncWidth(),
|
||||
blinker->FuncHeight());
|
||||
if (pix) {
|
||||
pix->DrawRectangle(blinkRect, clrTransparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::Debug(bool full) {
|
||||
esyslog("skindesigner: --> area");
|
||||
esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->Debug();
|
||||
if (!full)
|
||||
return;
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->Debug();
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::Flush(void) {
|
||||
sdOsd->Flush();
|
||||
}
|
||||
/******************************************************************
|
||||
* Private Functions
|
||||
******************************************************************/
|
||||
void cArea::InitFunctions(void) {
|
||||
if (!attribs->Dynamic())
|
||||
return;
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
f->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::CreatePixmap(cRect drawPort) {
|
||||
if (pix) {
|
||||
sdOsd->DestroyPixmap(pix);
|
||||
pix = NULL;
|
||||
}
|
||||
if (attribs->Width() <=0 || attribs->Height() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int layer = attribs->Layer();
|
||||
cRect viewPort(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
pix = sdOsd->CreatePixmap(layer, viewPort, drawPort);
|
||||
if (pix)
|
||||
pix->Clear();
|
||||
|
||||
int pixTransparency = attribs->Transparency();
|
||||
if (pixTransparency > 0) {
|
||||
SetTransparency(pixTransparency, true);
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::SetScrollFunc(void) {
|
||||
//if area has only one function, take this anyway
|
||||
if (functions.Count() == 1) {
|
||||
scrollFunc = functions.First();
|
||||
return;
|
||||
}
|
||||
//else use scrollelement name
|
||||
const char *scrollFuncName = attribs->GetScrollElement();
|
||||
if (!scrollFuncName)
|
||||
return;
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
if (!f->Name())
|
||||
continue;
|
||||
if (!strcmp(f->Name(), scrollFuncName)) {
|
||||
scrollFunc = f;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::StartBlinkers(void) {
|
||||
if (blinking)
|
||||
return;
|
||||
blinking = true;
|
||||
int func = 0;
|
||||
for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
|
||||
if (!f->DoExecute()) {
|
||||
func++;
|
||||
continue;
|
||||
}
|
||||
if (f->Blinking()) {
|
||||
cAnimation *blink = new cAnimation((cBlinkable*)this, func);
|
||||
blinkers.Add(blink);
|
||||
blink->Start();
|
||||
}
|
||||
func++;
|
||||
}
|
||||
}
|
||||
|
||||
void cArea::StopBlinkers(void) {
|
||||
blinking = false;
|
||||
blinkers.Clear();
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cAreaContainer
|
||||
******************************************************************/
|
||||
cAreaContainer::cAreaContainer(void) {
|
||||
attribs = new cAreaContainerAttribs((int)eAreaContainerAttribs::count);
|
||||
}
|
||||
|
||||
cAreaContainer::cAreaContainer(const cAreaContainer &other) {
|
||||
globals = other.globals;
|
||||
attribs = new cAreaContainerAttribs(*other.attribs);
|
||||
for (cArea *area = other.areas.First(); area; area = other.areas.Next(area)) {
|
||||
cArea *a = new cArea(*area);
|
||||
a->SetAreaContainer(this);
|
||||
areas.Add(a);
|
||||
}
|
||||
}
|
||||
|
||||
cAreaContainer::~cAreaContainer(void) {
|
||||
delete attribs;
|
||||
}
|
||||
|
||||
void cAreaContainer::SetAttributes(vector<stringpair> &attributes) {
|
||||
attribs->Set(attributes);
|
||||
}
|
||||
|
||||
void cAreaContainer::SetGlobals(cGlobals *globals) {
|
||||
this->globals = globals;
|
||||
attribs->SetGlobals(globals);
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetGlobals(globals);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {
|
||||
attribs->SetTokenContainer(tokenContainer);
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetTokenContainer(tokenContainer);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
|
||||
attribs->SetTokenContainerDeep(tokenContainer);
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetTokenContainerDeep(tokenContainer);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::AddArea(cArea *area) {
|
||||
area->SetAreaContainer(this);
|
||||
areas.Add(area);
|
||||
}
|
||||
|
||||
cFunction *cAreaContainer::GetFunction(const char *name) {
|
||||
cFunction *fRef = NULL;
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
fRef = area->GetFunction(name);
|
||||
if (fRef)
|
||||
return fRef;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cAreaContainer::SetX(int x) {
|
||||
attribs->SetX(x);
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetX(x);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::SetY(int y) {
|
||||
attribs->SetY(y);
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetY(y);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::SetWidth(int width) {
|
||||
attribs->SetWidth(width);
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetWidth(width);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::SetHeight(int height) {
|
||||
attribs->SetHeight(height);
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetHeight(height);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::Cache(void) {
|
||||
attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->Cache();
|
||||
int x = attribs->X() > -1 ? attribs->X() : container.X();
|
||||
int y = attribs->Y() > -1 ? attribs->Y() : container.Y();
|
||||
int width = attribs->Width() > -1 ? attribs->Width() : container.Width();
|
||||
int height = attribs->Height() > -1 ? attribs->Height() : container.Height();
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetContainer(x, y, width, height);
|
||||
if (attribs->Width() > -1) {
|
||||
area->SetWidth(width);
|
||||
}
|
||||
if (attribs->Height() > -1) {
|
||||
area->SetHeight(height);
|
||||
}
|
||||
area->Cache();
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::Close(void) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::Clear(void) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::Hide(void) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::Show(void) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::Render(void) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
if (area->Execute())
|
||||
area->Render();
|
||||
}
|
||||
}
|
||||
|
||||
bool cAreaContainer::Execute(void) {
|
||||
return attribs->DoExecute();
|
||||
}
|
||||
|
||||
void cAreaContainer::SetTransparency(int transparency, bool absolute) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetTransparency(transparency, absolute);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::SetViewPort(cRect &vp) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetViewPort(vp);
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainer::SetPosition(cPoint &pos, cPoint &ref) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->SetPosition(pos, ref);
|
||||
}
|
||||
}
|
||||
|
||||
cRect cAreaContainer::CoveringArea(void) {
|
||||
cRect unionArea;
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
unionArea.Combine(area->CoveringArea());
|
||||
}
|
||||
return unionArea;
|
||||
}
|
||||
|
||||
bool cAreaContainer::Scrolling(void) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
if (area->Scrolling())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
cArea *cAreaContainer::ScrollingArea(void) {
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
if (area->Execute() && area->Scrolling())
|
||||
return area;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cAreaContainer::Debug(bool full) {
|
||||
esyslog("skindesigner: --> area container");
|
||||
esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->Debug();
|
||||
if (!full)
|
||||
return;
|
||||
for (cArea *area = areas.First(); area; area = areas.Next(area)) {
|
||||
area->Debug(full);
|
||||
}
|
||||
}
|
||||
178
coreengine/area.h
Normal file
178
coreengine/area.h
Normal file
@@ -0,0 +1,178 @@
|
||||
#ifndef __TEMPLATEAREA_H
|
||||
#define __TEMPLATEAREA_H
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "osdwrapper.h"
|
||||
#include "definitions.h"
|
||||
#include "globals.h"
|
||||
#include "../libskindesignerapi/tokencontainer.h"
|
||||
#include "attributes.h"
|
||||
#include "functions.h"
|
||||
#include "animation.h"
|
||||
|
||||
class cArea;
|
||||
/******************************************************************
|
||||
* cAreaNode
|
||||
******************************************************************/
|
||||
class cAreaNode : public cListObject {
|
||||
protected:
|
||||
cGlobals *globals;
|
||||
cRect container;
|
||||
bool isTab;
|
||||
bool activeTab;
|
||||
public:
|
||||
cAreaNode(void);
|
||||
virtual ~cAreaNode(void);
|
||||
virtual void SetGlobals(cGlobals *globals) {};
|
||||
virtual void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {};
|
||||
virtual void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {};
|
||||
void SetContainer(int x, int y, int width, int height);
|
||||
virtual void SetAttributes(vector<stringpair> &attributes) {};
|
||||
virtual void SetX(int x) {};
|
||||
virtual void SetY(int y) {};
|
||||
virtual void SetWidth(int width) {};
|
||||
virtual void SetHeight(int height) {};
|
||||
void SetTab(void) { isTab = true; };
|
||||
bool IsTab(void) { return isTab; };
|
||||
void SetActiveTab(bool active) { activeTab = active; };
|
||||
bool ActiveTab(void) { return activeTab; };
|
||||
virtual int GetWidth(void) { return 0; };
|
||||
virtual void Cache(void) {};
|
||||
virtual void Close(void) {};
|
||||
virtual void Clear(void) {};
|
||||
virtual void Hide(void) {};
|
||||
virtual void Show(void) {};
|
||||
virtual void Render(void) {};
|
||||
virtual bool Execute(void) { return true; };
|
||||
virtual void SetTransparency(int transparency, bool absolute = false) {};
|
||||
virtual void SetViewPort(cRect &vp) {};
|
||||
virtual void SetPosition(cPoint &pos, cPoint &ref) {};
|
||||
virtual cRect CoveringArea(void) { return cRect::Null; };
|
||||
virtual bool Scrolling(void) { return false; };
|
||||
virtual cArea *ScrollingArea(void) { return NULL; };
|
||||
virtual cFunction *GetFunction(const char *name) { return NULL; };
|
||||
virtual const char *Name(void) { return NULL; };
|
||||
virtual bool BackgroundArea(void) { return false; };
|
||||
virtual void Debug(bool full = false) {};
|
||||
};
|
||||
|
||||
class cAreaContainer;
|
||||
/******************************************************************
|
||||
* cArea
|
||||
******************************************************************/
|
||||
class cArea : public cAreaNode, public cScrollable, public cBlinkable {
|
||||
private:
|
||||
cSdOsd *sdOsd;
|
||||
bool init;
|
||||
bool isBackgroundArea;
|
||||
cPixmap *pix;
|
||||
cAreaAttribs *attribs;
|
||||
cAreaContainer *areaContainer;
|
||||
cList<cFunction> functions;
|
||||
bool scrolling;
|
||||
bool isScrolling;
|
||||
cFunction *scrollFunc;
|
||||
cList<cAnimation> blinkers;
|
||||
bool blinking;
|
||||
void InitFunctions(void);
|
||||
void CreatePixmap(cRect drawPort = cRect::Null);
|
||||
void SetScrollFunc(void);
|
||||
void StartBlinkers(void);
|
||||
void StopBlinkers(void);
|
||||
public:
|
||||
cArea(void);
|
||||
cArea(const cArea &other);
|
||||
virtual ~cArea(void);
|
||||
void SetOsd(cSdOsd *osd) { sdOsd = osd; };
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void SetAttributes(vector<stringpair> &attributes);
|
||||
void SetScrolling(void) { scrolling = true; };
|
||||
void SetAreaContainer(cAreaContainer *ac) { areaContainer = ac; };
|
||||
bool ValidFunction(const char *func);
|
||||
cFunction *AddFunction(const char *name, vector<stringpair> attribs, cFuncLoop *loopFunc = NULL);
|
||||
cFunction *GetFunction(const char *name);
|
||||
void SetX(int x);
|
||||
void SetY(int y);
|
||||
void SetWidth(int width);
|
||||
void SetHeight(int height);
|
||||
void Cache(void);
|
||||
int GetWidth(void) { return attribs->Width(); };
|
||||
void Close(void);
|
||||
void Clear(void);
|
||||
void Hide(void);
|
||||
void Show(void);
|
||||
void Render(void);
|
||||
bool Execute(void);
|
||||
void SetTransparency(int transparency, bool absolute = false);
|
||||
cRect CoveringArea(void);
|
||||
//Scrollable
|
||||
bool Scrolling(void);
|
||||
int ScrollWidth(void);
|
||||
int ScrollHeight(void);
|
||||
int ScrollDelay(void);
|
||||
eScrollMode ScrollMode(void);
|
||||
eScrollSpeed ScrollSpeed(void);
|
||||
eOrientation ScrollOrientation(void);
|
||||
cArea *ScrollingArea(void) { return this; };
|
||||
void StartScrolling(void);
|
||||
void StopScrolling(void);
|
||||
cRect ViewPort(void);
|
||||
void SetDrawPort(cPoint &point);
|
||||
void SetViewPort(cRect &vp);
|
||||
void SetPosition(cPoint &pos, cPoint &ref);
|
||||
cRect DrawPort(void);
|
||||
int ScrollStep(void) { return attribs->ScrollStep(); };
|
||||
//Blinkable
|
||||
int BlinkFreq(int func);
|
||||
void DoBlink(int func, bool on);
|
||||
//Common
|
||||
const char *Name(void) { return attribs->Name(); };
|
||||
bool BackgroundArea(void) { return attribs->BackgroundArea(); };
|
||||
void Flush(void);
|
||||
void Debug(bool full = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cAreaContainer
|
||||
******************************************************************/
|
||||
class cAreaContainer : public cAreaNode {
|
||||
private:
|
||||
cAreaContainerAttribs *attribs;
|
||||
cList<cArea> areas;
|
||||
public:
|
||||
cAreaContainer(void);
|
||||
cAreaContainer(const cAreaContainer &other);
|
||||
virtual ~cAreaContainer(void);
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void SetAttributes(vector<stringpair> &attributes);
|
||||
void AddArea(cArea *area);
|
||||
cFunction *GetFunction(const char *name);
|
||||
void SetX(int x);
|
||||
void SetY(int y);
|
||||
void SetWidth(int width);
|
||||
void SetHeight(int height);
|
||||
void Cache(void);
|
||||
void Close(void);
|
||||
void Clear(void);
|
||||
void Hide(void);
|
||||
void Show(void);
|
||||
void Render(void);
|
||||
bool Execute(void);
|
||||
void SetTransparency(int transparency, bool absolute = false);
|
||||
void SetViewPort(cRect &vp);
|
||||
void SetPosition(cPoint &pos, cPoint &ref);
|
||||
cRect CoveringArea(void);
|
||||
bool Scrolling(void);
|
||||
cArea *ScrollingArea(void);
|
||||
void Debug(bool full = false);
|
||||
};
|
||||
|
||||
#endif //__TEMPLATEAREA_H
|
||||
478
coreengine/attribute.c
Normal file
478
coreengine/attribute.c
Normal file
@@ -0,0 +1,478 @@
|
||||
#include "attribute.h"
|
||||
#include "../config.h"
|
||||
|
||||
/***************************************************************************
|
||||
* cAttributes
|
||||
***************************************************************************/
|
||||
cAttributes::cAttributes(int numAttributes) {
|
||||
globals = NULL;
|
||||
tokenContainer = NULL;
|
||||
numAttribs = (int)eCommonAttribs::count + numAttributes;
|
||||
attribs = new int[numAttribs];
|
||||
for (int i=0; i < numAttribs; i++)
|
||||
attribs[i] = ATTR_UNKNOWN;
|
||||
attribCtors = new cNumericExpr*[numAttribs];
|
||||
for (int i=0; i < numAttribs; i++)
|
||||
attribCtors[i] = NULL;
|
||||
cond = NULL;
|
||||
SetCommonAttributesDefs();
|
||||
}
|
||||
|
||||
cAttributes::cAttributes(const cAttributes &other) : cAttributes(other.numAttribs - (int)eCommonAttribs::count){
|
||||
globals = other.globals;
|
||||
for (int i=0; i < numAttribs; i++) {
|
||||
attribs[i] = other.attribs[i];
|
||||
if (other.attribCtors[i]) {
|
||||
attribCtors[i] = new cNumericExpr(*other.attribCtors[i]);
|
||||
attribCtors[i]->SetContainer(&container);
|
||||
}
|
||||
}
|
||||
cond = NULL;
|
||||
if (other.cond) {
|
||||
cond = new cCondition(*other.cond);
|
||||
}
|
||||
attribIDs = other.attribIDs;
|
||||
attribNames = other.attribNames;
|
||||
}
|
||||
|
||||
cAttributes::~cAttributes(void) {
|
||||
delete[] attribs;
|
||||
for (int i=0; i < numAttribs; i++) {
|
||||
delete attribCtors[i];
|
||||
}
|
||||
delete[] attribCtors;
|
||||
delete cond;
|
||||
}
|
||||
|
||||
void cAttributes::SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {
|
||||
this->tokenContainer = tokenContainer;
|
||||
}
|
||||
|
||||
void cAttributes::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
|
||||
this->tokenContainer = tokenContainer;
|
||||
if (cond) {
|
||||
cond->SetTokenContainer(tokenContainer);
|
||||
}
|
||||
for (int i=0; i < numAttribs; i++) {
|
||||
if (!attribCtors[i])
|
||||
continue;
|
||||
attribCtors[i]->SetTokenContainer(tokenContainer);
|
||||
}
|
||||
}
|
||||
|
||||
void cAttributes::SetContainer(int x, int y, int width, int height) {
|
||||
container.SetX(x);
|
||||
container.SetY(y);
|
||||
container.SetWidth(width);
|
||||
container.SetHeight(height);
|
||||
}
|
||||
|
||||
void cAttributes::SetX(int x) {
|
||||
attribs[(int)eCommonAttribs::x] = x;
|
||||
}
|
||||
|
||||
void cAttributes::SetY(int y) {
|
||||
attribs[(int)eCommonAttribs::y] = y;
|
||||
}
|
||||
|
||||
void cAttributes::SetWidth(int width) {
|
||||
attribs[(int)eCommonAttribs::width] = width;
|
||||
}
|
||||
|
||||
void cAttributes::SetHeight(int height) {
|
||||
attribs[(int)eCommonAttribs::height] = height;
|
||||
}
|
||||
|
||||
void cAttributes::Cache(void) {
|
||||
if (cond) {
|
||||
cond->SetGlobals(globals);
|
||||
cond->SetTokenContainer(tokenContainer);
|
||||
cond->Prepare();
|
||||
}
|
||||
for (int i=0; i < numAttribs; i++) {
|
||||
if (!attribCtors[i])
|
||||
continue;
|
||||
attribCtors[i]->SetContainer(&container);
|
||||
attribCtors[i]->SetGlobals(globals);
|
||||
attribCtors[i]->SetTokenContainer(tokenContainer);
|
||||
if (attribCtors[i]->CacheStatic()) {
|
||||
int val = attribCtors[i]->GetValue();
|
||||
attribs[i] = val;
|
||||
delete attribCtors[i];
|
||||
attribCtors[i] = NULL;
|
||||
} else {
|
||||
attribCtors[i]->PrepareTokens();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cAttributes::GetValue(int id) {
|
||||
if (!attribCtors[id + (int)eCommonAttribs::count])
|
||||
return attribs[(int)id + (int)eCommonAttribs::count];
|
||||
return attribCtors[id + (int)eCommonAttribs::count]->Calculate();
|
||||
}
|
||||
|
||||
|
||||
int cAttributes::X(void) {
|
||||
int x = 0;
|
||||
if (!attribCtors[(int)eCommonAttribs::x])
|
||||
x = attribs[(int)eCommonAttribs::x];
|
||||
else
|
||||
x = attribCtors[(int)eCommonAttribs::x]->Calculate();
|
||||
x += container.X();
|
||||
return x;
|
||||
}
|
||||
|
||||
int cAttributes::Y(void) {
|
||||
int y = 0;
|
||||
if (!attribCtors[(int)eCommonAttribs::y])
|
||||
y = attribs[(int)eCommonAttribs::y];
|
||||
else
|
||||
y = attribCtors[(int)eCommonAttribs::y]->Calculate();
|
||||
y += container.Y();
|
||||
return y;
|
||||
}
|
||||
|
||||
int cAttributes::Width(void) {
|
||||
if (!attribCtors[(int)eCommonAttribs::width])
|
||||
return attribs[(int)eCommonAttribs::width];
|
||||
return attribCtors[(int)eCommonAttribs::width]->Calculate();
|
||||
}
|
||||
|
||||
int cAttributes::Height(void) {
|
||||
if (!attribCtors[(int)eCommonAttribs::height])
|
||||
return attribs[(int)eCommonAttribs::height];
|
||||
return attribCtors[(int)eCommonAttribs::height]->Calculate();
|
||||
}
|
||||
|
||||
bool cAttributes::DoExecute(void) {
|
||||
if (!cond)
|
||||
return true;
|
||||
return cond->True();
|
||||
}
|
||||
|
||||
|
||||
void cAttributes::Debug(void) {
|
||||
esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
|
||||
for (int i=0; i < numAttribs; i++) {
|
||||
if (attribs[i] != ATTR_UNKNOWN) {
|
||||
if (i == (int)eCommonAttribs::debug)
|
||||
continue;
|
||||
const char *attName = "attribute";
|
||||
if (i < (int)eCommonAttribs::count)
|
||||
attName = CommonAttributeName(i);
|
||||
else
|
||||
attName = AttributeName(i - (int)eCommonAttribs::count);
|
||||
dsyslog("skindesigner: fixed Value %s = %d", attName, attribs[i]);
|
||||
}
|
||||
if (attribCtors[i]) {
|
||||
const char *attName = "attribute";
|
||||
if (i < (int)eCommonAttribs::count)
|
||||
attName = CommonAttributeName(i);
|
||||
else
|
||||
attName = AttributeName(i - (int)eCommonAttribs::count);
|
||||
dsyslog("skindesigner: %s constructor:", attName);
|
||||
attribCtors[i]->Debug();
|
||||
}
|
||||
}
|
||||
if (cond) {
|
||||
cond->Debug();
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Protected Functions
|
||||
***************************************************************************/
|
||||
int cAttributes::CommonAttributeId(const char *att) {
|
||||
if (!strcmp(att, "condition"))
|
||||
return ATTR_COND;
|
||||
map<string, int>::iterator hit = commonAttribIDs.find(att);
|
||||
if (hit != commonAttribIDs.end())
|
||||
return hit->second;
|
||||
return ATTR_UNKNOWN;
|
||||
}
|
||||
|
||||
const char *cAttributes::CommonAttributeName(int id) {
|
||||
if (id < 0 || id >= (int)eCommonAttribs::count)
|
||||
return "";
|
||||
map<int, string>::iterator hit = commonAttribNames.find(id);
|
||||
if (hit != commonAttribNames.end())
|
||||
return hit->second.c_str();
|
||||
return "";
|
||||
}
|
||||
|
||||
int cAttributes::AttributeId(const char *att) {
|
||||
int id = CommonAttributeId(att);
|
||||
if (id != ATTR_UNKNOWN)
|
||||
return id;
|
||||
map<string, int>::iterator hit = attribIDs.find(att);
|
||||
if (hit != attribIDs.end())
|
||||
id = (int)hit->second + (int)eCommonAttribs::count;
|
||||
return id;
|
||||
}
|
||||
|
||||
const char *cAttributes::AttributeName(int id) {
|
||||
map<int, string>::iterator hit = attribNames.find(id);
|
||||
if (hit != attribNames.end())
|
||||
return hit->second.c_str();
|
||||
return "";
|
||||
}
|
||||
|
||||
bool cAttributes::SetCommon(int id, const char *val) {
|
||||
if (id == ATTR_COND) {
|
||||
cond = new cCondition(val);
|
||||
return true;
|
||||
}
|
||||
if (id == (int)eCommonAttribs::debug) {
|
||||
SetBool(id, val);
|
||||
return true;
|
||||
} else if (id == (int)eCommonAttribs::x || id == (int)eCommonAttribs::width) {
|
||||
attribCtors[id] = new cNumericExpr(val);
|
||||
return true;
|
||||
} else if (id == (int)eCommonAttribs::y || id == (int)eCommonAttribs::height) {
|
||||
attribCtors[id] = new cNumericExpr(val);
|
||||
attribCtors[id]->SetVertical();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cAttributes::IdEqual(int id, int compId) {
|
||||
if (compId + (int)eCommonAttribs::count == id)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void cAttributes::SetBool(int id, const char *val) {
|
||||
if (!strcmp(val, "true")) {
|
||||
attribs[id] = 1;
|
||||
} else {
|
||||
attribs[id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void cAttributes::SetViewElementMode(int id, const char *val) {
|
||||
eViewElementMode mode = eViewElementMode::regular;
|
||||
if (!strcmp(val, "light"))
|
||||
mode = eViewElementMode::light;
|
||||
attribs[id] = (int)mode;
|
||||
}
|
||||
|
||||
void cAttributes::SetShiftType(int id, const char *val) {
|
||||
eShiftType shiftType = eShiftType::none;
|
||||
if (!strcmp(val, "left"))
|
||||
shiftType = eShiftType::left;
|
||||
else if (!strcmp(val, "right"))
|
||||
shiftType = eShiftType::right;
|
||||
else if (!strcmp(val, "top"))
|
||||
shiftType = eShiftType::top;
|
||||
else if (!strcmp(val, "bottom"))
|
||||
shiftType = eShiftType::bottom;
|
||||
else {
|
||||
esyslog("skindesigner: unknown shift type \"%s\"", val);
|
||||
return;
|
||||
}
|
||||
attribs[id] = (int)shiftType;
|
||||
}
|
||||
|
||||
void cAttributes::SetShiftMode(int id, const char *val) {
|
||||
eShiftMode shiftMode = eShiftMode::linear;
|
||||
if (!strcmp(val, "slowed"))
|
||||
shiftMode = eShiftMode::slowedDown;
|
||||
attribs[id] = (int)shiftMode;
|
||||
}
|
||||
|
||||
void cAttributes::SetScrollMode(int id, const char *val) {
|
||||
eScrollMode mode = eScrollMode::none;
|
||||
if (!strcmp(val, "forthandback"))
|
||||
mode = eScrollMode::forthandback;
|
||||
else if (!strcmp(val, "carriagereturn"))
|
||||
mode = eScrollMode::carriagereturn;
|
||||
attribs[id] = (int)mode;
|
||||
}
|
||||
|
||||
void cAttributes::SetScrollSpeed(int id, const char *val) {
|
||||
eScrollSpeed speed = eScrollSpeed::medium;
|
||||
if (!strcmp(val, "slow"))
|
||||
speed = eScrollSpeed::slow;
|
||||
else if (!strcmp(val, "fast"))
|
||||
speed = eScrollSpeed::fast;
|
||||
else if (!strcmp(val, "medium"))
|
||||
speed = eScrollSpeed::medium;
|
||||
attribs[id] = (int)speed;
|
||||
}
|
||||
|
||||
void cAttributes::SetOrientation(int id, const char *val) {
|
||||
eOrientation orientation = eOrientation::none;
|
||||
if (!strcmp(val, "horizontal"))
|
||||
orientation = eOrientation::horizontal;
|
||||
else if (!strcmp(val, "vertical"))
|
||||
orientation = eOrientation::vertical;
|
||||
else if (!strcmp(val, "absolute"))
|
||||
orientation = eOrientation::absolute;
|
||||
attribs[id] = (int)orientation;
|
||||
}
|
||||
|
||||
void cAttributes::SetAlign(int id, const char *val) {
|
||||
eAlign align = eAlign::left;
|
||||
if (!strcmp(val, "center")) {
|
||||
align = eAlign::center;
|
||||
} else if (!strcmp(val, "right")) {
|
||||
align = eAlign::right;
|
||||
} else if (!strcmp(val, "top")) {
|
||||
align = eAlign::top;
|
||||
} else if (!strcmp(val, "bottom")) {
|
||||
align = eAlign::bottom;
|
||||
} else if (!strcmp(val, "left")) {
|
||||
align = eAlign::left;
|
||||
}
|
||||
attribs[id] = (int)align;
|
||||
}
|
||||
|
||||
void cAttributes::SetDirection(int id, const char *val) {
|
||||
eDirection direction = eDirection::none;
|
||||
if (!strcmp(val, "bottomup"))
|
||||
direction = eDirection::bottomup;
|
||||
else if (!strcmp(val, "topdown"))
|
||||
direction = eDirection::topdown;
|
||||
attribs[id] = (int)direction;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
***************************************************************************/
|
||||
void cAttributes::SetCommonAttributesDefs(void) {
|
||||
commonAttribIDs.insert(pair<string, int>("x", (int)eCommonAttribs::x));
|
||||
commonAttribIDs.insert(pair<string, int>("y", (int)eCommonAttribs::y));
|
||||
commonAttribIDs.insert(pair<string, int>("width", (int)eCommonAttribs::width));
|
||||
commonAttribIDs.insert(pair<string, int>("height", (int)eCommonAttribs::height));
|
||||
commonAttribIDs.insert(pair<string, int>("debug", (int)eCommonAttribs::debug));
|
||||
commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::x, "x"));
|
||||
commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::y, "y"));
|
||||
commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::width, "width"));
|
||||
commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::height, "height"));
|
||||
commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::debug, "debug"));
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* cFunction
|
||||
***************************************************************************/
|
||||
cFunction::cFunction(cArea *owner, int numAttributes) : cAttributes(numAttributes) {
|
||||
funcType = "Unknown";
|
||||
owningArea = owner;
|
||||
color = NULL;
|
||||
name = NULL;
|
||||
scrolling = false;
|
||||
}
|
||||
|
||||
cFunction::cFunction(const cFunction &other) : cAttributes(other) {
|
||||
funcType = other.funcType;
|
||||
owningArea = NULL;
|
||||
color = NULL;
|
||||
if (other.color)
|
||||
color = new cColor(*other.color);
|
||||
name = NULL;
|
||||
if (other.name)
|
||||
name = strdup(other.name);
|
||||
scrolling = other.scrolling;
|
||||
}
|
||||
|
||||
cFunction::~cFunction(void) {
|
||||
delete color;
|
||||
free(name);
|
||||
}
|
||||
|
||||
void cFunction::SetLoopInfo(cLoopInfo *loopInfo) {
|
||||
for (int i=0; i < numAttribs; i++) {
|
||||
if (!attribCtors[i])
|
||||
continue;
|
||||
attribCtors[i]->SetLoopInfo(loopInfo);
|
||||
}
|
||||
if (cond)
|
||||
cond->SetLoopInfo(loopInfo);
|
||||
}
|
||||
|
||||
void cFunction::Cache(void) {
|
||||
if (color) {
|
||||
color->SetGlobals(globals);
|
||||
color->Cache();
|
||||
}
|
||||
cAttributes::Cache();
|
||||
}
|
||||
|
||||
void cFunction::CacheFuncReferences(void) {
|
||||
for (int i=0; i < numAttribs; i++) {
|
||||
if (!attribCtors[i])
|
||||
continue;
|
||||
vector<cFactor*> refFactors = attribCtors[i]->GetRefFactors();
|
||||
for (vector<cFactor*>::iterator it = refFactors.begin(); it != refFactors.end(); it++) {
|
||||
cFactor *f = *it;
|
||||
if (!f->funcRefName)
|
||||
continue;
|
||||
cFunction *fRef = owningArea->GetFunction(f->funcRefName);
|
||||
if (fRef) {
|
||||
f->funcRef = fRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cFunction::GetX(eAlign align, int x0, int colWidth) {
|
||||
int containerWidth = colWidth > 0 ? colWidth : container.Width();
|
||||
int x = x0 + X();
|
||||
if (align == eAlign::right) {
|
||||
x = x0 + containerWidth - FuncWidth();
|
||||
} else if (align == eAlign::center) {
|
||||
x = x0 + (containerWidth - FuncWidth()) / 2;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int cFunction::GetY(eAlign valign, int y0, int rowHeight) {
|
||||
int containerHeight = rowHeight > 0 ? rowHeight : container.Height();
|
||||
int y = y0 + Y();
|
||||
if (valign == eAlign::bottom) {
|
||||
y = y0 + containerHeight - FuncHeight();
|
||||
} else if (valign == eAlign::center) {
|
||||
y = y0 + (containerHeight - FuncHeight()) / 2;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
void cFunction::Debug(void) {
|
||||
esyslog("skindesigner: ---> Function %s", funcType);
|
||||
cAttributes::Debug();
|
||||
if (name) {
|
||||
esyslog("skindesigner: name %s", name);
|
||||
}
|
||||
if (color) {
|
||||
color->Debug();
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Protected Functions
|
||||
***************************************************************************/
|
||||
|
||||
void cFunction::SetColor(const char *val) {
|
||||
color = new cColor(val);
|
||||
}
|
||||
|
||||
void cFunction::SetAnimType(int id, const char *val) {
|
||||
eAnimType animType = eAnimType::none;
|
||||
if (!strcmp(val, "blink"))
|
||||
animType = eAnimType::blink;
|
||||
else if (!strcmp(val, "animated"))
|
||||
animType = eAnimType::animated;
|
||||
attribs[id] = (int)animType;
|
||||
}
|
||||
|
||||
void cFunction::SetOverflow(int id, const char *val) {
|
||||
eOverflowType overflowType = eOverflowType::none;
|
||||
if (!strcmp(val, "linewrap"))
|
||||
overflowType = eOverflowType::wrap;
|
||||
else if (!strcmp(val, "cut"))
|
||||
overflowType = eOverflowType::cut;
|
||||
attribs[id] = (int)overflowType;
|
||||
}
|
||||
126
coreengine/attribute.h
Normal file
126
coreengine/attribute.h
Normal file
@@ -0,0 +1,126 @@
|
||||
#ifndef __ATTRIBUTE_H
|
||||
#define __ATTRIBUTE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <vdr/skins.h>
|
||||
#include "globals.h"
|
||||
#include "../libskindesignerapi/tokencontainer.h"
|
||||
#include "definitions.h"
|
||||
#include "complextypes.h"
|
||||
|
||||
class cArea;
|
||||
/******************************************************************
|
||||
* cAttributes
|
||||
******************************************************************/
|
||||
class cAttributes {
|
||||
private:
|
||||
map<string, int> commonAttribIDs;
|
||||
map<int, string> commonAttribNames;
|
||||
void SetCommonAttributesDefs(void);
|
||||
protected:
|
||||
cGlobals *globals;
|
||||
skindesignerapi::cTokenContainer *tokenContainer;
|
||||
cRect container;
|
||||
int numAttribs;
|
||||
int *attribs;
|
||||
cNumericExpr **attribCtors;
|
||||
cCondition *cond;
|
||||
map<string, int> attribIDs;
|
||||
map<int, string> attribNames;
|
||||
int CommonAttributeId(const char *att);
|
||||
const char *CommonAttributeName(int id);
|
||||
int AttributeId(const char *att);
|
||||
const char *AttributeName(int id);
|
||||
bool SetCommon(int id, const char *val);
|
||||
virtual bool IdEqual(int id, int compId);
|
||||
void SetBool(int id, const char *val);
|
||||
void SetViewElementMode(int id, const char *val);
|
||||
void SetShiftType(int id, const char *val);
|
||||
void SetShiftMode(int id, const char *val);
|
||||
void SetScrollMode(int id, const char *val);
|
||||
void SetScrollSpeed(int id, const char *val);
|
||||
void SetOrientation(int id, const char *val);
|
||||
void SetDirection(int id, const char *val);
|
||||
void SetAlign(int id, const char *val);
|
||||
public:
|
||||
cAttributes(int numAttributes);
|
||||
cAttributes(const cAttributes &other);
|
||||
virtual ~cAttributes(void);
|
||||
void SetGlobals(cGlobals *globals) { this->globals = globals; };
|
||||
void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
virtual void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
virtual void SetContainer(int x, int y, int width, int height);
|
||||
virtual void Set(vector<stringpair> &attributes) {};
|
||||
void SetX(int width);
|
||||
void SetY(int height);
|
||||
void SetWidth(int width);
|
||||
void SetHeight(int height);
|
||||
virtual void Cache(void);
|
||||
int GetValue(int id);
|
||||
int X(void);
|
||||
int Y(void);
|
||||
int Width(void);
|
||||
int Height(void);
|
||||
int DoDebug(void) { return attribs[(int)eCommonAttribs::debug] == 1 ? true : false; };
|
||||
bool DoExecute(void);
|
||||
virtual void Debug(void);
|
||||
};
|
||||
/******************************************************************
|
||||
* cLoopInfo
|
||||
******************************************************************/
|
||||
class cLoopInfo {
|
||||
public:
|
||||
int colWidth;
|
||||
int rowHeight;
|
||||
int index;
|
||||
int row;
|
||||
cLoopInfo(void) {
|
||||
colWidth = 0;
|
||||
rowHeight = 0;
|
||||
index = 0;
|
||||
row = 0;
|
||||
};
|
||||
};
|
||||
/******************************************************************
|
||||
* cFunction
|
||||
******************************************************************/
|
||||
class cFunction : public cAttributes, public cListObject {
|
||||
private:
|
||||
cArea *owningArea;
|
||||
protected:
|
||||
const char *funcType;
|
||||
cColor *color;
|
||||
char *name;
|
||||
bool scrolling;
|
||||
void SetColor(const char *val);
|
||||
void SetAnimType(int id, const char *val);
|
||||
void SetOverflow(int id, const char *val);
|
||||
public:
|
||||
cFunction(cArea *owner, int numAttributes);
|
||||
cFunction(const cFunction &other);
|
||||
virtual ~cFunction(void);
|
||||
virtual void SetLoopInfo(cLoopInfo *loopInfo);
|
||||
void SetOwner(cArea *owner) { owningArea = owner; };
|
||||
const char *Name(void) { return name; };
|
||||
virtual void Cache(void);
|
||||
void CacheFuncReferences(void);
|
||||
void Scrolling(bool scrolling) { this->scrolling = scrolling; };
|
||||
virtual void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0) {};
|
||||
virtual int FuncX(void) { return X(); };
|
||||
virtual int FuncY(void) { return Y(); };
|
||||
virtual int FuncWidth(void) { return Width(); };
|
||||
virtual int FuncHeight(void) { return Height(); };
|
||||
virtual int Align(void) { return (int)eAlign::left; };
|
||||
virtual int Valign(void) { return (int)eAlign::top; };
|
||||
int GetX(eAlign align, int x0, int colWidth);
|
||||
int GetY(eAlign valign, int y0, int rowHeight);
|
||||
virtual bool Blinking(void) { return false; };
|
||||
virtual int BlinkFreq(void) { return -1; };
|
||||
virtual void Debug(void);
|
||||
};
|
||||
|
||||
#endif //__ATTRIBUTE_H
|
||||
447
coreengine/attributes.c
Normal file
447
coreengine/attributes.c
Normal file
@@ -0,0 +1,447 @@
|
||||
#include "attributes.h"
|
||||
#include "../config.h"
|
||||
|
||||
/***************************************************************************
|
||||
* cViewAttribs
|
||||
***************************************************************************/
|
||||
cViewAttribs::cViewAttribs(int numAttributes) : cAttributes(numAttributes) {
|
||||
orientation = NULL;
|
||||
SetAttributesDefs();
|
||||
}
|
||||
|
||||
cViewAttribs::~cViewAttribs(void) {
|
||||
delete orientation;
|
||||
}
|
||||
|
||||
void cViewAttribs::Set(vector<stringpair> &attributes) {
|
||||
for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
|
||||
const char *attName = (*att).first.c_str();
|
||||
const char *attVal = (*att).second.c_str();
|
||||
int id = AttributeId(attName);
|
||||
if (id == ATTR_UNKNOWN) {
|
||||
esyslog("skindesigner: unknown view attribute \"%s\" = \"%s\"", attName, attVal);
|
||||
continue;
|
||||
}
|
||||
if (SetCommon(id, attVal))
|
||||
continue;
|
||||
if (IdEqual(id, (int)eViewAttribs::shifttype)) {
|
||||
SetShiftType(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewAttribs::shiftmode)) {
|
||||
SetShiftMode(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewAttribs::orientation)) {
|
||||
SetOrientationDynamic(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewAttribs::hideroot)) {
|
||||
SetBool(id, attVal);
|
||||
} else {
|
||||
attribCtors[id] = new cNumericExpr(attVal);
|
||||
if ( (id == (int)eViewAttribs::starty + (int)eCommonAttribs::count) ||
|
||||
(id == (int)eViewAttribs::scaletvy + (int)eCommonAttribs::count) ||
|
||||
(id == (int)eViewAttribs::scaletvheight + (int)eCommonAttribs::count) ) {
|
||||
attribCtors[id]->SetVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewAttribs::SetAttributesDefs(void) {
|
||||
attribIDs.insert(pair<string, int>("fadetime", (int)eViewAttribs::fadetime));
|
||||
attribIDs.insert(pair<string, int>("shifttime", (int)eViewAttribs::shifttime));
|
||||
attribIDs.insert(pair<string, int>("shifttype", (int)eViewAttribs::shifttype));
|
||||
attribIDs.insert(pair<string, int>("shiftmode", (int)eViewAttribs::shiftmode));
|
||||
attribIDs.insert(pair<string, int>("startx", (int)eViewAttribs::startx));
|
||||
attribIDs.insert(pair<string, int>("starty", (int)eViewAttribs::starty));
|
||||
attribIDs.insert(pair<string, int>("scaletvx", (int)eViewAttribs::scaletvx));
|
||||
attribIDs.insert(pair<string, int>("scaletvy", (int)eViewAttribs::scaletvy));
|
||||
attribIDs.insert(pair<string, int>("scaletvwidth", (int)eViewAttribs::scaletvwidth));
|
||||
attribIDs.insert(pair<string, int>("scaletvheight", (int)eViewAttribs::scaletvheight));
|
||||
attribIDs.insert(pair<string, int>("orientation", (int)eViewAttribs::orientation));
|
||||
attribIDs.insert(pair<string, int>("debuggrid", (int)eViewAttribs::debuggrid));
|
||||
attribIDs.insert(pair<string, int>("hideroot", (int)eViewAttribs::hideroot));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::fadetime, "fadetime"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::shifttime, "shifttime"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::shifttype, "shifttype"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::shiftmode, "shiftmode"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::startx, "startx"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::starty, "starty"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvx, "scaletvx"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvy, "scaletvy"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvwidth, "scaletvwidth"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvheight, "scaletvheight"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::orientation, "orientation"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::debuggrid, "debuggrid"));
|
||||
attribNames.insert(pair<int, string>((int)eViewAttribs::hideroot, "hideroot"));
|
||||
}
|
||||
|
||||
void cViewAttribs::Cache(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
cAttributes::Cache();
|
||||
if (orientation) {
|
||||
orientation->SetGlobals(globals);
|
||||
orientation->SetTokenContainer(tokenContainer);
|
||||
orientation->Cache();
|
||||
char *res = orientation->DeterminateText();
|
||||
if (res) {
|
||||
SetOrientation((int)eViewAttribs::orientation + (int)eCommonAttribs::count, res);
|
||||
}
|
||||
free(res);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewAttribs::Debug(void) {
|
||||
esyslog("skindesigner: --> View Attribs");
|
||||
cAttributes::Debug();
|
||||
}
|
||||
|
||||
eOrientation cViewAttribs::Orientation(void) {
|
||||
int orientation = GetValue((int)eViewAttribs::orientation);
|
||||
if (orientation == -1)
|
||||
return eOrientation::vertical;
|
||||
if (orientation == (int)eOrientation::none)
|
||||
return eOrientation::vertical;
|
||||
return (eOrientation)orientation;
|
||||
}
|
||||
|
||||
cRect cViewAttribs::TvFrame(void) {
|
||||
int frameX = GetValue((int)eViewAttribs::scaletvx);
|
||||
int frameY = GetValue((int)eViewAttribs::scaletvy);
|
||||
int frameWidth = GetValue((int)eViewAttribs::scaletvwidth);
|
||||
int frameHeight = GetValue((int)eViewAttribs::scaletvheight);
|
||||
if (frameX < 0 || frameY < 0 || frameWidth <= 0 || frameHeight <= 0)
|
||||
return cRect::Null;
|
||||
frameX += cOsd::OsdLeft();
|
||||
frameY += cOsd::OsdTop();
|
||||
return cRect(frameX, frameY, frameWidth, frameHeight);
|
||||
}
|
||||
|
||||
void cViewAttribs::SetOrientationDynamic(int id, const char *val) {
|
||||
if (strchr(val, '{') && strchr(val, '}')) {
|
||||
orientation = new cTextExpr(val);
|
||||
} else {
|
||||
SetOrientation(id, val);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* cViewElementAttribs
|
||||
***************************************************************************/
|
||||
cViewElementAttribs::cViewElementAttribs(int numAttributes) : cAttributes(numAttributes) {
|
||||
name = NULL;
|
||||
SetAttributesDefs();
|
||||
}
|
||||
|
||||
cViewElementAttribs::cViewElementAttribs(const cViewElementAttribs &other) : cAttributes(other) {
|
||||
name = NULL;
|
||||
}
|
||||
|
||||
cViewElementAttribs::~cViewElementAttribs(void) {
|
||||
free(name);
|
||||
}
|
||||
|
||||
void cViewElementAttribs::Set(vector<stringpair> &attributes) {
|
||||
for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
|
||||
const char *attName = (*att).first.c_str();
|
||||
const char *attVal = (*att).second.c_str();
|
||||
int id = AttributeId(attName);
|
||||
if (id == ATTR_UNKNOWN) {
|
||||
esyslog("skindesigner: unknown view element attribute \"%s\" = \"%s\"", attName, attVal);
|
||||
continue;
|
||||
}
|
||||
if (SetCommon(id, attVal))
|
||||
continue;
|
||||
if (IdEqual(id, (int)eViewElementAttribs::mode)) {
|
||||
SetViewElementMode(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewElementAttribs::shifttype)) {
|
||||
SetShiftType(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewElementAttribs::shiftmode)) {
|
||||
SetShiftMode(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewElementAttribs::orientation)) {
|
||||
SetOrientation(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewElementAttribs::name)) {
|
||||
name = strdup(attVal);
|
||||
} else {
|
||||
attribCtors[id] = new cNumericExpr(attVal);
|
||||
if (id == (int)eViewElementAttribs::starty + (int)eCommonAttribs::count) {
|
||||
attribCtors[id]->SetVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElementAttribs::SetAttributesDefs(void) {
|
||||
attribIDs.insert(pair<string, int>("delay", (int)eViewElementAttribs::delay));
|
||||
attribIDs.insert(pair<string, int>("fadetime", (int)eViewElementAttribs::fadetime));
|
||||
attribIDs.insert(pair<string, int>("shifttime", (int)eViewElementAttribs::shifttime));
|
||||
attribIDs.insert(pair<string, int>("shifttype", (int)eViewElementAttribs::shifttype));
|
||||
attribIDs.insert(pair<string, int>("shiftmode", (int)eViewElementAttribs::shiftmode));
|
||||
attribIDs.insert(pair<string, int>("startx", (int)eViewElementAttribs::startx));
|
||||
attribIDs.insert(pair<string, int>("starty", (int)eViewElementAttribs::starty));
|
||||
attribIDs.insert(pair<string, int>("orientation", (int)eViewElementAttribs::orientation));
|
||||
attribIDs.insert(pair<string, int>("mode", (int)eViewElementAttribs::mode));
|
||||
attribIDs.insert(pair<string, int>("name", (int)eViewElementAttribs::name));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::delay, "delay"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::fadetime, "fadetime"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::shifttime, "shifttime"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::shifttype, "shifttype"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::shiftmode, "shiftmode"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::startx, "startx"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::starty, "starty"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::orientation, "orientation"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::mode, "mode"));
|
||||
attribNames.insert(pair<int, string>((int)eViewElementAttribs::name, "name"));
|
||||
}
|
||||
|
||||
eOrientation cViewElementAttribs::Orientation(void) {
|
||||
int orientation = GetValue((int)eViewElementAttribs::orientation);
|
||||
if (orientation == -1)
|
||||
return eOrientation::vertical;
|
||||
if (orientation == (int)eOrientation::none)
|
||||
return eOrientation::vertical;
|
||||
return (eOrientation)orientation;
|
||||
}
|
||||
|
||||
void cViewElementAttribs::Debug(void) {
|
||||
esyslog("skindesigner: ---> View Element Attribs");
|
||||
cAttributes::Debug();
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* cViewListAttribs
|
||||
***************************************************************************/
|
||||
cViewListAttribs::cViewListAttribs(int numAttributes) : cAttributes(numAttributes) {
|
||||
determinateFont = NULL;
|
||||
SetAttributesDefs();
|
||||
}
|
||||
|
||||
cViewListAttribs::~cViewListAttribs(void) {
|
||||
free(determinateFont);
|
||||
}
|
||||
|
||||
void cViewListAttribs::Set(vector<stringpair> &attributes) {
|
||||
for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
|
||||
const char *attName = (*att).first.c_str();
|
||||
const char *attVal = (*att).second.c_str();
|
||||
int id = AttributeId(attName);
|
||||
if (id == ATTR_UNKNOWN) {
|
||||
esyslog("skindesigner: unknown view list attribute \"%s\" = \"%s\"", attName, attVal);
|
||||
continue;
|
||||
}
|
||||
if (SetCommon(id, attVal))
|
||||
continue;
|
||||
if (IdEqual(id, (int)eViewListAttribs::align)) {
|
||||
SetAlign(id, attVal);
|
||||
} else if (IdEqual(id, (int)eViewListAttribs::determinatefont)) {
|
||||
determinateFont = strdup(attVal);
|
||||
} else if (IdEqual(id, (int)eViewListAttribs::orientation)) {
|
||||
SetOrientation(id, attVal);
|
||||
} else {
|
||||
attribCtors[id] = new cNumericExpr(attVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cViewListAttribs::NumListElements(void) {
|
||||
return GetValue((int)eViewListAttribs::numlistelements);
|
||||
}
|
||||
|
||||
int cViewListAttribs::MenuItemWidth(void) {
|
||||
return GetValue((int)eViewListAttribs::menuitemwidth);
|
||||
}
|
||||
|
||||
const char *cViewListAttribs::DeterminateFont(void) {
|
||||
return determinateFont;
|
||||
}
|
||||
|
||||
eAlign cViewListAttribs::Align(void) {
|
||||
int align = GetValue((int)eViewListAttribs::align);
|
||||
if (align < 0)
|
||||
return eAlign::top;
|
||||
return (eAlign)align;
|
||||
}
|
||||
|
||||
eOrientation cViewListAttribs::Orientation(void) {
|
||||
int orientation = GetValue((int)eViewListAttribs::orientation);
|
||||
if (orientation < 0)
|
||||
return eOrientation::vertical;
|
||||
return (eOrientation)orientation;
|
||||
}
|
||||
|
||||
void cViewListAttribs::SetAttributesDefs(void) {
|
||||
attribIDs.insert(pair<string, int>("align", (int)eViewListAttribs::align));
|
||||
attribIDs.insert(pair<string, int>("menuitemwidth", (int)eViewListAttribs::menuitemwidth));
|
||||
attribIDs.insert(pair<string, int>("determinatefont", (int)eViewListAttribs::determinatefont));
|
||||
attribIDs.insert(pair<string, int>("numlistelements", (int)eViewListAttribs::numlistelements));
|
||||
attribIDs.insert(pair<string, int>("orientation", (int)eViewListAttribs::orientation));
|
||||
attribIDs.insert(pair<string, int>("condition", (int)eViewListAttribs::condition));
|
||||
attribNames.insert(pair<int, string>((int)eViewListAttribs::align, "align"));
|
||||
attribNames.insert(pair<int, string>((int)eViewListAttribs::menuitemwidth, "menuitemwidth"));
|
||||
attribNames.insert(pair<int, string>((int)eViewListAttribs::determinatefont, "determinatefont"));
|
||||
attribNames.insert(pair<int, string>((int)eViewListAttribs::numlistelements, "numlistelements"));
|
||||
attribNames.insert(pair<int, string>((int)eViewListAttribs::orientation, "orientation"));
|
||||
attribNames.insert(pair<int, string>((int)eViewListAttribs::condition, "condition"));
|
||||
}
|
||||
|
||||
void cViewListAttribs::Debug(void) {
|
||||
esyslog("skindesigner: ---> View List Attribs");
|
||||
esyslog("skindesigner: DeterminateFont %s", determinateFont);
|
||||
cAttributes::Debug();
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* cAreaAttribs
|
||||
***************************************************************************/
|
||||
cAreaAttribs::cAreaAttribs(int numAttributes) : cAttributes(numAttributes) {
|
||||
name = NULL;
|
||||
scrollElement = NULL;
|
||||
dynamic = false;
|
||||
SetAttributesDefs();
|
||||
}
|
||||
|
||||
cAreaAttribs::cAreaAttribs(const cAreaAttribs &other) : cAttributes(other) {
|
||||
name = NULL;
|
||||
if (other.name)
|
||||
name = new cTextExpr(*other.name);
|
||||
scrollElement = NULL;
|
||||
if (other.scrollElement)
|
||||
scrollElement = strdup(other.scrollElement);
|
||||
dynamic = false;
|
||||
}
|
||||
|
||||
cAreaAttribs::~cAreaAttribs(void) {
|
||||
delete name;
|
||||
free(scrollElement);
|
||||
}
|
||||
|
||||
void cAreaAttribs::Set(vector<stringpair> &attributes) {
|
||||
for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
|
||||
const char *attName = (*att).first.c_str();
|
||||
const char *attVal = (*att).second.c_str();
|
||||
int id = AttributeId(attName);
|
||||
if (id == ATTR_UNKNOWN) {
|
||||
esyslog("skindesigner: unknown area attribute \"%s\" = \"%s\"", attName, attVal);
|
||||
continue;
|
||||
}
|
||||
if (SetCommon(id, attVal))
|
||||
continue;
|
||||
if (IdEqual(id, (int)eAreaAttribs::scrollelement)) {
|
||||
scrollElement = strdup(attVal);
|
||||
} else if (IdEqual(id, (int)eAreaAttribs::mode)) {
|
||||
SetScrollMode(id, attVal);
|
||||
} else if (IdEqual(id, (int)eAreaAttribs::orientation)) {
|
||||
SetOrientation(id, attVal);
|
||||
} else if (IdEqual(id, (int)eAreaAttribs::scrollspeed)) {
|
||||
SetScrollSpeed(id, attVal);
|
||||
} else if (IdEqual(id, (int)eAreaAttribs::background)) {
|
||||
SetBool(id, attVal);
|
||||
} else if (IdEqual(id, (int)eAreaAttribs::name)) {
|
||||
name = new cTextExpr(attVal);
|
||||
} else {
|
||||
attribCtors[id] = new cNumericExpr(attVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cAreaAttribs::Layer(void) {
|
||||
if (GetValue((int)eAreaAttribs::layer) > 0) {
|
||||
return GetValue((int)eAreaAttribs::layer);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool cAreaAttribs::BackgroundArea(void) {
|
||||
int isBackground = GetValue((int)eAreaAttribs::background);
|
||||
if (isBackground == 1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void cAreaAttribs::CheckDynamic(void) {
|
||||
for (int i = (int)eCommonAttribs::x; i <= (int)eCommonAttribs::height; ++i ) {
|
||||
if (attribCtors[i] && attribCtors[i]->Dynamic()) {
|
||||
dynamic = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *cAreaAttribs::Name(void) {
|
||||
if (name)
|
||||
return name->DeterminateText();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cAreaAttribs::SetAttributesDefs(void) {
|
||||
attribIDs.insert(pair<string, int>("layer", (int)eAreaAttribs::layer));
|
||||
attribIDs.insert(pair<string, int>("transparency", (int)eAreaAttribs::transparency));
|
||||
attribIDs.insert(pair<string, int>("mode", (int)eAreaAttribs::mode));
|
||||
attribIDs.insert(pair<string, int>("orientation", (int)eAreaAttribs::orientation));
|
||||
attribIDs.insert(pair<string, int>("scrollelement", (int)eAreaAttribs::scrollelement));
|
||||
attribIDs.insert(pair<string, int>("scrollspeed", (int)eAreaAttribs::scrollspeed));
|
||||
attribIDs.insert(pair<string, int>("delay", (int)eAreaAttribs::delay));
|
||||
attribIDs.insert(pair<string, int>("background", (int)eAreaAttribs::background));
|
||||
attribIDs.insert(pair<string, int>("name", (int)eAreaAttribs::name));
|
||||
attribIDs.insert(pair<string, int>("scrollheight", (int)eAreaAttribs::scrollheight));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::layer, "layer"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::transparency, "transparency"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::mode, "mode"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::orientation, "orientation"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::scrollelement, "scrollelement"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::scrollspeed, "scrollspeed"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::delay, "delay"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::background, "background"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::name, "name"));
|
||||
attribNames.insert(pair<int, string>((int)eAreaAttribs::scrollheight, "scrollheight"));
|
||||
}
|
||||
|
||||
void cAreaAttribs::Cache(void) {
|
||||
cAttributes::Cache();
|
||||
if (name) {
|
||||
name->SetGlobals(globals);
|
||||
name->SetTokenContainer(tokenContainer);
|
||||
name->Cache();
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaAttribs::Debug(void) {
|
||||
if (!name) {
|
||||
esyslog("skindesigner: ---> Area Attribs");
|
||||
} else {
|
||||
esyslog("skindesigner: ---> Tab %s Attribs", name->DeterminateText());
|
||||
}
|
||||
cAttributes::Debug();
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* cAreaContainerAttribs
|
||||
***************************************************************************/
|
||||
cAreaContainerAttribs::cAreaContainerAttribs(int numAttributes) : cAttributes(numAttributes) {
|
||||
SetAttributesDefs();
|
||||
}
|
||||
|
||||
cAreaContainerAttribs::cAreaContainerAttribs(const cAreaContainerAttribs &other) : cAttributes(other) {
|
||||
}
|
||||
|
||||
cAreaContainerAttribs::~cAreaContainerAttribs(void) {
|
||||
}
|
||||
|
||||
void cAreaContainerAttribs::Set(vector<stringpair> &attributes) {
|
||||
for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
|
||||
const char *attName = (*att).first.c_str();
|
||||
const char *attVal = (*att).second.c_str();
|
||||
int id = AttributeId(attName);
|
||||
if (id == ATTR_UNKNOWN) {
|
||||
esyslog("skindesigner: unknown area container attribute \"%s\" = \"%s\"", attName, attVal);
|
||||
continue;
|
||||
}
|
||||
if (SetCommon(id, attVal))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void cAreaContainerAttribs::SetAttributesDefs(void) {
|
||||
}
|
||||
|
||||
void cAreaContainerAttribs::Debug(void) {
|
||||
esyslog("skindesigner: ---> Area Container Attribs");
|
||||
cAttributes::Debug();
|
||||
}
|
||||
|
||||
111
coreengine/attributes.h
Normal file
111
coreengine/attributes.h
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef __ATTRIBUTES_H
|
||||
#define __ATTRIBUTES_H
|
||||
|
||||
#include "attribute.h"
|
||||
/******************************************************************
|
||||
* cViewAttribs
|
||||
******************************************************************/
|
||||
class cViewAttribs : public cAttributes {
|
||||
private:
|
||||
cTextExpr *orientation;
|
||||
void SetAttributesDefs(void);
|
||||
void SetOrientationDynamic(int id, const char *val);
|
||||
public:
|
||||
cViewAttribs(int numAttributes);
|
||||
virtual ~cViewAttribs(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
eOrientation Orientation(void);
|
||||
int FadeTime(void) { return GetValue((int)eViewAttribs::fadetime); };
|
||||
int ShiftTime(void) { return GetValue((int)eViewAttribs::shifttime); };
|
||||
cPoint ShiftStartpoint(void) { return cPoint(GetValue((int)eViewAttribs::startx), GetValue((int)eViewAttribs::starty)); };
|
||||
int ShiftType(void) { return GetValue((int)eViewAttribs::shifttype); };
|
||||
int ShiftMode(void) { return GetValue((int)eViewAttribs::shiftmode); };
|
||||
cRect TvFrame(void);
|
||||
void Cache(void);
|
||||
void Debug(void);
|
||||
};
|
||||
/******************************************************************
|
||||
* cViewElementAttribs
|
||||
******************************************************************/
|
||||
class cViewElementAttribs : public cAttributes {
|
||||
private:
|
||||
char *name;
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cViewElementAttribs(int numAttributes);
|
||||
cViewElementAttribs(const cViewElementAttribs &other);
|
||||
virtual ~cViewElementAttribs(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
int Mode(void) { return GetValue((int)eViewElementAttribs::mode); };
|
||||
int Delay(void) { return GetValue((int)eViewElementAttribs::delay); };
|
||||
eOrientation Orientation(void);
|
||||
int FadeTime(void) { return GetValue((int)eViewElementAttribs::fadetime); };
|
||||
int ShiftTime(void) { return GetValue((int)eViewElementAttribs::shifttime); };
|
||||
cPoint ShiftStartpoint(void) { return cPoint(GetValue((int)eViewElementAttribs::startx), GetValue((int)eViewElementAttribs::starty)); };
|
||||
int ShiftType(void) { return GetValue((int)eViewElementAttribs::shifttype); };
|
||||
int ShiftMode(void) { return GetValue((int)eViewElementAttribs::shiftmode); };
|
||||
const char *Name(void) { return name; };
|
||||
void Debug(void);
|
||||
};
|
||||
/******************************************************************
|
||||
* cViewListAttribs
|
||||
******************************************************************/
|
||||
class cViewListAttribs : public cAttributes {
|
||||
private:
|
||||
char *determinateFont;
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cViewListAttribs(int numAttributes);
|
||||
virtual ~cViewListAttribs(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
int NumListElements(void);
|
||||
int MenuItemWidth(void);
|
||||
const char *DeterminateFont(void);
|
||||
eAlign Align(void);
|
||||
eOrientation Orientation(void);
|
||||
void Debug(void);
|
||||
};
|
||||
/******************************************************************
|
||||
* cAreaAttribs
|
||||
******************************************************************/
|
||||
class cAreaAttribs : public cAttributes {
|
||||
private:
|
||||
cTextExpr *name;
|
||||
char *scrollElement;
|
||||
void SetAttributesDefs(void);
|
||||
bool dynamic;
|
||||
public:
|
||||
cAreaAttribs(int numAttributes);
|
||||
cAreaAttribs(const cAreaAttribs &other);
|
||||
virtual ~cAreaAttribs(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
const char *GetScrollElement(void) { return scrollElement; };
|
||||
int Orientation(void) { return GetValue((int)eAreaAttribs::orientation); };
|
||||
int Delay(void) { return GetValue((int)eAreaAttribs::delay); };
|
||||
int Mode(void) { return GetValue((int)eAreaAttribs::mode); };
|
||||
int ScrollSpeed(void) { return GetValue((int)eAreaAttribs::scrollspeed); };
|
||||
int Transparency(void) { return GetValue((int)eAreaAttribs::transparency); };
|
||||
int Layer(void);
|
||||
int ScrollStep(void) { return GetValue((int)eAreaAttribs::scrollheight); };
|
||||
bool BackgroundArea(void);
|
||||
const char *Name(void);
|
||||
void CheckDynamic(void);
|
||||
bool Dynamic(void) {return dynamic; };
|
||||
void Cache(void);
|
||||
void Debug(void);
|
||||
};
|
||||
/******************************************************************
|
||||
* cAreaContainerAttribs
|
||||
******************************************************************/
|
||||
class cAreaContainerAttribs : public cAttributes {
|
||||
private:
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cAreaContainerAttribs(int numAttributes);
|
||||
cAreaContainerAttribs(const cAreaContainerAttribs &other);
|
||||
virtual ~cAreaContainerAttribs(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
#endif //__ATTRIBUTES_H
|
||||
1605
coreengine/complextypes.c
Normal file
1605
coreengine/complextypes.c
Normal file
File diff suppressed because it is too large
Load Diff
318
coreengine/complextypes.h
Normal file
318
coreengine/complextypes.h
Normal file
@@ -0,0 +1,318 @@
|
||||
#ifndef __COMPLEXTYPES_H
|
||||
#define __COMPLEXTYPES_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vdr/skins.h>
|
||||
#include "globals.h"
|
||||
#include "../libskindesignerapi/tokencontainer.h"
|
||||
|
||||
class cLoopInfo;
|
||||
class cFunction;
|
||||
/******************************************************************
|
||||
* helpers
|
||||
******************************************************************/
|
||||
char *RemoveSpace(char *e);
|
||||
void ReplaceDecimalpoint(char *e);
|
||||
void ReplaceStart(char *e, int num);
|
||||
void ReplaceEnd(char *e, int num);
|
||||
|
||||
/******************************************************************
|
||||
* cCondition
|
||||
******************************************************************/
|
||||
enum class eCondOp {
|
||||
tAnd,
|
||||
tOr
|
||||
};
|
||||
|
||||
enum class eCondType {
|
||||
token,
|
||||
negtoken,
|
||||
lowerInt,
|
||||
equalInt,
|
||||
greaterInt,
|
||||
isset,
|
||||
empty,
|
||||
equalString,
|
||||
notEqualString,
|
||||
contains,
|
||||
notContains
|
||||
};
|
||||
|
||||
enum class eCondTokenType {
|
||||
inttoken,
|
||||
stringtoken,
|
||||
looptoken
|
||||
};
|
||||
|
||||
class cCond : public cListObject {
|
||||
public:
|
||||
cCond(const char *expression);
|
||||
cCond(const cCond &other);
|
||||
virtual ~cCond(void);
|
||||
void Debug(void);
|
||||
char *expr;
|
||||
eCondOp operation;
|
||||
eCondType type;
|
||||
eCondTokenType tokenType;
|
||||
bool constant;
|
||||
bool isTrue;
|
||||
int tokenIndex;
|
||||
int compareValue;
|
||||
char *compareStrValue;
|
||||
};
|
||||
|
||||
class cCondition {
|
||||
private:
|
||||
char *expr;
|
||||
cGlobals *globals;
|
||||
skindesignerapi::cTokenContainer *tokenContainer;
|
||||
cLoopInfo *loopInfo;
|
||||
cList<cCond> conds;
|
||||
void Tokenize(void);
|
||||
void PrepareTokens(void);
|
||||
void SetTokenCond(cCond *c);
|
||||
void SetIntegerCond(cCond *c);
|
||||
void SetStringCond(cCond *c);
|
||||
void SetStringCompareCond(cCond *c);
|
||||
void SetTokenIndex(cCond *c, const char *token);
|
||||
public:
|
||||
cCondition(const char *expression);
|
||||
cCondition(const cCondition &other);
|
||||
virtual ~cCondition(void);
|
||||
void SetGlobals(cGlobals *globals) { this->globals = globals; };
|
||||
void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {this->tokenContainer = tokenContainer; };
|
||||
void SetLoopInfo(cLoopInfo *loopInfo) { this->loopInfo = loopInfo; };
|
||||
void Prepare(void);
|
||||
bool True(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cNumericExpr
|
||||
******************************************************************/
|
||||
enum class eFactorType {
|
||||
constant = 0,
|
||||
stringtoken,
|
||||
inttoken,
|
||||
looptoken,
|
||||
xref,
|
||||
yref,
|
||||
widthref,
|
||||
heightref,
|
||||
areawidth,
|
||||
areaheight,
|
||||
columnwidth,
|
||||
rowheight
|
||||
};
|
||||
|
||||
class cFactor: public cListObject {
|
||||
public:
|
||||
cFactor(void) {
|
||||
multiplication = true;
|
||||
type = eFactorType::constant;
|
||||
constValue = 1.0f;
|
||||
tokenIndex = -1;
|
||||
funcRefName = NULL;
|
||||
funcRef = NULL;
|
||||
};
|
||||
cFactor(const cFactor &other) {
|
||||
multiplication = other.multiplication;
|
||||
type = other.type;
|
||||
constValue = other.constValue;
|
||||
tokenIndex = other.tokenIndex;
|
||||
funcRefName = NULL;
|
||||
if (other.funcRefName)
|
||||
funcRefName = strdup(other.funcRefName);
|
||||
funcRef = other.funcRef;
|
||||
}
|
||||
~cFactor(void) {
|
||||
free(funcRefName);
|
||||
};
|
||||
bool multiplication;
|
||||
eFactorType type;
|
||||
double constValue;
|
||||
int tokenIndex;
|
||||
char *funcRefName;
|
||||
cFunction *funcRef;
|
||||
};
|
||||
|
||||
class cSummand : public cListObject {
|
||||
public:
|
||||
cSummand(const char *summand);
|
||||
cSummand(const cSummand &other);
|
||||
~cSummand(void);
|
||||
void Debug(void);
|
||||
char *summand;
|
||||
bool positive;
|
||||
cList<cFactor> factors;
|
||||
};
|
||||
|
||||
class cNumericExpr {
|
||||
private:
|
||||
cGlobals *globals;
|
||||
cRect *container;
|
||||
skindesignerapi::cTokenContainer *tokenContainer;
|
||||
cLoopInfo *loopInfo;
|
||||
char *expr;
|
||||
cList<cSummand> summands;
|
||||
bool horizontal;
|
||||
int value;
|
||||
bool dynamic;
|
||||
//common string functions
|
||||
bool IsNumeric(const char *e);
|
||||
bool IsNumericExpression(const char *e);
|
||||
bool PercentValue(const char *e);
|
||||
char *ReplacePercentValue(char *e);
|
||||
char *ReplaceToken(char *e, const char* token, int value);
|
||||
char *ReplaceTokens(char *e, const char* token, int value);
|
||||
//calculate numeric expressions
|
||||
int EvaluateExpression(char *e);
|
||||
double EvaluateExpressionDouble(char *e);
|
||||
double ParseAtom(char*& e);
|
||||
double ParseFactors(char*& e);
|
||||
double ParseSummands(char*& e);
|
||||
//prepare expressions with tokens
|
||||
void CreateSummands(void);
|
||||
void CreateFactors(void);
|
||||
bool SetTokenFactor(cFactor *f, char *tokenName);
|
||||
bool SetReferenceFactor(cFactor *f, char *tokenName);
|
||||
bool SetGeometryFactor(cFactor *f, char *tokenName);
|
||||
void ConsolidateSummand(void);
|
||||
void ConsolidateFactors(void);
|
||||
public:
|
||||
cNumericExpr(const char *expression);
|
||||
cNumericExpr(const cNumericExpr &other);
|
||||
virtual ~cNumericExpr(void);
|
||||
void SetContainer(cRect *container) { this->container = container; };
|
||||
void SetGlobals(cGlobals *globals) { this->globals = globals; };
|
||||
void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) { this->tokenContainer = tokenContainer; };
|
||||
void SetLoopInfo(cLoopInfo *loopInfo) { this->loopInfo = loopInfo; };
|
||||
void SetVertical(void) { horizontal = false; };
|
||||
bool CacheStatic(void);
|
||||
void PrepareTokens(void);
|
||||
vector<cFactor*> GetRefFactors(void);
|
||||
int GetValue(void) { return value; };
|
||||
bool Dynamic(void) { return dynamic; };
|
||||
int Calculate(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cColor
|
||||
******************************************************************/
|
||||
class cColor {
|
||||
private:
|
||||
cGlobals *globals;
|
||||
char *expr;
|
||||
tColor value;
|
||||
public:
|
||||
cColor(const char *expression);
|
||||
cColor(const cColor &other);
|
||||
virtual ~cColor(void);
|
||||
void SetGlobals(cGlobals *globals) { this->globals = globals; };
|
||||
void Cache(void);
|
||||
tColor Color(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cTextExpr
|
||||
******************************************************************/
|
||||
enum class eTexttokenType {
|
||||
constant = 0,
|
||||
stringtoken,
|
||||
inttoken,
|
||||
looptoken,
|
||||
printftoken,
|
||||
condstringtoken,
|
||||
condinttoken,
|
||||
};
|
||||
|
||||
enum class ePrintfVarType {
|
||||
stringtoken,
|
||||
inttoken,
|
||||
looptoken
|
||||
};
|
||||
|
||||
struct sPrintfInfo {
|
||||
ePrintfVarType type;
|
||||
int index;
|
||||
};
|
||||
|
||||
class cTextToken: public cListObject {
|
||||
public:
|
||||
cTextToken(void) {
|
||||
type = eTexttokenType::constant;
|
||||
constValue = NULL;
|
||||
printfExpr = NULL;
|
||||
printfResult = NULL;
|
||||
tokenIndex = -1;
|
||||
condStart = NULL;
|
||||
condEnd = NULL;
|
||||
};
|
||||
cTextToken(const cTextToken &other) {
|
||||
type = other.type;
|
||||
constValue = NULL;
|
||||
if (other.constValue)
|
||||
constValue = strdup(other.constValue);
|
||||
printfExpr = NULL;
|
||||
if (other.printfExpr)
|
||||
printfExpr = strdup(other.printfExpr);
|
||||
printfVarIndices = other.printfVarIndices;
|
||||
printfResult = NULL;
|
||||
if (other.printfResult)
|
||||
printfResult = strdup(other.printfResult);
|
||||
tokenIndex = other.tokenIndex;
|
||||
condStart = NULL;
|
||||
if (other.condStart)
|
||||
condStart = strdup(other.condStart);
|
||||
condEnd = NULL;
|
||||
if (other.condEnd)
|
||||
condEnd = strdup(other.condEnd);
|
||||
};
|
||||
~cTextToken(void) {
|
||||
free(constValue);
|
||||
free(printfExpr);
|
||||
};
|
||||
eTexttokenType type;
|
||||
char *constValue;
|
||||
int tokenIndex;
|
||||
char *printfExpr;
|
||||
vector<sPrintfInfo> printfVarIndices;
|
||||
char *printfResult;
|
||||
char *condStart;
|
||||
char *condEnd;
|
||||
};
|
||||
|
||||
class cTextExpr {
|
||||
private:
|
||||
cGlobals *globals;
|
||||
skindesignerapi::cTokenContainer *tokenContainer;
|
||||
cLoopInfo *loopInfo;
|
||||
char *expr;
|
||||
cList<cTextToken> textTokens;
|
||||
void Translate(void);
|
||||
void Tokenize(void);
|
||||
void PrepareTokens(void);
|
||||
bool CheckGlobals(cTextToken *t);
|
||||
bool ParsePrintfToken(cTextToken *t);
|
||||
void DeterminatePrintfToken(cTextToken *t);
|
||||
void ParseCondToken(cTextToken *t);
|
||||
char *CopyTextPart(char *start, char *stop, bool incLastChar= true);
|
||||
public:
|
||||
cTextExpr(const char *expression);
|
||||
cTextExpr(const cTextExpr &other);
|
||||
virtual ~cTextExpr(void);
|
||||
void SetGlobals(cGlobals *globals) { this->globals = globals; };
|
||||
void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) { this->tokenContainer = tokenContainer; };
|
||||
void SetLoopInfo(cLoopInfo *loopInfo) { this->loopInfo = loopInfo; };
|
||||
void CorrectImagePath(void);
|
||||
void Cache(void);
|
||||
char *DeterminateText(void);
|
||||
void Debug(const char *exprName);
|
||||
};
|
||||
|
||||
#endif //__COMPLEXTYPES_H
|
||||
1746
coreengine/definitions.h
Normal file
1746
coreengine/definitions.h
Normal file
File diff suppressed because it is too large
Load Diff
1565
coreengine/functions.c
Normal file
1565
coreengine/functions.c
Normal file
File diff suppressed because it is too large
Load Diff
220
coreengine/functions.h
Normal file
220
coreengine/functions.h
Normal file
@@ -0,0 +1,220 @@
|
||||
#ifndef __FUNCTIONS_H
|
||||
#define __FUNCTIONS_H
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
class cFuncFill : public cFunction {
|
||||
private:
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cFuncFill(cArea *owner, int numAttributes);
|
||||
cFuncFill(const cFuncFill &other);
|
||||
virtual ~cFuncFill(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
};
|
||||
|
||||
class cFuncDrawRectangle : public cFunction {
|
||||
private:
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cFuncDrawRectangle(cArea *owner, int numAttributes);
|
||||
cFuncDrawRectangle(const cFuncDrawRectangle &other);
|
||||
virtual ~cFuncDrawRectangle(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
bool Blinking(void) { return GetValue((int)eDrawRectangleAttribs::animtype) == (int)eAnimType::blink; };
|
||||
int BlinkFreq(void) { return GetValue((int)eDrawRectangleAttribs::animfreq); };
|
||||
int Align(void) { return GetValue((int)eDrawRectangleAttribs::align); };
|
||||
int Valign(void) { return GetValue((int)eDrawRectangleAttribs::valign); };
|
||||
};
|
||||
|
||||
class cFuncDrawEllipse : public cFunction {
|
||||
private:
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cFuncDrawEllipse(cArea *owner, int numAttributes);
|
||||
cFuncDrawEllipse(const cFuncDrawEllipse &other);
|
||||
virtual ~cFuncDrawEllipse(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
bool Blinking(void) { return GetValue((int)eDrawEllipseAttribs::animtype) == (int)eAnimType::blink; };
|
||||
int BlinkFreq(void) { return GetValue((int)eDrawEllipseAttribs::animfreq); };
|
||||
int Align(void) { return GetValue((int)eDrawEllipseAttribs::align); };
|
||||
int Valign(void) { return GetValue((int)eDrawEllipseAttribs::valign); };
|
||||
};
|
||||
|
||||
class cFuncDrawSlope : public cFunction {
|
||||
private:
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cFuncDrawSlope(cArea *owner, int numAttributes);
|
||||
cFuncDrawSlope(const cFuncDrawSlope &other);
|
||||
virtual ~cFuncDrawSlope(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
bool Blinking(void) { return GetValue((int)eDrawSlopeAttribs::animtype) == (int)eAnimType::blink; };
|
||||
int BlinkFreq(void) { return GetValue((int)eDrawSlopeAttribs::animfreq); };
|
||||
int Align(void) { return GetValue((int)eDrawSlopeAttribs::align); };
|
||||
int Valign(void) { return GetValue((int)eDrawSlopeAttribs::valign); };
|
||||
};
|
||||
|
||||
class cTextDrawer {
|
||||
private:
|
||||
static cMutex fontLock;
|
||||
protected:
|
||||
const cFont *font;
|
||||
char *fontName;
|
||||
int fontSize;
|
||||
void CacheFont(cGlobals *globals, int size);
|
||||
void LoadFont(int size);
|
||||
int TextWidth(const char *text);
|
||||
int FontHeight(void);
|
||||
public:
|
||||
cTextDrawer(void);
|
||||
virtual ~cTextDrawer(void);
|
||||
};
|
||||
|
||||
class cFuncDrawText : public cFunction, public cTextDrawer {
|
||||
private:
|
||||
cTextExpr *text;
|
||||
void SetAttributesDefs(void);
|
||||
char *Cut(char *expr, int width);
|
||||
public:
|
||||
cFuncDrawText(cArea *owner, int numAttributes);
|
||||
cFuncDrawText(const cFuncDrawText &other);
|
||||
virtual ~cFuncDrawText(void);
|
||||
void SetLoopInfo(cLoopInfo *loopInfo);
|
||||
void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Cache(void);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
int FuncX(void);
|
||||
int FuncY(void);
|
||||
int FuncWidth(void);
|
||||
int FuncHeight(void);
|
||||
int AvrgFontWidth(void);
|
||||
const cFont *GetFont(void);
|
||||
bool Blinking(void) { return GetValue((int)eDrawTextAttribs::animtype) == (int)eAnimType::blink; };
|
||||
int BlinkFreq(void) { return GetValue((int)eDrawTextAttribs::animfreq); };
|
||||
int Align(void) { return GetValue((int)eDrawTextAttribs::align); };
|
||||
int Valign(void) { return GetValue((int)eDrawTextAttribs::valign); };
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
class cFuncDrawTextVertical : public cFunction, public cTextDrawer {
|
||||
private:
|
||||
cTextExpr *text;
|
||||
void SetAttributesDefs(void);
|
||||
public:
|
||||
cFuncDrawTextVertical(cArea *owner, int numAttributes);
|
||||
cFuncDrawTextVertical(const cFuncDrawTextVertical &other);
|
||||
virtual ~cFuncDrawTextVertical(void);
|
||||
void SetLoopInfo(cLoopInfo *loopInfo);
|
||||
void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Cache(void);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
int FuncWidth(void);
|
||||
int FuncHeight(void);
|
||||
bool Blinking(void) { return GetValue((int)eDrawTextAttribsVertical::animtype) == (int)eAnimType::blink; };
|
||||
int BlinkFreq(void) { return GetValue((int)eDrawTextAttribsVertical::animfreq); };
|
||||
int Align(void) { return GetValue((int)eDrawTextAttribsVertical::align); };
|
||||
int Valign(void) { return GetValue((int)eDrawTextAttribsVertical::valign); };
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
class cTextFloater;
|
||||
|
||||
class cFuncDrawTextBox : public cFunction, public cTextDrawer {
|
||||
private:
|
||||
cTextExpr *text;
|
||||
cTextFloater *floater;
|
||||
void SetFloater(void);
|
||||
void SetAttributesDefs(void);
|
||||
void SetFloatMode(int id, const char *val);
|
||||
public:
|
||||
cFuncDrawTextBox(cArea *owner, int numAttributes);
|
||||
cFuncDrawTextBox(const cFuncDrawTextBox &other);
|
||||
virtual ~cFuncDrawTextBox(void);
|
||||
void SetLoopInfo(cLoopInfo *loopInfo);
|
||||
void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Cache(void);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
int FuncWidth(void);
|
||||
int FuncHeight(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
class cFuncDrawImage : public cFunction {
|
||||
private:
|
||||
cTextExpr *path;
|
||||
void SetAttributesDefs(void);
|
||||
void SetImageType(int id, const char *val);
|
||||
void PreCacheImage(void);
|
||||
public:
|
||||
cFuncDrawImage(cArea *owner, int numAttributes);
|
||||
cFuncDrawImage(const cFuncDrawImage &other);
|
||||
virtual ~cFuncDrawImage(void);
|
||||
void SetLoopInfo(cLoopInfo *loopInfo);
|
||||
void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void Cache(void);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
bool Blinking(void) { return GetValue((int)eDrawImageAttribs::animtype) == (int)eAnimType::blink; };
|
||||
int BlinkFreq(void) { return GetValue((int)eDrawImageAttribs::animfreq); };
|
||||
int Align(void) { return GetValue((int)eDrawImageAttribs::align); };
|
||||
int Valign(void) { return GetValue((int)eDrawImageAttribs::valign); };
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
class cFuncLoop : public cFunction {
|
||||
private:
|
||||
cLoopInfo loopInfo;
|
||||
cList<cFunction> functions;
|
||||
void SetAttributesDefs(void);
|
||||
int ColumnWidth(void);
|
||||
int RowHeight(void);
|
||||
public:
|
||||
cFuncLoop(cArea *owner, int numAttributes);
|
||||
virtual ~cFuncLoop(void);
|
||||
void Set(vector<stringpair> &attributes);
|
||||
void SetContainer(int x, int y, int width, int height);
|
||||
void Cache(void);
|
||||
void AddFunction(cFunction *f);
|
||||
cFunction *GetFunction(const char *name);
|
||||
void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
|
||||
int FuncWidth(void);
|
||||
int FuncHeight(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
class cTextFloater {
|
||||
private:
|
||||
char *text;
|
||||
char *eol;
|
||||
int lines;
|
||||
int lastLine;
|
||||
public:
|
||||
cTextFloater(void);
|
||||
cTextFloater(const char *text, const cFont *font, int width, int height = 0, int floatWidth = 0, int floatHeight = 0, int maxLines = 0);
|
||||
~cTextFloater();
|
||||
void Set(const char *Text, const cFont *font, int width, int height = 0, int floatWidth = 0, int floatHeight = 0, int maxLines = 0);
|
||||
///< Wraps the Text to make it fit into the area defined by the given Width
|
||||
///< when displayed with the given Font.
|
||||
///< Wrapping is done by inserting the necessary number of newline
|
||||
///< characters into the string.
|
||||
///< if height is set, new lines are only set till height is reached
|
||||
///< if floatwidth and floatheight are set, the first lines (depending on
|
||||
///< size of floatheight) are set to floatwidth
|
||||
const char *Text(void);
|
||||
///< Returns the full wrapped text.
|
||||
int Lines(void) { return lines; }
|
||||
///< Returns the actual number of lines needed to display the full wrapped text.
|
||||
const char *GetLine(int line);
|
||||
///< Returns the given Line. The first line is numbered 0.
|
||||
};
|
||||
|
||||
|
||||
#endif //__FUNCTIONS_H
|
||||
305
coreengine/globals.c
Normal file
305
coreengine/globals.c
Normal file
@@ -0,0 +1,305 @@
|
||||
#include "globals.h"
|
||||
#include "xmlparser.h"
|
||||
#include "../config.h"
|
||||
#include <locale.h>
|
||||
|
||||
cGlobals::cGlobals(void) {
|
||||
customTokenChange = 0;
|
||||
lastCustomTokenQuery = 0;
|
||||
|
||||
fonts.insert(pair<string, string>("vdrOsd", Setup.FontOsd));
|
||||
fonts.insert(pair<string, string>("vdrFix", Setup.FontFix));
|
||||
fonts.insert(pair<string, string>("vdrSml", Setup.FontSml));
|
||||
language = Setup.OSDLanguage;
|
||||
dsyslog("skindesigner: using language %s", language.c_str());
|
||||
}
|
||||
|
||||
bool cGlobals::ReadFromXML(void) {
|
||||
//globals.xml is mandatory
|
||||
string xmlFile = "globals.xml";
|
||||
cXmlParser parser;
|
||||
if (!parser.ReadGlobals(this, xmlFile))
|
||||
return false;
|
||||
if (!parser.ParseGlobals())
|
||||
return false;
|
||||
//theme.xml is optional
|
||||
xmlFile = "theme.xml";
|
||||
if (parser.ReadGlobals(this, xmlFile)) {
|
||||
parser.ParseGlobals();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void cGlobals::AddColor(string &name, tColor &col) {
|
||||
colors.erase(name);
|
||||
colors.insert(pair<string, tColor>(name, col));
|
||||
}
|
||||
|
||||
bool cGlobals::GetColor(string &name, tColor &col) {
|
||||
int size = name.size();
|
||||
if (size < 2)
|
||||
return false;
|
||||
string nameCutted = name.substr(1, size-2);
|
||||
map <string, tColor>::iterator hit = colors.find(nameCutted);
|
||||
if (hit != colors.end()) {
|
||||
col = hit->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cGlobals::AddFont(string &name, string &font) {
|
||||
fonts.erase(name);
|
||||
fonts.insert(pair<string, string>(name, font));
|
||||
}
|
||||
|
||||
bool cGlobals::GetFont(string name, string &font) {
|
||||
int size = name.size();
|
||||
if (size < 2)
|
||||
return false;
|
||||
string nameCutted = name.substr(1, size-2);
|
||||
map<string,string>::iterator hit = fonts.find(nameCutted);
|
||||
if (hit != fonts.end()) {
|
||||
font = hit->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cGlobals::AddInt(string &name, int value) {
|
||||
intVars.erase(name);
|
||||
intVars.insert(pair<string, int>(name, value));
|
||||
}
|
||||
|
||||
void cGlobals::ReplaceIntVars(string &value) {
|
||||
for (map<string, int>::iterator it = intVars.begin(); it != intVars.end(); it++) {
|
||||
stringstream sToken;
|
||||
sToken << "{" << it->first << "}";
|
||||
string token = sToken.str();
|
||||
size_t foundToken = string::npos;
|
||||
do {
|
||||
foundToken = value.find(token);
|
||||
if (foundToken != string::npos) {
|
||||
stringstream st;
|
||||
st << it->second;
|
||||
value = value.replace(foundToken, token.size(), st.str());
|
||||
}
|
||||
} while (foundToken != string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
bool cGlobals::GetInt(string name, int &val) {
|
||||
DeleteCurledBrackets(name);
|
||||
map < string, int >::iterator hit = intVars.find(name);
|
||||
if (hit != intVars.end()) {
|
||||
val = hit->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cGlobals::AddDouble(string &name, string &value) {
|
||||
doubleVars.erase(name);
|
||||
if (config.replaceDecPoint) {
|
||||
if (value.find_first_of('.') != string::npos) {
|
||||
std::replace( value.begin(), value.end(), '.', config.decPoint);
|
||||
}
|
||||
}
|
||||
double val = atof(value.c_str());
|
||||
doubleVars.insert(pair<string, double>(name, val));
|
||||
}
|
||||
|
||||
void cGlobals::ReplaceDoubleVars(string &value) {
|
||||
for (map<string, double>::iterator it = doubleVars.begin(); it != doubleVars.end(); it++) {
|
||||
stringstream sToken;
|
||||
sToken << "{" << it->first << "}";
|
||||
string token = sToken.str();
|
||||
size_t foundToken = string::npos;
|
||||
do {
|
||||
foundToken = value.find(token);
|
||||
if (foundToken != string::npos) {
|
||||
stringstream st;
|
||||
st << it->second;
|
||||
string doubleVal = st.str();
|
||||
if (config.replaceDecPoint) {
|
||||
if (doubleVal.find_first_of('.') != string::npos) {
|
||||
std::replace( doubleVal.begin(), doubleVal.end(), '.', config.decPoint);
|
||||
}
|
||||
}
|
||||
value = value.replace(foundToken, token.size(), doubleVal);
|
||||
}
|
||||
} while (foundToken != string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
void cGlobals::AddString(string &name, string &value) {
|
||||
stringVars.erase(name);
|
||||
stringVars.insert(pair<string, string>(name, value));
|
||||
}
|
||||
|
||||
void cGlobals::ReplaceStringVars(string &value) {
|
||||
for (map<string,string>::iterator it = stringVars.begin(); it != stringVars.end(); it++) {
|
||||
stringstream sToken;
|
||||
sToken << "{" << it->first << "}";
|
||||
string token = sToken.str();
|
||||
size_t foundToken = value.find(token);
|
||||
if (foundToken != string::npos) {
|
||||
value = value.replace(foundToken, token.size(), it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool cGlobals::GetString(string name, string &value) {
|
||||
DeleteCurledBrackets(name);
|
||||
map<string,string>::iterator hit = stringVars.find(name);
|
||||
if (hit == stringVars.end())
|
||||
return false;
|
||||
value = hit->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cGlobals::AddTranslation(string name, map < string, string > transl) {
|
||||
translations.erase(name);
|
||||
translations.insert(pair<string, map < string, string > >(name, transl));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cGlobals::Translate(string text, string &translation) {
|
||||
string transStart = "{tr(";
|
||||
string transEnd = ")}";
|
||||
size_t foundStart = text.find(transStart);
|
||||
size_t foundEnd = text.find(transEnd);
|
||||
bool translated = false;
|
||||
|
||||
while (foundStart != string::npos && foundEnd != string::npos) {
|
||||
string token = text.substr(foundStart + 1, foundEnd - foundStart);
|
||||
string transToken = DoTranslate(token);
|
||||
if (transToken.size() > 0)
|
||||
translated = true;
|
||||
else
|
||||
return false;
|
||||
text.replace(foundStart, foundEnd - foundStart + 2, transToken);
|
||||
foundStart = text.find(transStart);
|
||||
foundEnd = text.find(transEnd);
|
||||
}
|
||||
if (translated)
|
||||
translation = text;
|
||||
return translated;
|
||||
}
|
||||
|
||||
string cGlobals::DoTranslate(string token) {
|
||||
string translation = "";
|
||||
map <string, map< string, string > >::iterator hit = translations.find(token);
|
||||
if (hit == translations.end()) {
|
||||
esyslog("skindesigner: invalid translation token %s", token.c_str());
|
||||
return translation;
|
||||
}
|
||||
map< string, string > translats = hit->second;
|
||||
map< string, string >::iterator trans = translats.find(language);
|
||||
if (trans != translats.end()) {
|
||||
translation = trans->second;
|
||||
} else {
|
||||
map< string, string >::iterator transDefault = translats.find("en_EN");
|
||||
if (transDefault != translats.end()) {
|
||||
translation = transDefault->second;
|
||||
}
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
|
||||
void cGlobals::AddCustomInt(int num, int value) {
|
||||
customIntTokens.erase(num);
|
||||
customIntTokens.insert(pair<int,int>(num, value));
|
||||
customTokenChange = time(0);
|
||||
}
|
||||
|
||||
void cGlobals::AddCustomString(int num, string &value) {
|
||||
customStringTokens.erase(num);
|
||||
customStringTokens.insert(pair<int,string>(num, value));
|
||||
customTokenChange = time(0);
|
||||
}
|
||||
|
||||
bool cGlobals::GetCustomInt(int num, int &val) {
|
||||
map < int, int >::iterator hit = customIntTokens.find(num);
|
||||
if (hit != customIntTokens.end()) {
|
||||
val = hit->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cGlobals::GetCustomString(int num, string &val) {
|
||||
map < int, string >::iterator hit = customStringTokens.find(num);
|
||||
if (hit != customStringTokens.end()) {
|
||||
val = hit->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
map <int, string> cGlobals::GetCustomStringTokens(void) {
|
||||
lastCustomTokenQuery = time(0);
|
||||
return customStringTokens;
|
||||
}
|
||||
|
||||
map <int, int> cGlobals::GetCustomIntTokens(void) {
|
||||
lastCustomTokenQuery = time(0);
|
||||
return customIntTokens;
|
||||
}
|
||||
|
||||
bool cGlobals::CustomTokenChange(void) {
|
||||
if (!lastCustomTokenQuery)
|
||||
return true;
|
||||
if (lastCustomTokenQuery < customTokenChange)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void cGlobals::ResetCustomTokenChange(void) {
|
||||
lastCustomTokenQuery = 0;
|
||||
}
|
||||
|
||||
void cGlobals::ListCustomTokens(void) {
|
||||
for (map<int, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) {
|
||||
dsyslog("skindesigner: custom string token %d = \"%s\"", it->first, (it->second).c_str());
|
||||
}
|
||||
for (map<int, int>::iterator it = customIntTokens.begin(); it != customIntTokens.end(); it++) {
|
||||
dsyslog("skindesigner: custom int token %d = \"%d\"", it->first, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
void cGlobals::Debug(void) {
|
||||
dsyslog("skindesigner: GLOBAL VARIABLES");
|
||||
for (map <string, tColor>::iterator col = colors.begin(); col != colors.end(); col++) {
|
||||
dsyslog("skindesigner: Color \"%s\": %x", (col->first).c_str(), col->second);
|
||||
}
|
||||
for (map <string, int>::iterator myInt = intVars.begin(); myInt != intVars.end(); myInt++) {
|
||||
dsyslog("skindesigner: Integer Variable \"%s\": %d", (myInt->first).c_str(), myInt->second);
|
||||
}
|
||||
for (map <string, double>::iterator myDouble = doubleVars.begin(); myDouble != doubleVars.end(); myDouble++) {
|
||||
dsyslog("skindesigner: Double Variable \"%s\": %f", (myDouble->first).c_str(), myDouble->second);
|
||||
}
|
||||
for (map <string, string>::iterator myStr = stringVars.begin(); myStr != stringVars.end(); myStr++) {
|
||||
dsyslog("skindesigner: String Variable \"%s\": \"%s\"", (myStr->first).c_str(), (myStr->second).c_str());
|
||||
}
|
||||
for (map <string, string>::iterator font = fonts.begin(); font != fonts.end(); font++) {
|
||||
dsyslog("skindesigner: Font \"%s\": \"%s\"", (font->first).c_str(), (font->second).c_str());
|
||||
}
|
||||
|
||||
for (map <string, map< string, string > >::iterator trans = translations.begin(); trans != translations.end(); trans++) {
|
||||
dsyslog("skindesigner: Translation Token %s", (trans->first).c_str());
|
||||
map< string, string > tokenTrans = trans->second;
|
||||
for (map< string, string >::iterator transTok = tokenTrans.begin(); transTok != tokenTrans.end(); transTok++) {
|
||||
dsyslog("skindesigner: language %s, translation %s", (transTok->first).c_str(), (transTok->second).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cGlobals::DeleteCurledBrackets(string &token) {
|
||||
if (token.find("{") != 0)
|
||||
return;
|
||||
if (token.find("}") != token.size() - 1)
|
||||
return;
|
||||
token = token.substr(1, token.size() - 2);
|
||||
}
|
||||
|
||||
67
coreengine/globals.h
Normal file
67
coreengine/globals.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef __XMLGLOBALS_H
|
||||
#define __XMLGLOBALS_H
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <vdr/plugin.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef uint32_t tColor;
|
||||
|
||||
// --- cGlobals -------------------------------------------------------------
|
||||
|
||||
class cGlobals {
|
||||
private:
|
||||
time_t customTokenChange;
|
||||
time_t lastCustomTokenQuery;
|
||||
string language;
|
||||
string DoTranslate(string token);
|
||||
void DeleteCurledBrackets(string &token);
|
||||
map <string, tColor> colors;
|
||||
map <string, string> fonts;
|
||||
map <string, int> intVars;
|
||||
map <string, double> doubleVars;
|
||||
map <string, string> stringVars;
|
||||
map <string, map< string, string > > translations;
|
||||
map <int, string> customStringTokens;
|
||||
map <int, int> customIntTokens;
|
||||
public:
|
||||
cGlobals(void);
|
||||
virtual ~cGlobals(void) {};
|
||||
bool ReadFromXML(void);
|
||||
void AddColor(string &name, tColor &col);
|
||||
bool GetColor(string &name, tColor &col);
|
||||
void AddFont(string &name, string &font);
|
||||
bool GetFont(string name, string &font);
|
||||
void AddInt(string &name, int value);
|
||||
void ReplaceIntVars(string &value);
|
||||
bool GetInt(string name, int &val);
|
||||
void AddDouble(string &name, string &value);
|
||||
void ReplaceDoubleVars(string &value);
|
||||
void AddString(string &name, string &value);
|
||||
void ReplaceStringVars(string &value);
|
||||
bool GetString(string name, string &value);
|
||||
bool AddTranslation(string name, map < string, string > transl);
|
||||
bool Translate(string text, string &translation);
|
||||
void AddCustomInt(int num, int value);
|
||||
void AddCustomString(int num, string &value);
|
||||
bool GetCustomInt(int num, int &val);
|
||||
bool GetCustomString(int num, string &val);
|
||||
map <int, string> GetCustomStringTokens(void);
|
||||
map <int, int> GetCustomIntTokens(void);
|
||||
bool CustomTokenChange(void);
|
||||
void ResetCustomTokenChange(void);
|
||||
void ListCustomTokens(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
#endif //__XMLGLOBALS_H
|
||||
57
coreengine/gridelement.c
Normal file
57
coreengine/gridelement.c
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "gridelement.h"
|
||||
#include "../config.h"
|
||||
|
||||
cGridElement::cGridElement(void) {
|
||||
current = false;
|
||||
indexCurrent = -1;
|
||||
viewId = -1;
|
||||
plugId = -1;
|
||||
}
|
||||
|
||||
cGridElement::cGridElement(const cGridElement &other) : cViewElement(other) {
|
||||
current = false;
|
||||
viewId = other.viewId;
|
||||
plugId = other.plugId;
|
||||
tokenContainer = new skindesignerapi::cTokenContainer(*other.tokenContainer);
|
||||
indexCurrent = other.indexCurrent;
|
||||
InheritTokenContainerDeep();
|
||||
}
|
||||
|
||||
cGridElement::~cGridElement(void) {
|
||||
}
|
||||
|
||||
void cGridElement::SetTokenContainer(void) {
|
||||
skindesignerapi::cTokenContainer *tkGe = plgManager->GetTokenContainerGE(plugId, viewId, id);
|
||||
if (!tkGe)
|
||||
return;
|
||||
tokenContainer = new skindesignerapi::cTokenContainer(*tkGe);
|
||||
indexCurrent = tokenContainer->GetNumDefinedIntTokens();
|
||||
tokenContainer->DefineIntToken("{current}", indexCurrent);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cGridElement::Set(skindesignerapi::cTokenContainer *tk) {
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->SetTokens(tk);
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
void cGridElement::SetCurrent(bool current) {
|
||||
this->current = current;
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
bool cGridElement::Parse(bool forced) {
|
||||
if (!dirty)
|
||||
return false;
|
||||
tokenContainer->AddIntToken(indexCurrent, current);
|
||||
return true;
|
||||
}
|
||||
|
||||
int cGridElement::Width(void) {
|
||||
return container.Width();
|
||||
}
|
||||
|
||||
int cGridElement::Height(void) {
|
||||
return container.Height();
|
||||
}
|
||||
27
coreengine/gridelement.h
Normal file
27
coreengine/gridelement.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef __GRIDELEMENT_H
|
||||
#define __GRIDELEMENT_H
|
||||
|
||||
#include "viewelement.h"
|
||||
|
||||
class cGridElement : public cViewElement {
|
||||
private:
|
||||
int viewId;
|
||||
int plugId;
|
||||
bool current;
|
||||
int indexCurrent;
|
||||
public:
|
||||
cGridElement(void);
|
||||
cGridElement(const cGridElement &other);
|
||||
virtual ~cGridElement(void);
|
||||
void SetPluginId(int plugId) { this->plugId = plugId; };
|
||||
void SetViewId(int viewId) { this->viewId = viewId; };
|
||||
void SetTokenContainer(void);
|
||||
skindesignerapi::cTokenContainer *GetTokenContainer(void) { return tokenContainer; };
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
void SetCurrent(bool current);
|
||||
bool Parse(bool forced = true);
|
||||
int Width(void);
|
||||
int Height(void);
|
||||
};
|
||||
|
||||
#endif //__GRIDELEMENT_H
|
||||
1830
coreengine/listelements.c
Normal file
1830
coreengine/listelements.c
Normal file
File diff suppressed because it is too large
Load Diff
337
coreengine/listelements.h
Normal file
337
coreengine/listelements.h
Normal file
@@ -0,0 +1,337 @@
|
||||
#ifndef __LISTELEMENTS_H
|
||||
#define __LISTELEMENTS_H
|
||||
|
||||
#include "viewelement.h"
|
||||
#include "../extensions/scrapmanager.h"
|
||||
|
||||
#define MAX_TABS 6
|
||||
/******************************************************************
|
||||
* cListElement
|
||||
******************************************************************/
|
||||
class cListElement : public cViewElement {
|
||||
protected:
|
||||
eMenuCategory menuCat;
|
||||
int num;
|
||||
bool current;
|
||||
bool wasCurrent;
|
||||
bool selectable;
|
||||
cViewElement *currentElement;
|
||||
char *ParseSeparator(const char *text);
|
||||
public:
|
||||
cListElement(void);
|
||||
cListElement(const cListElement &other);
|
||||
virtual ~cListElement(void) {};
|
||||
void SetMenuCategory(eMenuCategory menuCat) { this->menuCat = menuCat; };
|
||||
void SetNumber(int number) { num = number; };
|
||||
void SetCurrent(bool cur);
|
||||
bool Current(void) { return current; };
|
||||
void WakeCurrent(void);
|
||||
void SetSelectable(bool sel) { selectable = sel; };
|
||||
bool DoScroll(void) { return current; };
|
||||
virtual void RenderCurrent(void) { };
|
||||
void Close(void);
|
||||
void Clear(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cCurrentElement
|
||||
******************************************************************/
|
||||
class cCurrentElement : public cViewElement {
|
||||
protected:
|
||||
int listX;
|
||||
int listY;
|
||||
int listWidth;
|
||||
int listHeight;
|
||||
public:
|
||||
cCurrentElement(void);
|
||||
virtual ~cCurrentElement(void) {};
|
||||
void SetListPosition(int x, int y, int width, int height);
|
||||
void SetListTokens(skindesignerapi::cTokenContainer *tokenContainer);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeMenuDefault
|
||||
******************************************************************/
|
||||
class cLeMenuDefault : public cListElement {
|
||||
private:
|
||||
char *text;
|
||||
int *colX;
|
||||
int *colWidths;
|
||||
const char *plugName;
|
||||
const char *GetTabbedText(const char *s, int tab);
|
||||
void SetMenuCategory(void);
|
||||
void CheckProgressBar(const char *text, int tab);
|
||||
public:
|
||||
cLeMenuDefault(void);
|
||||
cLeMenuDefault(const cLeMenuDefault &other);
|
||||
virtual ~cLeMenuDefault(void);
|
||||
void SetListInfo(int *colX, int *colWidths);
|
||||
void SetText(const char *text);
|
||||
void SetPlugin(const char *plugName) { this->plugName = plugName; };
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeMenuMain
|
||||
******************************************************************/
|
||||
class cVeMenuMain {
|
||||
protected:
|
||||
char *text;
|
||||
char *number;
|
||||
char *label;
|
||||
void SplitText(void);
|
||||
public:
|
||||
cVeMenuMain(void);
|
||||
virtual ~cVeMenuMain(void);
|
||||
void SetText(const char *text);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeMenuMain
|
||||
******************************************************************/
|
||||
class cCeMenuMain;
|
||||
class cLeMenuMain : public cListElement, public cVeMenuMain {
|
||||
private:
|
||||
cCeMenuMain *currentMain;
|
||||
public:
|
||||
cLeMenuMain(void);
|
||||
cLeMenuMain(const cLeMenuMain &other);
|
||||
virtual ~cLeMenuMain(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetCurrentElement(cCeMenuMain *cur) { currentMain = cur; currentElement = (cViewElement*)cur; };
|
||||
void ClearCurrentElement(void);
|
||||
void SetText(const char *text);
|
||||
bool Parse(bool forced = true);
|
||||
void RenderCurrent(void);
|
||||
const char *PluginName(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cCeMenuMain
|
||||
******************************************************************/
|
||||
class cCeMenuMain : public cCurrentElement, public cVeMenuMain {
|
||||
private:
|
||||
public:
|
||||
cCeMenuMain(void);
|
||||
virtual ~cCeMenuMain(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetText(const char *text);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeMenuSchedules
|
||||
******************************************************************/
|
||||
class cVeMenuSchedules {
|
||||
protected:
|
||||
const cEvent *event;
|
||||
const cChannel *channel;
|
||||
bool withDate;
|
||||
eTimerMatch timerMatch;
|
||||
bool epgSearchFav;
|
||||
public:
|
||||
cVeMenuSchedules(void);
|
||||
virtual ~cVeMenuSchedules(void){};
|
||||
void SetEpgSearchFav(bool isFav) { epgSearchFav = isFav; };
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeMenuSchedules
|
||||
******************************************************************/
|
||||
class cCeMenuSchedules;
|
||||
class cLeMenuSchedules : public cListElement, public cVeMenuSchedules {
|
||||
private:
|
||||
cCeMenuSchedules *currentSchedules;
|
||||
public:
|
||||
cLeMenuSchedules(void);
|
||||
cLeMenuSchedules(const cLeMenuSchedules &other);
|
||||
virtual ~cLeMenuSchedules(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetCurrentElement(cCeMenuSchedules *cur) { currentSchedules = cur; currentElement = (cViewElement*)cur; };
|
||||
void ClearCurrentElement(void);
|
||||
void Set(const cEvent *event, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
|
||||
bool Parse(bool forced = true);
|
||||
void RenderCurrent(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cCeMenuSchedules
|
||||
******************************************************************/
|
||||
class cCeMenuSchedules : public cCurrentElement, public cVeMenuSchedules, public cScrapManager {
|
||||
private:
|
||||
eMenuCategory menuCat;
|
||||
int schedulesIndex;
|
||||
public:
|
||||
cCeMenuSchedules(void);
|
||||
virtual ~cCeMenuSchedules(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cEvent *event, const cChannel *channel, bool withDate, eTimerMatch timerMatch, eMenuCategory menuCat);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeMenuChannels
|
||||
******************************************************************/
|
||||
class cCeMenuChannels;
|
||||
class cLeMenuChannels : public cListElement {
|
||||
private:
|
||||
cCeMenuChannels *currentChannel;
|
||||
const cChannel *channel;
|
||||
bool withProvider;
|
||||
public:
|
||||
cLeMenuChannels(void);
|
||||
cLeMenuChannels(const cLeMenuChannels &other);
|
||||
virtual ~cLeMenuChannels(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetCurrentElement(cCeMenuChannels *cur) { currentChannel = cur; currentElement = (cViewElement*)cur; };
|
||||
void ClearCurrentElement(void);
|
||||
void Set(const cChannel *channel, bool withProvider);
|
||||
bool Parse(bool forced = true);
|
||||
void RenderCurrent(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cCeMenuChannels
|
||||
******************************************************************/
|
||||
class cCeMenuChannels : public cCurrentElement {
|
||||
private:
|
||||
const cChannel *channel;
|
||||
bool withProvider;
|
||||
int schedulesIndex;
|
||||
public:
|
||||
cCeMenuChannels(void);
|
||||
virtual ~cCeMenuChannels(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cChannel *channel, bool withProvider);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeMenuTimers
|
||||
******************************************************************/
|
||||
class cCeMenuTimers;
|
||||
class cLeMenuTimers : public cListElement {
|
||||
private:
|
||||
cCeMenuTimers *currentTimer;
|
||||
const cTimer *timer;
|
||||
public:
|
||||
cLeMenuTimers(void);
|
||||
virtual ~cLeMenuTimers(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetCurrentElement(cCeMenuTimers *cur) { currentTimer = cur; currentElement = (cViewElement*)cur; };
|
||||
void ClearCurrentElement(void);
|
||||
void Set(const cTimer *timer);
|
||||
bool Parse(bool forced = true);
|
||||
void RenderCurrent(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cCeMenuTimers
|
||||
******************************************************************/
|
||||
class cCeMenuTimers : public cCurrentElement {
|
||||
private:
|
||||
const cTimer *timer;
|
||||
public:
|
||||
cCeMenuTimers(void);
|
||||
virtual ~cCeMenuTimers(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cTimer *timer);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeMenuRecordings
|
||||
******************************************************************/
|
||||
class cCeMenuRecordings;
|
||||
class cLeMenuRecordings : public cListElement, public cScrapManager {
|
||||
private:
|
||||
cCeMenuRecordings *currentRecording;
|
||||
const cRecording *recording;
|
||||
int level;
|
||||
int total;
|
||||
int New;
|
||||
char *RecName(const char *path, int level);
|
||||
char *FolderName(const char *path, int level);
|
||||
public:
|
||||
cLeMenuRecordings(void);
|
||||
virtual ~cLeMenuRecordings(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetCurrentElement(cCeMenuRecordings *cur) { currentRecording = cur; currentElement = (cViewElement*)cur; };
|
||||
void ClearCurrentElement(void);
|
||||
void Set(const cRecording *recording, int level, int total, int New);
|
||||
bool Parse(bool forced = true);
|
||||
void RenderCurrent(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cCeMenuRecordings
|
||||
******************************************************************/
|
||||
class cCeMenuRecordings : public cCurrentElement, public cScrapManager {
|
||||
private:
|
||||
const cRecording *recording;
|
||||
int level;
|
||||
int total;
|
||||
int New;
|
||||
public:
|
||||
cCeMenuRecordings(void);
|
||||
virtual ~cCeMenuRecordings(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cRecording *recording, int level, int total, int New);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeMenuPlugin
|
||||
******************************************************************/
|
||||
class cCeMenuPlugin;
|
||||
class cLeMenuPlugin : public cListElement {
|
||||
private:
|
||||
int plugId;
|
||||
int plugMenuId;
|
||||
cCeMenuPlugin *currentPlugin;
|
||||
public:
|
||||
cLeMenuPlugin(void);
|
||||
virtual ~cLeMenuPlugin(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetPlugId(int id) { plugId = id; };
|
||||
void SetPlugMenuId(int id) { plugMenuId = id; };
|
||||
void SetCurrentElement(cCeMenuPlugin *cur) { currentPlugin = cur; currentElement = (cViewElement*)cur; };
|
||||
void ClearCurrentElement(void);
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
bool Parse(bool forced = true);
|
||||
void RenderCurrent(void);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cCeMenuPlugin
|
||||
******************************************************************/
|
||||
class cCeMenuPlugin : public cCurrentElement {
|
||||
private:
|
||||
int plugId;
|
||||
int plugMenuId;
|
||||
public:
|
||||
cCeMenuPlugin(void);
|
||||
virtual ~cCeMenuPlugin(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetPlugId(int id) { plugId = id; };
|
||||
void SetPlugMenuId(int id) { plugMenuId = id; };
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cLeAudioTracks
|
||||
******************************************************************/
|
||||
class cLeAudioTracks : public cListElement {
|
||||
private:
|
||||
char *text;
|
||||
public:
|
||||
cLeAudioTracks(void);
|
||||
virtual ~cLeAudioTracks(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const char *text);
|
||||
bool Parse(bool forced = true);
|
||||
};
|
||||
|
||||
#endif //__LISTELEMENTS_H
|
||||
71
coreengine/osdwrapper.c
Normal file
71
coreengine/osdwrapper.c
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "osdwrapper.h"
|
||||
|
||||
cSdOsd::cSdOsd(void) {
|
||||
osd = NULL;
|
||||
flushLocked = false;
|
||||
}
|
||||
|
||||
cSdOsd::~cSdOsd(void) {
|
||||
DeleteOsd();
|
||||
}
|
||||
|
||||
void cSdOsd::Lock(void) {
|
||||
mutex.Lock();
|
||||
}
|
||||
|
||||
void cSdOsd::Unlock(void) {
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
||||
void cSdOsd::LockFlush(void) {
|
||||
Lock();
|
||||
flushLocked = true;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void cSdOsd::UnlockFlush(void) {
|
||||
Lock();
|
||||
flushLocked = false;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
bool cSdOsd::CreateOsd(int x, int y, int width, int height) {
|
||||
cOsd *newOsd = cOsdProvider::NewOsd(cOsd::OsdLeft() + x, cOsd::OsdTop() + y);
|
||||
if (newOsd) {
|
||||
tArea Area = { 0, 0, width - 1, height - 1, 32 };
|
||||
if (newOsd->SetAreas(&Area, 1) == oeOk) {
|
||||
Lock();
|
||||
osd = newOsd;
|
||||
Unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cSdOsd::DeleteOsd(void) {
|
||||
Lock();
|
||||
delete osd;
|
||||
osd = NULL;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
cPixmap *cSdOsd::CreatePixmap(int layer, cRect &viewPort, cRect &drawPort) {
|
||||
if (osd) {
|
||||
return osd->CreatePixmap(layer, viewPort, drawPort);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cSdOsd::DestroyPixmap(cPixmap *pix) {
|
||||
if (osd) {
|
||||
osd->DestroyPixmap(pix);
|
||||
}
|
||||
}
|
||||
|
||||
void cSdOsd::Flush(void) {
|
||||
Lock();
|
||||
if (osd && !flushLocked)
|
||||
osd->Flush();
|
||||
Unlock();
|
||||
}
|
||||
26
coreengine/osdwrapper.h
Normal file
26
coreengine/osdwrapper.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef __OSDWRAPPER_H
|
||||
#define __OSDWRAPPER_H
|
||||
|
||||
#include <vdr/osd.h>
|
||||
#include <vdr/thread.h>
|
||||
|
||||
class cSdOsd {
|
||||
private:
|
||||
cOsd *osd;
|
||||
cMutex mutex;
|
||||
bool flushLocked;
|
||||
public:
|
||||
cSdOsd(void);
|
||||
virtual ~cSdOsd(void);
|
||||
void Lock(void);
|
||||
void Unlock(void);
|
||||
void LockFlush(void);
|
||||
void UnlockFlush(void);
|
||||
bool CreateOsd(int x, int y, int width, int height);
|
||||
void DeleteOsd(void);
|
||||
cPixmap *CreatePixmap(int layer, cRect &viewPort, cRect &drawPort);
|
||||
void DestroyPixmap(cPixmap *pix);
|
||||
void Flush(void);
|
||||
};
|
||||
|
||||
#endif //__OSDWRAPPER_H
|
||||
419
coreengine/view.c
Normal file
419
coreengine/view.c
Normal file
@@ -0,0 +1,419 @@
|
||||
#include "../config.h"
|
||||
#include "view.h"
|
||||
|
||||
// --- cView -------------------------------------------------------------
|
||||
|
||||
cView::cView(void) {
|
||||
globals = NULL;
|
||||
viewName = NULL;
|
||||
attribs = new cViewAttribs((int)eViewAttribs::count);
|
||||
numViewElements = 0;
|
||||
viewElements = NULL;
|
||||
viewElementsHorizontal = NULL;
|
||||
fader = NULL;
|
||||
shifter = NULL;
|
||||
currentTvFrame = NULL;
|
||||
newTvFrame = NULL;
|
||||
menuInit = false;
|
||||
}
|
||||
|
||||
cView::~cView() {
|
||||
for (int i=0; i< numViewElements; i++)
|
||||
delete viewElements[i];
|
||||
delete[] viewElements;
|
||||
if (viewElementsHorizontal) {
|
||||
for (int i=0; i< numViewElements; i++)
|
||||
delete viewElementsHorizontal[i];
|
||||
delete[] viewElementsHorizontal;
|
||||
}
|
||||
delete attribs;
|
||||
free(viewName);
|
||||
delete fader;
|
||||
delete shifter;
|
||||
sdOsd.DeleteOsd();
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* Public Functions
|
||||
*******************************************************************/
|
||||
bool cView::ReadFromXML(void) {
|
||||
const char *xmlFile;
|
||||
switch (viewId) {
|
||||
case eViewType::DisplayChannel:
|
||||
xmlFile = "displaychannel.xml";
|
||||
break;
|
||||
case eViewType::DisplayMenu:
|
||||
xmlFile = "displaymenu.xml";
|
||||
break;
|
||||
case eViewType::DisplayMessage:
|
||||
xmlFile = "displaymessage.xml";
|
||||
break;
|
||||
case eViewType::DisplayReplay:
|
||||
xmlFile = "displayreplay.xml";
|
||||
break;
|
||||
case eViewType::DisplayVolume:
|
||||
xmlFile = "displayvolume.xml";
|
||||
break;
|
||||
case eViewType::DisplayTracks:
|
||||
xmlFile = "displayaudiotracks.xml";
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
cXmlParser parser;
|
||||
parser.SetOsd(&sdOsd);
|
||||
if (!parser.ReadView(this, xmlFile)) {
|
||||
return false;
|
||||
}
|
||||
if (!parser.ParseView()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//read additional plugin menu templates
|
||||
bool ok = true;
|
||||
if (viewId == eViewType::DisplayMenu) {
|
||||
plgManager->InitPluginMenuIterator();
|
||||
map <int,skindesignerapi::sPlugMenu> *plugMenus = NULL;
|
||||
string plugName = "";
|
||||
int plugId = -1;
|
||||
while ( plugMenus = plgManager->GetPluginMenus(plugName, plugId) ) {
|
||||
for (map <int,skindesignerapi::sPlugMenu>::iterator it = plugMenus->begin(); it != plugMenus->end(); it++) {
|
||||
int templateNumber = it->first;
|
||||
int menuType = it->second.type;
|
||||
cString templateName = cString::sprintf("plug-%s-%s", plugName.c_str(), it->second.tplname.c_str());
|
||||
if (parser.ReadPluginView(*templateName)) {
|
||||
ok = parser.ParsePluginView(plugName, plugId, templateNumber, menuType);
|
||||
} else {
|
||||
dsyslog("skindesigner: template %s for plugin %s not available", *templateName, plugName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void cView::SetGlobals(cGlobals *globals) {
|
||||
this->globals = globals;
|
||||
attribs->SetGlobals(globals);
|
||||
for (int i=0; i < numViewElements; ++i) {
|
||||
if (viewElements[i]) {
|
||||
viewElements[i]->SetGlobals(globals);
|
||||
}
|
||||
if (viewElementsHorizontal && viewElementsHorizontal[i]) {
|
||||
viewElementsHorizontal[i]->SetGlobals(globals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cView::SetContainer(int x, int y, int width, int height) {
|
||||
container.SetX(x);
|
||||
container.SetY(y);
|
||||
container.SetWidth(width);
|
||||
container.SetHeight(height);
|
||||
}
|
||||
|
||||
void cView::SetAttributes(vector<stringpair> &attributes) {
|
||||
attribs->Set(attributes);
|
||||
}
|
||||
|
||||
void cView::AddViewElement(const char *sViewElement, cViewElement *viewElement) {
|
||||
int id = ViewElementId(sViewElement);
|
||||
if (id == ATTR_UNKNOWN)
|
||||
return;
|
||||
viewElement->SetId(id);
|
||||
viewElement->SetTokenContainer();
|
||||
eOrientation orientation = viewElement->Orientation();
|
||||
if (viewElementsHorizontal && orientation == eOrientation::horizontal) {
|
||||
viewElementsHorizontal[id] = viewElement;
|
||||
} else {
|
||||
viewElements[id] = viewElement;
|
||||
}
|
||||
}
|
||||
|
||||
bool cView::ValidViewElement(const char *viewElement) {
|
||||
if (ViewElementId(viewElement) != ATTR_UNKNOWN)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cView::ValidViewList(const char *viewList) {
|
||||
if (!strcmp(viewList, "menuitems"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void cView::PreCache(void) {
|
||||
if (container.Width() == 0) {
|
||||
SetContainer(0, 0, cOsd::OsdWidth(), cOsd::OsdHeight());
|
||||
attribs->SetContainer(0, 0, cOsd::OsdWidth(), cOsd::OsdHeight());
|
||||
attribs->Cache();
|
||||
}
|
||||
//set frame for scaling tv picture
|
||||
tvFrame = attribs->TvFrame();
|
||||
//cache viewelements
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (!viewElements[i])
|
||||
continue;
|
||||
viewElements[i]->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
viewElements[i]->Cache();
|
||||
}
|
||||
if (viewElementsHorizontal) {
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (!viewElementsHorizontal[i])
|
||||
continue;
|
||||
viewElementsHorizontal[i]->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
viewElementsHorizontal[i]->Cache();
|
||||
}
|
||||
}
|
||||
|
||||
//cleanup viewelements
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (!viewElements[i])
|
||||
continue;
|
||||
if (!viewElements[i]->Execute()) {
|
||||
delete viewElements[i];
|
||||
viewElements[i] = NULL;
|
||||
}
|
||||
}
|
||||
if (viewElementsHorizontal) {
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (!viewElementsHorizontal[i])
|
||||
continue;
|
||||
if (!viewElementsHorizontal[i]->Execute()) {
|
||||
delete viewElementsHorizontal[i];
|
||||
viewElementsHorizontal[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
//set viewelement objects for each view
|
||||
SetViewElementObjects();
|
||||
}
|
||||
|
||||
bool cView::Init(void) {
|
||||
int osdX = attribs->X();
|
||||
int osdY = attribs->Y();
|
||||
int osdWidth = attribs->Width();
|
||||
int osdHeight = attribs->Height();
|
||||
return sdOsd.CreateOsd(osdX, osdY, osdWidth, osdHeight);
|
||||
}
|
||||
|
||||
void cView::Clear(int ve) {
|
||||
if (!viewElements[ve])
|
||||
return;
|
||||
viewElements[ve]->Clear();
|
||||
}
|
||||
|
||||
void cView::Render(int ve, bool force) {
|
||||
if (!viewElements[ve])
|
||||
return;
|
||||
if (viewElements[ve]->Parse(force))
|
||||
viewElements[ve]->Render();
|
||||
}
|
||||
|
||||
void cView::Close(void) {
|
||||
delete fader;
|
||||
fader = NULL;
|
||||
delete shifter;
|
||||
shifter = NULL;
|
||||
if (initFinished && ShiftTime() > 0) {
|
||||
cRect shiftbox = CoveredArea();
|
||||
cPoint ref = cPoint(shiftbox.X(), shiftbox.Y());
|
||||
cPoint end = ShiftStart(shiftbox);
|
||||
shifter = new cAnimation((cShiftable*)this, end, ref, false);
|
||||
shifter->Shift();
|
||||
delete shifter;
|
||||
shifter = NULL;
|
||||
} else if (initFinished && FadeTime() > 0) {
|
||||
fader = new cAnimation((cFadable*)this, false);
|
||||
fader->Fade();
|
||||
delete fader;
|
||||
fader = NULL;
|
||||
}
|
||||
if (initFinished)
|
||||
UnScaleTv();
|
||||
ClearVariables();
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (!viewElements[i])
|
||||
continue;
|
||||
viewElements[i]->Close();
|
||||
}
|
||||
sdOsd.DeleteOsd();
|
||||
}
|
||||
|
||||
int cView::FadeTime(void) {
|
||||
return attribs->FadeTime();
|
||||
}
|
||||
|
||||
void cView::SetTransparency(int transparency, bool force) {
|
||||
for (int i = 0; i < numViewElements; i++) {
|
||||
if (viewElements[i] && (!viewElements[i]->Fading() || force)) {
|
||||
viewElements[i]->SetTransparency(transparency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cView::ShiftTime(void) {
|
||||
return attribs->ShiftTime();
|
||||
}
|
||||
|
||||
int cView::ShiftMode(void) {
|
||||
return attribs->ShiftMode();
|
||||
}
|
||||
|
||||
void cView::SetPosition(cPoint &position, cPoint &reference, bool force) {
|
||||
for (int i = 0; i < numViewElements; i++) {
|
||||
if (viewElements[i] && (!viewElements[i]->Shifting() || force)) {
|
||||
viewElements[i]->SetPosition(position, reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cView::Flush(void) {
|
||||
if (init) {
|
||||
init = false;
|
||||
StartAnimation();
|
||||
menuInit = true;
|
||||
//LockFlush was set at startup of view to avoid display
|
||||
//of not positioned pixmaps for shifting and fading
|
||||
sdOsd.UnlockFlush();
|
||||
}
|
||||
if (menuInit) {
|
||||
ScaleTv();
|
||||
WakeViewElements();
|
||||
menuInit = false;
|
||||
}
|
||||
sdOsd.Flush();
|
||||
}
|
||||
|
||||
void cView::Debug(void) {
|
||||
esyslog("skindesigner: ---> view %s", viewName);
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (!viewElements[i])
|
||||
continue;
|
||||
esyslog("skindesigner: debugging ve %d", i);
|
||||
viewElements[i]->Debug(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* Protected Functions
|
||||
*******************************************************************/
|
||||
void cView::ClearVariables(void) {
|
||||
init = true;
|
||||
initFinished = false;
|
||||
newTvFrame = NULL;
|
||||
currentTvFrame = NULL;
|
||||
menuInit = false;
|
||||
}
|
||||
|
||||
int cView::ViewElementId(const char *name) {
|
||||
map<string, int>::iterator hit = viewElementNames.find(name);
|
||||
if (hit != viewElementNames.end())
|
||||
return (int)hit->second;
|
||||
return ATTR_UNKNOWN;
|
||||
}
|
||||
|
||||
void cView::StartAnimation(void) {
|
||||
if (ShiftTime() > 0) {
|
||||
cRect shiftbox = CoveredArea();
|
||||
cPoint ref = cPoint(shiftbox.X(), shiftbox.Y());
|
||||
cPoint start = ShiftStart(shiftbox);
|
||||
SetPosition(start, ref);
|
||||
shifter = new cAnimation((cShiftable*)this, start, ref, true);
|
||||
shifter->Start();
|
||||
} else if (FadeTime() > 0) {
|
||||
if (fader)
|
||||
return;
|
||||
SetTransparency(100);
|
||||
sdOsd.Flush();
|
||||
fader = new cAnimation((cFadable*)this, true);
|
||||
fader->Start();
|
||||
}
|
||||
initFinished = true;
|
||||
}
|
||||
|
||||
void cView::WakeViewElements(void) {
|
||||
for (int i = 0; i < numViewElements; i++) {
|
||||
if (viewElements[i]) {
|
||||
viewElements[i]->WakeUp();
|
||||
}
|
||||
}
|
||||
if (!viewElementsHorizontal)
|
||||
return;
|
||||
for (int i = 0; i < numViewElements; i++) {
|
||||
if (viewElementsHorizontal[i]) {
|
||||
viewElementsHorizontal[i]->WakeUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cPoint cView::ShiftStart(cRect &shiftbox) {
|
||||
eShiftType type = (eShiftType)attribs->ShiftType();
|
||||
cPoint start;
|
||||
if (type == eShiftType::none) {
|
||||
start = attribs->ShiftStartpoint();
|
||||
} else if (type == eShiftType::left) {
|
||||
start.SetX(-shiftbox.Width());
|
||||
start.SetY(shiftbox.Y());
|
||||
} else if (type == eShiftType::right) {
|
||||
start.SetX(attribs->Width());
|
||||
start.SetY(shiftbox.Y());
|
||||
} else if (type == eShiftType::top) {
|
||||
start.SetX(shiftbox.X());
|
||||
start.SetY(-shiftbox.Height());
|
||||
} else if (type == eShiftType::bottom) {
|
||||
start.SetX(shiftbox.X());
|
||||
start.SetY(attribs->Height());
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
cRect cView::CoveredArea(void) {
|
||||
cRect unionArea;
|
||||
for (int i = 0; i < numViewElements; i++) {
|
||||
if (viewElements[i] && !viewElements[i]->Shifting()) {
|
||||
unionArea.Combine(viewElements[i]->CoveredArea());
|
||||
}
|
||||
}
|
||||
return unionArea;
|
||||
}
|
||||
|
||||
void cView::ScaleTv(void) {
|
||||
bool scale = false;
|
||||
if (newTvFrame) {
|
||||
if (currentTvFrame) {
|
||||
if (*newTvFrame != *currentTvFrame) {
|
||||
scale = true;
|
||||
}
|
||||
} else {
|
||||
scale = true;
|
||||
}
|
||||
currentTvFrame = newTvFrame;
|
||||
} else {
|
||||
if (tvFrame != cRect::Null) {
|
||||
scale = true;
|
||||
currentTvFrame = &tvFrame;
|
||||
}
|
||||
}
|
||||
if (currentTvFrame && scale) {
|
||||
DoScaleTv(currentTvFrame);
|
||||
}
|
||||
}
|
||||
|
||||
void cView::UnScaleTv(void) {
|
||||
if (currentTvFrame) {
|
||||
DoScaleTv(&cRect::Null);
|
||||
currentTvFrame = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cView::DoScaleTv(const cRect *frame) {
|
||||
if (*frame == cRect::Null) {
|
||||
cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
|
||||
} else {
|
||||
cRect scalingWindow = cDevice::PrimaryDevice()->CanScaleVideo(*frame);
|
||||
if (scalingWindow != cRect::Null) {
|
||||
cDevice::PrimaryDevice()->ScaleVideo(scalingWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
93
coreengine/view.h
Normal file
93
coreengine/view.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef __VIEW_H
|
||||
#define __VIEW_H
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "osdwrapper.h"
|
||||
#include "globals.h"
|
||||
#include "../libskindesignerapi/tokencontainer.h"
|
||||
#include "viewelementplugin.h"
|
||||
#include "viewelementscommon.h"
|
||||
#include "viewelementsdisplaychannel.h"
|
||||
#include "viewelementsdisplaymenu.h"
|
||||
#include "viewelementsdisplayreplay.h"
|
||||
#include "viewelementsdisplaytracks.h"
|
||||
#include "viewlist.h"
|
||||
class cView;
|
||||
#include "xmlparser.h"
|
||||
#include "animation.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class cView : public cFadable, public cShiftable {
|
||||
private:
|
||||
void DoScaleTv(const cRect *frame);
|
||||
protected:
|
||||
cSdOsd sdOsd;
|
||||
cViewAttribs *attribs;
|
||||
cRect container;
|
||||
bool init;
|
||||
bool initFinished;
|
||||
eViewType viewId;
|
||||
cGlobals *globals;
|
||||
char *viewName;
|
||||
int numViewElements;
|
||||
cViewElement **viewElements;
|
||||
cViewElement **viewElementsHorizontal;
|
||||
map<string,int> viewElementNames;
|
||||
cAnimation *fader;
|
||||
cAnimation *shifter;
|
||||
cRect tvFrame;
|
||||
cRect *currentTvFrame;
|
||||
cRect *newTvFrame;
|
||||
bool menuInit;
|
||||
int ViewElementId(const char *name);
|
||||
virtual void ClearVariables(void);
|
||||
virtual void SetViewElementObjects(void) { };
|
||||
virtual void StartAnimation(void);
|
||||
virtual void WakeViewElements(void);
|
||||
cPoint ShiftStart(cRect &shiftbox);
|
||||
virtual cRect CoveredArea(void);
|
||||
void ScaleTv(void);
|
||||
void UnScaleTv(void);
|
||||
public:
|
||||
cView(void);
|
||||
virtual ~cView(void);
|
||||
//Loading and Caching functionality
|
||||
bool ReadFromXML(void);
|
||||
virtual void SetGlobals(cGlobals *globals);
|
||||
const char *GetViewName(void) { return viewName; };
|
||||
void SetContainer(int x, int y, int width, int height);
|
||||
void SetAttributes(vector<stringpair> &attributes);
|
||||
void AddViewElement(const char *sViewElement, cViewElement *viewElement);
|
||||
bool ValidViewElement(const char *viewElement);
|
||||
virtual void AddViewList(cViewList *viewList) { };
|
||||
bool ValidViewList(const char *viewList);
|
||||
virtual void PreCache(void);
|
||||
cRect *GetTvFrame(void) { return &tvFrame; };
|
||||
virtual const cFont *GetTextAreaFont(void) { return NULL; };
|
||||
virtual int GetTextAreaWidth(void) { return 0; };
|
||||
virtual int GetListWidth(void) { return 0; };
|
||||
//View API
|
||||
virtual bool Init(void);
|
||||
void Clear(int ve);
|
||||
void Render(int ve, bool force = false);
|
||||
virtual void Close(void);
|
||||
virtual void Flush(void);
|
||||
virtual void Debug(void);
|
||||
bool Detached(void) { return false; };
|
||||
int Delay(void) { return 0; };
|
||||
//Fadable
|
||||
int FadeTime(void);
|
||||
virtual void SetTransparency(int transparency, bool force = false);
|
||||
//Shiftable
|
||||
int ShiftTime(void);
|
||||
int ShiftMode(void);
|
||||
virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false);
|
||||
};
|
||||
|
||||
#endif //__VIEW_H
|
||||
978
coreengine/viewdetail.c
Normal file
978
coreengine/viewdetail.c
Normal file
@@ -0,0 +1,978 @@
|
||||
#include "viewdetail.h"
|
||||
#include "../config.h"
|
||||
/******************************************************************
|
||||
* cViewDetail
|
||||
******************************************************************/
|
||||
cViewDetail::cViewDetail(void) {
|
||||
activeTab = NULL;
|
||||
activeTabIndex = -1;
|
||||
numTabs = 0;
|
||||
plugId = -1;
|
||||
plugMenuId = -1;
|
||||
}
|
||||
|
||||
cViewDetail::~cViewDetail(void) {
|
||||
}
|
||||
|
||||
void cViewDetail::SetActiveTab(void) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
if (node->ActiveTab()) {
|
||||
activeTab = dynamic_cast<cArea*>(node);
|
||||
activeTabIndex = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cViewDetail::GetWidth(void) {
|
||||
cAreaNode *node = areaNodes.First();
|
||||
if (!node)
|
||||
return 0;
|
||||
return node->GetWidth();
|
||||
}
|
||||
|
||||
void cViewDetail::ResetTabs(void) {
|
||||
activeTab = NULL;
|
||||
activeTabIndex = -1;
|
||||
}
|
||||
|
||||
void cViewDetail::Clear(void) {
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cViewDetail::Close(void) {
|
||||
cViewElement::Close();
|
||||
activeTab = NULL;
|
||||
activeTabIndex = -1;
|
||||
numTabs = 0;
|
||||
}
|
||||
|
||||
void cViewDetail::Render(void) {
|
||||
if (!dirty || blocked)
|
||||
return;
|
||||
|
||||
if (attribs->DoDebug())
|
||||
Debug();
|
||||
|
||||
if (!activeTab)
|
||||
SetActiveTab();
|
||||
if (!activeTab)
|
||||
return;
|
||||
|
||||
activeTab->Clear();
|
||||
if (activeTab->Execute()) {
|
||||
activeTab->Render();
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
void cViewDetail::Scrollbar(int &barheight, int &offset, bool &end) {
|
||||
if (!activeTab)
|
||||
return;
|
||||
cRect tabViewPort = activeTab->ViewPort();
|
||||
cRect tabDrawPort = activeTab->DrawPort();
|
||||
int totalHeight = tabDrawPort.Height();
|
||||
int screenHeight = tabViewPort.Height();
|
||||
int y = (-1)*tabDrawPort.Y();
|
||||
if (totalHeight == 0) {
|
||||
return;
|
||||
}
|
||||
if (totalHeight <= screenHeight)
|
||||
barheight = 1000;
|
||||
else {
|
||||
barheight = (double)screenHeight / (double) totalHeight * 1000;
|
||||
}
|
||||
offset = (double)y / (double) totalHeight * 1000;
|
||||
end = true;
|
||||
}
|
||||
|
||||
bool cViewDetail::ScrollUp(bool page) {
|
||||
if (!activeTab)
|
||||
return false;
|
||||
cRect tabDrawPort = activeTab->DrawPort();
|
||||
int scrollStep = activeTab->ScrollStep();
|
||||
if (page) {
|
||||
cRect tabViewPort = activeTab->ViewPort();
|
||||
scrollStep = tabViewPort.Height();
|
||||
}
|
||||
int aktHeight = tabDrawPort.Y();
|
||||
if (aktHeight >= 0) {
|
||||
return false;
|
||||
}
|
||||
int newY = aktHeight + scrollStep;
|
||||
if (newY > 0)
|
||||
newY = 0;
|
||||
cPoint dp(0, newY);
|
||||
activeTab->SetDrawPort(dp);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cViewDetail::ScrollDown(bool page) {
|
||||
if (!activeTab)
|
||||
return false;
|
||||
cRect tabViewPort = activeTab->ViewPort();
|
||||
cRect tabDrawPort = activeTab->DrawPort();
|
||||
int scrollStep = activeTab->ScrollStep();
|
||||
if (page) {
|
||||
scrollStep = tabViewPort.Height();
|
||||
}
|
||||
int aktHeight = tabDrawPort.Y();
|
||||
int totalHeight = tabDrawPort.Height();
|
||||
int screenHeight = tabViewPort.Height();
|
||||
|
||||
if (totalHeight - ((-1)*aktHeight) == screenHeight) {
|
||||
return false;
|
||||
}
|
||||
int newY = aktHeight - scrollStep;
|
||||
if ((-1)*newY > totalHeight - screenHeight)
|
||||
newY = (-1)*(totalHeight - screenHeight);
|
||||
cPoint dp(0, newY);
|
||||
activeTab->SetDrawPort(dp);
|
||||
return true;
|
||||
}
|
||||
|
||||
int cViewDetail::GetTabs(vector<const char*> &tabs) {
|
||||
int i=0;
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
if (!node->Execute())
|
||||
continue;
|
||||
tabs.push_back(node->Name());
|
||||
if (node->ActiveTab()) {
|
||||
activeTabIndex = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
numTabs = i;
|
||||
return activeTabIndex;
|
||||
}
|
||||
|
||||
void cViewDetail::NextTab(void) {
|
||||
cArea *nextActiveTab = NULL;
|
||||
for (cAreaNode *node = areaNodes.Next(activeTab); node; node = areaNodes.Next(node)) {
|
||||
if (node->Execute()) {
|
||||
nextActiveTab = dynamic_cast<cArea*>(node);
|
||||
activeTabIndex++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nextActiveTab) {
|
||||
nextActiveTab = dynamic_cast<cArea*>(areaNodes.First());
|
||||
activeTabIndex = 0;
|
||||
}
|
||||
activeTab = nextActiveTab;
|
||||
}
|
||||
|
||||
void cViewDetail::PrevTab(void) {
|
||||
cArea *prevActiveTab = NULL;
|
||||
for (cAreaNode *node = areaNodes.Prev(activeTab); node; node = areaNodes.Prev(node)) {
|
||||
if (node->Execute()) {
|
||||
prevActiveTab = dynamic_cast<cArea*>(node);
|
||||
activeTabIndex--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!prevActiveTab) {
|
||||
int numActiveTabs = 0;
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
if (node->Execute()) {
|
||||
numActiveTabs++;
|
||||
}
|
||||
}
|
||||
for (cAreaNode *node = areaNodes.Last(); node; node = areaNodes.Prev(node)) {
|
||||
if (node->Execute()) {
|
||||
prevActiveTab = dynamic_cast<cArea*>(node);
|
||||
activeTabIndex = numActiveTabs-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
activeTab = prevActiveTab;
|
||||
}
|
||||
|
||||
void cViewDetail::SetTransparency(int transparency, bool forceDetached) {
|
||||
if (activeTab)
|
||||
activeTab->SetTransparency(transparency);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewDetailEpg
|
||||
******************************************************************/
|
||||
cViewDetailEpg::cViewDetailEpg(void) {
|
||||
event = NULL;
|
||||
rerunsIndex = -1;
|
||||
actorsIndex = -1;
|
||||
}
|
||||
|
||||
cViewDetailEpg::~cViewDetailEpg(void) {
|
||||
}
|
||||
|
||||
void cViewDetailEpg::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{title}", (int)eDmDetailedEpgST::title);
|
||||
tokenContainer->DefineStringToken("{shorttext}", (int)eDmDetailedEpgST::shorttext);
|
||||
tokenContainer->DefineStringToken("{description}", (int)eDmDetailedEpgST::description);
|
||||
tokenContainer->DefineStringToken("{start}", (int)eDmDetailedEpgST::start);
|
||||
tokenContainer->DefineStringToken("{stop}", (int)eDmDetailedEpgST::stop);
|
||||
tokenContainer->DefineStringToken("{day}", (int)eDmDetailedEpgST::day);
|
||||
tokenContainer->DefineStringToken("{date}", (int)eDmDetailedEpgST::date);
|
||||
tokenContainer->DefineStringToken("{durationminutes}", (int)eDmDetailedEpgST::durationminutes);
|
||||
tokenContainer->DefineStringToken("{vps}", (int)eDmDetailedEpgST::vps);
|
||||
tokenContainer->DefineStringToken("{channelname}", (int)eDmDetailedEpgST::channelname);
|
||||
tokenContainer->DefineStringToken("{channelid}", (int)eDmDetailedEpgST::channelid);
|
||||
tokenContainer->DefineStringToken("{epgpic1path}", (int)eDmDetailedEpgST::epgpic1path);
|
||||
tokenContainer->DefineStringToken("{epgpic2path}", (int)eDmDetailedEpgST::epgpic2path);
|
||||
tokenContainer->DefineStringToken("{epgpic3path}", (int)eDmDetailedEpgST::epgpic3path);
|
||||
tokenContainer->DefineStringToken("{movietitle}", (int)eScraperST::movietitle);
|
||||
tokenContainer->DefineStringToken("{movieoriginalTitle}", (int)eScraperST::movieoriginalTitle);
|
||||
tokenContainer->DefineStringToken("{movietagline}", (int)eScraperST::movietagline);
|
||||
tokenContainer->DefineStringToken("{movieoverview}", (int)eScraperST::movieoverview);
|
||||
tokenContainer->DefineStringToken("{moviegenres}", (int)eScraperST::moviegenres);
|
||||
tokenContainer->DefineStringToken("{moviehomepage}", (int)eScraperST::moviehomepage);
|
||||
tokenContainer->DefineStringToken("{moviereleasedate}", (int)eScraperST::moviereleasedate);
|
||||
tokenContainer->DefineStringToken("{moviepopularity}", (int)eScraperST::moviepopularity);
|
||||
tokenContainer->DefineStringToken("{movievoteaverage}", (int)eScraperST::movievoteaverage);
|
||||
tokenContainer->DefineStringToken("{posterpath}", (int)eScraperST::posterpath);
|
||||
tokenContainer->DefineStringToken("{fanartpath}", (int)eScraperST::fanartpath);
|
||||
tokenContainer->DefineStringToken("{moviecollectionName}", (int)eScraperST::moviecollectionName);
|
||||
tokenContainer->DefineStringToken("{collectionposterpath}", (int)eScraperST::collectionposterpath);
|
||||
tokenContainer->DefineStringToken("{collectionfanartpath}", (int)eScraperST::collectionfanartpath);
|
||||
tokenContainer->DefineStringToken("{seriesname}", (int)eScraperST::seriesname);
|
||||
tokenContainer->DefineStringToken("{seriesoverview}", (int)eScraperST::seriesoverview);
|
||||
tokenContainer->DefineStringToken("{seriesfirstaired}", (int)eScraperST::seriesfirstaired);
|
||||
tokenContainer->DefineStringToken("{seriesnetwork}", (int)eScraperST::seriesnetwork);
|
||||
tokenContainer->DefineStringToken("{seriesgenre}", (int)eScraperST::seriesgenre);
|
||||
tokenContainer->DefineStringToken("{seriesrating}", (int)eScraperST::seriesrating);
|
||||
tokenContainer->DefineStringToken("{seriesstatus}", (int)eScraperST::seriesstatus);
|
||||
tokenContainer->DefineStringToken("{episodetitle}", (int)eScraperST::episodetitle);
|
||||
tokenContainer->DefineStringToken("{episodefirstaired}", (int)eScraperST::episodefirstaired);
|
||||
tokenContainer->DefineStringToken("{episodegueststars}", (int)eScraperST::episodegueststars);
|
||||
tokenContainer->DefineStringToken("{episodeoverview}", (int)eScraperST::episodeoverview);
|
||||
tokenContainer->DefineStringToken("{episoderating}", (int)eScraperST::episoderating);
|
||||
tokenContainer->DefineStringToken("{episodeimagepath}", (int)eScraperST::episodeimagepath);
|
||||
tokenContainer->DefineStringToken("{seasonposterpath}", (int)eScraperST::seasonposterpath);
|
||||
tokenContainer->DefineStringToken("{seriesposter1path}", (int)eScraperST::seriesposter1path);
|
||||
tokenContainer->DefineStringToken("{seriesposter2path}", (int)eScraperST::seriesposter2path);
|
||||
tokenContainer->DefineStringToken("{seriesposter3path}", (int)eScraperST::seriesposter3path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart1path}", (int)eScraperST::seriesfanart1path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart2path}", (int)eScraperST::seriesfanart2path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart3path}", (int)eScraperST::seriesfanart3path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner1path}", (int)eScraperST::seriesbanner1path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner2path}", (int)eScraperST::seriesbanner2path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner3path}", (int)eScraperST::seriesbanner3path);
|
||||
tokenContainer->DefineIntToken("{daynumeric}", (int)eDmDetailedEpgIT::daynumeric);
|
||||
tokenContainer->DefineIntToken("{month}", (int)eDmDetailedEpgIT::month);
|
||||
tokenContainer->DefineIntToken("{year}", (int)eDmDetailedEpgIT::year);
|
||||
tokenContainer->DefineIntToken("{running}", (int)eDmDetailedEpgIT::running);
|
||||
tokenContainer->DefineIntToken("{elapsed}", (int)eDmDetailedEpgIT::elapsed);
|
||||
tokenContainer->DefineIntToken("{duration}", (int)eDmDetailedEpgIT::duration);
|
||||
tokenContainer->DefineIntToken("{durationhours}", (int)eDmDetailedEpgIT::durationhours);
|
||||
tokenContainer->DefineIntToken("{channelnumber}", (int)eDmDetailedEpgIT::channelnumber);
|
||||
tokenContainer->DefineIntToken("{channellogoexists}", (int)eDmDetailedEpgIT::channellogoexists);
|
||||
tokenContainer->DefineIntToken("{hasreruns}", (int)eDmDetailedEpgIT::hasreruns);
|
||||
tokenContainer->DefineIntToken("{epgpic1avaialble}", (int)eDmDetailedEpgIT::epgpic1avaialble);
|
||||
tokenContainer->DefineIntToken("{epgpic2avaialble}", (int)eDmDetailedEpgIT::epgpic2avaialble);
|
||||
tokenContainer->DefineIntToken("{epgpic3avaialble}", (int)eDmDetailedEpgIT::epgpic3avaialble);
|
||||
tokenContainer->DefineIntToken("{ismovie}", (int)eScraperIT::ismovie);
|
||||
tokenContainer->DefineIntToken("{moviebudget}", (int)eScraperIT::moviebudget);
|
||||
tokenContainer->DefineIntToken("{movierevenue}", (int)eScraperIT::movierevenue);
|
||||
tokenContainer->DefineIntToken("{movieadult}", (int)eScraperIT::movieadult);
|
||||
tokenContainer->DefineIntToken("{movieruntime}", (int)eScraperIT::movieruntime);
|
||||
tokenContainer->DefineIntToken("{isseries}", (int)eScraperIT::isseries);
|
||||
tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperIT::posterwidth);
|
||||
tokenContainer->DefineIntToken("{posterheight}", (int)eScraperIT::posterheight);
|
||||
tokenContainer->DefineIntToken("{fanartwidth}", (int)eScraperIT::fanartwidth);
|
||||
tokenContainer->DefineIntToken("{fanartheight}", (int)eScraperIT::fanartheight);
|
||||
tokenContainer->DefineIntToken("{movieiscollection}", (int)eScraperIT::movieiscollection);
|
||||
tokenContainer->DefineIntToken("{collectionposterwidth}", (int)eScraperIT::collectionposterwidth);
|
||||
tokenContainer->DefineIntToken("{collectionposterheight}", (int)eScraperIT::collectionposterheight);
|
||||
tokenContainer->DefineIntToken("{collectionfanartwidth}", (int)eScraperIT::collectionfanartwidth);
|
||||
tokenContainer->DefineIntToken("{collectionfanartheight}", (int)eScraperIT::collectionfanartheight);
|
||||
tokenContainer->DefineIntToken("{epgpicavailable}", (int)eScraperIT::epgpicavailable);
|
||||
tokenContainer->DefineIntToken("{episodenumber}", (int)eScraperIT::episodenumber);
|
||||
tokenContainer->DefineIntToken("{episodeseason}", (int)eScraperIT::episodeseason);
|
||||
tokenContainer->DefineIntToken("{episodeimagewidth}", (int)eScraperIT::episodeimagewidth);
|
||||
tokenContainer->DefineIntToken("{episodeimageheight}", (int)eScraperIT::episodeimageheight);
|
||||
tokenContainer->DefineIntToken("{seasonposterwidth}", (int)eScraperIT::seasonposterwidth);
|
||||
tokenContainer->DefineIntToken("{seasonposterheight}", (int)eScraperIT::seasonposterheight);
|
||||
tokenContainer->DefineIntToken("{seriesposter1width}", (int)eScraperIT::seriesposter1width);
|
||||
tokenContainer->DefineIntToken("{seriesposter1height}", (int)eScraperIT::seriesposter1height);
|
||||
tokenContainer->DefineIntToken("{seriesposter2width}", (int)eScraperIT::seriesposter2width);
|
||||
tokenContainer->DefineIntToken("{seriesposter2height}", (int)eScraperIT::seriesposter2height);
|
||||
tokenContainer->DefineIntToken("{seriesposter3width}", (int)eScraperIT::seriesposter3width);
|
||||
tokenContainer->DefineIntToken("{seriesposter3height}", (int)eScraperIT::seriesposter3height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart1width}", (int)eScraperIT::seriesfanart1width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart1height}", (int)eScraperIT::seriesfanart1height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart2width}", (int)eScraperIT::seriesfanart2width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart2height}", (int)eScraperIT::seriesfanart2height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart3width}", (int)eScraperIT::seriesfanart3width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart3height}", (int)eScraperIT::seriesfanart3height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner1width}", (int)eScraperIT::seriesbanner1width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner1height}", (int)eScraperIT::seriesbanner1height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner2width}", (int)eScraperIT::seriesbanner2width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner2height}", (int)eScraperIT::seriesbanner2height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner3width}", (int)eScraperIT::seriesbanner3width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner3height}", (int)eScraperIT::seriesbanner3height);
|
||||
tokenContainer->DefineLoopToken("{reruns[title]}", (int)eRerunsLT::title);
|
||||
tokenContainer->DefineLoopToken("{reruns[shorttext]}", (int)eRerunsLT::shorttext);
|
||||
tokenContainer->DefineLoopToken("{reruns[date]}", (int)eRerunsLT::date);
|
||||
tokenContainer->DefineLoopToken("{reruns[day]}", (int)eRerunsLT::day);
|
||||
tokenContainer->DefineLoopToken("{reruns[start]}", (int)eRerunsLT::start);
|
||||
tokenContainer->DefineLoopToken("{reruns[stop]}", (int)eRerunsLT::stop);
|
||||
tokenContainer->DefineLoopToken("{reruns[channelname]}", (int)eRerunsLT::channelname);
|
||||
tokenContainer->DefineLoopToken("{reruns[channelnumber]}", (int)eRerunsLT::channelnumber);
|
||||
tokenContainer->DefineLoopToken("{reruns[channelid]}", (int)eRerunsLT::channelid);
|
||||
tokenContainer->DefineLoopToken("{reruns[channellogoexists]}", (int)eRerunsLT::channellogoexists);
|
||||
tokenContainer->DefineLoopToken("{actors[name]}", (int)eScraperLT::name);
|
||||
tokenContainer->DefineLoopToken("{actors[role]}", (int)eScraperLT::role);
|
||||
tokenContainer->DefineLoopToken("{actors[thumb]}", (int)eScraperLT::thumb);
|
||||
tokenContainer->DefineLoopToken("{actors[thumbwidth]}", (int)eScraperLT::thumbwidth);
|
||||
tokenContainer->DefineLoopToken("{actors[thumbheight]}", (int)eScraperLT::thumbheight);
|
||||
rerunsIndex = tokenContainer->LoopIndex("reruns");
|
||||
actorsIndex = tokenContainer->LoopIndex("actors");
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cViewDetailEpg::Parse(bool forced) {
|
||||
if (!cViewElement::Parse())
|
||||
return false;
|
||||
if (!event)
|
||||
return false;
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::title, event->Title());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::shorttext, event->ShortText());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::description, event->Description());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::start, *(event->GetTimeString()));
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::stop, *(event->GetEndTimeString()));
|
||||
time_t startTime = event->StartTime();
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::day, *WeekDayName(startTime));
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::date, *ShortDateString(startTime));
|
||||
struct tm * sStartTime = localtime(&startTime);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::year, sStartTime->tm_year + 1900);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::daynumeric, sStartTime->tm_mday);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::month, sStartTime->tm_mon+1);
|
||||
const cChannel *channel = Channels.GetByChannelID(event->ChannelID());
|
||||
if (channel) {
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::channelname, channel->Name());
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::channelnumber, channel->Number());
|
||||
}
|
||||
cString channelID = event->ChannelID().ToString();
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::channelid, *channelID);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::channellogoexists, imgCache->LogoExists(*channelID));
|
||||
|
||||
bool isRunning = false;
|
||||
time_t now = time(NULL);
|
||||
if ((now >= event->StartTime()) && (now <= event->EndTime()))
|
||||
isRunning = true;
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::running, isRunning);
|
||||
if (isRunning) {
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::elapsed, (now - event->StartTime())/60);
|
||||
} else {
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::elapsed, 0);
|
||||
}
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::duration, event->Duration() / 60);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::durationhours, event->Duration() / 3600);
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::durationminutes, *cString::sprintf("%.2d", (event->Duration() / 60)%60));
|
||||
if (event->Vps())
|
||||
tokenContainer->AddStringToken((int)eDmDetailedEpgST::vps, *event->GetVpsString());
|
||||
|
||||
cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns = LoadReruns();
|
||||
int numReruns = NumReruns(reruns);
|
||||
vector<int> loopInfo;
|
||||
//num reruns
|
||||
loopInfo.push_back(numReruns);
|
||||
//num actors
|
||||
bool scrapInfoAvailable = LoadFullScrapInfo(event, NULL);
|
||||
int numActors = NumActors();
|
||||
loopInfo.push_back(numActors);
|
||||
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
||||
if (numReruns > 0) {
|
||||
tokenContainer->AddIntToken((int)eDmDetailedEpgIT::hasreruns, 1);
|
||||
SetReruns(reruns);
|
||||
}
|
||||
if (scrapInfoAvailable) {
|
||||
SetFullScrapInfo(tokenContainer, actorsIndex);
|
||||
}
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *cViewDetailEpg::LoadReruns(void) {
|
||||
cPlugin *epgSearchPlugin = cPluginManager::GetPlugin("epgsearch");
|
||||
if (!epgSearchPlugin)
|
||||
return NULL;
|
||||
|
||||
if (isempty(event->Title()))
|
||||
return NULL;
|
||||
|
||||
Epgsearch_searchresults_v1_0 data;
|
||||
data.query = (char*)event->Title();
|
||||
data.mode = 0;
|
||||
data.channelNr = 0;
|
||||
data.useTitle = true;
|
||||
data.useSubTitle = true;
|
||||
data.useDescription = false;
|
||||
|
||||
cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *result = NULL;
|
||||
if (epgSearchPlugin->Service("Epgsearch-searchresults-v1.0", &data))
|
||||
result = data.pResultList;
|
||||
return result;
|
||||
}
|
||||
|
||||
int cViewDetailEpg::NumReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns) {
|
||||
if (!reruns || reruns->Count() < 2)
|
||||
return 0;
|
||||
|
||||
int maxNumReruns = config.rerunAmount;
|
||||
int rerunDistance = config.rerunDistance * 3600;
|
||||
int rerunMaxChannel = config.rerunMaxChannel;
|
||||
|
||||
int i = 0;
|
||||
for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = reruns->First(); r && i < maxNumReruns; r = reruns->Next(r)) {
|
||||
time_t eventStart = event->StartTime();
|
||||
time_t rerunStart = r->event->StartTime();
|
||||
cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true);
|
||||
//check for identical event
|
||||
if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart))
|
||||
continue;
|
||||
//check for timely distance
|
||||
if (rerunDistance > 0)
|
||||
if (rerunStart - eventStart < rerunDistance)
|
||||
continue;
|
||||
//check for maxchannel
|
||||
if (rerunMaxChannel > 0)
|
||||
if (channel && channel->Number() > rerunMaxChannel)
|
||||
continue;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void cViewDetailEpg::SetReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns) {
|
||||
if (!reruns || reruns->Count() < 2)
|
||||
return;
|
||||
|
||||
int maxNumReruns = config.rerunAmount;
|
||||
int rerunDistance = config.rerunDistance * 3600;
|
||||
int rerunMaxChannel = config.rerunMaxChannel;
|
||||
|
||||
int i = 0;
|
||||
for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = reruns->First(); r && i < maxNumReruns; r = reruns->Next(r)) {
|
||||
time_t eventStart = event->StartTime();
|
||||
time_t rerunStart = r->event->StartTime();
|
||||
cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true);
|
||||
//check for identical event
|
||||
if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart))
|
||||
continue;
|
||||
//check for timely distance
|
||||
if (rerunDistance > 0)
|
||||
if (rerunStart - eventStart < rerunDistance)
|
||||
continue;
|
||||
//check for maxchannel
|
||||
if (rerunMaxChannel > 0)
|
||||
if (channel && channel->Number() > rerunMaxChannel)
|
||||
continue;
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::title, r->event->Title());
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::shorttext, r->event->ShortText());
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::start, *(r->event->GetTimeString()));
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::stop, *(r->event->GetEndTimeString()));
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::date, *ShortDateString(r->event->StartTime()));
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::day, *WeekDayName(r->event->StartTime()));
|
||||
cString channelID = r->event->ChannelID().ToString();
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelid, *channelID);
|
||||
bool logoExists = imgCache->LogoExists(*channelID);
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channellogoexists, logoExists ? "1" : "0");
|
||||
if (channel) {
|
||||
cString channelNumber = cString::sprintf("%d", channel->Number());
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelname, channel->ShortName(true));
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelnumber, *channelNumber);
|
||||
} else {
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelname, "");
|
||||
tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelnumber, "");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewDetailRec
|
||||
******************************************************************/
|
||||
cViewDetailRec::cViewDetailRec(void) {
|
||||
recording = NULL;
|
||||
actorsIndex = -1;
|
||||
}
|
||||
|
||||
cViewDetailRec::~cViewDetailRec(void) {
|
||||
}
|
||||
|
||||
void cViewDetailRec::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{name}", (int)eDmDetailedRecST::name);
|
||||
tokenContainer->DefineStringToken("{epgname}", (int)eDmDetailedRecST::epgname);
|
||||
tokenContainer->DefineStringToken("{shorttext}", (int)eDmDetailedRecST::shorttext);
|
||||
tokenContainer->DefineStringToken("{description}", (int)eDmDetailedRecST::description);
|
||||
tokenContainer->DefineStringToken("{day}", (int)eDmDetailedRecST::day);
|
||||
tokenContainer->DefineStringToken("{date}", (int)eDmDetailedRecST::date);
|
||||
tokenContainer->DefineStringToken("{time}", (int)eDmDetailedRecST::time);
|
||||
tokenContainer->DefineStringToken("{durationminutes}", (int)eDmDetailedRecST::durationminutes);
|
||||
tokenContainer->DefineStringToken("{durationeventminutes}", (int)eDmDetailedRecST::durationeventminutes);
|
||||
tokenContainer->DefineStringToken("{recchannelname}", (int)eDmDetailedRecST::recchannelname);
|
||||
tokenContainer->DefineStringToken("{recchannelid}", (int)eDmDetailedRecST::recchannelid);
|
||||
tokenContainer->DefineStringToken("{recordingsize}", (int)eDmDetailedRecST::recordingsize);
|
||||
tokenContainer->DefineStringToken("{recordingsizecutted}", (int)eDmDetailedRecST::recordingsizecutted);
|
||||
tokenContainer->DefineStringToken("{recordinglength}", (int)eDmDetailedRecST::recordinglength);
|
||||
tokenContainer->DefineStringToken("{recordinglengthcutted}", (int)eDmDetailedRecST::recordinglengthcutted);
|
||||
tokenContainer->DefineStringToken("{recordingbitrate}", (int)eDmDetailedRecST::recordingbitrate);
|
||||
tokenContainer->DefineStringToken("{recordingformat}", (int)eDmDetailedRecST::recordingformat);
|
||||
tokenContainer->DefineStringToken("{searchtimer}", (int)eDmDetailedRecST::searchtimer);
|
||||
tokenContainer->DefineStringToken("{recimg1path}", (int)eDmDetailedRecST::recimg1path);
|
||||
tokenContainer->DefineStringToken("{recimg2path}", (int)eDmDetailedRecST::recimg2path);
|
||||
tokenContainer->DefineStringToken("{recimg3path}", (int)eDmDetailedRecST::recimg3path);
|
||||
tokenContainer->DefineStringToken("{movietitle}", (int)eScraperST::movietitle);
|
||||
tokenContainer->DefineStringToken("{movieoriginalTitle}", (int)eScraperST::movieoriginalTitle);
|
||||
tokenContainer->DefineStringToken("{movietagline}", (int)eScraperST::movietagline);
|
||||
tokenContainer->DefineStringToken("{movieoverview}", (int)eScraperST::movieoverview);
|
||||
tokenContainer->DefineStringToken("{moviegenres}", (int)eScraperST::moviegenres);
|
||||
tokenContainer->DefineStringToken("{moviehomepage}", (int)eScraperST::moviehomepage);
|
||||
tokenContainer->DefineStringToken("{moviereleasedate}", (int)eScraperST::moviereleasedate);
|
||||
tokenContainer->DefineStringToken("{moviepopularity}", (int)eScraperST::moviepopularity);
|
||||
tokenContainer->DefineStringToken("{movievoteaverage}", (int)eScraperST::movievoteaverage);
|
||||
tokenContainer->DefineStringToken("{posterpath}", (int)eScraperST::posterpath);
|
||||
tokenContainer->DefineStringToken("{fanartpath}", (int)eScraperST::fanartpath);
|
||||
tokenContainer->DefineStringToken("{moviecollectionName}", (int)eScraperST::moviecollectionName);
|
||||
tokenContainer->DefineStringToken("{collectionposterpath}", (int)eScraperST::collectionposterpath);
|
||||
tokenContainer->DefineStringToken("{collectionfanartpath}", (int)eScraperST::collectionfanartpath);
|
||||
tokenContainer->DefineStringToken("{seriesname}", (int)eScraperST::seriesname);
|
||||
tokenContainer->DefineStringToken("{seriesoverview}", (int)eScraperST::seriesoverview);
|
||||
tokenContainer->DefineStringToken("{seriesfirstaired}", (int)eScraperST::seriesfirstaired);
|
||||
tokenContainer->DefineStringToken("{seriesnetwork}", (int)eScraperST::seriesnetwork);
|
||||
tokenContainer->DefineStringToken("{seriesgenre}", (int)eScraperST::seriesgenre);
|
||||
tokenContainer->DefineStringToken("{seriesrating}", (int)eScraperST::seriesrating);
|
||||
tokenContainer->DefineStringToken("{seriesstatus}", (int)eScraperST::seriesstatus);
|
||||
tokenContainer->DefineStringToken("{episodetitle}", (int)eScraperST::episodetitle);
|
||||
tokenContainer->DefineStringToken("{episodefirstaired}", (int)eScraperST::episodefirstaired);
|
||||
tokenContainer->DefineStringToken("{episodegueststars}", (int)eScraperST::episodegueststars);
|
||||
tokenContainer->DefineStringToken("{episodeoverview}", (int)eScraperST::episodeoverview);
|
||||
tokenContainer->DefineStringToken("{episoderating}", (int)eScraperST::episoderating);
|
||||
tokenContainer->DefineStringToken("{episodeimagepath}", (int)eScraperST::episodeimagepath);
|
||||
tokenContainer->DefineStringToken("{seasonposterpath}", (int)eScraperST::seasonposterpath);
|
||||
tokenContainer->DefineStringToken("{seriesposter1path}", (int)eScraperST::seriesposter1path);
|
||||
tokenContainer->DefineStringToken("{seriesposter2path}", (int)eScraperST::seriesposter2path);
|
||||
tokenContainer->DefineStringToken("{seriesposter3path}", (int)eScraperST::seriesposter3path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart1path}", (int)eScraperST::seriesfanart1path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart2path}", (int)eScraperST::seriesfanart2path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart3path}", (int)eScraperST::seriesfanart3path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner1path}", (int)eScraperST::seriesbanner1path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner2path}", (int)eScraperST::seriesbanner2path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner3path}", (int)eScraperST::seriesbanner3path);
|
||||
tokenContainer->DefineIntToken("{daynumeric}", (int)eDmDetailedRecIT::daynumeric);
|
||||
tokenContainer->DefineIntToken("{month}", (int)eDmDetailedRecIT::month);
|
||||
tokenContainer->DefineIntToken("{year}", (int)eDmDetailedRecIT::year);
|
||||
tokenContainer->DefineIntToken("{duration}", (int)eDmDetailedRecIT::duration);
|
||||
tokenContainer->DefineIntToken("{durationhours}", (int)eDmDetailedRecIT::durationhours);
|
||||
tokenContainer->DefineIntToken("{durationevent}", (int)eDmDetailedRecIT::durationevent);
|
||||
tokenContainer->DefineIntToken("{durationeventhours}", (int)eDmDetailedRecIT::durationeventhours);
|
||||
tokenContainer->DefineIntToken("{recchannelnumber}", (int)eDmDetailedRecIT::recchannelnumber);
|
||||
tokenContainer->DefineIntToken("{cutted}", (int)eDmDetailedRecIT::cutted);
|
||||
tokenContainer->DefineIntToken("{recimg1avaialble}", (int)eDmDetailedRecIT::recimg1avaialble);
|
||||
tokenContainer->DefineIntToken("{recimg2avaialble}", (int)eDmDetailedRecIT::recimg2avaialble);
|
||||
tokenContainer->DefineIntToken("{recimg3avaialble}", (int)eDmDetailedRecIT::recimg3avaialble);
|
||||
tokenContainer->DefineIntToken("{ismovie}", (int)eScraperIT::ismovie);
|
||||
tokenContainer->DefineIntToken("{moviebudget}", (int)eScraperIT::moviebudget);
|
||||
tokenContainer->DefineIntToken("{movierevenue}", (int)eScraperIT::movierevenue);
|
||||
tokenContainer->DefineIntToken("{movieadult}", (int)eScraperIT::movieadult);
|
||||
tokenContainer->DefineIntToken("{movieruntime}", (int)eScraperIT::movieruntime);
|
||||
tokenContainer->DefineIntToken("{isseries}", (int)eScraperIT::isseries);
|
||||
tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperIT::posterwidth);
|
||||
tokenContainer->DefineIntToken("{posterheight}", (int)eScraperIT::posterheight);
|
||||
tokenContainer->DefineIntToken("{fanartwidth}", (int)eScraperIT::fanartwidth);
|
||||
tokenContainer->DefineIntToken("{fanartheight}", (int)eScraperIT::fanartheight);
|
||||
tokenContainer->DefineIntToken("{movieiscollection}", (int)eScraperIT::movieiscollection);
|
||||
tokenContainer->DefineIntToken("{collectionposterwidth}", (int)eScraperIT::collectionposterwidth);
|
||||
tokenContainer->DefineIntToken("{collectionposterheight}", (int)eScraperIT::collectionposterheight);
|
||||
tokenContainer->DefineIntToken("{collectionfanartwidth}", (int)eScraperIT::collectionfanartwidth);
|
||||
tokenContainer->DefineIntToken("{collectionfanartheight}", (int)eScraperIT::collectionfanartheight);
|
||||
tokenContainer->DefineIntToken("{epgpicavailable}", (int)eScraperIT::epgpicavailable);
|
||||
tokenContainer->DefineIntToken("{episodenumber}", (int)eScraperIT::episodenumber);
|
||||
tokenContainer->DefineIntToken("{episodeseason}", (int)eScraperIT::episodeseason);
|
||||
tokenContainer->DefineIntToken("{episodeimagewidth}", (int)eScraperIT::episodeimagewidth);
|
||||
tokenContainer->DefineIntToken("{episodeimageheight}", (int)eScraperIT::episodeimageheight);
|
||||
tokenContainer->DefineIntToken("{seasonposterwidth}", (int)eScraperIT::seasonposterwidth);
|
||||
tokenContainer->DefineIntToken("{seasonposterheight}", (int)eScraperIT::seasonposterheight);
|
||||
tokenContainer->DefineIntToken("{seriesposter1width}", (int)eScraperIT::seriesposter1width);
|
||||
tokenContainer->DefineIntToken("{seriesposter1height}", (int)eScraperIT::seriesposter1height);
|
||||
tokenContainer->DefineIntToken("{seriesposter2width}", (int)eScraperIT::seriesposter2width);
|
||||
tokenContainer->DefineIntToken("{seriesposter2height}", (int)eScraperIT::seriesposter2height);
|
||||
tokenContainer->DefineIntToken("{seriesposter3width}", (int)eScraperIT::seriesposter3width);
|
||||
tokenContainer->DefineIntToken("{seriesposter3height}", (int)eScraperIT::seriesposter3height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart1width}", (int)eScraperIT::seriesfanart1width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart1height}", (int)eScraperIT::seriesfanart1height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart2width}", (int)eScraperIT::seriesfanart2width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart2height}", (int)eScraperIT::seriesfanart2height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart3width}", (int)eScraperIT::seriesfanart3width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart3height}", (int)eScraperIT::seriesfanart3height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner1width}", (int)eScraperIT::seriesbanner1width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner1height}", (int)eScraperIT::seriesbanner1height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner2width}", (int)eScraperIT::seriesbanner2width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner2height}", (int)eScraperIT::seriesbanner2height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner3width}", (int)eScraperIT::seriesbanner3width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner3height}", (int)eScraperIT::seriesbanner3height);
|
||||
tokenContainer->DefineLoopToken("{actors[name]}", (int)eScraperLT::name);
|
||||
tokenContainer->DefineLoopToken("{actors[role]}", (int)eScraperLT::role);
|
||||
tokenContainer->DefineLoopToken("{actors[thumb]}", (int)eScraperLT::thumb);
|
||||
tokenContainer->DefineLoopToken("{actors[thumbwidth]}", (int)eScraperLT::thumbwidth);
|
||||
tokenContainer->DefineLoopToken("{actors[thumbheight]}", (int)eScraperLT::thumbheight);
|
||||
actorsIndex = tokenContainer->LoopIndex("actors");
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cViewDetailRec::Parse(bool forced) {
|
||||
if (!cViewElement::Parse())
|
||||
return false;
|
||||
if (!recording)
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::name, recording->Name());
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::cutted, recording->IsEdited());
|
||||
|
||||
const cRecordingInfo *info = recording->Info();
|
||||
if (info) {
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::epgname, info->Title());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::shorttext, info->ShortText());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::description, info->Description());
|
||||
const cEvent *event = info->GetEvent();
|
||||
if (event) {
|
||||
cString recDate = event->GetDateString();
|
||||
cString recTime = event->GetTimeString();
|
||||
if (strstr(*recDate, "1970")) {
|
||||
time_t start = recording->Start();
|
||||
recDate = DateString(start);
|
||||
recTime = TimeString(start);
|
||||
}
|
||||
int duration = event->Duration() / 60;
|
||||
int recDuration = recording->LengthInSeconds();
|
||||
recDuration = (recDuration>0) ? (recDuration / 60) : 0;
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::date, *recDate);
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::time, *recTime);
|
||||
time_t startTime = event->StartTime();
|
||||
struct tm * sStartTime = localtime(&startTime);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::year, sStartTime->tm_year + 1900);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::daynumeric, sStartTime->tm_mday);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::month, sStartTime->tm_mon+1);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::duration, recDuration);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationhours, recDuration / 60);
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::durationminutes, *cString::sprintf("%.2d", recDuration%60));
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationevent, duration);
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationeventhours, duration / 60);
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::durationeventminutes, *cString::sprintf("%.2d", duration%60));
|
||||
}
|
||||
}
|
||||
SetRecInfos();
|
||||
SetRecordingImages(recording->FileName());
|
||||
|
||||
vector<int> loopInfo;
|
||||
bool scrapInfoAvailable = LoadFullScrapInfo(NULL, recording);
|
||||
int numActors = NumActors();
|
||||
loopInfo.push_back(numActors);
|
||||
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
||||
if (scrapInfoAvailable) {
|
||||
SetFullScrapInfo(tokenContainer, actorsIndex);
|
||||
}
|
||||
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
void cViewDetailRec::SetRecInfos(void) {
|
||||
unsigned long long nRecSize = -1;
|
||||
unsigned long long nFileSize[1000];
|
||||
nFileSize[0] = 0;
|
||||
int i = 0;
|
||||
struct stat filebuf;
|
||||
cString filename;
|
||||
int rc = 0;
|
||||
do {
|
||||
if (recording->IsPesRecording())
|
||||
filename = cString::sprintf("%s/%03d.vdr", recording->FileName(), ++i);
|
||||
else
|
||||
filename = cString::sprintf("%s/%05d.ts", recording->FileName(), ++i);
|
||||
rc = stat(filename, &filebuf);
|
||||
if (rc == 0)
|
||||
nFileSize[i] = nFileSize[i-1] + filebuf.st_size;
|
||||
else
|
||||
if (ENOENT != errno) {
|
||||
nRecSize = -1;
|
||||
}
|
||||
} while (i <= 999 && !rc);
|
||||
nRecSize = nFileSize[i-1];
|
||||
|
||||
cMarks marks;
|
||||
bool fHasMarks = marks.Load(recording->FileName(), recording->FramesPerSecond(), recording->IsPesRecording()) && marks.Count();
|
||||
cIndexFile *index = new cIndexFile(recording->FileName(), false, recording->IsPesRecording());
|
||||
|
||||
int nCutLength = 0;
|
||||
long nCutInFrame = 0;
|
||||
unsigned long long nRecSizeCut = nRecSize < 0 ? -1 : 0;
|
||||
unsigned long long nCutInOffset = 0;
|
||||
|
||||
if (fHasMarks && index) {
|
||||
uint16_t FileNumber;
|
||||
off_t FileOffset;
|
||||
|
||||
bool fCutIn = true;
|
||||
cMark *mark = marks.First();
|
||||
while (mark) {
|
||||
int pos = mark->Position();
|
||||
index->Get(pos, &FileNumber, &FileOffset); //TODO: will disc spin up?
|
||||
if (fCutIn) {
|
||||
nCutInFrame = pos;
|
||||
fCutIn = false;
|
||||
if (nRecSize >= 0)
|
||||
nCutInOffset = nFileSize[FileNumber-1] + FileOffset;
|
||||
} else {
|
||||
nCutLength += pos - nCutInFrame;
|
||||
fCutIn = true;
|
||||
if (nRecSize >= 0)
|
||||
nRecSizeCut += nFileSize[FileNumber-1] + FileOffset - nCutInOffset;
|
||||
}
|
||||
cMark *nextmark = marks.Next(mark);
|
||||
mark = nextmark;
|
||||
}
|
||||
if (!fCutIn) {
|
||||
nCutLength += index->Last() - nCutInFrame;
|
||||
index->Get(index->Last() - 1, &FileNumber, &FileOffset);
|
||||
if (nRecSize >= 0)
|
||||
nRecSizeCut += nFileSize[FileNumber-1] + FileOffset - nCutInOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (nRecSize < 0) {
|
||||
if ((nRecSize = ReadSizeVdr(recording->FileName())) < 0) {
|
||||
nRecSize = DirSizeMB(recording->FileName());
|
||||
}
|
||||
}
|
||||
if (nRecSize >= 0) {
|
||||
cString strRecSize = "";
|
||||
cString strRecSizeCut = "";
|
||||
|
||||
if (fHasMarks) {
|
||||
if (nRecSize > MEGABYTE(1023)) {
|
||||
strRecSize = cString::sprintf("%.2f GB", (float)nRecSize / MEGABYTE(1024));
|
||||
strRecSizeCut = cString::sprintf("%.2f GB", (float)nRecSizeCut / MEGABYTE(1024));
|
||||
} else {
|
||||
strRecSize = cString::sprintf("%lld MB", nRecSize / MEGABYTE(1));
|
||||
strRecSizeCut = cString::sprintf("%lld MB", nRecSizeCut / MEGABYTE(1));
|
||||
}
|
||||
} else {
|
||||
if (nRecSize > MEGABYTE(1023)) {
|
||||
strRecSize = cString::sprintf("%.2f GB", (float)nRecSize / MEGABYTE(1024));
|
||||
strRecSizeCut = strRecSize;
|
||||
} else {
|
||||
strRecSize = cString::sprintf("%lld MB", nRecSize / MEGABYTE(1));
|
||||
strRecSizeCut = strRecSize;
|
||||
}
|
||||
}
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingsize, *strRecSize);
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingsizecutted, *strRecSizeCut);
|
||||
}
|
||||
|
||||
const cRecordingInfo *info = recording->Info();
|
||||
if (info) {
|
||||
cChannel *channel = Channels.GetByChannelID(info->ChannelID());
|
||||
if (channel) {
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recchannelname, channel->Name());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recchannelid, *channel->GetChannelID().ToString());
|
||||
tokenContainer->AddIntToken((int)eDmDetailedRecIT::recchannelnumber, channel->Number());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (index) {
|
||||
int nLastIndex = index->Last();
|
||||
if (nLastIndex) {
|
||||
string strLength = *IndexToHMSF(nLastIndex, false, recording->FramesPerSecond());
|
||||
string strLengthCutted = "";
|
||||
if (fHasMarks) {
|
||||
strLengthCutted = *IndexToHMSF(nCutLength, false, recording->FramesPerSecond());
|
||||
} else {
|
||||
strLengthCutted = strLength;
|
||||
}
|
||||
string strBitrate = *cString::sprintf("%.2f MBit/s", (float)nRecSize / nLastIndex * recording->FramesPerSecond() * 8 / MEGABYTE(1));
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recordinglength, strLength.c_str());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recordinglengthcutted, strLengthCutted.c_str());
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingbitrate, strBitrate.c_str());
|
||||
}
|
||||
delete index;
|
||||
}
|
||||
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingformat, recording->IsPesRecording() ? "PES" : "TS");
|
||||
|
||||
bool searchTimerFound = false;
|
||||
if (info) {
|
||||
const char *aux = NULL;
|
||||
aux = info->Aux();
|
||||
if (aux) {
|
||||
string strAux = aux;
|
||||
string auxEpgsearch = StripXmlTag(strAux, "epgsearch");
|
||||
if (!auxEpgsearch.empty()) {
|
||||
string searchTimer = StripXmlTag(auxEpgsearch, "searchtimer");
|
||||
if (!searchTimer.empty()) {
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::searchtimer, searchTimer.c_str());
|
||||
searchTimerFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!searchTimerFound)
|
||||
tokenContainer->AddStringToken((int)eDmDetailedRecST::searchtimer, "n.a.");
|
||||
}
|
||||
|
||||
int cViewDetailRec::ReadSizeVdr(const char *strPath) {
|
||||
int dirSize = -1;
|
||||
char buffer[20];
|
||||
char *strFilename = NULL;
|
||||
if (-1 != asprintf(&strFilename, "%s/size.vdr", strPath)) {
|
||||
struct stat st;
|
||||
if (stat(strFilename, &st) == 0) {
|
||||
int fd = open(strFilename, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
if (safe_read(fd, &buffer, sizeof(buffer)) >= 0) {
|
||||
dirSize = atoi(buffer);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
free(strFilename);
|
||||
}
|
||||
return dirSize;
|
||||
}
|
||||
|
||||
string cViewDetailRec::StripXmlTag(string &Line, const char *Tag) {
|
||||
// set the search strings
|
||||
stringstream strStart, strStop;
|
||||
strStart << "<" << Tag << ">";
|
||||
strStop << "</" << Tag << ">";
|
||||
// find the strings
|
||||
string::size_type locStart = Line.find(strStart.str());
|
||||
string::size_type locStop = Line.find(strStop.str());
|
||||
if (locStart == string::npos || locStop == string::npos)
|
||||
return "";
|
||||
// extract relevant text
|
||||
int pos = locStart + strStart.str().size();
|
||||
int len = locStop - pos;
|
||||
return len < 0 ? "" : Line.substr(pos, len);
|
||||
}
|
||||
|
||||
void cViewDetailRec::SetRecordingImages(const char *recPath) {
|
||||
if (!recPath) {
|
||||
return;
|
||||
}
|
||||
DIR *dirHandle;
|
||||
struct dirent *dirEntry;
|
||||
dirHandle = opendir(recPath);
|
||||
if (!dirHandle) {
|
||||
return;
|
||||
}
|
||||
int picsFound = 0;
|
||||
int indexStr = (int)eDmDetailedRecST::recimg1path;
|
||||
int indexInt = (int)eDmDetailedRecIT::recimg1avaialble;
|
||||
while ( 0 != (dirEntry = readdir(dirHandle))) {
|
||||
if (endswith(dirEntry->d_name, "jpg")) {
|
||||
tokenContainer->AddStringToken(indexStr, *cString::sprintf("%s/%s", recPath, dirEntry->d_name));
|
||||
tokenContainer->AddIntToken(indexInt, 1);
|
||||
picsFound++;
|
||||
}
|
||||
if (picsFound == 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(dirHandle);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewDetailText
|
||||
******************************************************************/
|
||||
cViewDetailText::cViewDetailText(void) {
|
||||
text = NULL;
|
||||
}
|
||||
|
||||
cViewDetailText::~cViewDetailText(void) {
|
||||
}
|
||||
|
||||
void cViewDetailText::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{text}", (int)eDmDetailedTextST::text);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cViewDetailText::Parse(bool forced) {
|
||||
if (!cViewElement::Parse())
|
||||
return false;
|
||||
if (!text)
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDmDetailedTextST::text, text);
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewDetailPlugin
|
||||
******************************************************************/
|
||||
cViewDetailPlugin::cViewDetailPlugin(void) {
|
||||
}
|
||||
|
||||
cViewDetailPlugin::~cViewDetailPlugin(void) {
|
||||
}
|
||||
|
||||
void cViewDetailPlugin::SetTokenContainer(void) {
|
||||
if (plugId == -1 || plugMenuId == -1)
|
||||
return;
|
||||
skindesignerapi::cTokenContainer *tkPlugMenu = plgManager->GetTokenContainer(plugId, plugMenuId);
|
||||
tokenContainer = new skindesignerapi::cTokenContainer(*tkPlugMenu);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cViewDetailPlugin::Set(skindesignerapi::cTokenContainer *tk) {
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->SetTokens(tk);
|
||||
}
|
||||
|
||||
bool cViewDetailPlugin::Parse(bool forced) {
|
||||
if (!cViewElement::Parse())
|
||||
return false;
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewDetailAdvancedPlugin
|
||||
******************************************************************/
|
||||
cViewDetailAdvancedPlugin::cViewDetailAdvancedPlugin(int viewId, int plugId) {
|
||||
this->plugId = plugId;
|
||||
plugViewId = viewId;
|
||||
}
|
||||
|
||||
cViewDetailAdvancedPlugin::~cViewDetailAdvancedPlugin(void) {
|
||||
}
|
||||
|
||||
void cViewDetailAdvancedPlugin::SetTokenContainer(void) {
|
||||
if (plugId == -1 || plugViewId == -1)
|
||||
return;
|
||||
skindesignerapi::cTokenContainer *tkDetail = plgManager->GetTokenContainerTab(plugId, plugViewId);
|
||||
tokenContainer = new skindesignerapi::cTokenContainer(*tkDetail);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cViewDetailAdvancedPlugin::Set(skindesignerapi::cTokenContainer *tk) {
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->SetTokens(tk);
|
||||
}
|
||||
|
||||
bool cViewDetailAdvancedPlugin::Parse(bool forced) {
|
||||
if (!cViewElement::Parse())
|
||||
return false;
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
114
coreengine/viewdetail.h
Normal file
114
coreengine/viewdetail.h
Normal file
@@ -0,0 +1,114 @@
|
||||
#ifndef __VIEWDETAIL_H
|
||||
#define __VIEWDETAIL_H
|
||||
|
||||
#include "../services/epgsearch.h"
|
||||
#include "../extensions/scrapmanager.h"
|
||||
#include "viewelement.h"
|
||||
/******************************************************************
|
||||
* cViewDetail
|
||||
******************************************************************/
|
||||
class cViewDetail : public cViewElement, public cScrapManager {
|
||||
protected:
|
||||
int plugId;
|
||||
int plugMenuId;
|
||||
cArea *activeTab;
|
||||
int activeTabIndex;
|
||||
int numTabs;
|
||||
void SetActiveTab(void);
|
||||
public:
|
||||
cViewDetail(void);
|
||||
virtual ~cViewDetail(void);
|
||||
void SetPlugId(int id) { plugId = id; };
|
||||
void SetPlugMenuId(int id) { plugMenuId = id; };
|
||||
int GetWidth(void);
|
||||
void ResetTabs(void);
|
||||
void Clear(void);
|
||||
void Close(void);
|
||||
void Render(void);
|
||||
void Scrollbar(int &barheight, int &offset, bool &end);
|
||||
bool ScrollUp(bool page = false);
|
||||
bool ScrollDown(bool page = false);
|
||||
int GetTabs(vector<const char*> &tabs);
|
||||
int NumTabs(void) { return numTabs; };
|
||||
int ActiveTab(void) { return activeTabIndex; };
|
||||
void NextTab(void);
|
||||
void PrevTab(void);
|
||||
void SetTransparency(int transparency, bool forceDetached = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cViewDetailEpg
|
||||
******************************************************************/
|
||||
class cViewDetailEpg : public cViewDetail {
|
||||
protected:
|
||||
const cEvent *event;
|
||||
int rerunsIndex;
|
||||
int actorsIndex;
|
||||
cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *LoadReruns(void);
|
||||
int NumReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns);
|
||||
void SetReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns);
|
||||
public:
|
||||
cViewDetailEpg(void);
|
||||
virtual ~cViewDetailEpg(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetEvent(const cEvent *event) { this->event = event; };
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cViewDetailRec
|
||||
******************************************************************/
|
||||
class cViewDetailRec : public cViewDetail {
|
||||
protected:
|
||||
const cRecording *recording;
|
||||
int actorsIndex;
|
||||
void SetRecInfos(void);
|
||||
int ReadSizeVdr(const char *strPath);
|
||||
string StripXmlTag(string &Line, const char *Tag);
|
||||
void SetRecordingImages(const char *recPath);
|
||||
public:
|
||||
cViewDetailRec(void);
|
||||
virtual ~cViewDetailRec(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetRecording(const cRecording *recording) { this->recording = recording; };
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cViewDetailText
|
||||
******************************************************************/
|
||||
class cViewDetailText : public cViewDetail {
|
||||
protected:
|
||||
const char *text;
|
||||
public:
|
||||
cViewDetailText(void);
|
||||
virtual ~cViewDetailText(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetText(const char *text) { this->text = text; };
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cViewDetailPlugin
|
||||
******************************************************************/
|
||||
class cViewDetailPlugin : public cViewDetail {
|
||||
protected:
|
||||
public:
|
||||
cViewDetailPlugin(void);
|
||||
virtual ~cViewDetailPlugin(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cViewDetailAdvancedPlugin
|
||||
******************************************************************/
|
||||
class cViewDetailAdvancedPlugin : public cViewDetail {
|
||||
protected:
|
||||
int plugViewId;
|
||||
public:
|
||||
cViewDetailAdvancedPlugin(int viewId, int plugId);
|
||||
virtual ~cViewDetailAdvancedPlugin(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
#endif //__VIEWDETAIL_H
|
||||
199
coreengine/viewdisplaychannel.c
Normal file
199
coreengine/viewdisplaychannel.c
Normal file
@@ -0,0 +1,199 @@
|
||||
#include "viewdisplaychannel.h"
|
||||
#include "../config.h"
|
||||
|
||||
/************************************************************************************
|
||||
* cViewChannel
|
||||
************************************************************************************/
|
||||
|
||||
cViewChannel::cViewChannel(void) {
|
||||
veCustomTokens = NULL;
|
||||
ClearVariables();
|
||||
viewId = eViewType::DisplayChannel;
|
||||
viewName = strdup("displaychannel");
|
||||
numViewElements = (int)eVeDisplayChannel::count;
|
||||
viewElements = new cViewElement*[numViewElements];
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
viewElements[i] = NULL;
|
||||
}
|
||||
SetViewElements();
|
||||
veMessage = NULL;
|
||||
veChannelInfo = NULL;
|
||||
veChannelGroup = NULL;
|
||||
veEpgInfo = NULL;
|
||||
veProgressBar = NULL;
|
||||
veStatusInfo = NULL;
|
||||
veScraperContent = NULL;
|
||||
veEcmInfo = NULL;
|
||||
}
|
||||
|
||||
cViewChannel::~cViewChannel() {
|
||||
}
|
||||
|
||||
void cViewChannel::SetViewElements(void) {
|
||||
viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayChannel::background));
|
||||
viewElementNames.insert(pair<string, int>("channelgroup", (int)eVeDisplayChannel::channelgroup));
|
||||
viewElementNames.insert(pair<string, int>("channelinfo", (int)eVeDisplayChannel::channelinfo));
|
||||
viewElementNames.insert(pair<string, int>("epginfo", (int)eVeDisplayChannel::epginfo));
|
||||
viewElementNames.insert(pair<string, int>("progressbar", (int)eVeDisplayChannel::progressbar));
|
||||
viewElementNames.insert(pair<string, int>("statusinfo", (int)eVeDisplayChannel::statusinfo));
|
||||
viewElementNames.insert(pair<string, int>("audioinfo", (int)eVeDisplayChannel::audioinfo));
|
||||
viewElementNames.insert(pair<string, int>("ecminfo", (int)eVeDisplayChannel::ecminfo));
|
||||
viewElementNames.insert(pair<string, int>("screenresolution", (int)eVeDisplayChannel::screenresolution));
|
||||
viewElementNames.insert(pair<string, int>("signalquality", (int)eVeDisplayChannel::signalquality));
|
||||
viewElementNames.insert(pair<string, int>("devices", (int)eVeDisplayChannel::devices));
|
||||
viewElementNames.insert(pair<string, int>("currentweather", (int)eVeDisplayChannel::currentweather));
|
||||
viewElementNames.insert(pair<string, int>("scrapercontent", (int)eVeDisplayChannel::scrapercontent));
|
||||
viewElementNames.insert(pair<string, int>("datetime", (int)eVeDisplayChannel::datetime));
|
||||
viewElementNames.insert(pair<string, int>("time", (int)eVeDisplayChannel::time));
|
||||
viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayChannel::message));
|
||||
viewElementNames.insert(pair<string, int>("customtokens", (int)eVeDisplayChannel::customtokens));
|
||||
}
|
||||
|
||||
void cViewChannel::SetViewElementObjects(void) {
|
||||
for (int i = 0; i < numViewElements; i++) {
|
||||
if (!viewElements[i])
|
||||
continue;
|
||||
if (dynamic_cast<cVeMessage*>(viewElements[i]))
|
||||
{
|
||||
veMessage = dynamic_cast<cVeMessage*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDcChannelInfo*>(viewElements[i])) {
|
||||
|
||||
veChannelInfo = dynamic_cast<cVeDcChannelInfo*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDcChannelGroup*>(viewElements[i]))
|
||||
{
|
||||
veChannelGroup = dynamic_cast<cVeDcChannelGroup*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDcEpgInfo*>(viewElements[i]))
|
||||
{
|
||||
veEpgInfo = dynamic_cast<cVeDcEpgInfo*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDcProgressBar*>(viewElements[i]))
|
||||
{
|
||||
veProgressBar = dynamic_cast<cVeDcProgressBar*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDcStatusInfo*>(viewElements[i]))
|
||||
{
|
||||
veStatusInfo = dynamic_cast<cVeDcStatusInfo*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDcScraperContent*>(viewElements[i]))
|
||||
{
|
||||
veScraperContent = dynamic_cast<cVeDcScraperContent*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDcEcmInfo*>(viewElements[i]))
|
||||
{
|
||||
veEcmInfo = dynamic_cast<cVeDcEcmInfo*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeCustomTokens*>(viewElements[i]))
|
||||
{
|
||||
veCustomTokens = dynamic_cast<cVeCustomTokens*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDevices*>(viewElements[i]))
|
||||
{
|
||||
viewElements[i]->SetDetached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewChannel::ClearVariables(void) {
|
||||
cView::ClearVariables();
|
||||
channelChange = false;
|
||||
displayChannelGroups = false;
|
||||
if (veCustomTokens)
|
||||
veCustomTokens->Reset();
|
||||
}
|
||||
|
||||
void cViewChannel::SetChannel(const cChannel *channel, int number) {
|
||||
channelChange = true;
|
||||
bool wasChannelGroups = displayChannelGroups;
|
||||
displayChannelGroups = false;
|
||||
|
||||
if (veChannelInfo) {
|
||||
veChannelInfo->Set(channel, number);
|
||||
}
|
||||
|
||||
if (channel) {
|
||||
if (!channel->GroupSep()) {
|
||||
if (wasChannelGroups)
|
||||
Clear((int)eVeDisplayChannel::channelgroup);
|
||||
if (veStatusInfo)
|
||||
veStatusInfo->Set(channel);
|
||||
if (veEcmInfo)
|
||||
veEcmInfo->Set(channel);
|
||||
} else {
|
||||
displayChannelGroups = true;
|
||||
Clear((int)eVeDisplayChannel::channelinfo);
|
||||
Clear((int)eVeDisplayChannel::epginfo);
|
||||
Clear((int)eVeDisplayChannel::statusinfo);
|
||||
Clear((int)eVeDisplayChannel::progressbar);
|
||||
Clear((int)eVeDisplayChannel::screenresolution);
|
||||
Clear((int)eVeDisplayChannel::signalquality);
|
||||
Clear((int)eVeDisplayChannel::audioinfo);
|
||||
Clear((int)eVeDisplayChannel::ecminfo);
|
||||
Clear((int)eVeDisplayChannel::devices);
|
||||
Clear((int)eVeDisplayChannel::customtokens);
|
||||
if (veChannelGroup)
|
||||
veChannelGroup->Set(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewChannel::SetEvents(const cEvent *present, const cEvent *following) {
|
||||
Clear((int)eVeDisplayChannel::epginfo);
|
||||
Clear((int)eVeDisplayChannel::progressbar);
|
||||
Clear((int)eVeDisplayChannel::scrapercontent);
|
||||
if (veProgressBar)
|
||||
veProgressBar->Set(present);
|
||||
|
||||
if (!present && !following)
|
||||
return;
|
||||
|
||||
if (veEpgInfo)
|
||||
veEpgInfo->Set(present, following);
|
||||
|
||||
if (veScraperContent)
|
||||
veScraperContent->Set(present);
|
||||
}
|
||||
|
||||
void cViewChannel::SetMessage(eMessageType type, const char *text) {
|
||||
if (veMessage) {
|
||||
if (text)
|
||||
veMessage->Set(type, text);
|
||||
else
|
||||
veMessage->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewChannel::Flush(void) {
|
||||
if (init) {
|
||||
sdOsd.LockFlush();
|
||||
Render((int)eVeDisplayChannel::background);
|
||||
Render((int)eVeDisplayChannel::progressbar);
|
||||
Render((int)eVeDisplayChannel::currentweather);
|
||||
}
|
||||
|
||||
if (!displayChannelGroups) {
|
||||
//normal display
|
||||
Render((int)eVeDisplayChannel::channelinfo);
|
||||
Render((int)eVeDisplayChannel::epginfo);
|
||||
Render((int)eVeDisplayChannel::statusinfo);
|
||||
Render((int)eVeDisplayChannel::scrapercontent);
|
||||
Render((int)eVeDisplayChannel::progressbar, channelChange);
|
||||
Render((int)eVeDisplayChannel::screenresolution);
|
||||
Render((int)eVeDisplayChannel::signalquality);
|
||||
Render((int)eVeDisplayChannel::audioinfo);
|
||||
Render((int)eVeDisplayChannel::ecminfo);
|
||||
Render((int)eVeDisplayChannel::devices);
|
||||
Render((int)eVeDisplayChannel::customtokens);
|
||||
Render((int)eVeDisplayChannel::message);
|
||||
} else {
|
||||
//channelgroup display
|
||||
Render((int)eVeDisplayChannel::channelgroup);
|
||||
}
|
||||
Render((int)eVeDisplayChannel::datetime);
|
||||
Render((int)eVeDisplayChannel::time);
|
||||
channelChange = false;
|
||||
cView::Flush();
|
||||
}
|
||||
|
||||
31
coreengine/viewdisplaychannel.h
Normal file
31
coreengine/viewdisplaychannel.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef __VIEWDISPLAYCHANNEL_H
|
||||
#define __VIEWDISPLAYCHANNEL_H
|
||||
|
||||
#include "view.h"
|
||||
|
||||
class cViewChannel : public cView {
|
||||
private:
|
||||
cVeMessage *veMessage;
|
||||
cVeCustomTokens *veCustomTokens;
|
||||
cVeDcChannelInfo *veChannelInfo;
|
||||
cVeDcChannelGroup *veChannelGroup;
|
||||
cVeDcEpgInfo *veEpgInfo;
|
||||
cVeDcProgressBar *veProgressBar;
|
||||
cVeDcStatusInfo *veStatusInfo;
|
||||
cVeDcScraperContent *veScraperContent;
|
||||
cVeDcEcmInfo *veEcmInfo;
|
||||
bool channelChange;
|
||||
bool displayChannelGroups;
|
||||
void SetViewElements(void);
|
||||
void ClearVariables(void);
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewChannel(void);
|
||||
virtual ~cViewChannel(void);
|
||||
void SetChannel(const cChannel *channel, int number);
|
||||
void SetEvents(const cEvent *present, const cEvent *following);
|
||||
void SetMessage(eMessageType type, const char *text);
|
||||
void Flush(void);
|
||||
};
|
||||
|
||||
#endif //__VIEWDISPLAYCHANNEL_H
|
||||
1705
coreengine/viewdisplaymenu.c
Normal file
1705
coreengine/viewdisplaymenu.c
Normal file
File diff suppressed because it is too large
Load Diff
316
coreengine/viewdisplaymenu.h
Normal file
316
coreengine/viewdisplaymenu.h
Normal file
@@ -0,0 +1,316 @@
|
||||
#ifndef __VIEWDISPLAYMENU_H
|
||||
#define __VIEWDISPLAYMENU_H
|
||||
|
||||
#include "view.h"
|
||||
#include "viewdetail.h"
|
||||
|
||||
/***********************************************************
|
||||
* cViewMenu
|
||||
***********************************************************/
|
||||
class cSubView;
|
||||
class cViewMenuDefault;
|
||||
class cViewMenuMain;
|
||||
class cViewMenuSetup;
|
||||
class cViewMenuSchedules;
|
||||
class cViewMenuChannels;
|
||||
class cViewMenuTimers;
|
||||
class cViewMenuRecordings;
|
||||
class cViewMenuDetail;
|
||||
|
||||
class cViewMenu : public cView {
|
||||
protected:
|
||||
map<string,int> subviewNames;
|
||||
cSubView **subViews;
|
||||
int numSubviews;
|
||||
cSubView *activeSubview;
|
||||
cSubView *activeSubviewLast;
|
||||
cViewMenuDefault *menuDefault;
|
||||
cViewMenuMain *menuMain;
|
||||
cViewMenuSetup *menuSetup;
|
||||
cViewMenuSchedules *menuSchedules;
|
||||
cViewMenuChannels *menuChannels;
|
||||
cViewMenuTimers *menuTimers;
|
||||
cViewMenuRecordings *menuRecordings;
|
||||
cViewMenuDetail *menuDetailedEpg;
|
||||
cViewMenuDetail *menuDetailedRec;
|
||||
cViewMenuDetail *menuDetailedText;
|
||||
eMenuCategory menuCat;
|
||||
//name of current plugin for menu icon
|
||||
const char *plugName;
|
||||
//external plugin menus
|
||||
bool pluginIdSet;
|
||||
int plugId;
|
||||
int plugMenuId;
|
||||
//status variables
|
||||
bool menuChange;
|
||||
bool listChange;
|
||||
bool detailViewInit;
|
||||
void SetViewElements(void);
|
||||
void SetViewElementObjects(void);
|
||||
void SetSubViews(void);
|
||||
void ClearVariables(void);
|
||||
int SubviewId(const char *name);
|
||||
bool SetPluginSubView(eMenuCategory menuCat);
|
||||
void WakeViewElements(void);
|
||||
public:
|
||||
cViewMenu(void);
|
||||
virtual ~cViewMenu(void);
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void PreCache(void);
|
||||
bool ValidSubView(const char *subView);
|
||||
static cSubView *CreateSubview(const char *name);
|
||||
static cSubView *CreatePluginview(const char *plugname, int plugId, int menuNumber, int menuType);
|
||||
void AddSubview(const char *sSubView, cSubView *subView);
|
||||
void AddPluginview(cSubView *plugView);
|
||||
void SetSubView(eMenuCategory MenuCat);
|
||||
void SetSortMode(eMenuSortMode sortMode);
|
||||
void SetPluginMenu(int plugId, int plugMenuId);
|
||||
int NumListItems(void);
|
||||
eMenuOrientation MenuOrientation(void);
|
||||
const cFont *GetTextAreaFont(void);
|
||||
int GetTextAreaWidth(void);
|
||||
int GetListWidth(void);
|
||||
void SetTitleHeader(const char *title);
|
||||
void SetChannelHeader(const cEvent *event);
|
||||
void SetMessage(eMessageType type, const char *text);
|
||||
void SetMenuButtons(const char *red, const char *green, const char *yellow, const char *blue);
|
||||
void SetScrollbar(int total, int offset);
|
||||
void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
|
||||
void SetItem(const char *text, int index, bool current, bool selectable);
|
||||
bool SetItemEvent(const cEvent *event, int index, bool current, bool selectable, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
|
||||
bool SetItemTimer(const cTimer *timer, int index, bool current, bool selectable);
|
||||
bool SetItemChannel(const cChannel *channel, int index, bool current, bool selectable, bool withProvider);
|
||||
bool SetItemRecording(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New);
|
||||
bool SetItemPlugin(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable);
|
||||
void SetEvent(const cEvent *event);
|
||||
void SetRecording(const cRecording *recording);
|
||||
void SetText(const char *text);
|
||||
bool SetPluginText(skindesignerapi::cTokenContainer *tk);
|
||||
void SetCurrentRecording(const char *currentRec);
|
||||
void KeyDetailView(bool up, bool page);
|
||||
bool Init(void);
|
||||
void Close(void);
|
||||
void Clear(void);
|
||||
void Flush(void);
|
||||
void SetTransparency(int transparency, bool forceDetached = false);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
/***********************************************************
|
||||
* cSubView
|
||||
***********************************************************/
|
||||
class cSubView : public cView {
|
||||
protected:
|
||||
eMenuCategory menuCat;
|
||||
int plugId;
|
||||
int plugMenuId;
|
||||
cViewList *viewList;
|
||||
cViewList *viewListVertical;
|
||||
cViewList *viewListHorizontal;
|
||||
cViewElement *background;
|
||||
cVeDmHeader *header;
|
||||
cVeDateTime *datetime;
|
||||
cVeTime *time;
|
||||
cVeMessage *message;
|
||||
cVeDmSortmode *sortmode;
|
||||
cVeDmColorbuttons *colorbuttons;
|
||||
cVeDmScrollbar *scrollbar;
|
||||
virtual void SetViewElementObjects(void);
|
||||
virtual void SetViewElements(void);
|
||||
public:
|
||||
cSubView(const char *name);
|
||||
virtual ~cSubView(void);
|
||||
virtual void SetGlobals(cGlobals *globals);
|
||||
virtual void PreCache(void);
|
||||
bool ViewElementSet(int ve);
|
||||
bool ViewElementHorizontalSet(int ve);
|
||||
void SetViewElement(eVeDisplayMenu ve, cViewElement *viewElement);
|
||||
void SetViewElementHorizontal(eVeDisplayMenu ve, cViewElement *viewElement);
|
||||
void AddViewList(cViewList *viewList);
|
||||
virtual void AddTab(cArea *tab) {};
|
||||
int NumListItems(void);
|
||||
eMenuOrientation MenuOrientation(void);
|
||||
void SetMenuCategory(eMenuCategory menuCat) { this->menuCat = menuCat; };
|
||||
void SetPlugId(int id) { plugId = id; };
|
||||
void SetPlugMenuId(int id) { plugMenuId = id; };
|
||||
void SetTitle(const char *title);
|
||||
void SetMessage(eMessageType type, const char *text);
|
||||
void SetChannel(const cChannel *channel);
|
||||
void SetMenuButtons(const char *red, const char *green, const char *yellow, const char *blue);
|
||||
void SetScrollbar(int total, int offset);
|
||||
void SetSortMode(eMenuSortMode sortMode);
|
||||
virtual void Close(void);
|
||||
virtual void Clear(void);
|
||||
void ClearViewList(void);
|
||||
void WakeViewElements(void);
|
||||
virtual void DrawStaticVEs(void);
|
||||
virtual void DrawDynamicVEs(void);
|
||||
void DrawList(void);
|
||||
virtual void DrawDetailedView(void) {};
|
||||
virtual void UpdateDetailedView(void) {};
|
||||
void SetTransparency(int transparency, bool forceDetached = false);
|
||||
};
|
||||
/***********************************************************
|
||||
* cViewMenuDefault
|
||||
***********************************************************/
|
||||
class cViewMenuDefault : public cSubView {
|
||||
private:
|
||||
cViewListDefault *listDefault;
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuDefault(const char *name);
|
||||
virtual ~cViewMenuDefault(void);
|
||||
void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
|
||||
void SetPlugin(const char *plugName);
|
||||
void SetItem(const char *text, int index, bool current, bool selectable);
|
||||
const cFont *GetTextAreaFont(void);
|
||||
int GetListWidth(void);
|
||||
};
|
||||
/***********************************************************
|
||||
* cViewMenuMain
|
||||
***********************************************************/
|
||||
class cViewMenuMain : public cSubView {
|
||||
private:
|
||||
cViewListMain *listMain;
|
||||
cVeDmTimers *timers;
|
||||
cVeDevices *devices;
|
||||
cVeCurrentWeather *weather;
|
||||
cVeDmDiscusage *discusage;
|
||||
cVeDmSystemload *load;
|
||||
cVeDmSystemmemory *memory;
|
||||
cVeDmVdrstatistics *vdrstats;
|
||||
cVeDmTemperatures *temperatures;
|
||||
cVeDmCurrentschedule *currentSchedule;
|
||||
cVeDmLastrecordings *lastRecordings;
|
||||
cVeCustomTokens *customTokens;
|
||||
uint64_t lastDrawDynamic;
|
||||
void ClearVariables(void);
|
||||
void SetViewElements(void);
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuMain(const char *name);
|
||||
virtual ~cViewMenuMain(void);
|
||||
void Clear(void);
|
||||
void SetItem(const char *text, int index, bool current, bool selectable);
|
||||
void SetCurrentRecording(const char *currentRec);
|
||||
void DrawStaticVEs(void);
|
||||
void DrawDynamicVEs(void);
|
||||
const char *GetPlugin(void);
|
||||
};
|
||||
/***********************************************************
|
||||
* cViewMenuSetup
|
||||
***********************************************************/
|
||||
class cViewMenuSetup : public cSubView {
|
||||
private:
|
||||
cViewListMain *listSetup;
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuSetup(const char *name);
|
||||
virtual ~cViewMenuSetup(void);
|
||||
void SetItem(const char *text, int index, bool current, bool selectable);
|
||||
};
|
||||
/***********************************************************
|
||||
* cViewMenuSchedules
|
||||
***********************************************************/
|
||||
class cViewMenuSchedules : public cSubView {
|
||||
private:
|
||||
cViewListSchedules *listSchedules;
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuSchedules(const char *name);
|
||||
virtual ~cViewMenuSchedules(void);
|
||||
void SetItem(const cEvent *event, int index, bool current, bool selectable, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
|
||||
};
|
||||
/***********************************************************
|
||||
* cViewMenuChannels
|
||||
***********************************************************/
|
||||
class cViewMenuChannels : public cSubView {
|
||||
private:
|
||||
cViewListChannels *listChannels;
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuChannels(const char *name);
|
||||
virtual ~cViewMenuChannels(void);
|
||||
void SetItem(const cChannel *channel, int index, bool current, bool selectable, bool withProvider);
|
||||
};
|
||||
/***********************************************************
|
||||
* cViewMenuTimers
|
||||
***********************************************************/
|
||||
class cViewMenuTimers : public cSubView {
|
||||
private:
|
||||
cViewListTimers *listTimers;
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuTimers(const char *name);
|
||||
virtual ~cViewMenuTimers(void);
|
||||
void SetItem(const cTimer *timer, int index, bool current, bool selectable);
|
||||
};
|
||||
/***********************************************************
|
||||
* cViewMenuRecordings
|
||||
***********************************************************/
|
||||
class cViewMenuRecordings : public cSubView {
|
||||
private:
|
||||
cViewListRecordings *listRecordings;
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuRecordings(const char *name);
|
||||
virtual ~cViewMenuRecordings(void);
|
||||
void SetItem(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New);
|
||||
};
|
||||
|
||||
/***********************************************************
|
||||
* cViewMenuPlugins
|
||||
***********************************************************/
|
||||
class cViewMenuPlugin : public cSubView {
|
||||
private:
|
||||
cViewListPlugin *listPlugin;
|
||||
void SetViewElementObjects(void);
|
||||
public:
|
||||
cViewMenuPlugin(const char *name);
|
||||
virtual ~cViewMenuPlugin(void);
|
||||
void SetItem(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable);
|
||||
};
|
||||
|
||||
/***********************************************************
|
||||
* cViewMenuDetail
|
||||
***********************************************************/
|
||||
class cViewMenuDetail : public cSubView {
|
||||
private:
|
||||
bool firstTab;
|
||||
cVeDmDetailheaderEpg *detailedheaderEpg;
|
||||
cVeDmDetailheaderRec *detailedheaderRec;
|
||||
cVeDmDetailheaderPlugin *detailedheaderPlug;
|
||||
cVeDmTablabels *tablabels;
|
||||
cViewDetail *detailView;
|
||||
cViewDetailEpg *detailViewEpg;
|
||||
cViewDetailRec *detailViewRec;
|
||||
cViewDetailText *detailViewText;
|
||||
cViewDetailPlugin *detailViewPlugin;
|
||||
void SetDetailedView(void);
|
||||
void SetViewElements(void);
|
||||
void SetViewElementObjects(void);
|
||||
void DrawScrollbar(void);
|
||||
public:
|
||||
cViewMenuDetail(const char *name);
|
||||
virtual ~cViewMenuDetail(void);
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void AddTab(cArea *tab);
|
||||
void PreCache(void);
|
||||
int GetWidth(void);
|
||||
void SetEvent(const cEvent *event);
|
||||
void SetRecording(const cRecording *recording);
|
||||
void SetText(const char *text);
|
||||
void SetPluginText(skindesignerapi::cTokenContainer *tk);
|
||||
void Clear(void);
|
||||
void Close(void);
|
||||
void DrawStaticVEs(void);
|
||||
void DrawDynamicVEs(void);
|
||||
void DrawDetailedView(void);
|
||||
void KeyLeft(void);
|
||||
void KeyRight(void);
|
||||
void KeyUp(void);
|
||||
void KeyDown(void);
|
||||
void SetTransparency(int transparency, bool forceDetached = false);
|
||||
};
|
||||
|
||||
#endif //__VIEWDISPLAYMENU_H
|
||||
54
coreengine/viewdisplaymessage.c
Normal file
54
coreengine/viewdisplaymessage.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "viewdisplaymessage.h"
|
||||
#include "../config.h"
|
||||
|
||||
/************************************************************************************
|
||||
* cViewMessage
|
||||
************************************************************************************/
|
||||
|
||||
cViewMessage::cViewMessage(void) {
|
||||
ClearVariables();
|
||||
viewId = eViewType::DisplayMessage;
|
||||
viewName = strdup("displaymessage");
|
||||
numViewElements = (int)eVeDisplayMessage::count;
|
||||
viewElements = new cViewElement*[numViewElements];
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
viewElements[i] = NULL;
|
||||
}
|
||||
SetViewElements();
|
||||
veMessage = NULL;
|
||||
}
|
||||
|
||||
cViewMessage::~cViewMessage() {
|
||||
}
|
||||
|
||||
void cViewMessage::SetViewElements(void) {
|
||||
viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayMessage::background));
|
||||
viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayMessage::message));
|
||||
}
|
||||
|
||||
void cViewMessage::SetViewElementObjects(void) {
|
||||
if (!viewElements[(int)eVeDisplayMessage::message])
|
||||
return;
|
||||
veMessage = dynamic_cast<cVeMessage*>(viewElements[(int)eVeDisplayMessage::message]);
|
||||
}
|
||||
|
||||
void cViewMessage::ClearVariables(void) {
|
||||
init = true;
|
||||
}
|
||||
|
||||
void cViewMessage::SetMessage(eMessageType type, const char *text) {
|
||||
if (!text)
|
||||
veMessage->Clear();
|
||||
else
|
||||
veMessage->Set(type, text);
|
||||
}
|
||||
|
||||
void cViewMessage::Flush(void) {
|
||||
if (init) {
|
||||
sdOsd.LockFlush();
|
||||
Render((int)eVeDisplayMessage::background);
|
||||
}
|
||||
Render((int)eVeDisplayMessage::message);
|
||||
cView::Flush();
|
||||
}
|
||||
|
||||
19
coreengine/viewdisplaymessage.h
Normal file
19
coreengine/viewdisplaymessage.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef __VIEWDISPLAYMESSAGE_H
|
||||
#define __VIEWDISPLAYMESSAGE_H
|
||||
|
||||
#include "view.h"
|
||||
|
||||
class cViewMessage : public cView {
|
||||
private:
|
||||
cVeMessage *veMessage;
|
||||
void SetViewElements(void);
|
||||
void SetViewElementObjects(void);
|
||||
void ClearVariables(void);
|
||||
public:
|
||||
cViewMessage(void);
|
||||
virtual ~cViewMessage(void);
|
||||
void SetMessage(eMessageType type, const char *text);
|
||||
void Flush(void);
|
||||
};
|
||||
|
||||
#endif //__VIEWDISPLAYMESSAGE_H
|
||||
556
coreengine/viewdisplayplugin.c
Normal file
556
coreengine/viewdisplayplugin.c
Normal file
@@ -0,0 +1,556 @@
|
||||
#include "viewdisplayplugin.h"
|
||||
#include "../config.h"
|
||||
/***********************************************************
|
||||
* cViewPlugin
|
||||
***********************************************************/
|
||||
cViewPlugin::cViewPlugin(int id, int plugId) {
|
||||
this->id = id;
|
||||
this->plugId = plugId;
|
||||
viewId = eViewType::DisplayPlugin;
|
||||
viewName = strdup("displayplugin");
|
||||
if (id == 0)
|
||||
numViews = plgManager->GetNumSubviews(plugId) + 1;
|
||||
else
|
||||
numViews = 1;
|
||||
views = new cViewPlugin*[numViews];
|
||||
views[0] = this;
|
||||
for (int i=1; i < numViews; i++) {
|
||||
views[i] = NULL;
|
||||
}
|
||||
numViewElements = plgManager->GetNumViewElements(plugId, id);
|
||||
viewElements = new cViewElement*[numViewElements];
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
viewElements[i] = NULL;
|
||||
}
|
||||
SetViewElements();
|
||||
numViewGrids = plgManager->GetNumViewGrids(plugId, id);
|
||||
viewGrids = new cViewGrid*[numViewGrids];
|
||||
for (int i=0; i < numViewGrids; i++) {
|
||||
viewGrids[i] = NULL;
|
||||
}
|
||||
SetViewGrids();
|
||||
tabView = NULL;
|
||||
viewChanged = true;
|
||||
newViewId = 0;
|
||||
}
|
||||
|
||||
cViewPlugin::~cViewPlugin(void) {
|
||||
for (int i=0; i< numViewGrids; i++)
|
||||
delete viewGrids[i];
|
||||
delete[] viewGrids;
|
||||
delete tabView;
|
||||
for (int i=1; i < numViews; i++) {
|
||||
delete views[i];
|
||||
}
|
||||
delete[] views;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Public Functions
|
||||
***********************************************************/
|
||||
bool cViewPlugin::ReadFromXML(const char *plugName, const char *tplName, cSdOsd *osd) {
|
||||
cString xmlFile = cString::sprintf("plug-%s-%s", plugName, tplName);
|
||||
cXmlParser parser;
|
||||
if (osd)
|
||||
parser.SetOsd(osd);
|
||||
else
|
||||
parser.SetOsd(&sdOsd);
|
||||
if (!parser.ReadView(this, *xmlFile)) {
|
||||
return false;
|
||||
}
|
||||
if (!parser.ParsePluginView()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cViewPlugin::ReadSubViews(const char *plugName) {
|
||||
plgManager->InitPluginSubviewIterator(plugId);
|
||||
int svId = -1;
|
||||
string svTpl = "";
|
||||
while (plgManager->GetNextSubView(svId, svTpl)) {
|
||||
cViewPlugin *plugSubView = new cViewPlugin(svId, plugId);
|
||||
if (!plugSubView->ReadFromXML(plugName, svTpl.c_str(), &sdOsd))
|
||||
return false;
|
||||
views[svId] = plugSubView;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void cViewPlugin::SetGlobals(cGlobals *globals) {
|
||||
cView::SetGlobals(globals);
|
||||
for (int i=0; i < numViewGrids; i++) {
|
||||
if (viewGrids[i])
|
||||
viewGrids[i]->SetGlobals(globals);
|
||||
}
|
||||
for (int i=1; i < numViews; i++) {
|
||||
views[i]->SetGlobals(globals);
|
||||
}
|
||||
if (tabView) {
|
||||
tabView->SetGlobals(globals);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewPlugin::AddViewElement(cVePlugin *viewElement) {
|
||||
int veId = ViewElementId(viewElement->Name());
|
||||
if (veId == ATTR_UNKNOWN)
|
||||
return;
|
||||
viewElement->SetId(veId);
|
||||
viewElement->SetPluginId(plugId);
|
||||
viewElement->SetViewId(id);
|
||||
viewElement->SetTokenContainer();
|
||||
viewElements[veId] = viewElement;
|
||||
}
|
||||
|
||||
void cViewPlugin::AddViewGrid(cViewGrid *viewGrid) {
|
||||
int gId = GridId(viewGrid->Name());
|
||||
if (gId == ATTR_UNKNOWN)
|
||||
return;
|
||||
viewGrid->SetId(gId);
|
||||
viewGrid->SetPluginId(plugId);
|
||||
viewGrid->SetViewId(id);
|
||||
viewGrid->SetTokenContainer();
|
||||
viewGrids[gId] = viewGrid;
|
||||
}
|
||||
|
||||
void cViewPlugin::AddTab(cArea *tab) {
|
||||
if (!tabView) {
|
||||
tabView = new cPluginTabView(id, plugId);
|
||||
tabView->SetOsd(&sdOsd);
|
||||
}
|
||||
tabView->AddTab(tab);
|
||||
}
|
||||
|
||||
void cViewPlugin::AddScrollbar(cVeDmScrollbar *scrollbar) {
|
||||
if (!tabView) {
|
||||
tabView = new cPluginTabView(id, plugId);
|
||||
tabView->SetOsd(&sdOsd);
|
||||
}
|
||||
int id = ViewElementId("scrollbar");
|
||||
scrollbar->SetId(id);
|
||||
scrollbar->SetTokenContainer();
|
||||
tabView->AddScrollbar(scrollbar);
|
||||
}
|
||||
|
||||
void cViewPlugin::AddTablabels(cVeDmTablabels *tablabels) {
|
||||
if (!tabView) {
|
||||
tabView = new cPluginTabView(id, plugId);
|
||||
tabView->SetOsd(&sdOsd);
|
||||
}
|
||||
int id = ViewElementId("tablabels");
|
||||
tablabels->SetId(id);
|
||||
tablabels->SetTokenContainer();
|
||||
tabView->AddTablabels(tablabels);
|
||||
}
|
||||
|
||||
void cViewPlugin::PreCache(void) {
|
||||
if (container.Width() > 0) {
|
||||
attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->Cache();
|
||||
}
|
||||
cView::PreCache();
|
||||
for (int i=0; i < numViewGrids; i++) {
|
||||
if (viewGrids[i]) {
|
||||
viewGrids[i]->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
viewGrids[i]->PreCache();
|
||||
}
|
||||
}
|
||||
for (int i=1; i < numViews; i++) {
|
||||
views[i]->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
views[i]->PreCache();
|
||||
}
|
||||
if (tabView) {
|
||||
tabView->PreCache(0, 0, attribs->Width(), attribs->Height());
|
||||
}
|
||||
}
|
||||
|
||||
cVePlugin *cViewPlugin::GetViewElement(int veId) {
|
||||
if (!viewElements[veId])
|
||||
return NULL;
|
||||
cVePlugin *ve = dynamic_cast<cVePlugin*>(viewElements[veId]);
|
||||
return ve;
|
||||
}
|
||||
|
||||
cViewGrid *cViewPlugin::GetViewGrid(int gId) {
|
||||
return viewGrids[gId];
|
||||
}
|
||||
|
||||
cPluginTabView *cViewPlugin::GetViewTab(void) {
|
||||
return tabView;
|
||||
}
|
||||
|
||||
void cViewPlugin::Hide(void) {
|
||||
for (int i=0; i < numViewGrids; i++) {
|
||||
if (viewGrids[i])
|
||||
viewGrids[i]->Hide();
|
||||
}
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (viewElements[i])
|
||||
viewElements[i]->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewPlugin::Show(void) {
|
||||
for (int i=0; i < numViewGrids; i++) {
|
||||
if (viewGrids[i])
|
||||
viewGrids[i]->Show();
|
||||
}
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (viewElements[i])
|
||||
viewElements[i]->Show();
|
||||
}
|
||||
}
|
||||
/***********************************************************
|
||||
* libskindesigner api interface
|
||||
***********************************************************/
|
||||
bool cViewPlugin::InitOsd(void) {
|
||||
return Init();
|
||||
}
|
||||
|
||||
void cViewPlugin::CloseOsd(void) {
|
||||
viewChanged = true;
|
||||
newViewId = 0;
|
||||
Close();
|
||||
for (int i=0 ; i < numViewGrids; i++) {
|
||||
if (viewGrids[i])
|
||||
viewGrids[i]->Close();
|
||||
}
|
||||
for (int i=1 ; i < numViews; i++) {
|
||||
if (views[i])
|
||||
views[i]->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewPlugin::Deactivate(int viewId, bool hide) {
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (viewElements[i])
|
||||
viewElements[i]->StopScrolling(false);
|
||||
}
|
||||
if (hide)
|
||||
views[viewId]->Hide();
|
||||
}
|
||||
|
||||
void cViewPlugin::Activate(int viewId) {
|
||||
viewChanged = true;
|
||||
newViewId = viewId;
|
||||
views[viewId]->Show();
|
||||
}
|
||||
|
||||
void cViewPlugin::SetViewElementTokens(int veId, int viewId, skindesignerapi::cTokenContainer *tk) {
|
||||
cVePlugin *ve = views[viewId]->GetViewElement(veId);
|
||||
if (!ve)
|
||||
return;
|
||||
ve->Set(tk);
|
||||
}
|
||||
|
||||
void cViewPlugin::ClearViewElement(int veId, int viewId) {
|
||||
cVePlugin *ve = views[viewId]->GetViewElement(veId);
|
||||
if (!ve)
|
||||
return;
|
||||
ve->StopScrolling();
|
||||
ve->Clear();
|
||||
}
|
||||
|
||||
void cViewPlugin::DisplayViewElement(int veId, int viewId) {
|
||||
cVePlugin *ve = views[viewId]->GetViewElement(veId);
|
||||
if (!ve)
|
||||
return;
|
||||
if (ve->Parse())
|
||||
ve->Render();
|
||||
}
|
||||
|
||||
void cViewPlugin::SetGrid(long gId, int viewId, int viewGridId, double x, double y, double width, double height, skindesignerapi::cTokenContainer *tk){
|
||||
cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
|
||||
if (!grid)
|
||||
return;
|
||||
grid->CheckSize(gId);
|
||||
grid->PositionGrid(gId, x, y, width, height);
|
||||
if (tk) {
|
||||
//only set tokens new if necessary
|
||||
grid->SetTokens(gId, tk);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewPlugin::SetGridCurrent(long gId, int viewId, int viewGridId, bool current) {
|
||||
if (gId < 0)
|
||||
return;
|
||||
cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
|
||||
if (!grid)
|
||||
return;
|
||||
grid->SetCurrentGrid(gId, current);
|
||||
}
|
||||
|
||||
void cViewPlugin::DeleteGrid(long gId, int viewId, int viewGridId) {
|
||||
cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
|
||||
if (!grid)
|
||||
return;
|
||||
grid->DeleteGrid(gId);
|
||||
}
|
||||
|
||||
void cViewPlugin::DisplayGrids(int viewId, int viewGridId) {
|
||||
cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
|
||||
if (!grid)
|
||||
return;
|
||||
grid->Render();
|
||||
}
|
||||
|
||||
void cViewPlugin::ClearGrids(int viewId, int viewGridId) {
|
||||
cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
|
||||
if (!grid)
|
||||
return;
|
||||
grid->ClearGrids();
|
||||
}
|
||||
|
||||
void cViewPlugin::SetTabTokens(int viewId, skindesignerapi::cTokenContainer *tk) {
|
||||
cPluginTabView *tab = views[viewId]->GetViewTab();
|
||||
if (!tab)
|
||||
return;
|
||||
tab->SetOsd(&sdOsd);
|
||||
tab->Set(tk);
|
||||
}
|
||||
|
||||
void cViewPlugin::TabLeft(int viewId) {
|
||||
cPluginTabView *tab = views[viewId]->GetViewTab();
|
||||
if (!tab)
|
||||
return;
|
||||
tab->KeyLeft();
|
||||
}
|
||||
|
||||
void cViewPlugin::TabRight(int viewId) {
|
||||
cPluginTabView *tab = views[viewId]->GetViewTab();
|
||||
if (!tab)
|
||||
return;
|
||||
tab->KeyRight();
|
||||
}
|
||||
|
||||
void cViewPlugin::TabUp(int viewId) {
|
||||
cPluginTabView *tab = views[viewId]->GetViewTab();
|
||||
if (!tab)
|
||||
return;
|
||||
tab->KeyUp();
|
||||
}
|
||||
|
||||
void cViewPlugin::TabDown(int viewId) {
|
||||
cPluginTabView *tab = views[viewId]->GetViewTab();
|
||||
if (!tab)
|
||||
return;
|
||||
tab->KeyDown();
|
||||
}
|
||||
|
||||
void cViewPlugin::DisplayTabs(int viewId) {
|
||||
cPluginTabView *tab = views[viewId]->GetViewTab();
|
||||
if (!tab)
|
||||
return;
|
||||
tab->Render();
|
||||
}
|
||||
|
||||
void cViewPlugin::ClearTab(int viewId) {
|
||||
cPluginTabView *tab = views[viewId]->GetViewTab();
|
||||
if (!tab)
|
||||
return;
|
||||
tab->Clear();
|
||||
}
|
||||
|
||||
void cViewPlugin::Flush(void) {
|
||||
if (viewChanged) {
|
||||
viewChanged = false;
|
||||
newTvFrame = views[newViewId]->GetTvFrame();
|
||||
menuInit = true;
|
||||
}
|
||||
cView::Flush();
|
||||
}
|
||||
|
||||
bool cViewPlugin::ChannelLogoExists(string channelId) {
|
||||
return imgCache->LogoExists(channelId);
|
||||
}
|
||||
|
||||
string cViewPlugin::GetEpgImagePath(void) {
|
||||
return *config.epgImagePath;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Private Functions
|
||||
***********************************************************/
|
||||
void cViewPlugin::SetViewElements(void) {
|
||||
plgManager->InitViewElementIterator(plugId, id);
|
||||
int veId = -1;
|
||||
string veName = "";
|
||||
while (plgManager->GetNextViewElement(veId, veName)) {
|
||||
viewElementNames.insert(pair<string, int>(veName, veId));
|
||||
}
|
||||
}
|
||||
|
||||
void cViewPlugin::SetViewGrids(void) {
|
||||
plgManager->InitViewGridIterator(plugId, id);
|
||||
int gId = -1;
|
||||
string gName = "";
|
||||
while (plgManager->GetNextViewGrid(gId, gName)) {
|
||||
gridNames.insert(pair<string, int>(gName, gId));
|
||||
}
|
||||
}
|
||||
|
||||
int cViewPlugin::GridId(const char *name) {
|
||||
map<string, int>::iterator hit = gridNames.find(name);
|
||||
if (hit != gridNames.end())
|
||||
return (int)hit->second;
|
||||
return ATTR_UNKNOWN;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* cPluginTabView
|
||||
***********************************************************/
|
||||
cPluginTabView::cPluginTabView(int viewId, int plugId) {
|
||||
sdOsd = NULL;
|
||||
init = true;
|
||||
drawScrollbar = true;
|
||||
scrollbar = NULL;
|
||||
tablabels = NULL;
|
||||
detailView = new cViewDetailAdvancedPlugin(viewId, plugId);
|
||||
firstTab = true;
|
||||
}
|
||||
|
||||
cPluginTabView::~cPluginTabView(void) {
|
||||
delete scrollbar;
|
||||
delete tablabels;
|
||||
delete detailView;
|
||||
}
|
||||
|
||||
void cPluginTabView::SetGlobals(cGlobals *globals) {
|
||||
detailView->SetGlobals(globals);
|
||||
if (scrollbar)
|
||||
scrollbar->SetGlobals(globals);
|
||||
if (tablabels)
|
||||
tablabels->SetGlobals(globals);
|
||||
}
|
||||
|
||||
void cPluginTabView::AddTab(cArea *tab) {
|
||||
if (firstTab) {
|
||||
tab->SetActiveTab(true);
|
||||
firstTab = false;
|
||||
}
|
||||
detailView->AddArea(tab);
|
||||
}
|
||||
|
||||
void cPluginTabView::AddScrollbar(cVeDmScrollbar *scrollbar) {
|
||||
this->scrollbar = scrollbar;
|
||||
}
|
||||
|
||||
void cPluginTabView::AddTablabels(cVeDmTablabels *tablabels) {
|
||||
this->tablabels = tablabels;
|
||||
}
|
||||
|
||||
void cPluginTabView::PreCache(int containerX, int containerY, int containerWidth, int containerHeight) {
|
||||
detailView->SetOsd(sdOsd);
|
||||
detailView->SetTokenContainer();
|
||||
detailView->SetContainer(containerX, containerY, containerWidth, containerHeight);
|
||||
detailView->Cache();
|
||||
if (scrollbar) {
|
||||
scrollbar->SetContainer(containerX, containerY, containerWidth, containerHeight);
|
||||
scrollbar->Cache();
|
||||
}
|
||||
if (tablabels) {
|
||||
tablabels->SetContainer(containerX, containerY, containerWidth, containerHeight);
|
||||
tablabels->Cache();
|
||||
}
|
||||
}
|
||||
|
||||
void cPluginTabView::Set(skindesignerapi::cTokenContainer *tk) {
|
||||
detailView->Set(tk);
|
||||
}
|
||||
|
||||
void cPluginTabView::Render(void) {
|
||||
detailView->Render();
|
||||
if (drawScrollbar) {
|
||||
drawScrollbar = false;
|
||||
DrawScrollbar();
|
||||
}
|
||||
if (!init)
|
||||
return;
|
||||
init = false;
|
||||
vector<const char*> tabs;
|
||||
int activeTab = detailView->GetTabs(tabs);
|
||||
if (tablabels) {
|
||||
tablabels->SetTabs(tabs);
|
||||
tablabels->SetActiveTab(activeTab);
|
||||
if (tablabels->Parse())
|
||||
tablabels->Render();
|
||||
}
|
||||
}
|
||||
|
||||
void cPluginTabView::Clear(void) {
|
||||
init = true;
|
||||
drawScrollbar = true;
|
||||
detailView->ResetTabs();
|
||||
detailView->Close();
|
||||
if (tablabels)
|
||||
tablabels->Close();
|
||||
if (scrollbar)
|
||||
scrollbar->Close();
|
||||
}
|
||||
|
||||
void cPluginTabView::KeyLeft(void) {
|
||||
if (detailView->NumTabs() > 1) {
|
||||
detailView->Clear();
|
||||
detailView->PrevTab();
|
||||
detailView->SetDirty();
|
||||
if (tablabels) {
|
||||
tablabels->Clear();
|
||||
tablabels->SetActiveTab(detailView->ActiveTab());
|
||||
if (tablabels->Parse())
|
||||
tablabels->Render();
|
||||
}
|
||||
sdOsd->Flush();
|
||||
drawScrollbar = true;
|
||||
} else {
|
||||
//scroll page
|
||||
if (detailView->ScrollUp(true)) {
|
||||
drawScrollbar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cPluginTabView::KeyRight(void) {
|
||||
if (detailView->NumTabs() > 1) {
|
||||
detailView->Clear();
|
||||
detailView->NextTab();
|
||||
detailView->SetDirty();
|
||||
if (tablabels) {
|
||||
tablabels->Clear();
|
||||
tablabels->SetActiveTab(detailView->ActiveTab());
|
||||
if (tablabels->Parse())
|
||||
tablabels->Render();
|
||||
}
|
||||
sdOsd->Flush();
|
||||
drawScrollbar = true;
|
||||
} else {
|
||||
//scroll page
|
||||
if (detailView->ScrollDown(true)) {
|
||||
drawScrollbar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cPluginTabView::KeyUp(void) {
|
||||
if (detailView->ScrollUp()) {
|
||||
drawScrollbar = true;
|
||||
}
|
||||
}
|
||||
|
||||
void cPluginTabView::KeyDown(void) {
|
||||
if (detailView->ScrollDown()) {
|
||||
drawScrollbar = true;
|
||||
}
|
||||
}
|
||||
|
||||
void cPluginTabView::DrawScrollbar(void) {
|
||||
if (!scrollbar)
|
||||
return;
|
||||
int barheight = 0;
|
||||
int offset = 0;
|
||||
bool end = true;
|
||||
detailView->Scrollbar(barheight, offset, end);
|
||||
scrollbar->SetDetail(barheight, offset, end);
|
||||
scrollbar->Render();
|
||||
}
|
||||
|
||||
101
coreengine/viewdisplayplugin.h
Normal file
101
coreengine/viewdisplayplugin.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef __VIEWDISPLAYPLUGIN_H
|
||||
#define __VIEWDISPLAYPLUGIN_H
|
||||
|
||||
#include "view.h"
|
||||
#include "viewdetail.h"
|
||||
#include "viewelementsdisplaymenu.h"
|
||||
#include "viewgrid.h"
|
||||
#include "../libskindesignerapi/skindesignerapi.h"
|
||||
|
||||
class cPluginTabView;
|
||||
/***********************************************************
|
||||
* cViewPlugin
|
||||
***********************************************************/
|
||||
class cViewPlugin : public cView, public skindesignerapi::ISkinDisplayPlugin {
|
||||
private:
|
||||
int id;
|
||||
int plugId;
|
||||
int numViews;
|
||||
cViewPlugin **views;
|
||||
int numViewGrids;
|
||||
cViewGrid **viewGrids;
|
||||
map<string,int> gridNames;
|
||||
cPluginTabView *tabView;
|
||||
bool viewChanged;
|
||||
int newViewId;
|
||||
void SetViewElements(void);
|
||||
void SetViewGrids(void);
|
||||
int GridId(const char *name);
|
||||
public:
|
||||
cViewPlugin(int id, int plugId);
|
||||
~cViewPlugin(void);
|
||||
//Internal Interface
|
||||
bool ReadFromXML(const char *plugName, const char *tplName, cSdOsd *osd = NULL);
|
||||
bool ReadSubViews(const char *plugName);
|
||||
void AddViewElement(cVePlugin *viewElement);
|
||||
void AddViewGrid(cViewGrid *viewGrid);
|
||||
void AddTab(cArea *tab);
|
||||
void AddScrollbar(cVeDmScrollbar *scrollbar);
|
||||
void AddTablabels(cVeDmTablabels *tablabels);
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void PreCache(void);
|
||||
cVePlugin *GetViewElement(int veId);
|
||||
cViewGrid *GetViewGrid(int gId);
|
||||
cPluginTabView *GetViewTab(void);
|
||||
void Hide(void);
|
||||
void Show(void);
|
||||
//libskindesigner api interface
|
||||
bool InitOsd(void);
|
||||
void CloseOsd(void);
|
||||
void Deactivate(int viewId, bool hide);
|
||||
void Activate(int viewId);
|
||||
void SetViewElementTokens(int veId, int viewId, skindesignerapi::cTokenContainer *tk);
|
||||
void ClearViewElement(int veId, int viewId);
|
||||
void DisplayViewElement(int veId, int viewId);
|
||||
void SetGrid(long gId, int viewId, int viewGridId, double x, double y, double width, double height, skindesignerapi::cTokenContainer *tk);
|
||||
void SetGridCurrent(long gId, int viewId, int viewGridId, bool current);
|
||||
void DeleteGrid(long gId, int viewId, int viewGridId);
|
||||
void DisplayGrids(int viewId, int viewGridId);
|
||||
void ClearGrids(int viewId, int viewGridId);
|
||||
void SetTabTokens(int viewId, skindesignerapi::cTokenContainer *tk);
|
||||
void TabLeft(int viewId);
|
||||
void TabRight(int viewId);
|
||||
void TabUp(int viewId);
|
||||
void TabDown(int viewId);
|
||||
void DisplayTabs(int viewId);
|
||||
void ClearTab(int viewId);
|
||||
void Flush(void);
|
||||
bool ChannelLogoExists(string channelId);
|
||||
string GetEpgImagePath(void);
|
||||
};
|
||||
/***********************************************************
|
||||
* cPluginTabView
|
||||
***********************************************************/
|
||||
class cPluginTabView {
|
||||
private:
|
||||
cSdOsd *sdOsd;
|
||||
bool init;
|
||||
bool drawScrollbar;
|
||||
bool firstTab;
|
||||
cVeDmScrollbar *scrollbar;
|
||||
cVeDmTablabels *tablabels;
|
||||
cViewDetailAdvancedPlugin *detailView;
|
||||
void DrawScrollbar(void);
|
||||
public:
|
||||
cPluginTabView(int viewId, int plugId);
|
||||
~cPluginTabView(void);
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void SetOsd(cSdOsd *osd) { sdOsd = osd; };
|
||||
void AddTab(cArea *tab);
|
||||
void AddScrollbar(cVeDmScrollbar *scrollbar);
|
||||
void AddTablabels(cVeDmTablabels *tablabels);
|
||||
void PreCache(int containerX, int containerY, int containerWidth, int containerHeight);
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
void Render(void);
|
||||
void Clear(void);
|
||||
void KeyLeft(void);
|
||||
void KeyRight(void);
|
||||
void KeyUp(void);
|
||||
void KeyDown(void);
|
||||
};
|
||||
#endif //__VIEWDISPLAYPLUGIN_H
|
||||
314
coreengine/viewdisplayreplay.c
Normal file
314
coreengine/viewdisplayreplay.c
Normal file
@@ -0,0 +1,314 @@
|
||||
#include "viewdisplayreplay.h"
|
||||
|
||||
/************************************************************************************
|
||||
* cViewReplay
|
||||
************************************************************************************/
|
||||
|
||||
cViewReplay::cViewReplay(void) {
|
||||
veCustomTokens = NULL;
|
||||
veEndTime = NULL;
|
||||
veMessage = NULL;
|
||||
veScraperContent = NULL;
|
||||
veRecTitle = NULL;
|
||||
veRecInfo = NULL;
|
||||
veCurrentTime = NULL;
|
||||
veTotalTime = NULL;
|
||||
veProgressbar = NULL;
|
||||
veCutMarks = NULL;
|
||||
veProgressModeOnly = NULL;
|
||||
veControlIcons = NULL;
|
||||
veControlIconsModeOnly = NULL;
|
||||
veJump = NULL;
|
||||
veOnPause = NULL;
|
||||
veOnPauseModeOnly = NULL;
|
||||
ClearVariables();
|
||||
viewId = eViewType::DisplayReplay;
|
||||
viewName = strdup("displayreplay");
|
||||
numViewElements = (int)eVeDisplayReplay::count;
|
||||
viewElements = new cViewElement*[numViewElements];
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
viewElements[i] = NULL;
|
||||
}
|
||||
SetViewElements();
|
||||
}
|
||||
|
||||
cViewReplay::~cViewReplay() {
|
||||
}
|
||||
|
||||
void cViewReplay::SetViewElements(void) {
|
||||
viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayReplay::background));
|
||||
viewElementNames.insert(pair<string, int>("backgroundmodeonly", (int)eVeDisplayReplay::backgroundmodeonly));
|
||||
viewElementNames.insert(pair<string, int>("datetime", (int)eVeDisplayReplay::datetime));
|
||||
viewElementNames.insert(pair<string, int>("time", (int)eVeDisplayReplay::time));
|
||||
viewElementNames.insert(pair<string, int>("scrapercontent", (int)eVeDisplayReplay::scrapercontent));
|
||||
viewElementNames.insert(pair<string, int>("rectitle", (int)eVeDisplayReplay::rectitle));
|
||||
viewElementNames.insert(pair<string, int>("recinfo", (int)eVeDisplayReplay::recinfo));
|
||||
viewElementNames.insert(pair<string, int>("currenttime", (int)eVeDisplayReplay::currenttime));
|
||||
viewElementNames.insert(pair<string, int>("endtime", (int)eVeDisplayReplay::endtime));
|
||||
viewElementNames.insert(pair<string, int>("totaltime", (int)eVeDisplayReplay::totaltime));
|
||||
viewElementNames.insert(pair<string, int>("progressbar", (int)eVeDisplayReplay::progressbar));
|
||||
viewElementNames.insert(pair<string, int>("cutmarks", (int)eVeDisplayReplay::cutmarks));
|
||||
viewElementNames.insert(pair<string, int>("cutmarks", (int)eVeDisplayReplay::cutmarks));
|
||||
viewElementNames.insert(pair<string, int>("controlicons", (int)eVeDisplayReplay::controlicons));
|
||||
viewElementNames.insert(pair<string, int>("controliconsmodeonly", (int)eVeDisplayReplay::controliconsmodeonly));
|
||||
viewElementNames.insert(pair<string, int>("progressmodeonly", (int)eVeDisplayReplay::progressmodeonly));
|
||||
viewElementNames.insert(pair<string, int>("jump", (int)eVeDisplayReplay::jump));
|
||||
viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayReplay::message));
|
||||
viewElementNames.insert(pair<string, int>("onpause", (int)eVeDisplayReplay::onpause));
|
||||
viewElementNames.insert(pair<string, int>("onpausemodeonly", (int)eVeDisplayReplay::onpausemodeonly));
|
||||
viewElementNames.insert(pair<string, int>("customtokens", (int)eVeDisplayReplay::customtokens));
|
||||
}
|
||||
|
||||
void cViewReplay::SetViewElementObjects(void) {
|
||||
for (int i = 0; i < numViewElements; i++) {
|
||||
if (!viewElements[i])
|
||||
continue;
|
||||
if (dynamic_cast<cVeMessage*>(viewElements[i]))
|
||||
{
|
||||
veMessage = dynamic_cast<cVeMessage*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrScraperContent*>(viewElements[i]))
|
||||
{
|
||||
veScraperContent = dynamic_cast<cVeDrScraperContent*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeCustomTokens*>(viewElements[i]))
|
||||
{
|
||||
veCustomTokens = dynamic_cast<cVeCustomTokens*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrRecTitle*>(viewElements[i]))
|
||||
{
|
||||
veRecTitle = dynamic_cast<cVeDrRecTitle*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrRecInfo*>(viewElements[i]))
|
||||
{
|
||||
veRecInfo = dynamic_cast<cVeDrRecInfo*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrCurrentTime*>(viewElements[i]))
|
||||
{
|
||||
veCurrentTime = dynamic_cast<cVeDrCurrentTime*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrTotalTime*>(viewElements[i]))
|
||||
{
|
||||
veTotalTime = dynamic_cast<cVeDrTotalTime*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrEndTime*>(viewElements[i]))
|
||||
{
|
||||
veEndTime = dynamic_cast<cVeDrEndTime*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrProgressBar*>(viewElements[i]))
|
||||
{
|
||||
veProgressbar = dynamic_cast<cVeDrProgressBar*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrCutMarks*>(viewElements[i]))
|
||||
{
|
||||
veCutMarks = dynamic_cast<cVeDrCutMarks*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrProgressModeonly*>(viewElements[i]))
|
||||
{
|
||||
veProgressModeOnly = dynamic_cast<cVeDrProgressModeonly*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrControlIcons*>(viewElements[i]) && (i == (int)eVeDisplayReplay::controlicons))
|
||||
{
|
||||
veControlIcons = dynamic_cast<cVeDrControlIcons*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrControlIcons*>(viewElements[i]) && i == (int)eVeDisplayReplay::controliconsmodeonly)
|
||||
{
|
||||
veControlIconsModeOnly = dynamic_cast<cVeDrControlIcons*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrJump*>(viewElements[i]))
|
||||
{
|
||||
veJump = dynamic_cast<cVeDrJump*>(viewElements[i]);
|
||||
}
|
||||
else if (dynamic_cast<cVeDrOnPause*>(viewElements[i]) && i == (int)eVeDisplayReplay::onpause)
|
||||
{
|
||||
veOnPause = dynamic_cast<cVeDrOnPause*>(viewElements[i]);
|
||||
veOnPause->SetDetached();
|
||||
veOnPause->UnsetWaitOnWakeup();
|
||||
}
|
||||
else if (dynamic_cast<cVeDrOnPause*>(viewElements[i]) && i == (int)eVeDisplayReplay::onpausemodeonly)
|
||||
{
|
||||
veOnPauseModeOnly = dynamic_cast<cVeDrOnPause*>(viewElements[i]);
|
||||
veOnPauseModeOnly->SetDetached();
|
||||
veOnPauseModeOnly->UnsetWaitOnWakeup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewReplay::ClearVariables(void) {
|
||||
cView::ClearVariables();
|
||||
modeOnly = false;
|
||||
lastFlush = 0;
|
||||
message = false;
|
||||
reclength = -1;
|
||||
timeShiftActive = false;
|
||||
timeShiftFramesTotal = -1;
|
||||
timeShiftLength = -1;
|
||||
timeShiftDuration = "";
|
||||
if (veCustomTokens)
|
||||
veCustomTokens->Reset();
|
||||
if (veEndTime)
|
||||
veEndTime->Set(cString(""));
|
||||
if (veCutMarks)
|
||||
veCutMarks->Reset();
|
||||
}
|
||||
|
||||
void cViewReplay::SetTimeShift(int framesTotal, int timeShiftLength) {
|
||||
timeShiftActive = true;
|
||||
timeShiftFramesTotal = framesTotal;
|
||||
this->timeShiftLength = timeShiftLength;
|
||||
int mins = (timeShiftLength / 60) % 60;
|
||||
int hours = (timeShiftLength / 3600) % 24;
|
||||
timeShiftDuration = cString::sprintf("%d:%02d", hours, mins);
|
||||
}
|
||||
|
||||
void cViewReplay::SetRecording(const cRecording *recording) {
|
||||
if (veRecTitle) {
|
||||
veRecTitle->Set(recording);
|
||||
}
|
||||
if (veRecInfo) {
|
||||
veRecInfo->Set(recording);
|
||||
}
|
||||
if (veScraperContent) {
|
||||
veScraperContent->Set(recording);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewReplay::SetTitle(const char *title) {
|
||||
if (veRecTitle) {
|
||||
veRecTitle->Set(title);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewReplay::SetCurrent(const char *current) {
|
||||
if (veCurrentTime)
|
||||
veCurrentTime->Set(current);
|
||||
Render((int)eVeDisplayReplay::currenttime);
|
||||
//good place to refresh these viewelements
|
||||
//since SetCurrent is called every second
|
||||
Render((int)eVeDisplayReplay::datetime);
|
||||
Render((int)eVeDisplayReplay::time);
|
||||
Render((int)eVeDisplayChannel::customtokens);
|
||||
}
|
||||
|
||||
void cViewReplay::SetTotal(const char *total) {
|
||||
if (veTotalTime)
|
||||
veTotalTime->Set(total, timeShiftActive, *timeShiftDuration);
|
||||
Render((int)eVeDisplayReplay::totaltime);
|
||||
}
|
||||
|
||||
void cViewReplay::SetEndTime(int current, int total) {
|
||||
if (!veEndTime)
|
||||
return;
|
||||
int totalLength = total;
|
||||
int recordingLength = reclength;
|
||||
if (timeShiftActive && timeShiftFramesTotal > 0) {
|
||||
totalLength = timeShiftFramesTotal;
|
||||
recordingLength = timeShiftLength;
|
||||
}
|
||||
double rest = (double)(totalLength - current) / (double)totalLength;
|
||||
time_t end = time(0) + rest*recordingLength;
|
||||
veEndTime->Set(TimeString(end));
|
||||
Render((int)eVeDisplayReplay::endtime);
|
||||
}
|
||||
|
||||
void cViewReplay::SetProgressbar(int current, int total) {
|
||||
if (veProgressbar)
|
||||
veProgressbar->Set(current, total, timeShiftActive, timeShiftFramesTotal);
|
||||
Render((int)eVeDisplayReplay::progressbar);
|
||||
}
|
||||
|
||||
void cViewReplay::SetMarks(const cMarks *marks, int current, int total) {
|
||||
if (veCutMarks)
|
||||
veCutMarks->Set(marks, current, total, timeShiftActive, timeShiftFramesTotal);
|
||||
Render((int)eVeDisplayReplay::cutmarks);
|
||||
}
|
||||
|
||||
void cViewReplay::SetControlIcons(bool play, bool forward, int speed) {
|
||||
if (!modeOnly) {
|
||||
if (veControlIcons)
|
||||
veControlIcons->Set(play, forward, speed);
|
||||
Render((int)eVeDisplayReplay::controlicons);
|
||||
} else {
|
||||
if (veControlIconsModeOnly)
|
||||
veControlIconsModeOnly->Set(play, forward, speed);
|
||||
Render((int)eVeDisplayReplay::controliconsmodeonly);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void cViewReplay::SetJump(const char *jump) {
|
||||
if (veJump) {
|
||||
if (!jump)
|
||||
veJump->Clear();
|
||||
else
|
||||
veJump->Set(jump);
|
||||
}
|
||||
Render((int)eVeDisplayReplay::jump);
|
||||
}
|
||||
|
||||
void cViewReplay::SetMessage(eMessageType type, const char *text) {
|
||||
if (veMessage) {
|
||||
if (text)
|
||||
veMessage->Set(type, text);
|
||||
else
|
||||
veMessage->Clear();
|
||||
}
|
||||
Render((int)eVeDisplayReplay::message);
|
||||
}
|
||||
|
||||
void cViewReplay::StartOnPause(const char *recfilename) {
|
||||
cVeDrOnPause *onPause = (!modeOnly) ? veOnPause : veOnPauseModeOnly;
|
||||
if (!onPause)
|
||||
return;
|
||||
onPause->Set(recfilename);
|
||||
onPause->Parse(true);
|
||||
}
|
||||
|
||||
void cViewReplay::ClearOnPause(void) {
|
||||
cVeDrOnPause *onPause = (!modeOnly) ? veOnPause : veOnPauseModeOnly;
|
||||
if (!onPause)
|
||||
return;
|
||||
onPause->Close();
|
||||
}
|
||||
|
||||
void cViewReplay::Flush(void) {
|
||||
if (init) {
|
||||
sdOsd.LockFlush();
|
||||
if (!modeOnly) {
|
||||
Render((int)eVeDisplayReplay::background);
|
||||
Render((int)eVeDisplayReplay::rectitle);
|
||||
Render((int)eVeDisplayReplay::recinfo);
|
||||
Render((int)eVeDisplayReplay::scrapercontent);
|
||||
} else {
|
||||
Render((int)eVeDisplayReplay::backgroundmodeonly);
|
||||
}
|
||||
}
|
||||
|
||||
if (modeOnly) {
|
||||
SetProgressModeOnly();
|
||||
}
|
||||
|
||||
cView::Flush();
|
||||
}
|
||||
|
||||
void cViewReplay::SetProgressModeOnly(void) {
|
||||
if (!veProgressModeOnly)
|
||||
return;
|
||||
time_t now = time(0);
|
||||
if (now == lastFlush) {
|
||||
return;
|
||||
}
|
||||
lastFlush = now;
|
||||
|
||||
cControl *control = cControl::Control();
|
||||
if (!control)
|
||||
return;
|
||||
double fps = control->FramesPerSecond();
|
||||
int current = 0;
|
||||
int total = 0;
|
||||
if (!control->GetIndex(current, total))
|
||||
return;
|
||||
veProgressModeOnly->Set(fps, current, total);
|
||||
if (veProgressModeOnly->Parse())
|
||||
veProgressModeOnly->Render();
|
||||
}
|
||||
57
coreengine/viewdisplayreplay.h
Normal file
57
coreengine/viewdisplayreplay.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef __VIEWDISPLAYREPLAY_H
|
||||
#define __VIEWDISPLAYREPLAY_H
|
||||
|
||||
#include "view.h"
|
||||
|
||||
class cViewReplay : public cView {
|
||||
private:
|
||||
cVeMessage *veMessage;
|
||||
cVeCustomTokens *veCustomTokens;
|
||||
cVeDrRecTitle *veRecTitle;
|
||||
cVeDrRecInfo *veRecInfo;
|
||||
cVeDrScraperContent *veScraperContent;
|
||||
cVeDrCurrentTime *veCurrentTime;
|
||||
cVeDrTotalTime *veTotalTime;
|
||||
cVeDrEndTime *veEndTime;
|
||||
cVeDrProgressBar *veProgressbar;
|
||||
cVeDrCutMarks *veCutMarks;
|
||||
cVeDrProgressModeonly *veProgressModeOnly;
|
||||
cVeDrControlIcons *veControlIcons;
|
||||
cVeDrControlIcons *veControlIconsModeOnly;
|
||||
cVeDrJump *veJump;
|
||||
cVeDrOnPause *veOnPause;
|
||||
cVeDrOnPause *veOnPauseModeOnly;
|
||||
bool modeOnly;
|
||||
time_t lastFlush;
|
||||
bool message;
|
||||
int reclength;
|
||||
bool timeShiftActive;
|
||||
int timeShiftFramesTotal;
|
||||
int timeShiftLength;
|
||||
cString timeShiftDuration;
|
||||
void SetViewElements(void);
|
||||
void ClearVariables(void);
|
||||
void SetViewElementObjects(void);
|
||||
void SetProgressModeOnly(void);
|
||||
public:
|
||||
cViewReplay(void);
|
||||
virtual ~cViewReplay(void);
|
||||
void SetModeOnly(bool modeOnly) { this->modeOnly = modeOnly; };
|
||||
void SetRecordingLength(int length) { reclength = length; };
|
||||
void SetTimeShift(int framesTotal, int timeShiftLength);
|
||||
void SetRecording(const cRecording *recording);
|
||||
void SetTitle(const char *title);
|
||||
void SetCurrent(const char *current);
|
||||
void SetTotal(const char *total);
|
||||
void SetEndTime(int current, int total);
|
||||
void SetProgressbar(int current, int total);
|
||||
void SetMarks(const cMarks *marks, int current, int total);
|
||||
void SetControlIcons(bool play, bool forward, int speed);
|
||||
void SetJump(const char *jump);
|
||||
void SetMessage(eMessageType type, const char *text);
|
||||
void StartOnPause(const char *recfilename);
|
||||
void ClearOnPause(void);
|
||||
void Flush(void);
|
||||
};
|
||||
|
||||
#endif //__VIEWDISPLAYREPLAY_H1
|
||||
122
coreengine/viewdisplaytracks.c
Normal file
122
coreengine/viewdisplaytracks.c
Normal file
@@ -0,0 +1,122 @@
|
||||
#include "viewdisplaytracks.h"
|
||||
#include "../config.h"
|
||||
|
||||
/************************************************************************************
|
||||
* cViewTracks
|
||||
************************************************************************************/
|
||||
|
||||
cViewTracks::cViewTracks(void) {
|
||||
ClearVariables();
|
||||
viewId = eViewType::DisplayTracks;
|
||||
viewName = strdup("displayaudiotracks");
|
||||
numViewElements = (int)eVeDisplayTracks::count;
|
||||
viewElements = new cViewElement*[numViewElements];
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
viewElements[i] = NULL;
|
||||
}
|
||||
viewList = NULL;
|
||||
veBackground = NULL;
|
||||
veHeader = NULL;
|
||||
SetViewElements();
|
||||
}
|
||||
|
||||
cViewTracks::~cViewTracks() {
|
||||
}
|
||||
|
||||
void cViewTracks::SetViewElements(void) {
|
||||
viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayTracks::background));
|
||||
viewElementNames.insert(pair<string, int>("header", (int)eVeDisplayTracks::header));
|
||||
}
|
||||
|
||||
void cViewTracks::SetViewElementObjects(void) {
|
||||
if (viewElements[(int)eVeDisplayTracks::background])
|
||||
veBackground = dynamic_cast<cVeDtBackground*>(viewElements[(int)eVeDisplayTracks::background]);
|
||||
if (viewElements[(int)eVeDisplayTracks::header])
|
||||
veHeader = dynamic_cast<cVeDtHeader*>(viewElements[(int)eVeDisplayTracks::header]);
|
||||
}
|
||||
|
||||
void cViewTracks::ClearVariables(void) {
|
||||
init = true;
|
||||
change = true;
|
||||
}
|
||||
|
||||
void cViewTracks::Close(void) {
|
||||
delete fader;
|
||||
fader = NULL;
|
||||
if (FadeTime() > 0) {
|
||||
fader = new cAnimation((cFadable*)this, false);
|
||||
fader->Fade();
|
||||
delete fader;
|
||||
fader = NULL;
|
||||
}
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
if (viewElements[i]) {
|
||||
viewElements[i]->Close();
|
||||
}
|
||||
}
|
||||
if (viewList) {
|
||||
viewList->Close();
|
||||
}
|
||||
ClearVariables();
|
||||
sdOsd.DeleteOsd();
|
||||
}
|
||||
|
||||
void cViewTracks::AddViewList(cViewList *viewList) {
|
||||
this->viewList = dynamic_cast<cViewListAudioTracks*>(viewList);
|
||||
}
|
||||
|
||||
void cViewTracks::PreCache(void) {
|
||||
cView::PreCache();
|
||||
if (viewList) {
|
||||
viewList->SetContainer(0, 0, attribs->Width(), attribs->Height());
|
||||
viewList->SetGlobals(globals);
|
||||
viewList->PreCache();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewTracks::SetTitle(const char *title) {
|
||||
if (veHeader)
|
||||
veHeader->SetTitle(title);
|
||||
change = true;
|
||||
}
|
||||
|
||||
void cViewTracks::SetNumtracks(int numTracks) {
|
||||
if (veBackground)
|
||||
veBackground->Set(numTracks);
|
||||
if (veHeader)
|
||||
veHeader->SetNumtracks(numTracks);
|
||||
if (viewList)
|
||||
viewList->SetNumtracks(numTracks);
|
||||
}
|
||||
|
||||
void cViewTracks::SetAudiochannel(int audioChannel) {
|
||||
if (veHeader)
|
||||
veHeader->SetAudiochannel(audioChannel);
|
||||
change = true;
|
||||
}
|
||||
|
||||
void cViewTracks::SetTracks(const char * const *tracks) {
|
||||
if (viewList)
|
||||
viewList->SetTracks(tracks);
|
||||
change = true;
|
||||
}
|
||||
|
||||
void cViewTracks::SetCurrentTrack(int index) {
|
||||
if (viewList)
|
||||
viewList->SetCurrentTrack(index);
|
||||
change = true;
|
||||
}
|
||||
|
||||
void cViewTracks::Flush(void) {
|
||||
if (init) {
|
||||
sdOsd.LockFlush();
|
||||
Render((int)eVeDisplayTracks::background);
|
||||
}
|
||||
if (change) {
|
||||
Render((int)eVeDisplayTracks::header);
|
||||
if (viewList)
|
||||
viewList->Draw();
|
||||
change = false;
|
||||
}
|
||||
cView::Flush();
|
||||
}
|
||||
29
coreengine/viewdisplaytracks.h
Normal file
29
coreengine/viewdisplaytracks.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef __VIEWDISPLAYTRACKS_H
|
||||
#define __VIEWDISPLAYTRACKS_H
|
||||
|
||||
#include "view.h"
|
||||
|
||||
class cViewTracks : public cView {
|
||||
private:
|
||||
cViewListAudioTracks *viewList;
|
||||
cVeDtBackground *veBackground;
|
||||
cVeDtHeader *veHeader;
|
||||
bool change;
|
||||
void SetViewElements(void);
|
||||
void SetViewElementObjects(void);
|
||||
void ClearVariables(void);
|
||||
public:
|
||||
cViewTracks(void);
|
||||
virtual ~cViewTracks(void);
|
||||
void Close(void);
|
||||
void AddViewList(cViewList *viewList);
|
||||
void PreCache(void);
|
||||
void SetTitle(const char *title);
|
||||
void SetNumtracks(int numTracks);
|
||||
void SetTracks(const char * const *tracks);
|
||||
void SetAudiochannel(int audioChannel);
|
||||
void SetCurrentTrack(int index);
|
||||
void Flush(void);
|
||||
};
|
||||
|
||||
#endif //__VIEWDISPLAYTRACKS_H
|
||||
52
coreengine/viewdisplayvolume.c
Normal file
52
coreengine/viewdisplayvolume.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "viewdisplayvolume.h"
|
||||
|
||||
/************************************************************************************
|
||||
* cViewVolume
|
||||
************************************************************************************/
|
||||
|
||||
cViewVolume::cViewVolume(void) {
|
||||
viewId = eViewType::DisplayVolume;
|
||||
viewName = strdup("displayvolume");
|
||||
numViewElements = (int)eVeDisplayVolume::count;
|
||||
viewElements = new cViewElement*[numViewElements];
|
||||
for (int i=0; i < numViewElements; i++) {
|
||||
viewElements[i] = NULL;
|
||||
}
|
||||
SetViewElements();
|
||||
ClearVariables();
|
||||
veVolume = NULL;
|
||||
}
|
||||
|
||||
cViewVolume::~cViewVolume() {
|
||||
}
|
||||
|
||||
void cViewVolume::SetViewElements(void) {
|
||||
viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayVolume::background));
|
||||
viewElementNames.insert(pair<string, int>("volume", (int)eVeDisplayVolume::volume));
|
||||
}
|
||||
|
||||
void cViewVolume::SetViewElementObjects(void) {
|
||||
if (!viewElements[(int)eVeDisplayVolume::volume])
|
||||
return;
|
||||
veVolume = dynamic_cast<cVeVolume*>(viewElements[(int)eVeDisplayVolume::volume]);
|
||||
}
|
||||
|
||||
void cViewVolume::ClearVariables(void) {
|
||||
init = true;
|
||||
}
|
||||
|
||||
void cViewVolume::SetVolume(int current, int total, bool mute) {
|
||||
if (veVolume)
|
||||
veVolume->Set(current, total, mute);
|
||||
}
|
||||
|
||||
void cViewVolume::Flush(void) {
|
||||
if (init) {
|
||||
sdOsd.LockFlush();
|
||||
Render((int)eVeDisplayVolume::background);
|
||||
}
|
||||
Render((int)eVeDisplayVolume::volume);
|
||||
cView::Flush();
|
||||
}
|
||||
|
||||
|
||||
19
coreengine/viewdisplayvolume.h
Normal file
19
coreengine/viewdisplayvolume.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef __VIEWDISPLAYVOLUME_H
|
||||
#define __VIEWDISPLAYVOLUME_H
|
||||
|
||||
#include "view.h"
|
||||
|
||||
class cViewVolume : public cView {
|
||||
private:
|
||||
cVeVolume *veVolume;
|
||||
void SetViewElements(void);
|
||||
void SetViewElementObjects(void);
|
||||
void ClearVariables(void);
|
||||
public:
|
||||
cViewVolume(void);
|
||||
virtual ~cViewVolume(void);
|
||||
void SetVolume(int current, int total, bool mute);
|
||||
void Flush(void);
|
||||
};
|
||||
|
||||
#endif //__VIEWDISPLAYVOLUME_H
|
||||
532
coreengine/viewelement.c
Normal file
532
coreengine/viewelement.c
Normal file
@@ -0,0 +1,532 @@
|
||||
#include "viewelement.h"
|
||||
#include "../config.h"
|
||||
|
||||
/******************************************************************
|
||||
* cViewElement
|
||||
******************************************************************/
|
||||
cViewElement::cViewElement(void) {
|
||||
sdOsd = NULL;
|
||||
id = -1;
|
||||
dirty = true;
|
||||
init = true;
|
||||
drawn = false;
|
||||
scrollingStarted = false;
|
||||
blocked = false;
|
||||
detached = false;
|
||||
waitOnWakeup = true;
|
||||
startAnimation = true;
|
||||
globals = NULL;
|
||||
tokenContainer = NULL;
|
||||
attribs = new cViewElementAttribs((int)eViewElementAttribs::count);
|
||||
detacher = NULL;
|
||||
fader = NULL;
|
||||
shifter = NULL;
|
||||
}
|
||||
|
||||
cViewElement::cViewElement(const cViewElement &other) {
|
||||
sdOsd = other.sdOsd;
|
||||
id = other.id;
|
||||
dirty = other.dirty;
|
||||
init = other.init;
|
||||
drawn = false;
|
||||
scrollingStarted = false;
|
||||
blocked = false;
|
||||
detached = false;
|
||||
waitOnWakeup = true;
|
||||
startAnimation = true;
|
||||
globals = other.globals;
|
||||
container.Set(other.container.X(), other.container.Y(), other.container.Width(), other.container.Height());
|
||||
tokenContainer = NULL;
|
||||
attribs = new cViewElementAttribs(*other.attribs);
|
||||
|
||||
for (cAreaNode *node = other.areaNodes.First(); node; node = other.areaNodes.Next(node)) {
|
||||
if (cArea *a = dynamic_cast<cArea*>(node)) {
|
||||
areaNodes.Add(new cArea(*a));
|
||||
} else if (cAreaContainer *ac = dynamic_cast<cAreaContainer*>(node)) {
|
||||
areaNodes.Add(new cAreaContainer(*ac));
|
||||
}
|
||||
}
|
||||
|
||||
detacher = NULL;
|
||||
fader = NULL;
|
||||
shifter = NULL;
|
||||
}
|
||||
|
||||
cViewElement::~cViewElement(void) {
|
||||
delete attribs;
|
||||
delete detacher;
|
||||
delete fader;
|
||||
delete shifter;
|
||||
delete tokenContainer;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* Public Functions
|
||||
******************************************************************/
|
||||
cViewElement *cViewElement::CreateViewElement(const char *name, const char *viewname) {
|
||||
cViewElement *e = NULL;
|
||||
|
||||
//common view elements
|
||||
if (!strcmp(name, "background") && strcmp(viewname, "displayaudiotracks"))
|
||||
e = new cViewElement();
|
||||
else if (!strcmp(name, "datetime"))
|
||||
e = new cVeDateTime();
|
||||
else if (!strcmp(name, "time"))
|
||||
e = new cVeTime();
|
||||
else if (!strcmp(name, "message"))
|
||||
e = new cVeMessage();
|
||||
else if (!strcmp(name, "devices"))
|
||||
e = new cVeDevices();
|
||||
else if (!strcmp(name, "currentweather"))
|
||||
e = new cVeCurrentWeather();
|
||||
else if (!strcmp(name, "customtokens"))
|
||||
e = new cVeCustomTokens();
|
||||
|
||||
//displaychannel viewelements
|
||||
else if (!strcmp(name, "channelinfo"))
|
||||
e = new cVeDcChannelInfo();
|
||||
else if (!strcmp(name, "channelgroup"))
|
||||
e = new cVeDcChannelGroup();
|
||||
else if (!strcmp(name, "epginfo"))
|
||||
e = new cVeDcEpgInfo();
|
||||
else if (!strcmp(name, "progressbar") && !strcmp(viewname, "displaychannel"))
|
||||
e = new cVeDcProgressBar();
|
||||
else if (!strcmp(name, "statusinfo"))
|
||||
e = new cVeDcStatusInfo();
|
||||
else if (!strcmp(name, "audioinfo"))
|
||||
e = new cVeDcAudioInfo();
|
||||
else if (!strcmp(name, "screenresolution"))
|
||||
e = new cVeDcScreenResolution();
|
||||
else if (!strcmp(name, "signalquality"))
|
||||
e = new cVeDcSignalQuality();
|
||||
else if (!strcmp(name, "scrapercontent") && !strcmp(viewname, "displaychannel"))
|
||||
e = new cVeDcScraperContent();
|
||||
else if (!strcmp(name, "ecminfo"))
|
||||
e = new cVeDcEcmInfo();
|
||||
|
||||
//displaymenu viewelements
|
||||
else if (!strcmp(name, "header") && strcmp(viewname, "displayaudiotracks"))
|
||||
e = new cVeDmHeader();
|
||||
else if (!strcmp(name, "sortmode"))
|
||||
e = new cVeDmSortmode();
|
||||
else if (!strcmp(name, "colorbuttons"))
|
||||
e = new cVeDmColorbuttons();
|
||||
else if (!strcmp(name, "scrollbar"))
|
||||
e = new cVeDmScrollbar();
|
||||
else if (!strcmp(name, "timers"))
|
||||
e = new cVeDmTimers();
|
||||
else if (!strcmp(name, "currentschedule"))
|
||||
e = new cVeDmCurrentschedule();
|
||||
else if (!strcmp(name, "discusage"))
|
||||
e = new cVeDmDiscusage();
|
||||
else if (!strcmp(name, "systemload"))
|
||||
e = new cVeDmSystemload();
|
||||
else if (!strcmp(name, "systemmemory"))
|
||||
e = new cVeDmSystemmemory();
|
||||
else if (!strcmp(name, "temperatures"))
|
||||
e = new cVeDmTemperatures();
|
||||
else if (!strcmp(name, "vdrstatistics"))
|
||||
e = new cVeDmVdrstatistics();
|
||||
else if (!strcmp(name, "lastrecordings"))
|
||||
e = new cVeDmLastrecordings();
|
||||
else if (!strcmp(name, "detailheaderepg"))
|
||||
e = new cVeDmDetailheaderEpg();
|
||||
else if (!strcmp(name, "detailheaderrec"))
|
||||
e = new cVeDmDetailheaderRec();
|
||||
else if (!strcmp(name, "detailheaderplugin"))
|
||||
e = new cVeDmDetailheaderPlugin();
|
||||
else if (!strcmp(name, "tablabels"))
|
||||
e = new cVeDmTablabels();
|
||||
|
||||
//displayreplay viewelements
|
||||
else if (!strcmp(name, "backgroundmodeonly"))
|
||||
e = new cViewElement();
|
||||
else if (!strcmp(name, "rectitle"))
|
||||
e = new cVeDrRecTitle();
|
||||
else if (!strcmp(name, "recinfo"))
|
||||
e = new cVeDrRecInfo();
|
||||
else if (!strcmp(name, "currenttime"))
|
||||
e = new cVeDrCurrentTime();
|
||||
else if (!strcmp(name, "totaltime"))
|
||||
e = new cVeDrTotalTime();
|
||||
else if (!strcmp(name, "endtime"))
|
||||
e = new cVeDrEndTime();
|
||||
else if (!strcmp(name, "progressbar") && !strcmp(viewname, "displayreplay"))
|
||||
e = new cVeDrProgressBar();
|
||||
else if (!strcmp(name, "cutmarks"))
|
||||
e = new cVeDrCutMarks();
|
||||
else if (!strcmp(name, "controlicons"))
|
||||
e = new cVeDrControlIcons();
|
||||
else if (!strcmp(name, "controliconsmodeonly"))
|
||||
e = new cVeDrControlIcons();
|
||||
else if (!strcmp(name, "progressmodeonly"))
|
||||
e = new cVeDrProgressModeonly();
|
||||
else if (!strcmp(name, "jump"))
|
||||
e = new cVeDrJump();
|
||||
else if (!strcmp(name, "onpause"))
|
||||
e = new cVeDrOnPause();
|
||||
else if (!strcmp(name, "onpausemodeonly"))
|
||||
e = new cVeDrOnPause();
|
||||
else if (!strcmp(name, "scrapercontent") && !strcmp(viewname, "displayreplay"))
|
||||
e = new cVeDrScraperContent();
|
||||
|
||||
//displayvolume viewelements
|
||||
else if (!strcmp(name, "volume"))
|
||||
e = new cVeVolume();
|
||||
|
||||
//displayvolume viewelements
|
||||
else if (!strcmp(name, "background") && !strcmp(viewname, "displayaudiotracks"))
|
||||
e = new cVeDtBackground();
|
||||
else if (!strcmp(name, "header") && !strcmp(viewname, "displayaudiotracks"))
|
||||
e = new cVeDtHeader();
|
||||
|
||||
//default
|
||||
else {
|
||||
dsyslog("skindesigner: unknown view element %s", name);
|
||||
e = new cViewElement();
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
void cViewElement::SetGlobals(cGlobals *globals) {
|
||||
this->globals = globals;
|
||||
attribs->SetGlobals(globals);
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetGlobals(globals);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cViewElement::Detached(void) {
|
||||
return detached;
|
||||
}
|
||||
|
||||
void cViewElement::SetContainer(int x, int y, int width, int height) {
|
||||
container.SetX(x);
|
||||
container.SetY(y);
|
||||
container.SetWidth(width);
|
||||
container.SetHeight(height);
|
||||
}
|
||||
|
||||
void cViewElement::SetAttributes(vector<stringpair> &attributes) {
|
||||
attribs->Set(attributes);
|
||||
}
|
||||
|
||||
void cViewElement::AddArea(cAreaNode *area) {
|
||||
areaNodes.Add(area);
|
||||
}
|
||||
|
||||
void cViewElement::SetAreaX(int x) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetX(x);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::SetAreaY(int y) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetY(y);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::SetAreaWidth(int width) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetWidth(width);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::SetAreaHeight(int height) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetHeight(height);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::SetPosition(int newX, int newY, int newWidth, int newHeight) {
|
||||
cRect newPos(newX, newY, newWidth, newHeight);
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetViewPort(newPos);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::Cache(void) {
|
||||
attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->Cache();
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
node->Cache();
|
||||
}
|
||||
}
|
||||
|
||||
bool cViewElement::Execute(void) {
|
||||
return attribs->DoExecute();
|
||||
}
|
||||
|
||||
void cViewElement::Clear(void) {
|
||||
tokenContainer->Clear();
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
sdOsd->Lock();
|
||||
node->Clear();
|
||||
sdOsd->Unlock();
|
||||
}
|
||||
dirty = false;
|
||||
drawn = false;
|
||||
scrollingStarted = false;
|
||||
}
|
||||
|
||||
void cViewElement::Hide(void) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
sdOsd->Lock();
|
||||
node->Hide();
|
||||
sdOsd->Unlock();
|
||||
}
|
||||
init = true;
|
||||
StopScrolling();
|
||||
}
|
||||
|
||||
void cViewElement::Show(void) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
sdOsd->Lock();
|
||||
node->Show();
|
||||
sdOsd->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::WakeUp(void) {
|
||||
if (!detacher || !waitOnWakeup) {
|
||||
return;
|
||||
}
|
||||
detacher->WakeUp();
|
||||
}
|
||||
|
||||
void cViewElement::Close(void) {
|
||||
delete detacher;
|
||||
detacher = NULL;
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
sdOsd->Lock();
|
||||
node->Close();
|
||||
sdOsd->Unlock();
|
||||
}
|
||||
StopScrolling();
|
||||
dirty = true;
|
||||
init = true;
|
||||
startAnimation = true;
|
||||
drawn = false;
|
||||
scrollingStarted = false;
|
||||
blocked = false;
|
||||
}
|
||||
|
||||
void cViewElement::Render(void) {
|
||||
if (!dirty || blocked)
|
||||
return;
|
||||
|
||||
if (attribs->DoDebug())
|
||||
Debug();
|
||||
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
//Check redraw of already scrolling list element
|
||||
if (drawn && scrollingStarted && node->Scrolling()) {
|
||||
if (DoScroll()) {
|
||||
//current list element
|
||||
continue;
|
||||
} else {
|
||||
//not current list element anymore
|
||||
scrollingStarted = false;
|
||||
}
|
||||
}
|
||||
sdOsd->Lock();
|
||||
node->Clear();
|
||||
sdOsd->Unlock();
|
||||
if (!node->Execute())
|
||||
continue;
|
||||
if (node->BackgroundArea() && drawn)
|
||||
continue;
|
||||
sdOsd->Lock();
|
||||
node->Render();
|
||||
sdOsd->Unlock();
|
||||
|
||||
if (DoScroll() && node->Scrolling()) {
|
||||
cArea *scrollArea = node->ScrollingArea();
|
||||
if (scrollArea) {
|
||||
scrollingStarted = true;
|
||||
cAnimation *scroller = new cAnimation(scrollArea);
|
||||
scrollers.Add(scroller);
|
||||
scroller->Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
dirty = false;
|
||||
drawn = true;
|
||||
if (startAnimation) {
|
||||
startAnimation = false;
|
||||
StartAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::StopScrolling(bool deletePixmaps) {
|
||||
for (cAnimation *scroller = scrollers.First(); scroller; scroller = scrollers.Next(scroller)) {
|
||||
scroller->Stop(deletePixmaps);
|
||||
}
|
||||
scrollers.Clear();
|
||||
}
|
||||
|
||||
void cViewElement::ParseDetached(void) {
|
||||
Parse(true);
|
||||
}
|
||||
|
||||
void cViewElement::RenderDetached(void) {
|
||||
blocked = false;
|
||||
Render();
|
||||
}
|
||||
|
||||
bool cViewElement::Shifting(void) {
|
||||
if (attribs->ShiftTime() >= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cViewElement::Fading(void) {
|
||||
if (attribs->FadeTime() >= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int cViewElement::FadeTime(void) {
|
||||
return attribs->FadeTime();
|
||||
}
|
||||
|
||||
int cViewElement::ShiftTime(void) {
|
||||
return attribs->ShiftTime();
|
||||
}
|
||||
|
||||
int cViewElement::ShiftMode(void) {
|
||||
return attribs->ShiftMode();
|
||||
}
|
||||
|
||||
void cViewElement::StartAnimation(void) {
|
||||
if (ShiftTime() > 0) {
|
||||
cRect shiftbox = CoveredArea();
|
||||
cPoint ref = cPoint(shiftbox.X(), shiftbox.Y());
|
||||
cPoint start = ShiftStart(shiftbox);
|
||||
SetPosition(start, ref);
|
||||
sdOsd->Flush();
|
||||
delete shifter;
|
||||
shifter = new cAnimation((cShiftable*)this, start, ref, true);
|
||||
shifter->Start();
|
||||
} else if (FadeTime() > 0) {
|
||||
SetTransparency(100);
|
||||
sdOsd->Flush();
|
||||
delete fader;
|
||||
fader = new cAnimation((cFadable*)this, true);
|
||||
fader->Start();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::SetTransparency(int transparency, bool force) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
sdOsd->Lock();
|
||||
node->SetTransparency(transparency);
|
||||
sdOsd->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::SetPosition(cPoint &position, cPoint &reference, bool force) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
sdOsd->Lock();
|
||||
node->SetPosition(position, reference);
|
||||
sdOsd->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
cRect cViewElement::CoveredArea(void) {
|
||||
cRect unionArea;
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
unionArea.Combine(node->CoveringArea());
|
||||
}
|
||||
return unionArea;
|
||||
}
|
||||
|
||||
void cViewElement::Flush(void) {
|
||||
sdOsd->Flush();
|
||||
}
|
||||
|
||||
bool cViewElement::Parse(bool forced) {
|
||||
if (blocked && !forced) {
|
||||
return false;
|
||||
}
|
||||
if (!Detached() || !init) {
|
||||
return true;
|
||||
}
|
||||
delete detacher;
|
||||
detacher = new cAnimation((cDetachable*)this, waitOnWakeup, startAnimation);
|
||||
detacher->Start();
|
||||
startAnimation = false;
|
||||
init = false;
|
||||
blocked = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
cFunction *cViewElement::GetFunction(const char *name) {
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
if (cFunction *f = node->GetFunction(name))
|
||||
return f;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cViewElement::Debug(bool full) {
|
||||
esyslog("skindesigner: ---> viewElement %d", id);
|
||||
tokenContainer->Debug();
|
||||
esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->Debug();
|
||||
if (!full)
|
||||
return;
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->Debug(full);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* protected Functions
|
||||
******************************************************************/
|
||||
void cViewElement::InheritTokenContainer(void) {
|
||||
tokenContainer->CreateContainers();
|
||||
attribs->SetTokenContainer(tokenContainer);
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetTokenContainer(tokenContainer);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewElement::InheritTokenContainerDeep(void) {
|
||||
tokenContainer->CreateContainers();
|
||||
attribs->SetTokenContainerDeep(tokenContainer);
|
||||
for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
|
||||
node->SetTokenContainerDeep(tokenContainer);
|
||||
}
|
||||
}
|
||||
|
||||
cPoint cViewElement::ShiftStart(cRect &shiftbox) {
|
||||
eShiftType type = (eShiftType)attribs->ShiftType();
|
||||
cPoint start;
|
||||
if (type == eShiftType::none) {
|
||||
start = attribs->ShiftStartpoint();
|
||||
} else if (type == eShiftType::left) {
|
||||
start.SetX(-shiftbox.Width());
|
||||
start.SetY(shiftbox.Y());
|
||||
} else if (type == eShiftType::right) {
|
||||
start.SetX(cOsd::OsdWidth());
|
||||
start.SetY(shiftbox.Y());
|
||||
} else if (type == eShiftType::top) {
|
||||
start.SetX(shiftbox.X());
|
||||
start.SetY(-shiftbox.Height());
|
||||
} else if (type == eShiftType::bottom) {
|
||||
start.SetX(shiftbox.X());
|
||||
start.SetY(cOsd::OsdHeight());
|
||||
}
|
||||
return start;
|
||||
}
|
||||
93
coreengine/viewelement.h
Normal file
93
coreengine/viewelement.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef __VIEWELEMENT_H
|
||||
#define __VIEWELEMENT_H
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <vdr/tools.h>
|
||||
#include "osdwrapper.h"
|
||||
#include "globals.h"
|
||||
#include "../libskindesignerapi/tokencontainer.h"
|
||||
#include "area.h"
|
||||
#include "animation.h"
|
||||
|
||||
/******************************************************************
|
||||
* cViewElement
|
||||
******************************************************************/
|
||||
class cViewElement : public cDetachable, public cFadable, public cShiftable {
|
||||
protected:
|
||||
cSdOsd *sdOsd;
|
||||
int id;
|
||||
bool init;
|
||||
bool drawn;
|
||||
bool dirty;
|
||||
bool blocked;
|
||||
bool detached;
|
||||
bool waitOnWakeup;
|
||||
bool scrollingStarted;
|
||||
bool startAnimation;
|
||||
cGlobals *globals;
|
||||
cRect container;
|
||||
cViewElementAttribs *attribs;
|
||||
cList<cAreaNode> areaNodes;
|
||||
skindesignerapi::cTokenContainer *tokenContainer;
|
||||
cList<cAnimation> scrollers;
|
||||
cAnimation *detacher;
|
||||
cAnimation *fader;
|
||||
cAnimation *shifter;
|
||||
void InheritTokenContainer(void);
|
||||
void InheritTokenContainerDeep(void);
|
||||
virtual bool DoScroll(void) { return true; };
|
||||
cPoint ShiftStart(cRect &shiftbox);
|
||||
public:
|
||||
cViewElement(void);
|
||||
cViewElement(const cViewElement &other);
|
||||
virtual ~cViewElement(void);
|
||||
void SetOsd(cSdOsd *osd) { sdOsd = osd; };
|
||||
static cViewElement *CreateViewElement(const char *name, const char *viewname);
|
||||
void SetId(int id) { this->id = id; };
|
||||
void SetGlobals(cGlobals *globals);
|
||||
virtual void SetTokenContainer(void);
|
||||
void SetDetached(void) { detached = true; };
|
||||
void UnsetWaitOnWakeup(void) { waitOnWakeup = false; };
|
||||
bool Detached(void);
|
||||
void SetContainer(int x, int y, int width, int height);
|
||||
void SetAttributes(vector<stringpair> &attributes);
|
||||
void AddArea(cAreaNode *area);
|
||||
void SetAreaX(int x);
|
||||
void SetAreaY(int y);
|
||||
void SetAreaWidth(int width);
|
||||
void SetAreaHeight(int height);
|
||||
void Cache(void);
|
||||
virtual void Close(void);
|
||||
virtual void Clear(void);
|
||||
void Hide(void);
|
||||
void Show(void);
|
||||
void WakeUp(void);
|
||||
bool Execute(void);
|
||||
void SetDirty(void) { dirty = true; };
|
||||
bool Dirty(void) { return dirty; };
|
||||
void SetPosition(int newX, int newY, int newWidth, int newHeight);
|
||||
virtual void Render(void);
|
||||
void StopScrolling(bool deletePixmaps = true);
|
||||
eOrientation Orientation(void) { return attribs->Orientation(); };
|
||||
virtual int Delay(void) { return attribs->Delay(); };
|
||||
void ParseDetached(void);
|
||||
void RenderDetached(void);
|
||||
bool Shifting(void);
|
||||
bool Fading(void);
|
||||
int FadeTime(void);
|
||||
int ShiftTime(void);
|
||||
int ShiftMode(void);
|
||||
void StartAnimation(void);
|
||||
virtual void SetTransparency(int transparency, bool force = false);
|
||||
virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false);
|
||||
cRect CoveredArea(void);
|
||||
void Flush(void);
|
||||
virtual bool Parse(bool forced = false);
|
||||
cFunction *GetFunction(const char *name);
|
||||
virtual void Debug(bool full = false);
|
||||
};
|
||||
|
||||
#endif //__VIEWELEMENT_H
|
||||
36
coreengine/viewelementplugin.c
Normal file
36
coreengine/viewelementplugin.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "viewelementplugin.h"
|
||||
#include "../config.h"
|
||||
|
||||
cVePlugin::cVePlugin(void) {
|
||||
plugId = -1;
|
||||
viewId = -1;
|
||||
}
|
||||
|
||||
cVePlugin::~cVePlugin(void) {
|
||||
}
|
||||
|
||||
void cVePlugin::Close(void) {
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVePlugin::SetTokenContainer(void) {
|
||||
skindesignerapi::cTokenContainer *tkVe = plgManager->GetTokenContainerVE(plugId, viewId, id);
|
||||
if (!tkVe)
|
||||
return;
|
||||
tokenContainer = new skindesignerapi::cTokenContainer(*tkVe);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVePlugin::Set(skindesignerapi::cTokenContainer *tk) {
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->SetTokens(tk);
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
bool cVePlugin::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
if (!dirty)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
22
coreengine/viewelementplugin.h
Normal file
22
coreengine/viewelementplugin.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef __VIEWELEMENTPLUGIN_H
|
||||
#define __VIEWELEMENTPLUGIN_H
|
||||
|
||||
#include "viewelement.h"
|
||||
|
||||
class cVePlugin : public cViewElement {
|
||||
private:
|
||||
int plugId;
|
||||
int viewId;
|
||||
public:
|
||||
cVePlugin(void);
|
||||
virtual ~cVePlugin(void);
|
||||
void SetPluginId(int plugId) { this->plugId = plugId; };
|
||||
void SetViewId(int viewId) { this->viewId = viewId; };
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
bool Parse(bool forced = false);
|
||||
const char *Name(void) { return attribs->Name(); };
|
||||
};
|
||||
|
||||
#endif //__VIEWELEMENTPLUGIN_H
|
||||
531
coreengine/viewelementscommon.c
Normal file
531
coreengine/viewelementscommon.c
Normal file
@@ -0,0 +1,531 @@
|
||||
#include "viewelementscommon.h"
|
||||
#include "../config.h"
|
||||
#include "../services/weatherforecast.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDateTime
|
||||
******************************************************************/
|
||||
cVeDateTime::cVeDateTime(void) {
|
||||
lastMinute = -1;
|
||||
}
|
||||
|
||||
cVeDateTime::~cVeDateTime(void) {
|
||||
}
|
||||
|
||||
void cVeDateTime::Close(void) {
|
||||
lastMinute = -1;
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeDateTime::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{time}", (int)eDateTimeST::time);
|
||||
tokenContainer->DefineStringToken("{dayleadingzero}", (int)eDateTimeST::dayleadingzero);
|
||||
tokenContainer->DefineStringToken("{dayname}", (int)eDateTimeST::dayname);
|
||||
tokenContainer->DefineStringToken("{daynameshort}", (int)eDateTimeST::daynameshort);
|
||||
tokenContainer->DefineStringToken("{month}", (int)eDateTimeST::month);
|
||||
tokenContainer->DefineStringToken("{monthname}", (int)eDateTimeST::monthname);
|
||||
tokenContainer->DefineStringToken("{monthnameshort}", (int)eDateTimeST::monthnameshort);
|
||||
tokenContainer->DefineIntToken("{day}", (int)eDateTimeIT::day);
|
||||
tokenContainer->DefineIntToken("{year}", (int)eDateTimeIT::year);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeDateTime::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
time_t t = time(0); // get time now
|
||||
struct tm * now = localtime(&t);
|
||||
int min = now->tm_min;
|
||||
if (!forced && min == lastMinute) {
|
||||
return false;
|
||||
}
|
||||
lastMinute = min;
|
||||
SetDirty();
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDateTimeIT::year, now->tm_year + 1900);
|
||||
tokenContainer->AddIntToken((int)eDateTimeIT::day, now->tm_mday);
|
||||
|
||||
char monthname[20];
|
||||
char monthshort[10];
|
||||
strftime(monthshort, sizeof(monthshort), "%b", now);
|
||||
strftime(monthname, sizeof(monthname), "%B", now);
|
||||
|
||||
tokenContainer->AddStringToken((int)eDateTimeST::monthname, monthname);
|
||||
tokenContainer->AddStringToken((int)eDateTimeST::monthnameshort, monthshort);
|
||||
tokenContainer->AddStringToken((int)eDateTimeST::month, *cString::sprintf("%02d", now->tm_mon + 1));
|
||||
tokenContainer->AddStringToken((int)eDateTimeST::dayleadingzero, *cString::sprintf("%02d", now->tm_mday));
|
||||
tokenContainer->AddStringToken((int)eDateTimeST::dayname, *WeekDayNameFull(now->tm_wday));
|
||||
tokenContainer->AddStringToken((int)eDateTimeST::daynameshort, *WeekDayName(now->tm_wday));
|
||||
tokenContainer->AddStringToken((int)eDateTimeST::time, *TimeString(t));
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeTime
|
||||
******************************************************************/
|
||||
cVeTime::cVeTime(void) {
|
||||
lastSecond = -1;
|
||||
}
|
||||
|
||||
cVeTime::~cVeTime(void) {
|
||||
}
|
||||
|
||||
void cVeTime::Close(void) {
|
||||
lastSecond = -1;
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeTime::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{sec}", (int)eTimeIT::sec);
|
||||
tokenContainer->DefineIntToken("{min}", (int)eTimeIT::min);
|
||||
tokenContainer->DefineIntToken("{hour}", (int)eTimeIT::hour);
|
||||
tokenContainer->DefineIntToken("{hmins}", (int)eTimeIT::hmins);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeTime::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
time_t t = time(0); // get time now
|
||||
struct tm * now = localtime(&t);
|
||||
int sec = now->tm_sec;
|
||||
if (!forced && sec == lastSecond) {
|
||||
return false;
|
||||
}
|
||||
lastSecond = sec;
|
||||
SetDirty();
|
||||
|
||||
int min = now->tm_min;
|
||||
int hour = now->tm_hour;
|
||||
int hourMinutes = hour%12 * 5 + min / 12;
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eTimeIT::sec, sec);
|
||||
tokenContainer->AddIntToken((int)eTimeIT::min, min);
|
||||
tokenContainer->AddIntToken((int)eTimeIT::hour, hour);
|
||||
tokenContainer->AddIntToken((int)eTimeIT::hmins, hourMinutes);
|
||||
return true;
|
||||
}
|
||||
/******************************************************************
|
||||
* cVeMessage
|
||||
******************************************************************/
|
||||
cVeMessage::cVeMessage(void) {
|
||||
changed = false;
|
||||
text = NULL;
|
||||
type = mtStatus;
|
||||
}
|
||||
|
||||
cVeMessage::~cVeMessage(void) {
|
||||
free(text);
|
||||
}
|
||||
|
||||
void cVeMessage::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{text}", (int)eMessageST::text);
|
||||
tokenContainer->DefineIntToken("{status}", (int)eMessageIT::status);
|
||||
tokenContainer->DefineIntToken("{info}", (int)eMessageIT::info);
|
||||
tokenContainer->DefineIntToken("{warning}", (int)eMessageIT::warning);
|
||||
tokenContainer->DefineIntToken("{error}", (int)eMessageIT::error);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeMessage::Set(eMessageType type, const char *text) {
|
||||
if (!text)
|
||||
return;
|
||||
free(this->text);
|
||||
this->text = strdup(text);
|
||||
this->type = type;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeMessage::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced) || !changed)
|
||||
return false;
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eMessageIT::status, (type == mtStatus) ? true : false);
|
||||
tokenContainer->AddIntToken((int)eMessageIT::info, (type == mtInfo) ? true : false);
|
||||
tokenContainer->AddIntToken((int)eMessageIT::warning, (type == mtWarning) ? true : false);
|
||||
tokenContainer->AddIntToken((int)eMessageIT::error, (type == mtError) ? true : false);
|
||||
tokenContainer->AddStringToken((int)eMessageST::text, text);
|
||||
SetDirty();
|
||||
changed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDevices
|
||||
******************************************************************/
|
||||
cVeDevices::cVeDevices(void) {
|
||||
lastRefresh = 0;
|
||||
initial = true;
|
||||
devicesIndex = -1;
|
||||
lastSignalStrength = NULL;
|
||||
lastSignalQuality = NULL;
|
||||
recDevices = NULL;
|
||||
}
|
||||
|
||||
cVeDevices::~cVeDevices(void) {
|
||||
mutexDevices.Lock();
|
||||
delete[] lastSignalStrength;
|
||||
lastSignalStrength = NULL;
|
||||
delete[] lastSignalQuality;
|
||||
lastSignalQuality = NULL;
|
||||
delete[] recDevices;
|
||||
recDevices = NULL;
|
||||
mutexDevices.Unlock();
|
||||
}
|
||||
|
||||
void cVeDevices::Init(void) {
|
||||
light = (attribs->Mode() == (int)eViewElementMode::light) ? true : false;
|
||||
int totalDevices = cDevice::NumDevices();
|
||||
for (int i = 0; i < totalDevices; i++) {
|
||||
const cDevice *device = cDevice::GetDevice(i);
|
||||
if (!device || !device->NumProvidedSystems()) {
|
||||
continue;
|
||||
}
|
||||
devices.push_back(i);
|
||||
}
|
||||
numDevices = devices.size();
|
||||
lastSignalStrength = new int[numDevices];
|
||||
lastSignalQuality = new int[numDevices];
|
||||
recDevices = new bool[numDevices];
|
||||
mutexDevices.Lock();
|
||||
for (int i=0; i<numDevices; i++) {
|
||||
lastSignalStrength[i] = 0;
|
||||
lastSignalQuality[i] = 0;
|
||||
recDevices[i] = false;
|
||||
}
|
||||
mutexDevices.Unlock();
|
||||
}
|
||||
|
||||
void cVeDevices::Close(void) {
|
||||
devices.clear();
|
||||
initial = true;
|
||||
numDevices = 0;
|
||||
mutexDevices.Lock();
|
||||
delete[] lastSignalStrength;
|
||||
lastSignalStrength = NULL;
|
||||
delete[] lastSignalQuality;
|
||||
lastSignalQuality = NULL;
|
||||
delete[] recDevices;
|
||||
recDevices = NULL;
|
||||
mutexDevices.Unlock();
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeDevices::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{numdevices}", (int)eDevicesIT::numdevices);
|
||||
tokenContainer->DefineLoopToken("{devices[num]}", (int)eDevicesLT::num);
|
||||
tokenContainer->DefineLoopToken("{devices[type]}", (int)eDevicesLT::type);
|
||||
tokenContainer->DefineLoopToken("{devices[istuned]}", (int)eDevicesLT::istuned);
|
||||
tokenContainer->DefineLoopToken("{devices[livetv]}", (int)eDevicesLT::livetv);
|
||||
tokenContainer->DefineLoopToken("{devices[recording]}", (int)eDevicesLT::recording);
|
||||
tokenContainer->DefineLoopToken("{devices[hascam]}", (int)eDevicesLT::hascam);
|
||||
tokenContainer->DefineLoopToken("{devices[cam]}", (int)eDevicesLT::cam);
|
||||
tokenContainer->DefineLoopToken("{devices[signalstrength]}", (int)eDevicesLT::signalstrength);
|
||||
tokenContainer->DefineLoopToken("{devices[signalquality]}", (int)eDevicesLT::signalquality);
|
||||
tokenContainer->DefineLoopToken("{devices[channelnumber]}", (int)eDevicesLT::channelnumber);
|
||||
tokenContainer->DefineLoopToken("{devices[channelname]}", (int)eDevicesLT::channelname);
|
||||
tokenContainer->DefineLoopToken("{devices[channellogoexists]}", (int)eDevicesLT::channellogoexists);
|
||||
tokenContainer->DefineLoopToken("{devices[channelid]}", (int)eDevicesLT::channelid);
|
||||
tokenContainer->DefineLoopToken("{devices[source]}", (int)eDevicesLT::source);
|
||||
|
||||
devicesIndex = tokenContainer->LoopIndex("devices");
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeDevices::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
if (initial) {
|
||||
Init();
|
||||
initial = false;
|
||||
} else {
|
||||
//in light modus content is static
|
||||
if (light)
|
||||
return false;
|
||||
//check if drawing is necessary
|
||||
if (lastRefresh - cTimeMs::Now() < 500)
|
||||
return false;
|
||||
bool changed = false;
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
const cDevice *device = cDevice::GetDevice(devices[i]);
|
||||
if (!device || !device->NumProvidedSystems()) {
|
||||
continue;
|
||||
}
|
||||
int signalStrength = device->SignalStrength();
|
||||
int signalQuality = device->SignalQuality();
|
||||
int lastSigStr = 0;
|
||||
int lastSigQual = 0;
|
||||
mutexDevices.Lock();
|
||||
if (lastSignalStrength && lastSignalQuality) {
|
||||
lastSigStr = lastSignalStrength[i];
|
||||
lastSigQual = lastSignalQuality[i];
|
||||
}
|
||||
mutexDevices.Unlock();
|
||||
if ((signalStrength != lastSigStr) || (signalQuality != lastSigQual)) {
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!changed) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//check device which currently displays live tv
|
||||
int deviceLiveTV = -1;
|
||||
cDevice *primaryDevice = cDevice::PrimaryDevice();
|
||||
if (primaryDevice) {
|
||||
if (!primaryDevice->Replaying() || primaryDevice->Transferring())
|
||||
deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
|
||||
else
|
||||
deviceLiveTV = primaryDevice->DeviceNumber();
|
||||
}
|
||||
//check currently recording devices
|
||||
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
|
||||
if (!timer->Recording()) {
|
||||
continue;
|
||||
}
|
||||
if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) {
|
||||
const cDevice *recDevice = RecordControl->Device();
|
||||
if (recDevice) {
|
||||
mutexDevices.Lock();
|
||||
if (recDevices)
|
||||
recDevices[recDevice->DeviceNumber()] = true;
|
||||
mutexDevices.Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//create loop container
|
||||
tokenContainer->Clear();
|
||||
|
||||
vector<int> loopInfo;
|
||||
loopInfo.push_back(numDevices);
|
||||
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
||||
tokenContainer->AddIntToken((int)eDevicesIT::numdevices, numDevices);
|
||||
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
const cDevice *device = cDevice::GetDevice(devices[i]);
|
||||
if (!device || !device->NumProvidedSystems()) {
|
||||
continue;
|
||||
}
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::num, *cString::sprintf("%d", i));
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::type, *(device->DeviceType()));
|
||||
|
||||
cCamSlot *camSlot = device->CamSlot();
|
||||
int camNumber = -1;
|
||||
if (camSlot) {
|
||||
camNumber = camSlot->SlotNumber();
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::hascam, "1");
|
||||
} else {
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::hascam, "0");
|
||||
}
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::cam, *cString::sprintf("%d", camNumber));
|
||||
|
||||
int signalStrength = 0;
|
||||
int signalQuality = 0;
|
||||
if (!light) {
|
||||
signalStrength = device->SignalStrength();
|
||||
signalQuality = device->SignalQuality();
|
||||
}
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::signalstrength, *cString::sprintf("%d", signalStrength));
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::signalstrength, *cString::sprintf("%d", signalQuality));
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::livetv, i == deviceLiveTV ? "1" : "0");
|
||||
|
||||
bool isRecording = false;
|
||||
mutexDevices.Lock();
|
||||
if (recDevices && recDevices[i])
|
||||
isRecording = true;
|
||||
mutexDevices.Unlock();
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::recording, isRecording ? "1" : "0");
|
||||
|
||||
const cChannel *channel = device->GetCurrentlyTunedTransponder();
|
||||
const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
|
||||
if (channel && channel->Number() > 0) {
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channelnumber, *cString::sprintf("%d", channel->Number()));
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channelname, channel->Name());
|
||||
string channelID = *(channel->GetChannelID().ToString());
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channelid, channelID.c_str());
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channellogoexists, imgCache->LogoExists(channelID) ? "1" : "0");
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::istuned, "1");
|
||||
} else {
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::istuned, "0");
|
||||
}
|
||||
|
||||
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::source, source ? source->Description() : "");
|
||||
|
||||
mutexDevices.Lock();
|
||||
if (lastSignalStrength)
|
||||
lastSignalStrength[i] = signalStrength;
|
||||
if (lastSignalQuality)
|
||||
lastSignalQuality[i] = signalQuality;
|
||||
mutexDevices.Unlock();
|
||||
}
|
||||
|
||||
SetDirty();
|
||||
lastRefresh = cTimeMs::Now();
|
||||
return true;
|
||||
}
|
||||
/******************************************************************
|
||||
* cVeCurrentWeather
|
||||
******************************************************************/
|
||||
cVeCurrentWeather::cVeCurrentWeather(void) {
|
||||
}
|
||||
|
||||
cVeCurrentWeather::~cVeCurrentWeather(void) {
|
||||
}
|
||||
|
||||
void cVeCurrentWeather::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{timestamp}", (int)eCurrentWeatherST::timestamp);
|
||||
tokenContainer->DefineStringToken("{summary}", (int)eCurrentWeatherST::summary);
|
||||
tokenContainer->DefineStringToken("{icon}", (int)eCurrentWeatherST::icon);
|
||||
tokenContainer->DefineStringToken("{precipitationtype}", (int)eCurrentWeatherST::precipitationtype);
|
||||
tokenContainer->DefineStringToken("{windbearingstring}", (int)eCurrentWeatherST::windbearingstring);
|
||||
tokenContainer->DefineStringToken("{temperature}", (int)eCurrentWeatherST::temperature);
|
||||
tokenContainer->DefineStringToken("{apparenttemperature}", (int)eCurrentWeatherST::apparenttemperature);
|
||||
tokenContainer->DefineStringToken("{mintemperature}", (int)eCurrentWeatherST::mintemperature);
|
||||
tokenContainer->DefineStringToken("{maxtemperature}", (int)eCurrentWeatherST::maxtemperature);
|
||||
tokenContainer->DefineStringToken("{precipitationintensity}", (int)eCurrentWeatherST::precipitationintensity);
|
||||
tokenContainer->DefineStringToken("{windspeed}", (int)eCurrentWeatherST::windspeed);
|
||||
tokenContainer->DefineStringToken("{visibility}", (int)eCurrentWeatherST::visibility);
|
||||
tokenContainer->DefineStringToken("{pressure}", (int)eCurrentWeatherST::pressure);
|
||||
tokenContainer->DefineStringToken("{ozone}", (int)eCurrentWeatherST::ozone);
|
||||
tokenContainer->DefineIntToken("{precipitationprobability}", (int)eCurrentWeatherIT::precipitationprobability);
|
||||
tokenContainer->DefineIntToken("{humidity}", (int)eCurrentWeatherIT::humidity);
|
||||
tokenContainer->DefineIntToken("{windbearing}", (int)eCurrentWeatherIT::windbearing);
|
||||
tokenContainer->DefineIntToken("{cloudcover}", (int)eCurrentWeatherIT::cloudcover);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeCurrentWeather::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
static cPlugin *pWeatherForecast = cPluginManager::GetPlugin("weatherforecast");
|
||||
if (!pWeatherForecast)
|
||||
return false;
|
||||
cServiceCurrentWeather currentWeather;
|
||||
if (!pWeatherForecast->Service("GetCurrentWeather", ¤tWeather)) {
|
||||
return false;
|
||||
}
|
||||
SetDirty();
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::timestamp, currentWeather.timeStamp.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::temperature, currentWeather.temperature.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::apparenttemperature, currentWeather.apparentTemperature.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::mintemperature, currentWeather.minTemperature.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::maxtemperature, currentWeather.maxTemperature.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::summary, currentWeather.summary.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::icon, currentWeather.icon.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::precipitationintensity, currentWeather.precipitationIntensity.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::precipitationtype, currentWeather.precipitationType.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::windspeed, currentWeather.windSpeed.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::windbearingstring, currentWeather.windBearingString.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::visibility, currentWeather.visibility.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::pressure, currentWeather.pressure.c_str());
|
||||
tokenContainer->AddStringToken((int)eCurrentWeatherST::ozone, currentWeather.ozone.c_str());
|
||||
tokenContainer->AddIntToken((int)eCurrentWeatherIT::precipitationprobability, currentWeather.precipitationProbability);
|
||||
tokenContainer->AddIntToken((int)eCurrentWeatherIT::humidity, currentWeather.humidity);
|
||||
tokenContainer->AddIntToken((int)eCurrentWeatherIT::windbearing, currentWeather.windBearing);
|
||||
tokenContainer->AddIntToken((int)eCurrentWeatherIT::cloudcover, currentWeather.cloudCover);
|
||||
return true;
|
||||
}
|
||||
/******************************************************************
|
||||
* cVeCustomTokens
|
||||
******************************************************************/
|
||||
cVeCustomTokens::cVeCustomTokens(void) {
|
||||
}
|
||||
|
||||
cVeCustomTokens::~cVeCustomTokens(void) {
|
||||
}
|
||||
|
||||
void cVeCustomTokens::Reset(void) {
|
||||
globals->ResetCustomTokenChange();
|
||||
}
|
||||
|
||||
void cVeCustomTokens::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
int numTokens = config.numCustomTokens;
|
||||
for (int i=0; i < numTokens; i++) {
|
||||
cString nameIntToken = cString::sprintf("{customint%d}", i+1);
|
||||
cString nameStringToken = cString::sprintf("{customstring%d}", i+1);
|
||||
tokenContainer->DefineStringToken(*nameStringToken, i);
|
||||
tokenContainer->DefineIntToken(*nameIntToken, i);
|
||||
}
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeCustomTokens::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
|
||||
if (!globals->CustomTokenChange())
|
||||
return false;
|
||||
|
||||
tokenContainer->Clear();
|
||||
map <int, string> customStringTokens = globals->GetCustomStringTokens();
|
||||
for (map<int, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) {
|
||||
int index = it->first;
|
||||
if (index > 0 && index <= config.numCustomTokens) {
|
||||
tokenContainer->AddStringToken(index-1, it->second.c_str());
|
||||
}
|
||||
}
|
||||
map <int, int> customIntTokkens = globals-> GetCustomIntTokens();
|
||||
for (map<int, int>::iterator it = customIntTokkens.begin(); it != customIntTokkens.end(); it++) {
|
||||
int index = it->first;
|
||||
if (index > 0 && index <= config.numCustomTokens) {
|
||||
tokenContainer->AddIntToken(index-1, it->second);
|
||||
}
|
||||
}
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeVolume
|
||||
******************************************************************/
|
||||
cVeVolume::cVeVolume(void) {
|
||||
current = 0;
|
||||
total = 0;
|
||||
mute = false;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
cVeVolume::~cVeVolume(void) {
|
||||
}
|
||||
|
||||
void cVeVolume::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{volume}", (int)eDVVolumeIT::volume);
|
||||
tokenContainer->DefineIntToken("{volpercent}", (int)eDVVolumeIT::volpercent);
|
||||
tokenContainer->DefineIntToken("{maxvolume}", (int)eDVVolumeIT::maxvolume);
|
||||
tokenContainer->DefineIntToken("{mute}", (int)eDVVolumeIT::mute);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeVolume::Set(int current, int total, bool mute) {
|
||||
this->current = current;
|
||||
this->total = total;
|
||||
this->mute = mute;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeVolume::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced) || !changed)
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDVVolumeIT::volume, current);
|
||||
tokenContainer->AddIntToken((int)eDVVolumeIT::maxvolume, total);
|
||||
tokenContainer->AddIntToken((int)eDVVolumeIT::volpercent, (double)current *100 / (double)total);
|
||||
tokenContainer->AddIntToken((int)eDVVolumeIT::mute, mute);
|
||||
changed = false;
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
110
coreengine/viewelementscommon.h
Normal file
110
coreengine/viewelementscommon.h
Normal file
@@ -0,0 +1,110 @@
|
||||
#ifndef __VIEWELEMENTSCOMMON_H
|
||||
#define __VIEWELEMENTSCOMMON_H
|
||||
|
||||
#include <vdr/menu.h>
|
||||
#include "viewelement.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDateTime
|
||||
******************************************************************/
|
||||
class cVeDateTime : public cViewElement {
|
||||
private:
|
||||
int lastMinute;
|
||||
public:
|
||||
cVeDateTime(void);
|
||||
virtual ~cVeDateTime(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeTime
|
||||
******************************************************************/
|
||||
class cVeTime : public cViewElement {
|
||||
private:
|
||||
int lastSecond;
|
||||
public:
|
||||
cVeTime(void);
|
||||
virtual ~cVeTime(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeMessage
|
||||
******************************************************************/
|
||||
class cVeMessage : public cViewElement {
|
||||
private:
|
||||
bool changed;
|
||||
eMessageType type;
|
||||
char *text;
|
||||
public:
|
||||
cVeMessage(void);
|
||||
virtual ~cVeMessage(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(eMessageType type, const char *text);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDevices
|
||||
******************************************************************/
|
||||
class cVeDevices : public cViewElement {
|
||||
private:
|
||||
bool light;
|
||||
time_t lastRefresh;
|
||||
vector<int> devices;
|
||||
bool initial;
|
||||
int devicesIndex;
|
||||
cMutex mutexDevices;
|
||||
int numDevices;
|
||||
int* lastSignalStrength;
|
||||
int* lastSignalQuality;
|
||||
bool* recDevices;
|
||||
void Init(void);
|
||||
public:
|
||||
cVeDevices(void);
|
||||
virtual ~cVeDevices(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeCurrentWeather
|
||||
******************************************************************/
|
||||
class cVeCurrentWeather : public cViewElement {
|
||||
private:
|
||||
public:
|
||||
cVeCurrentWeather(void);
|
||||
virtual ~cVeCurrentWeather(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeCustomTokens
|
||||
******************************************************************/
|
||||
class cVeCustomTokens : public cViewElement {
|
||||
private:
|
||||
public:
|
||||
cVeCustomTokens(void);
|
||||
virtual ~cVeCustomTokens(void);
|
||||
void Reset(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeVolume
|
||||
******************************************************************/
|
||||
class cVeVolume : public cViewElement {
|
||||
private:
|
||||
int current;
|
||||
int total;
|
||||
bool mute;
|
||||
bool changed;
|
||||
public:
|
||||
cVeVolume(void);
|
||||
virtual ~cVeVolume(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(int current, int total, bool mute);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
#endif //__VIEWELEMENTSCOMMON_H
|
||||
650
coreengine/viewelementsdisplaychannel.c
Normal file
650
coreengine/viewelementsdisplaychannel.c
Normal file
@@ -0,0 +1,650 @@
|
||||
#include "viewelementsdisplaychannel.h"
|
||||
#include "../config.h"
|
||||
#include "../extensions/helpers.h"
|
||||
#include "../extensions/timers.h"
|
||||
#include "../services/scraper2vdr.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDcChannelInfo
|
||||
******************************************************************/
|
||||
cVeDcChannelInfo::cVeDcChannelInfo(void) {
|
||||
}
|
||||
|
||||
cVeDcChannelInfo::~cVeDcChannelInfo(void) {
|
||||
}
|
||||
|
||||
void cVeDcChannelInfo::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{channelnumber}", (int)eDCChannelInfoST::channelnumber);
|
||||
tokenContainer->DefineStringToken("{channelname}", (int)eDCChannelInfoST::channelname);
|
||||
tokenContainer->DefineStringToken("{channelid}", (int)eDCChannelInfoST::channelid);
|
||||
tokenContainer->DefineIntToken("{channellogoexists}", (int)eDCChannelInfoIT::channellogoexists);
|
||||
tokenContainer->DefineIntToken("{switching}", (int)eDCChannelInfoIT::switching);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDcChannelInfo::Set(const cChannel *c, int number) {
|
||||
cString channelNumber("");
|
||||
cString channelName("");
|
||||
cString channelId("");
|
||||
if (c) {
|
||||
channelName = c->Name() ? c->Name() : "";
|
||||
channelId = c->GetChannelID().ToString();
|
||||
if (!c->GroupSep()) {
|
||||
channelNumber = cString::sprintf("%d%s", c->Number(), number ? "-" : "");
|
||||
}
|
||||
} else if (number) {
|
||||
channelNumber = cString::sprintf("%d-", number);
|
||||
} else {
|
||||
channelName = ChannelString(NULL, 0);
|
||||
}
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDCChannelInfoST::channelnumber, *channelNumber);
|
||||
tokenContainer->AddStringToken((int)eDCChannelInfoST::channelname, *channelName);
|
||||
tokenContainer->AddStringToken((int)eDCChannelInfoST::channelid, *channelId);
|
||||
bool logoExists = imgCache->LogoExists(*channelId);
|
||||
tokenContainer->AddIntToken((int)eDCChannelInfoIT::channellogoexists, logoExists);
|
||||
tokenContainer->AddIntToken((int)eDCChannelInfoIT::switching, (number > 0)?true:false);
|
||||
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDcChannelGroup
|
||||
******************************************************************/
|
||||
cVeDcChannelGroup::cVeDcChannelGroup(void) {
|
||||
}
|
||||
|
||||
cVeDcChannelGroup::~cVeDcChannelGroup(void) {
|
||||
}
|
||||
|
||||
void cVeDcChannelGroup::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{group}", (int)eDCChannelGroupST::group);
|
||||
tokenContainer->DefineStringToken("{nextgroup}", (int)eDCChannelGroupST::nextgroup);
|
||||
tokenContainer->DefineStringToken("{prevgroup}", (int)eDCChannelGroupST::prevgroup);
|
||||
tokenContainer->DefineStringToken("{seppath}", (int)eDCChannelGroupST::seppath);
|
||||
tokenContainer->DefineIntToken("{prevAvailable}", (int)eDCChannelGroupIT::prevAvailable);
|
||||
tokenContainer->DefineIntToken("{nextAvailable}", (int)eDCChannelGroupIT::nextAvailable);
|
||||
tokenContainer->DefineIntToken("{sepexists}", (int)eDCChannelGroupIT::sepexists);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDcChannelGroup::Set(const cChannel *c) {
|
||||
const char *sep = c->Name();
|
||||
bool sepExists = imgCache->SeparatorLogoExists(sep);
|
||||
|
||||
const char *prevChannelSep = GetChannelSep(c, true);
|
||||
const char *nextChannelSep = GetChannelSep(c, false);
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDCChannelGroupST::group, sep);
|
||||
tokenContainer->AddStringToken((int)eDCChannelGroupST::nextgroup, nextChannelSep ? nextChannelSep : "");
|
||||
tokenContainer->AddStringToken((int)eDCChannelGroupST::prevgroup, prevChannelSep ? prevChannelSep : "");
|
||||
tokenContainer->AddStringToken((int)eDCChannelGroupST::seppath, sepExists ? sep : "");
|
||||
tokenContainer->AddIntToken((int)eDCChannelGroupIT::prevAvailable, (prevChannelSep)?true:false);
|
||||
tokenContainer->AddIntToken((int)eDCChannelGroupIT::nextAvailable, (nextChannelSep)?true:false);
|
||||
tokenContainer->AddIntToken((int)eDCChannelGroupIT::sepexists, sepExists);
|
||||
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
const char *cVeDcChannelGroup::GetChannelSep(const cChannel *c, bool prev) {
|
||||
const cChannel *sep = prev ? Channels.Prev(c) :
|
||||
Channels.Next(c);
|
||||
for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) {
|
||||
if (sep->GroupSep()) {
|
||||
return sep->Name();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/******************************************************************
|
||||
* cVeDcEpgInfo
|
||||
******************************************************************/
|
||||
cVeDcEpgInfo::cVeDcEpgInfo(void) {
|
||||
}
|
||||
|
||||
cVeDcEpgInfo::~cVeDcEpgInfo(void) {
|
||||
}
|
||||
|
||||
void cVeDcEpgInfo::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{currenttitle}", (int)eDCEpgInfoST::currenttitle);
|
||||
tokenContainer->DefineStringToken("{currentsubtitle}", (int)eDCEpgInfoST::currentsubtitle);
|
||||
tokenContainer->DefineStringToken("{currentstart}", (int)eDCEpgInfoST::currentstart);
|
||||
tokenContainer->DefineStringToken("{currentstop}", (int)eDCEpgInfoST::currentstop);
|
||||
tokenContainer->DefineStringToken("{nexttitle}", (int)eDCEpgInfoST::nexttitle);
|
||||
tokenContainer->DefineStringToken("{nextsubtitle}", (int)eDCEpgInfoST::nextsubtitle);
|
||||
tokenContainer->DefineStringToken("{nextstart}", (int)eDCEpgInfoST::nextstart);
|
||||
tokenContainer->DefineStringToken("{nextstop}", (int)eDCEpgInfoST::nextstop);
|
||||
tokenContainer->DefineIntToken("{currentduration}", (int)eDCEpgInfoIT::currentduration);
|
||||
tokenContainer->DefineIntToken("{currentdurationhours}", (int)eDCEpgInfoIT::currentdurationhours);
|
||||
tokenContainer->DefineIntToken("{currentdurationminutes}", (int)eDCEpgInfoIT::currentdurationminutes);
|
||||
tokenContainer->DefineIntToken("{currentelapsed}", (int)eDCEpgInfoIT::currentelapsed);
|
||||
tokenContainer->DefineIntToken("{currentremaining}", (int)eDCEpgInfoIT::currentremaining);
|
||||
tokenContainer->DefineIntToken("{nextduration}", (int)eDCEpgInfoIT::nextduration);
|
||||
tokenContainer->DefineIntToken("{nextdurationhours}", (int)eDCEpgInfoIT::nextdurationhours);
|
||||
tokenContainer->DefineIntToken("{nextdurationminutes}", (int)eDCEpgInfoIT::nextdurationminutes);
|
||||
tokenContainer->DefineIntToken("{nextrecording}", (int)eDCEpgInfoIT::nextrecording);
|
||||
tokenContainer->DefineIntToken("{currentrecording}", (int)eDCEpgInfoIT::currentrecording);
|
||||
tokenContainer->DefineIntToken("{hasVPS}", (int)eDCEpgInfoIT::hasVPS);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDcEpgInfo::Set(const cEvent *p, const cEvent *f) {
|
||||
tokenContainer->Clear();
|
||||
if (p) {
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::currenttitle, p->Title());
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::currentsubtitle, p->ShortText());
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::currentstart, *p->GetTimeString());
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::currentstop, *p->GetEndTimeString());
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentduration, p->Duration() / 60);
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentdurationhours, p->Duration() / 3600);
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentdurationminutes, (p->Duration() / 60) % 60);
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentelapsed, (int)round((time(NULL) - p->StartTime())/60));
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentremaining, (int)round((p->EndTime() - time(NULL))/60));
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentrecording, EventHasTimer(p));
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::hasVPS, (bool)p->Vps());
|
||||
}
|
||||
if (f) {
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::nexttitle, f->Title());
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::nextsubtitle, f->ShortText());
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::nextstart, *f->GetTimeString());
|
||||
tokenContainer->AddStringToken((int)eDCEpgInfoST::nextstop, *f->GetEndTimeString());
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::nextduration, f->Duration() / 60);
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::nextdurationhours, f->Duration() / 3600);
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::nextdurationminutes, (f->Duration() / 60) % 60);
|
||||
tokenContainer->AddIntToken((int)eDCEpgInfoIT::hasVPS, (bool)f->Vps());
|
||||
}
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
bool cVeDcEpgInfo::EventHasTimer(const cEvent *e) {
|
||||
if (!e) return false;
|
||||
cGlobalSortedTimers SortedTimers;// local and remote timers
|
||||
bool hasTimer = e->HasTimer();
|
||||
for (int i = 0; i < SortedTimers.Size() && !hasTimer; i++)
|
||||
if (const cTimer *Timer = SortedTimers[i])
|
||||
if (Timer->Channel()->GetChannelID() == e->ChannelID())
|
||||
if (const cEvent *timerEvent = Timer->Event())
|
||||
if (e->EventID() == timerEvent->EventID())
|
||||
hasTimer = true;
|
||||
return hasTimer;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDcProgressBar
|
||||
******************************************************************/
|
||||
cVeDcProgressBar::cVeDcProgressBar(void) {
|
||||
currentLast = -1;
|
||||
startTime = -1;
|
||||
duration = -1;
|
||||
}
|
||||
|
||||
cVeDcProgressBar::~cVeDcProgressBar(void) {
|
||||
}
|
||||
|
||||
void cVeDcProgressBar::Close(void) {
|
||||
currentLast = -1;
|
||||
startTime = -1;
|
||||
duration = -1;
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeDcProgressBar::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{start}", (int)eDCProgressBarST::start);
|
||||
tokenContainer->DefineStringToken("{stop}", (int)eDCProgressBarST::stop);
|
||||
tokenContainer->DefineIntToken("{duration}", (int)eDCProgressBarIT::duration);
|
||||
tokenContainer->DefineIntToken("{elapsed}", (int)eDCProgressBarIT::elapsed);
|
||||
tokenContainer->DefineIntToken("{remaining}", (int)eDCProgressBarIT::remaining);
|
||||
tokenContainer->DefineIntToken("{permashift}", (int)eDCProgressBarIT::permashift);
|
||||
tokenContainer->DefineIntToken("{livebuffer}", (int)eDCProgressBarIT::livebuffer);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDcProgressBar::Set(const cEvent *p) {
|
||||
if (!p) {
|
||||
startTime = -1;
|
||||
duration = -1;
|
||||
return;
|
||||
}
|
||||
startTime = p->StartTime();
|
||||
duration = p->Duration();
|
||||
|
||||
int current = 0;
|
||||
time_t t = time(NULL);
|
||||
if (t > startTime)
|
||||
current = t - startTime;
|
||||
|
||||
currentLast = current;
|
||||
SetDirty();
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDCProgressBarST::start, *p->GetTimeString());
|
||||
tokenContainer->AddStringToken((int)eDCProgressBarST::stop, *p->GetEndTimeString());
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::duration, duration);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::elapsed, current);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::remaining, duration - current);
|
||||
int liveBuffer = GetLiveBuffer();
|
||||
if (liveBuffer >= 0) {
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 1);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::livebuffer, liveBuffer);
|
||||
} else {
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool cVeDcProgressBar::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force))
|
||||
return false;
|
||||
int current = 0;
|
||||
time_t t = time(NULL);
|
||||
if (t > startTime)
|
||||
current = t - startTime;
|
||||
if (!(current > currentLast + 3) && !force && !Dirty())
|
||||
return false;
|
||||
SetDirty();
|
||||
if (duration <= 0) {
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::duration, 0);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::elapsed, 0);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::remaining, 0);
|
||||
} else {
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::duration, duration);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::elapsed, current);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::remaining, duration - current);
|
||||
int liveBuffer = GetLiveBuffer();
|
||||
if (liveBuffer >= 0) {
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 1);
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::livebuffer, liveBuffer);
|
||||
} else {
|
||||
tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int cVeDcProgressBar::GetLiveBuffer(void) {
|
||||
static cPlugin *pPermashift = cPluginManager::GetPlugin("permashift");
|
||||
if (!pPermashift) {
|
||||
return -1;
|
||||
}
|
||||
int buffer = 0;
|
||||
if (pPermashift->Service("Permashift-GetUsedBufferSecs-v1", &buffer)) {
|
||||
return buffer;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/******************************************************************
|
||||
* cVeDcStatusInfo
|
||||
******************************************************************/
|
||||
cVeDcStatusInfo::cVeDcStatusInfo(void) {
|
||||
}
|
||||
|
||||
cVeDcStatusInfo::~cVeDcStatusInfo(void) {
|
||||
}
|
||||
|
||||
void cVeDcStatusInfo::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{isRadio}", (int)eDCStatusInfoIT::isRadio);
|
||||
tokenContainer->DefineIntToken("{hasVT}", (int)eDCStatusInfoIT::hasVT);
|
||||
tokenContainer->DefineIntToken("{isStereo}", (int)eDCStatusInfoIT::isStereo);
|
||||
tokenContainer->DefineIntToken("{isDolby}", (int)eDCStatusInfoIT::isDolby);
|
||||
tokenContainer->DefineIntToken("{isEncrypted}", (int)eDCStatusInfoIT::isEncrypted);
|
||||
tokenContainer->DefineIntToken("{isRecording}", (int)eDCStatusInfoIT::isRecording);
|
||||
tokenContainer->DefineIntToken("{newmails}", (int)eDCStatusInfoIT::newmails);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDcStatusInfo::Set(const cChannel *c) {
|
||||
bool isRadio = !c->Vpid() && c->Apid(0);
|
||||
bool hasVT = c->Vpid() && c->Tpid();
|
||||
bool isStereo = c->Apid(0);
|
||||
bool isDolby = c->Dpid(0);
|
||||
bool isEncrypted = c->Ca();
|
||||
bool isRecording = cRecordControls::Active();
|
||||
cGlobalSortedTimers SortedTimers;// local and remote timers
|
||||
for (int i = 0; i < SortedTimers.Size() && !isRecording; i++)
|
||||
if (const cTimer *Timer = SortedTimers[i])
|
||||
if (Timer->Recording())
|
||||
isRecording = true;
|
||||
|
||||
tokenContainer->AddIntToken((int)eDCStatusInfoIT::isRadio, isRadio);
|
||||
tokenContainer->AddIntToken((int)eDCStatusInfoIT::hasVT, hasVT);
|
||||
tokenContainer->AddIntToken((int)eDCStatusInfoIT::isStereo, isStereo);
|
||||
tokenContainer->AddIntToken((int)eDCStatusInfoIT::isDolby, isDolby);
|
||||
tokenContainer->AddIntToken((int)eDCStatusInfoIT::isEncrypted, isEncrypted);
|
||||
tokenContainer->AddIntToken((int)eDCStatusInfoIT::isRecording, isRecording);
|
||||
tokenContainer->AddIntToken((int)eDCStatusInfoIT::newmails, CheckMails());
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
bool cVeDcStatusInfo::CheckMails(void) {
|
||||
static cPlugin *pMailbox = cPluginManager::GetPlugin("mailbox");
|
||||
if (!pMailbox) {
|
||||
return false;
|
||||
}
|
||||
bool newMail = false;
|
||||
if (pMailbox->Service("MailBox-HasNewMail-1.0", &newMail)) {
|
||||
return newMail;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDcAudioInfo
|
||||
******************************************************************/
|
||||
cVeDcAudioInfo::cVeDcAudioInfo(void) {
|
||||
lastNumAudioTracks = -1;
|
||||
lastAudioChannel = -1;
|
||||
lastTracDesc = NULL;
|
||||
lastTrackLang = NULL;
|
||||
}
|
||||
|
||||
cVeDcAudioInfo::~cVeDcAudioInfo(void) {
|
||||
}
|
||||
|
||||
void cVeDcAudioInfo::Close(void) {
|
||||
lastNumAudioTracks = -1;
|
||||
lastAudioChannel = -1;
|
||||
free(lastTracDesc);
|
||||
lastTracDesc = NULL;
|
||||
free(lastTrackLang);
|
||||
lastTrackLang = NULL;
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeDcAudioInfo::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{trackdesc}", (int)eDCAudioInfoST::trackdesc);
|
||||
tokenContainer->DefineStringToken("{tracklang}", (int)eDCAudioInfoST::tracklang);
|
||||
tokenContainer->DefineIntToken("{numaudiotracks}", (int)eDCAudioInfoIT::numaudiotracks);
|
||||
tokenContainer->DefineIntToken("{audiochannel}", (int)eDCAudioInfoIT::audiochannel);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeDcAudioInfo::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
int numAudioTracks = 0;
|
||||
int audioChannel = -1;
|
||||
const char *trackDescription = "";
|
||||
const char *trackLanguage = "";
|
||||
|
||||
cDevice *device = cDevice::PrimaryDevice();
|
||||
if (device) {
|
||||
numAudioTracks = device->NumAudioTracks();
|
||||
audioChannel = device->GetAudioChannel();
|
||||
if (numAudioTracks > 0) {
|
||||
const tTrackId *track = device->GetTrack(device->GetCurrentAudioTrack());
|
||||
if (track) {
|
||||
trackDescription = track->description ? track->description : "";
|
||||
trackLanguage = track->language ? track->language : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !Dirty() && !forced && lastNumAudioTracks == numAudioTracks
|
||||
&& lastAudioChannel == audioChannel
|
||||
&& lastTracDesc && !strcmp(trackDescription, lastTracDesc)
|
||||
&& lastTrackLang && !strcmp(trackLanguage, lastTrackLang)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lastNumAudioTracks = numAudioTracks;
|
||||
lastAudioChannel = audioChannel;
|
||||
free(lastTracDesc);
|
||||
lastTracDesc = strdup(trackDescription);
|
||||
free(lastTrackLang);
|
||||
lastTrackLang = strdup(trackLanguage);
|
||||
SetDirty();
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDCAudioInfoIT::numaudiotracks, numAudioTracks);
|
||||
tokenContainer->AddIntToken((int)eDCAudioInfoIT::audiochannel, audioChannel);
|
||||
tokenContainer->AddStringToken((int)eDCAudioInfoST::trackdesc, trackDescription);
|
||||
tokenContainer->AddStringToken((int)eDCAudioInfoST::tracklang, trackLanguage);
|
||||
return true;
|
||||
}
|
||||
/******************************************************************
|
||||
* cVeDcScreenResolution
|
||||
******************************************************************/
|
||||
cVeDcScreenResolution::cVeDcScreenResolution(void) {
|
||||
lastScreenWidth = -1;
|
||||
lastScreenHeight = -1;
|
||||
}
|
||||
|
||||
cVeDcScreenResolution::~cVeDcScreenResolution(void) {
|
||||
}
|
||||
|
||||
void cVeDcScreenResolution::Close(void) {
|
||||
lastScreenWidth = -1;
|
||||
lastScreenHeight = -1;
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeDcScreenResolution::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{resolution}", (int)eDCScreenResolutionST::resolution);
|
||||
tokenContainer->DefineStringToken("{aspect}", (int)eDCScreenResolutionST::aspect);
|
||||
tokenContainer->DefineIntToken("{screenwidth}", (int)eDCScreenResolutionIT::screenwidth);
|
||||
tokenContainer->DefineIntToken("{screenheight}", (int)eDCScreenResolutionIT::screenheight);
|
||||
tokenContainer->DefineIntToken("{isHD}", (int)eDCScreenResolutionIT::isHD);
|
||||
tokenContainer->DefineIntToken("{isWideScreen}", (int)eDCScreenResolutionIT::isWideScreen);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeDcScreenResolution::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
int screenWidth = 0;
|
||||
int screenHeight = 0;
|
||||
double aspect = 0;
|
||||
|
||||
cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, aspect);
|
||||
|
||||
if ((lastScreenWidth == screenWidth) && (lastScreenHeight == screenHeight))
|
||||
return false;
|
||||
|
||||
if ((screenWidth == 0) && (screenHeight == 0))
|
||||
return false;
|
||||
|
||||
lastScreenWidth = screenWidth;
|
||||
lastScreenHeight = screenHeight;
|
||||
SetDirty();
|
||||
|
||||
bool isHD = false;
|
||||
string resName = GetScreenResolutionString(screenWidth, screenHeight, &isHD);
|
||||
|
||||
bool isWideScreen = false;
|
||||
string aspectName = GetScreenAspectString(aspect, &isWideScreen);
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDCScreenResolutionIT::screenwidth, screenWidth);
|
||||
tokenContainer->AddIntToken((int)eDCScreenResolutionIT::screenheight, screenHeight);
|
||||
tokenContainer->AddIntToken((int)eDCScreenResolutionIT::isHD, isHD);
|
||||
tokenContainer->AddIntToken((int)eDCScreenResolutionIT::isWideScreen, isWideScreen);
|
||||
tokenContainer->AddStringToken((int)eDCScreenResolutionST::resolution, resName.c_str());
|
||||
tokenContainer->AddStringToken((int)eDCScreenResolutionST::aspect, aspectName.c_str());
|
||||
return true;
|
||||
}
|
||||
/******************************************************************
|
||||
* cVeDcSignalQuality
|
||||
******************************************************************/
|
||||
cVeDcSignalQuality::cVeDcSignalQuality(void) {
|
||||
lastSignalDisplay = -1;
|
||||
lastSignalStrength = -1;
|
||||
lastSignalQuality = -1;
|
||||
}
|
||||
|
||||
cVeDcSignalQuality::~cVeDcSignalQuality(void) {
|
||||
}
|
||||
|
||||
void cVeDcSignalQuality::Close(void) {
|
||||
lastSignalDisplay = -1;
|
||||
lastSignalStrength = -1;
|
||||
lastSignalQuality = -1;
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeDcSignalQuality::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{signalstrength}", (int)eDCSignalQualityIT::signalstrength);
|
||||
tokenContainer->DefineIntToken("{signalquality}", (int)eDCSignalQualityIT::signalquality);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
bool cVeDcSignalQuality::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
time_t now = time(NULL);
|
||||
if (now == lastSignalDisplay)
|
||||
return false;
|
||||
lastSignalDisplay = now;
|
||||
|
||||
int signalStrength = cDevice::ActualDevice()->SignalStrength();
|
||||
int signalQuality = cDevice::ActualDevice()->SignalQuality();
|
||||
|
||||
if (signalStrength < 0) signalStrength = 0;
|
||||
if (signalQuality < 0) signalQuality = 0;
|
||||
|
||||
if (signalStrength == 0 && signalQuality==0)
|
||||
return false;
|
||||
|
||||
if ((lastSignalStrength == signalStrength) && (lastSignalQuality == signalQuality))
|
||||
return false;
|
||||
SetDirty();
|
||||
lastSignalStrength = signalStrength;
|
||||
lastSignalQuality = signalQuality;
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDCSignalQualityIT::signalstrength, signalStrength);
|
||||
tokenContainer->AddIntToken((int)eDCSignalQualityIT::signalquality, signalQuality);
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDcScraperContent
|
||||
******************************************************************/
|
||||
cVeDcScraperContent::cVeDcScraperContent(void) {
|
||||
}
|
||||
|
||||
cVeDcScraperContent::~cVeDcScraperContent(void) {
|
||||
}
|
||||
|
||||
void cVeDcScraperContent::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{posterpath}", (int)eScraperPosterBannerST::posterpath);
|
||||
tokenContainer->DefineStringToken("{bannerpath}", (int)eScraperPosterBannerST::bannerpath);
|
||||
tokenContainer->DefineStringToken("{mediapath}", (int)eScraperPosterBannerST::mediapath);
|
||||
tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperPosterBannerIT::posterwidth);
|
||||
tokenContainer->DefineIntToken("{posterheight}", (int)eScraperPosterBannerIT::posterheight);
|
||||
tokenContainer->DefineIntToken("{hasPoster}", (int)eScraperPosterBannerIT::hasposter);
|
||||
tokenContainer->DefineIntToken("{bannerwidth}", (int)eScraperPosterBannerIT::bannerwidth);
|
||||
tokenContainer->DefineIntToken("{bannerheight}", (int)eScraperPosterBannerIT::bannerheight);
|
||||
tokenContainer->DefineIntToken("{hasBanner}", (int)eScraperPosterBannerIT::hasbanner);
|
||||
tokenContainer->DefineIntToken("{mediawidth}", (int)eScraperPosterBannerIT::mediawidth);
|
||||
tokenContainer->DefineIntToken("{mediaheight}", (int)eScraperPosterBannerIT::mediaheight);
|
||||
tokenContainer->DefineIntToken("{isbanner}", (int)eScraperPosterBannerIT::isbanner);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDcScraperContent::Set(const cEvent *e) {
|
||||
tokenContainer->Clear();
|
||||
SetPosterBanner(tokenContainer, e, NULL);
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDcScreenResolution
|
||||
******************************************************************/
|
||||
cVeDcEcmInfo::cVeDcEcmInfo(void) {
|
||||
channelSid = -1;
|
||||
lastEcmInfo.hops = -1;
|
||||
lastEcmInfo.ecmtime = -1;
|
||||
lastEcmInfo.caid = -1;
|
||||
lastEcmInfo.pid = -1;
|
||||
lastEcmInfo.prid = -1;
|
||||
}
|
||||
|
||||
cVeDcEcmInfo::~cVeDcEcmInfo(void) {
|
||||
}
|
||||
|
||||
void cVeDcEcmInfo::Close(void) {
|
||||
channelSid = -1;
|
||||
lastEcmInfo.hops = -1;
|
||||
lastEcmInfo.ecmtime = -1;
|
||||
lastEcmInfo.caid = -1;
|
||||
lastEcmInfo.pid = -1;
|
||||
lastEcmInfo.prid = -1;
|
||||
cViewElement::Close();
|
||||
}
|
||||
|
||||
void cVeDcEcmInfo::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{cardsystem}", (int)eDCEcmInfoST::cardsystem);
|
||||
tokenContainer->DefineStringToken("{reader}", (int)eDCEcmInfoST::reader);
|
||||
tokenContainer->DefineStringToken("{from}", (int)eDCEcmInfoST::from);
|
||||
tokenContainer->DefineStringToken("{protocol}", (int)eDCEcmInfoST::protocol);
|
||||
tokenContainer->DefineIntToken("{caid}", (int)eDCEcmInfoIT::caid);
|
||||
tokenContainer->DefineIntToken("{pid}", (int)eDCEcmInfoIT::pid);
|
||||
tokenContainer->DefineIntToken("{prid}", (int)eDCEcmInfoIT::prid);
|
||||
tokenContainer->DefineIntToken("{ecmtime}", (int)eDCEcmInfoIT::ecmtime);
|
||||
tokenContainer->DefineIntToken("{hops}", (int)eDCEcmInfoIT::hops);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDcEcmInfo::Set(const cChannel *c) {
|
||||
channelSid = c->Sid();
|
||||
}
|
||||
|
||||
bool cVeDcEcmInfo::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
static cPlugin *pDVBApi = cPluginManager::GetPlugin("dvbapi");
|
||||
if (!pDVBApi)
|
||||
return false;
|
||||
if (channelSid < 0)
|
||||
return false;
|
||||
|
||||
sDVBAPIEcmInfo ecmInfo;
|
||||
ecmInfo.sid = channelSid;
|
||||
|
||||
if (!pDVBApi->Service("GetEcmInfo", &ecmInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ecmInfo.hops < 0 || ecmInfo.ecmtime <= 0 || ecmInfo.ecmtime > 100000)
|
||||
return false;
|
||||
if (CompareECMInfos(&ecmInfo))
|
||||
return false;
|
||||
lastEcmInfo = ecmInfo;
|
||||
SetDirty();
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDCEcmInfoIT::caid, ecmInfo.caid);
|
||||
tokenContainer->AddIntToken((int)eDCEcmInfoIT::pid, ecmInfo.pid);
|
||||
tokenContainer->AddIntToken((int)eDCEcmInfoIT::prid, ecmInfo.prid);
|
||||
tokenContainer->AddIntToken((int)eDCEcmInfoIT::ecmtime, ecmInfo.ecmtime);
|
||||
tokenContainer->AddIntToken((int)eDCEcmInfoIT::hops, ecmInfo.hops);
|
||||
tokenContainer->AddStringToken((int)eDCEcmInfoST::cardsystem, *ecmInfo.cardsystem);
|
||||
tokenContainer->AddStringToken((int)eDCEcmInfoST::reader, *ecmInfo.reader);
|
||||
tokenContainer->AddStringToken((int)eDCEcmInfoST::from, *ecmInfo.from);
|
||||
tokenContainer->AddStringToken((int)eDCEcmInfoST::protocol, *ecmInfo.protocol);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cVeDcEcmInfo::CompareECMInfos(sDVBAPIEcmInfo *ecmInfo) {
|
||||
if (ecmInfo->caid != lastEcmInfo.caid)
|
||||
return false;
|
||||
if (ecmInfo->pid != lastEcmInfo.pid)
|
||||
return false;
|
||||
if (ecmInfo->prid != lastEcmInfo.prid)
|
||||
return false;
|
||||
if (ecmInfo->ecmtime != lastEcmInfo.ecmtime)
|
||||
return false;
|
||||
if (ecmInfo->hops != lastEcmInfo.hops)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
145
coreengine/viewelementsdisplaychannel.h
Normal file
145
coreengine/viewelementsdisplaychannel.h
Normal file
@@ -0,0 +1,145 @@
|
||||
#ifndef __VIEWELEMENTSDC_H
|
||||
#define __VIEWELEMENTSDC_H
|
||||
|
||||
#include "viewelement.h"
|
||||
#include "../extensions/scrapmanager.h"
|
||||
#include "../services/dvbapi.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDcChannelInfo
|
||||
******************************************************************/
|
||||
class cVeDcChannelInfo : public cViewElement {
|
||||
private:
|
||||
public:
|
||||
cVeDcChannelInfo(void);
|
||||
virtual ~cVeDcChannelInfo(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cChannel *c, int number);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcChannelGroup
|
||||
******************************************************************/
|
||||
class cVeDcChannelGroup : public cViewElement {
|
||||
private:
|
||||
const char *GetChannelSep(const cChannel *c, bool prev);
|
||||
public:
|
||||
cVeDcChannelGroup(void);
|
||||
virtual ~cVeDcChannelGroup(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cChannel *c);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcEpgInfo
|
||||
******************************************************************/
|
||||
class cVeDcEpgInfo : public cViewElement {
|
||||
private:
|
||||
bool EventHasTimer(const cEvent *e);
|
||||
public:
|
||||
cVeDcEpgInfo(void);
|
||||
virtual ~cVeDcEpgInfo(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cEvent *p, const cEvent *f);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcProgressBar
|
||||
******************************************************************/
|
||||
class cVeDcProgressBar : public cViewElement {
|
||||
private:
|
||||
int currentLast;
|
||||
int startTime;
|
||||
int duration;
|
||||
int GetLiveBuffer(void);
|
||||
public:
|
||||
cVeDcProgressBar(void);
|
||||
virtual ~cVeDcProgressBar(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cEvent *p);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcStatusInfo
|
||||
******************************************************************/
|
||||
class cVeDcStatusInfo : public cViewElement {
|
||||
private:
|
||||
bool CheckMails(void);
|
||||
public:
|
||||
cVeDcStatusInfo(void);
|
||||
virtual ~cVeDcStatusInfo(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cChannel *c);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcAudioInfo
|
||||
******************************************************************/
|
||||
class cVeDcAudioInfo : public cViewElement {
|
||||
private:
|
||||
int lastNumAudioTracks;
|
||||
int lastAudioChannel;
|
||||
char *lastTracDesc;
|
||||
char *lastTrackLang;
|
||||
public:
|
||||
cVeDcAudioInfo(void);
|
||||
virtual ~cVeDcAudioInfo(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcScreenResolution
|
||||
******************************************************************/
|
||||
class cVeDcScreenResolution : public cViewElement {
|
||||
private:
|
||||
int lastScreenWidth;
|
||||
int lastScreenHeight;
|
||||
public:
|
||||
cVeDcScreenResolution(void);
|
||||
virtual ~cVeDcScreenResolution(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcSignalQuality
|
||||
******************************************************************/
|
||||
class cVeDcSignalQuality : public cViewElement {
|
||||
private:
|
||||
int lastSignalDisplay;
|
||||
int lastSignalStrength;
|
||||
int lastSignalQuality;
|
||||
public:
|
||||
cVeDcSignalQuality(void);
|
||||
virtual ~cVeDcSignalQuality(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcScraperContent
|
||||
******************************************************************/
|
||||
class cVeDcScraperContent : public cViewElement, public cScrapManager {
|
||||
private:
|
||||
public:
|
||||
cVeDcScraperContent(void);
|
||||
virtual ~cVeDcScraperContent(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cEvent *e);
|
||||
};
|
||||
/******************************************************************
|
||||
* cVeDcEcmInfo
|
||||
******************************************************************/
|
||||
class cVeDcEcmInfo : public cViewElement {
|
||||
private:
|
||||
int channelSid;
|
||||
sDVBAPIEcmInfo lastEcmInfo;
|
||||
bool CompareECMInfos(sDVBAPIEcmInfo *ecmInfo);
|
||||
public:
|
||||
cVeDcEcmInfo(void);
|
||||
virtual ~cVeDcEcmInfo(void);
|
||||
void Close(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cChannel *c);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
#endif //__VIEWELEMENTSDC_H
|
||||
1232
coreengine/viewelementsdisplaymenu.c
Normal file
1232
coreengine/viewelementsdisplaymenu.c
Normal file
File diff suppressed because it is too large
Load Diff
250
coreengine/viewelementsdisplaymenu.h
Normal file
250
coreengine/viewelementsdisplaymenu.h
Normal file
@@ -0,0 +1,250 @@
|
||||
#ifndef __VIEWELEMENTSDM_H
|
||||
#define __VIEWELEMENTSDM_H
|
||||
|
||||
#include "viewelement.h"
|
||||
#include "../extensions/scrapmanager.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmHeader
|
||||
******************************************************************/
|
||||
class cVeDmHeader : public cViewElement {
|
||||
private:
|
||||
char *title;
|
||||
char *channelName;
|
||||
int channelNumber;
|
||||
char *channelId;
|
||||
bool epgSearchFav;
|
||||
public:
|
||||
cVeDmHeader(void);
|
||||
virtual ~cVeDmHeader(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetTitle(const char *title);
|
||||
void SetChannel(const cChannel *channel);
|
||||
void Set(eMenuCategory menuCat);
|
||||
void IsEpgSearchFav(bool isFav) { epgSearchFav = isFav;} ;
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmSortmode
|
||||
******************************************************************/
|
||||
class cVeDmSortmode : public cViewElement {
|
||||
private:
|
||||
eMenuSortMode sortMode;
|
||||
eMenuSortMode lastSortMode;
|
||||
public:
|
||||
cVeDmSortmode(void);
|
||||
virtual ~cVeDmSortmode(void);
|
||||
void Reset(void) { lastSortMode = msmUnknown; }
|
||||
void SetTokenContainer(void);
|
||||
void Set(eMenuSortMode sortMode);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmColorbuttons
|
||||
******************************************************************/
|
||||
class cVeDmColorbuttons : public cViewElement {
|
||||
private:
|
||||
bool changed;
|
||||
char *red;
|
||||
char *green;
|
||||
char *yellow;
|
||||
char *blue;
|
||||
public:
|
||||
cVeDmColorbuttons(void);
|
||||
virtual ~cVeDmColorbuttons(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetButtons(const char *red, const char *green, const char *yellow, const char *blue);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmScrollbar
|
||||
******************************************************************/
|
||||
class cVeDmScrollbar : public cViewElement {
|
||||
private:
|
||||
public:
|
||||
cVeDmScrollbar(void);
|
||||
virtual ~cVeDmScrollbar(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetList(int numDisplayed, int offset, int numMax);
|
||||
void SetDetail(int height, int offset, bool end);
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmTimers
|
||||
******************************************************************/
|
||||
class cVeDmTimers : public cViewElement {
|
||||
private:
|
||||
int timerIndex;
|
||||
public:
|
||||
cVeDmTimers(void);
|
||||
virtual ~cVeDmTimers(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmCurrentschedule
|
||||
******************************************************************/
|
||||
class cVeDmCurrentschedule : public cViewElement, public cScrapManager {
|
||||
private:
|
||||
const char *rec;
|
||||
void ParseFromChannel(const cChannel *channel);
|
||||
void ParseFromRecording(const cRecording *recording);
|
||||
void RecName(string &path, string &name, string &folder);
|
||||
public:
|
||||
cVeDmCurrentschedule(void);
|
||||
virtual ~cVeDmCurrentschedule(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetRecording(const char *currentRec);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmDiscusage
|
||||
******************************************************************/
|
||||
class cVeDmDiscusage : public cViewElement {
|
||||
private:
|
||||
public:
|
||||
cVeDmDiscusage(void);
|
||||
virtual ~cVeDmDiscusage(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmSystemload
|
||||
******************************************************************/
|
||||
class cVeDmSystemload : public cViewElement {
|
||||
private:
|
||||
double lastSystemLoad;
|
||||
public:
|
||||
cVeDmSystemload(void);
|
||||
virtual ~cVeDmSystemload(void);
|
||||
void Reset(void) { lastSystemLoad = -1.0f; }
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmSystemmemory
|
||||
******************************************************************/
|
||||
class cVeDmSystemmemory : public cViewElement {
|
||||
private:
|
||||
int lastMemUsage;
|
||||
public:
|
||||
cVeDmSystemmemory(void);
|
||||
virtual ~cVeDmSystemmemory(void);
|
||||
void Reset(void) { lastMemUsage = -1; }
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmTemperatures
|
||||
******************************************************************/
|
||||
class cVeDmTemperatures : public cViewElement {
|
||||
private:
|
||||
int lastCpuTemp;
|
||||
int lastGpuTemp;
|
||||
public:
|
||||
cVeDmTemperatures(void);
|
||||
virtual ~cVeDmTemperatures(void);
|
||||
void Reset(void) { lastCpuTemp = -1; lastGpuTemp = -1; }
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmVdrstatistics
|
||||
******************************************************************/
|
||||
class cVeDmVdrstatistics : public cViewElement {
|
||||
private:
|
||||
string lastVdrCPU;
|
||||
string lastVdrMEM;
|
||||
public:
|
||||
cVeDmVdrstatistics(void);
|
||||
virtual ~cVeDmVdrstatistics(void);
|
||||
void Reset(void) { lastVdrCPU = "undefined"; lastVdrMEM = "undefined"; }
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmLastrecordings
|
||||
******************************************************************/
|
||||
class cVeDmLastrecordings : public cViewElement, public cScrapManager {
|
||||
private:
|
||||
int recIndex;
|
||||
void RecName(string &path, string &name, string &folder);
|
||||
public:
|
||||
cVeDmLastrecordings(void);
|
||||
virtual ~cVeDmLastrecordings(void);
|
||||
void SetTokenContainer(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmDetailheaderEpg
|
||||
******************************************************************/
|
||||
class cVeDmDetailheaderEpg : public cViewElement, public cScrapManager {
|
||||
private:
|
||||
const cEvent *event;
|
||||
public:
|
||||
cVeDmDetailheaderEpg(void);
|
||||
virtual ~cVeDmDetailheaderEpg(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetEvent(const cEvent *event);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmDetailheaderRec
|
||||
******************************************************************/
|
||||
class cVeDmDetailheaderRec : public cViewElement, public cScrapManager {
|
||||
private:
|
||||
const cRecording *recording;
|
||||
public:
|
||||
cVeDmDetailheaderRec(void);
|
||||
virtual ~cVeDmDetailheaderRec(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetRecording(const cRecording *rec);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmDetailheaderPlugin
|
||||
******************************************************************/
|
||||
class cVeDmDetailheaderPlugin : public cViewElement {
|
||||
private:
|
||||
int plugId;
|
||||
int plugMenuId;
|
||||
public:
|
||||
cVeDmDetailheaderPlugin(void);
|
||||
virtual ~cVeDmDetailheaderPlugin(void);
|
||||
void SetPlugId(int id) { plugId = id; };
|
||||
void SetPlugMenuId(int id) { plugMenuId = id; };
|
||||
void SetTokenContainer(void);
|
||||
void Set(skindesignerapi::cTokenContainer *tk);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDmTablabels
|
||||
******************************************************************/
|
||||
class cVeDmTablabels : public cViewElement {
|
||||
private:
|
||||
int tabIndex;
|
||||
int activeTab;
|
||||
vector<const char*> tabs;
|
||||
public:
|
||||
cVeDmTablabels(void);
|
||||
virtual ~cVeDmTablabels(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetTabs(vector<const char*> &newTabs);
|
||||
void SetActiveTab(int activeTab) { SetDirty(); this->activeTab = activeTab; };
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
#endif //__VIEWELEMENTSDM_H
|
||||
816
coreengine/viewelementsdisplayreplay.c
Normal file
816
coreengine/viewelementsdisplayreplay.c
Normal file
@@ -0,0 +1,816 @@
|
||||
#include "viewelementsdisplayreplay.h"
|
||||
#include "../config.h"
|
||||
#include "../extensions/helpers.h"
|
||||
#include "../services/scraper2vdr.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrRecTitle
|
||||
******************************************************************/
|
||||
cVeDrRecTitle::cVeDrRecTitle(void) {
|
||||
recording = NULL;
|
||||
title = NULL;
|
||||
}
|
||||
|
||||
cVeDrRecTitle::~cVeDrRecTitle(void) {
|
||||
free(title);
|
||||
}
|
||||
|
||||
void cVeDrRecTitle::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{rectitle}", (int)eDRRecTitleST::rectitle);
|
||||
tokenContainer->DefineStringToken("{recsubtitle}", (int)eDRRecTitleST::recsubtitle);
|
||||
tokenContainer->DefineStringToken("{recdate}", (int)eDRRecTitleST::recdate);
|
||||
tokenContainer->DefineStringToken("{rectime}", (int)eDRRecTitleST::rectime);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrRecTitle::Set(const cRecording *recording) {
|
||||
this->recording = recording;
|
||||
}
|
||||
|
||||
void cVeDrRecTitle::Set(const char *title) {
|
||||
if (!title)
|
||||
return;
|
||||
free(this->title);
|
||||
this->title = strdup(title);
|
||||
}
|
||||
|
||||
bool cVeDrRecTitle::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force))
|
||||
return false;
|
||||
if (!recording && !title)
|
||||
return false;
|
||||
|
||||
tokenContainer->Clear();
|
||||
if (recording) {
|
||||
const char *recName = NULL;
|
||||
const cRecordingInfo *recInfo = recording->Info();
|
||||
if (recInfo)
|
||||
recName = recInfo->Title();
|
||||
if (!recName)
|
||||
recName = recording->Name();
|
||||
tokenContainer->AddStringToken((int)eDRRecTitleST::rectitle, recName);
|
||||
tokenContainer->AddStringToken((int)eDRRecTitleST::recsubtitle, recInfo ? recInfo->ShortText() : "");
|
||||
tokenContainer->AddStringToken((int)eDRRecTitleST::recdate, *ShortDateString(recording->Start()));
|
||||
tokenContainer->AddStringToken((int)eDRRecTitleST::rectime, *TimeString(recording->Start()));
|
||||
} else if (title) {
|
||||
tokenContainer->AddStringToken((int)eDRRecTitleST::rectitle, title);
|
||||
}
|
||||
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrRecInfo
|
||||
******************************************************************/
|
||||
cVeDrRecInfo::cVeDrRecInfo(void) {
|
||||
recording = NULL;
|
||||
}
|
||||
|
||||
cVeDrRecInfo::~cVeDrRecInfo(void) {
|
||||
}
|
||||
|
||||
void cVeDrRecInfo::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{resolution}", (int)eDRRecInfoST::resolution);
|
||||
tokenContainer->DefineStringToken("{aspect}", (int)eDRRecInfoST::aspect);
|
||||
tokenContainer->DefineIntToken("{screenwidth}", (int)eDRRecInfoIT::screenwidth);
|
||||
tokenContainer->DefineIntToken("{screenheight}", (int)eDRRecInfoIT::screenheight);
|
||||
tokenContainer->DefineIntToken("{isHD}", (int)eDRRecInfoIT::isHD);
|
||||
tokenContainer->DefineIntToken("{isWideScreen}", (int)eDRRecInfoIT::isWideScreen);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrRecInfo::Set(const cRecording *recording) {
|
||||
this->recording = recording;
|
||||
}
|
||||
|
||||
bool cVeDrRecInfo::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force))
|
||||
return false;
|
||||
if (!recording)
|
||||
return false;
|
||||
|
||||
int screenWidth = 0;
|
||||
int screenHeight = 0;
|
||||
double aspect = 0;
|
||||
cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, aspect);
|
||||
bool isHD = false;
|
||||
string resName = GetScreenResolutionString(screenWidth, screenHeight, &isHD);
|
||||
bool isWideScreen = false;
|
||||
string aspectName = GetScreenAspectString(aspect, &isWideScreen);
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDRRecInfoIT::screenwidth, screenWidth);
|
||||
tokenContainer->AddIntToken((int)eDRRecInfoIT::screenheight, screenHeight);
|
||||
tokenContainer->AddIntToken((int)eDRRecInfoIT::isHD, isHD);
|
||||
tokenContainer->AddIntToken((int)eDRRecInfoIT::isWideScreen, isWideScreen);
|
||||
tokenContainer->AddStringToken((int)eDRRecInfoST::resolution, resName.c_str());
|
||||
tokenContainer->AddStringToken((int)eDRRecInfoST::aspect, aspectName.c_str());
|
||||
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrCurrentTime
|
||||
******************************************************************/
|
||||
cVeDrCurrentTime::cVeDrCurrentTime(void) {
|
||||
changed = true;
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
cVeDrCurrentTime::~cVeDrCurrentTime(void) {
|
||||
free(current);
|
||||
}
|
||||
|
||||
void cVeDrCurrentTime::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{reccurrent}", (int)eDRCurrentTimeST::reccurrent);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrCurrentTime::Set(const char *current) {
|
||||
if (!current)
|
||||
return;
|
||||
free(this->current);
|
||||
this->current = strdup(current);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeDrCurrentTime::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force) || !changed)
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDRCurrentTimeST::reccurrent, current);
|
||||
SetDirty();
|
||||
changed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrTotalTime
|
||||
******************************************************************/
|
||||
cVeDrTotalTime::cVeDrTotalTime(void) {
|
||||
changed = true;
|
||||
total = NULL;
|
||||
timeshiftActive = false;
|
||||
timeshiftDuration = NULL;
|
||||
}
|
||||
|
||||
cVeDrTotalTime::~cVeDrTotalTime(void) {
|
||||
free(total);
|
||||
free(timeshiftDuration);
|
||||
}
|
||||
|
||||
void cVeDrTotalTime::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{rectotal}", (int)eDRTotalTimeST::rectotal);
|
||||
tokenContainer->DefineStringToken("{timeshifttotal}", (int)eDRTotalTimeST::timeshifttotal);
|
||||
tokenContainer->DefineIntToken("{timeshift}", (int)eDRTotalTimeIT::timeshift);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrTotalTime::Set(const char *total, bool timeshiftActive, const char *timeshiftDuration) {
|
||||
if (!total)
|
||||
return;
|
||||
free(this->total);
|
||||
this->total = strdup(total);
|
||||
this->timeshiftActive = timeshiftActive;
|
||||
free(this->timeshiftDuration);
|
||||
this->timeshiftDuration = NULL;
|
||||
if (timeshiftDuration)
|
||||
this->timeshiftDuration = strdup(timeshiftDuration);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeDrTotalTime::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force) || !changed)
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDRTotalTimeST::rectotal, total);
|
||||
tokenContainer->AddStringToken((int)eDRTotalTimeST::timeshifttotal, timeshiftDuration);
|
||||
tokenContainer->AddIntToken((int)eDRTotalTimeIT::timeshift, timeshiftActive);
|
||||
SetDirty();
|
||||
changed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrEndTime
|
||||
******************************************************************/
|
||||
cVeDrEndTime::cVeDrEndTime(void) {
|
||||
end = "";
|
||||
}
|
||||
|
||||
cVeDrEndTime::~cVeDrEndTime(void) {
|
||||
}
|
||||
|
||||
void cVeDrEndTime::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{recend}", (int)eDREndTimeST::recend);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrEndTime::Set(cString end) {
|
||||
if (strcmp(*this->end, *end)) {
|
||||
this->end = end;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool cVeDrEndTime::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force) || !changed)
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDREndTimeST::recend, *end);
|
||||
SetDirty();
|
||||
changed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrProgressBar
|
||||
******************************************************************/
|
||||
cVeDrProgressBar::cVeDrProgressBar(void) {
|
||||
current = -1;
|
||||
total = -1;
|
||||
timeshiftActive = false;
|
||||
timeshiftTotal = -1;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
cVeDrProgressBar::~cVeDrProgressBar(void) {
|
||||
}
|
||||
|
||||
void cVeDrProgressBar::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{current}", (int)eDRProgressbarIT::current);
|
||||
tokenContainer->DefineIntToken("{total}", (int)eDRProgressbarIT::total);
|
||||
tokenContainer->DefineIntToken("{timeshift}", (int)eDRProgressbarIT::timeshift);
|
||||
tokenContainer->DefineIntToken("{timeshifttotal}", (int)eDRProgressbarIT::timeshifttotal);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrProgressBar::Set(int current, int total, bool timeshiftActive, int timeshiftTotal) {
|
||||
if (this->current == current)
|
||||
return;
|
||||
this->current = current;
|
||||
this->total = total;
|
||||
this->timeshiftActive = timeshiftActive;
|
||||
this->timeshiftTotal = timeshiftTotal;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeDrProgressBar::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force) || !changed)
|
||||
return false;
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDRProgressbarIT::current, current);
|
||||
tokenContainer->AddIntToken((int)eDRProgressbarIT::total, total);
|
||||
tokenContainer->AddIntToken((int)eDRProgressbarIT::timeshift, timeshiftActive);
|
||||
tokenContainer->AddIntToken((int)eDRProgressbarIT::timeshifttotal, timeshiftTotal);
|
||||
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrCutMarks
|
||||
******************************************************************/
|
||||
cVeDrCutMarks::cVeDrCutMarks(void) {
|
||||
cutmarksIndex = -1;
|
||||
lastMarks = NULL;
|
||||
Reset();
|
||||
}
|
||||
|
||||
cVeDrCutMarks::~cVeDrCutMarks(void) {
|
||||
delete[] lastMarks;
|
||||
}
|
||||
|
||||
void cVeDrCutMarks::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{timeshift}", (int)eDRCutmarksIT::timeshift);
|
||||
tokenContainer->DefineLoopToken("{marks[position]}", (int)eDRCutmarksLT::position);
|
||||
tokenContainer->DefineLoopToken("{marks[endposition]}", (int)eDRCutmarksLT::endposition);
|
||||
tokenContainer->DefineLoopToken("{marks[total]}", (int)eDRCutmarksLT::total);
|
||||
tokenContainer->DefineLoopToken("{marks[timeshifttotal]}", (int)eDRCutmarksLT::timeshifttotal);
|
||||
tokenContainer->DefineLoopToken("{marks[active]}", (int)eDRCutmarksLT::active);
|
||||
tokenContainer->DefineLoopToken("{marks[startmark]}", (int)eDRCutmarksLT::startmark);
|
||||
cutmarksIndex = tokenContainer->LoopIndex("marks");
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrCutMarks::Set(const cMarks *marks, int current, int total, bool timeshiftActive, int timeshiftTotal) {
|
||||
this->marks = marks;
|
||||
this->current = current;
|
||||
this->total = total;
|
||||
this->timeshiftActive = timeshiftActive;
|
||||
this->timeshiftTotal = timeshiftTotal;
|
||||
}
|
||||
|
||||
void cVeDrCutMarks::Reset(void) {
|
||||
marks = NULL;
|
||||
current = -1;
|
||||
total = -1;
|
||||
numMarksLast = 0;
|
||||
delete[] lastMarks;
|
||||
lastMarks = NULL;
|
||||
markActive = -1;
|
||||
timeshiftActive = false;
|
||||
timeshiftTotal = -1;
|
||||
}
|
||||
|
||||
bool cVeDrCutMarks::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force))
|
||||
return false;
|
||||
if (!marks || !MarksChanged()) {
|
||||
return false;
|
||||
}
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDRCutmarksIT::timeshift, timeshiftActive);
|
||||
int numMarks = marks->Count();
|
||||
vector<int> cutmarksInfo;
|
||||
cutmarksInfo.push_back(numMarks);
|
||||
tokenContainer->CreateLoopTokenContainer(&cutmarksInfo);
|
||||
cString tot = cString::sprintf("%d", total);
|
||||
cString timeshifttot = cString::sprintf("%d",timeshiftTotal);
|
||||
int i = 0;
|
||||
bool isStartMark = true;
|
||||
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
|
||||
tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::position, *cString::sprintf("%d", m->Position()));
|
||||
tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::total, *tot);
|
||||
if (timeshiftActive) {
|
||||
tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::timeshifttotal, *timeshifttot);
|
||||
}
|
||||
tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::startmark, isStartMark ? "1" : "0");
|
||||
tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::active, (m->Position() == current) ? "1" : "0");
|
||||
const cMark *m2 = marks->Next(m);
|
||||
if (m2) {
|
||||
tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::endposition, *cString::sprintf("%d", m2->Position()));
|
||||
} else {
|
||||
tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::endposition, *tot);
|
||||
}
|
||||
i++;
|
||||
isStartMark = !isStartMark;
|
||||
}
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cVeDrCutMarks::MarksChanged(void) {
|
||||
bool redraw = false;
|
||||
//if mark was active, we redraw always
|
||||
if (markActive >= 0) {
|
||||
markActive = -1;
|
||||
redraw = true;
|
||||
}
|
||||
//check if current position in recording hits mark exactly
|
||||
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
|
||||
if (m->Position() == current) {
|
||||
markActive = current;
|
||||
redraw = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (redraw)
|
||||
return true;
|
||||
//if number of marks has changed, redraw
|
||||
int numMarks = marks->Count();
|
||||
if (numMarks != numMarksLast) {
|
||||
RememberMarks();
|
||||
return true;
|
||||
}
|
||||
if (!lastMarks)
|
||||
return false;
|
||||
//if position has changed, redraw
|
||||
int i=0;
|
||||
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
|
||||
if (m->Position() != lastMarks[i]) {
|
||||
RememberMarks();
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cVeDrCutMarks::RememberMarks(void) {
|
||||
if (!marks)
|
||||
return;
|
||||
numMarksLast = marks->Count();
|
||||
if (numMarksLast < 1)
|
||||
return;
|
||||
delete[] lastMarks;
|
||||
lastMarks = new int[numMarksLast];
|
||||
int i=0;
|
||||
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
|
||||
lastMarks[i] = m->Position();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrControlIcons
|
||||
******************************************************************/
|
||||
cVeDrControlIcons::cVeDrControlIcons(void) {
|
||||
play = false;
|
||||
forward = false;
|
||||
speed = 0;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
cVeDrControlIcons::~cVeDrControlIcons(void) {
|
||||
}
|
||||
|
||||
void cVeDrControlIcons::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{play}", (int)eDRControlIconsIT::play);
|
||||
tokenContainer->DefineIntToken("{pause}", (int)eDRControlIconsIT::pause);
|
||||
tokenContainer->DefineIntToken("{forward}", (int)eDRControlIconsIT::forward);
|
||||
tokenContainer->DefineIntToken("{forward1x}", (int)eDRControlIconsIT::forward1x);
|
||||
tokenContainer->DefineIntToken("{forward2x}", (int)eDRControlIconsIT::forward2x);
|
||||
tokenContainer->DefineIntToken("{forward3x}", (int)eDRControlIconsIT::forward3x);
|
||||
tokenContainer->DefineIntToken("{rewind}", (int)eDRControlIconsIT::rewind);
|
||||
tokenContainer->DefineIntToken("{rewind1x}", (int)eDRControlIconsIT::rewind1x);
|
||||
tokenContainer->DefineIntToken("{rewind2x}", (int)eDRControlIconsIT::rewind2x);
|
||||
tokenContainer->DefineIntToken("{rewind3x}", (int)eDRControlIconsIT::rewind3x);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrControlIcons::Set(bool play, bool forward, int speed) {
|
||||
this->play = play;
|
||||
this->forward = forward;
|
||||
this->speed = speed;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeDrControlIcons::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force) || !changed)
|
||||
return false;
|
||||
|
||||
bool isPlay = false;
|
||||
bool isPause = false;
|
||||
bool isFF = false;
|
||||
bool isFF1x = false;
|
||||
bool isFF2x = false;
|
||||
bool isFF3x = false;
|
||||
bool isRew = false;
|
||||
bool isRew1x = false;
|
||||
bool isRew2x = false;
|
||||
bool isRew3x = false;
|
||||
|
||||
if (speed == -1) {
|
||||
if (play) {
|
||||
isPlay = true;
|
||||
} else {
|
||||
isPause = true;
|
||||
}
|
||||
} else if (forward) {
|
||||
if (!play) {
|
||||
isPause = true;
|
||||
}
|
||||
if (speed == 1) {
|
||||
isFF1x = true;
|
||||
} else if (speed == 2) {
|
||||
isFF2x = true;
|
||||
} else if (speed == 3) {
|
||||
isFF3x = true;
|
||||
} else {
|
||||
isFF = true;
|
||||
}
|
||||
} else {
|
||||
if (!play) {
|
||||
isPause = true;
|
||||
}
|
||||
if (speed == 1) {
|
||||
isRew1x = true;
|
||||
} else if (speed == 2) {
|
||||
isRew2x = true;
|
||||
} else if (speed == 3) {
|
||||
isRew3x = true;
|
||||
} else {
|
||||
isRew = true;
|
||||
}
|
||||
}
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::play, isPlay);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::pause, isPause);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::forward, isFF);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::forward1x, isFF1x);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::forward2x, isFF2x);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::forward3x, isFF3x);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind, isRew);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind1x, isRew1x);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind2x, isRew2x);
|
||||
tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind3x, isRew3x);
|
||||
SetDirty();
|
||||
changed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrProgressModeonly
|
||||
******************************************************************/
|
||||
cVeDrProgressModeonly::cVeDrProgressModeonly(void) {
|
||||
fps = 0.0f;
|
||||
current = 0;
|
||||
total = 0;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
cVeDrProgressModeonly::~cVeDrProgressModeonly(void) {
|
||||
}
|
||||
|
||||
void cVeDrProgressModeonly::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{current}", (int)eDRProgressModeonlyIT::current);
|
||||
tokenContainer->DefineIntToken("{total}", (int)eDRProgressModeonlyIT::total);
|
||||
tokenContainer->DefineStringToken("{timecurrent}", (int)eDRProgressModeonlyST::timecurrent);
|
||||
tokenContainer->DefineStringToken("{timetotal}", (int)eDRProgressModeonlyST::timetotal);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrProgressModeonly::Set(double fps, int current, int total) {
|
||||
if (this->current == current)
|
||||
return;
|
||||
this->fps = fps;
|
||||
this->current = current;
|
||||
this->total = total;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeDrProgressModeonly::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force) || !changed)
|
||||
return false;
|
||||
|
||||
string cur = GetTimeString((double)current / fps);
|
||||
string tot = GetTimeString((double)total / fps);
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDRProgressModeonlyIT::current, current);
|
||||
tokenContainer->AddIntToken((int)eDRProgressModeonlyIT::total, total);
|
||||
tokenContainer->AddStringToken((int)eDRProgressModeonlyST::timecurrent, cur.c_str());
|
||||
tokenContainer->AddStringToken((int)eDRProgressModeonlyST::timetotal, tot.c_str());
|
||||
|
||||
SetDirty();
|
||||
changed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrJump
|
||||
******************************************************************/
|
||||
cVeDrJump::cVeDrJump(void) {
|
||||
jump = NULL;
|
||||
changed = false;
|
||||
}
|
||||
|
||||
cVeDrJump::~cVeDrJump(void) {
|
||||
free(jump);
|
||||
}
|
||||
|
||||
void cVeDrJump::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{jump}", (int)eDRJumpST::jump);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrJump::Set(const char *jump) {
|
||||
if (!jump)
|
||||
return;
|
||||
free(this->jump);
|
||||
this->jump = strdup(jump);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeDrJump::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force) || !changed)
|
||||
return false;
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDRJumpST::jump, jump);
|
||||
changed = false;
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrOnPause
|
||||
******************************************************************/
|
||||
cVeDrOnPause::cVeDrOnPause(void) {
|
||||
actorsIndex = -1;
|
||||
recfilename = NULL;
|
||||
}
|
||||
|
||||
cVeDrOnPause::~cVeDrOnPause(void) {
|
||||
free(recfilename);
|
||||
}
|
||||
|
||||
void cVeDrOnPause::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{name}", (int)eDROnpauseST::name);
|
||||
tokenContainer->DefineStringToken("{shorttext}", (int)eDROnpauseST::shorttext);
|
||||
tokenContainer->DefineStringToken("{description}", (int)eDROnpauseST::description);
|
||||
tokenContainer->DefineStringToken("{date}", (int)eDROnpauseST::date);
|
||||
tokenContainer->DefineStringToken("{time}", (int)eDROnpauseST::time);
|
||||
tokenContainer->DefineStringToken("{durationminutes}", (int)eDROnpauseST::durationminutes);
|
||||
tokenContainer->DefineStringToken("{durationeventminutes}", (int)eDROnpauseST::durationeventminutes);
|
||||
tokenContainer->DefineIntToken("{daynumeric}", (int)eDROnpauseIT::daynumeric);
|
||||
tokenContainer->DefineIntToken("{month}", (int)eDROnpauseIT::month);
|
||||
tokenContainer->DefineIntToken("{year}", (int)eDROnpauseIT::year);
|
||||
tokenContainer->DefineIntToken("{duration}", (int)eDROnpauseIT::duration);
|
||||
tokenContainer->DefineIntToken("{durationhours}", (int)eDROnpauseIT::durationhours);
|
||||
tokenContainer->DefineIntToken("{durationevent}", (int)eDROnpauseIT::durationevent);
|
||||
tokenContainer->DefineIntToken("{durationeventhours}", (int)eDROnpauseIT::durationeventhours);
|
||||
tokenContainer->DefineStringToken("{movietitle}", (int)eScraperST::movietitle);
|
||||
tokenContainer->DefineStringToken("{movieoriginalTitle}", (int)eScraperST::movieoriginalTitle);
|
||||
tokenContainer->DefineStringToken("{movietagline}", (int)eScraperST::movietagline);
|
||||
tokenContainer->DefineStringToken("{movieoverview}", (int)eScraperST::movieoverview);
|
||||
tokenContainer->DefineStringToken("{moviegenres}", (int)eScraperST::moviegenres);
|
||||
tokenContainer->DefineStringToken("{moviehomepage}", (int)eScraperST::moviehomepage);
|
||||
tokenContainer->DefineStringToken("{moviereleasedate}", (int)eScraperST::moviereleasedate);
|
||||
tokenContainer->DefineStringToken("{moviepopularity}", (int)eScraperST::moviepopularity);
|
||||
tokenContainer->DefineStringToken("{movievoteaverage}", (int)eScraperST::movievoteaverage);
|
||||
tokenContainer->DefineStringToken("{posterpath}", (int)eScraperST::posterpath);
|
||||
tokenContainer->DefineStringToken("{fanartpath}", (int)eScraperST::fanartpath);
|
||||
tokenContainer->DefineStringToken("{moviecollectionName}", (int)eScraperST::moviecollectionName);
|
||||
tokenContainer->DefineStringToken("{collectionposterpath}", (int)eScraperST::collectionposterpath);
|
||||
tokenContainer->DefineStringToken("{collectionfanartpath}", (int)eScraperST::collectionfanartpath);
|
||||
tokenContainer->DefineStringToken("{seriesname}", (int)eScraperST::seriesname);
|
||||
tokenContainer->DefineStringToken("{seriesoverview}", (int)eScraperST::seriesoverview);
|
||||
tokenContainer->DefineStringToken("{seriesfirstaired}", (int)eScraperST::seriesfirstaired);
|
||||
tokenContainer->DefineStringToken("{seriesnetwork}", (int)eScraperST::seriesnetwork);
|
||||
tokenContainer->DefineStringToken("{seriesgenre}", (int)eScraperST::seriesgenre);
|
||||
tokenContainer->DefineStringToken("{seriesrating}", (int)eScraperST::seriesrating);
|
||||
tokenContainer->DefineStringToken("{seriesstatus}", (int)eScraperST::seriesstatus);
|
||||
tokenContainer->DefineStringToken("{episodetitle}", (int)eScraperST::episodetitle);
|
||||
tokenContainer->DefineStringToken("{episodefirstaired}", (int)eScraperST::episodefirstaired);
|
||||
tokenContainer->DefineStringToken("{episodegueststars}", (int)eScraperST::episodegueststars);
|
||||
tokenContainer->DefineStringToken("{episodeoverview}", (int)eScraperST::episodeoverview);
|
||||
tokenContainer->DefineStringToken("{episoderating}", (int)eScraperST::episoderating);
|
||||
tokenContainer->DefineStringToken("{episodeimagepath}", (int)eScraperST::episodeimagepath);
|
||||
tokenContainer->DefineStringToken("{seasonposterpath}", (int)eScraperST::seasonposterpath);
|
||||
tokenContainer->DefineStringToken("{seriesposter1path}", (int)eScraperST::seriesposter1path);
|
||||
tokenContainer->DefineStringToken("{seriesposter2path}", (int)eScraperST::seriesposter2path);
|
||||
tokenContainer->DefineStringToken("{seriesposter3path}", (int)eScraperST::seriesposter3path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart1path}", (int)eScraperST::seriesfanart1path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart2path}", (int)eScraperST::seriesfanart2path);
|
||||
tokenContainer->DefineStringToken("{seriesfanart3path}", (int)eScraperST::seriesfanart3path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner1path}", (int)eScraperST::seriesbanner1path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner2path}", (int)eScraperST::seriesbanner2path);
|
||||
tokenContainer->DefineStringToken("{seriesbanner3path}", (int)eScraperST::seriesbanner3path);
|
||||
tokenContainer->DefineIntToken("{ismovie}", (int)eScraperIT::ismovie);
|
||||
tokenContainer->DefineIntToken("{moviebudget}", (int)eScraperIT::moviebudget);
|
||||
tokenContainer->DefineIntToken("{movierevenue}", (int)eScraperIT::movierevenue);
|
||||
tokenContainer->DefineIntToken("{movieadult}", (int)eScraperIT::movieadult);
|
||||
tokenContainer->DefineIntToken("{movieruntime}", (int)eScraperIT::movieruntime);
|
||||
tokenContainer->DefineIntToken("{isseries}", (int)eScraperIT::isseries);
|
||||
tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperIT::posterwidth);
|
||||
tokenContainer->DefineIntToken("{posterheight}", (int)eScraperIT::posterheight);
|
||||
tokenContainer->DefineIntToken("{fanartwidth}", (int)eScraperIT::fanartwidth);
|
||||
tokenContainer->DefineIntToken("{fanartheight}", (int)eScraperIT::fanartheight);
|
||||
tokenContainer->DefineIntToken("{movieiscollection}", (int)eScraperIT::movieiscollection);
|
||||
tokenContainer->DefineIntToken("{collectionposterwidth}", (int)eScraperIT::collectionposterwidth);
|
||||
tokenContainer->DefineIntToken("{collectionposterheight}", (int)eScraperIT::collectionposterheight);
|
||||
tokenContainer->DefineIntToken("{collectionfanartwidth}", (int)eScraperIT::collectionfanartwidth);
|
||||
tokenContainer->DefineIntToken("{collectionfanartheight}", (int)eScraperIT::collectionfanartheight);
|
||||
tokenContainer->DefineIntToken("{epgpicavailable}", (int)eScraperIT::epgpicavailable);
|
||||
tokenContainer->DefineIntToken("{episodenumber}", (int)eScraperIT::episodenumber);
|
||||
tokenContainer->DefineIntToken("{episodeseason}", (int)eScraperIT::episodeseason);
|
||||
tokenContainer->DefineIntToken("{episodeimagewidth}", (int)eScraperIT::episodeimagewidth);
|
||||
tokenContainer->DefineIntToken("{episodeimageheight}", (int)eScraperIT::episodeimageheight);
|
||||
tokenContainer->DefineIntToken("{seasonposterwidth}", (int)eScraperIT::seasonposterwidth);
|
||||
tokenContainer->DefineIntToken("{seasonposterheight}", (int)eScraperIT::seasonposterheight);
|
||||
tokenContainer->DefineIntToken("{seriesposter1width}", (int)eScraperIT::seriesposter1width);
|
||||
tokenContainer->DefineIntToken("{seriesposter1height}", (int)eScraperIT::seriesposter1height);
|
||||
tokenContainer->DefineIntToken("{seriesposter2width}", (int)eScraperIT::seriesposter2width);
|
||||
tokenContainer->DefineIntToken("{seriesposter2height}", (int)eScraperIT::seriesposter2height);
|
||||
tokenContainer->DefineIntToken("{seriesposter3width}", (int)eScraperIT::seriesposter3width);
|
||||
tokenContainer->DefineIntToken("{seriesposter3height}", (int)eScraperIT::seriesposter3height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart1width}", (int)eScraperIT::seriesfanart1width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart1height}", (int)eScraperIT::seriesfanart1height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart2width}", (int)eScraperIT::seriesfanart2width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart2height}", (int)eScraperIT::seriesfanart2height);
|
||||
tokenContainer->DefineIntToken("{seriesfanart3width}", (int)eScraperIT::seriesfanart3width);
|
||||
tokenContainer->DefineIntToken("{seriesfanart3height}", (int)eScraperIT::seriesfanart3height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner1width}", (int)eScraperIT::seriesbanner1width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner1height}", (int)eScraperIT::seriesbanner1height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner2width}", (int)eScraperIT::seriesbanner2width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner2height}", (int)eScraperIT::seriesbanner2height);
|
||||
tokenContainer->DefineIntToken("{seriesbanner3width}", (int)eScraperIT::seriesbanner3width);
|
||||
tokenContainer->DefineIntToken("{seriesbanner3height}", (int)eScraperIT::seriesbanner3height);
|
||||
tokenContainer->DefineLoopToken("{actors[name]}", (int)eScraperLT::name);
|
||||
tokenContainer->DefineLoopToken("{actors[role]}", (int)eScraperLT::role);
|
||||
tokenContainer->DefineLoopToken("{actors[thumb]}", (int)eScraperLT::thumb);
|
||||
tokenContainer->DefineLoopToken("{actors[thumbwidth]}", (int)eScraperLT::thumbwidth);
|
||||
tokenContainer->DefineLoopToken("{actors[thumbheight]}", (int)eScraperLT::thumbheight);
|
||||
actorsIndex = tokenContainer->LoopIndex("actors");
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrOnPause::Set(const char *recfilename) {
|
||||
if (!recfilename)
|
||||
return;
|
||||
free(this->recfilename);
|
||||
this->recfilename = strdup(recfilename);
|
||||
}
|
||||
|
||||
bool cVeDrOnPause::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force))
|
||||
return false;
|
||||
if (!recfilename)
|
||||
return false;
|
||||
const cRecording *recording = new cRecording(recfilename);
|
||||
if (!recording)
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddStringToken((int)eDROnpauseST::name, recording->Name());
|
||||
const cRecordingInfo *info = recording->Info();
|
||||
if (info) {
|
||||
tokenContainer->AddStringToken((int)eDROnpauseST::shorttext, info->ShortText());
|
||||
tokenContainer->AddStringToken((int)eDROnpauseST::description, info->Description());
|
||||
const cEvent *event = info->GetEvent();
|
||||
if (event) {
|
||||
string recDate = *(event->GetDateString());
|
||||
string recTime = *(event->GetTimeString());
|
||||
if (recDate.find("1970") != string::npos) {
|
||||
time_t start = recording->Start();
|
||||
recDate = *DateString(start);
|
||||
recTime = *TimeString(start);
|
||||
}
|
||||
tokenContainer->AddStringToken((int)eDROnpauseST::date, recDate.c_str());
|
||||
tokenContainer->AddStringToken((int)eDROnpauseST::time, recTime.c_str());
|
||||
time_t startTime = event->StartTime();
|
||||
struct tm * sStartTime = localtime(&startTime);
|
||||
tokenContainer->AddIntToken((int)eDROnpauseIT::year, sStartTime->tm_year + 1900);
|
||||
tokenContainer->AddIntToken((int)eDROnpauseIT::daynumeric, sStartTime->tm_mday);
|
||||
tokenContainer->AddIntToken((int)eDROnpauseIT::month, sStartTime->tm_mon+1);
|
||||
int duration = event->Duration() / 60;
|
||||
int recDuration = recording->LengthInSeconds();
|
||||
recDuration = (recDuration>0)?(recDuration / 60):0;
|
||||
tokenContainer->AddIntToken((int)eDROnpauseIT::duration, recDuration);
|
||||
tokenContainer->AddIntToken((int)eDROnpauseIT::durationhours, recDuration / 60);
|
||||
tokenContainer->AddStringToken((int)eDROnpauseST::durationminutes, *cString::sprintf("%.2d", recDuration%60));
|
||||
tokenContainer->AddIntToken((int)eDROnpauseIT::durationevent, duration);
|
||||
tokenContainer->AddIntToken((int)eDROnpauseIT::durationeventhours, duration / 60);
|
||||
tokenContainer->AddStringToken((int)eDROnpauseST::durationeventminutes, *cString::sprintf("%.2d", duration%60));
|
||||
}
|
||||
}
|
||||
|
||||
vector<int> loopInfo;
|
||||
bool scrapInfoAvailable = LoadFullScrapInfo(NULL, recording);
|
||||
int numActors = NumActors();
|
||||
loopInfo.push_back(numActors);
|
||||
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
||||
if (scrapInfoAvailable) {
|
||||
SetFullScrapInfo(tokenContainer, actorsIndex);
|
||||
}
|
||||
|
||||
SetDirty();
|
||||
delete recording;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrScraperContent
|
||||
******************************************************************/
|
||||
cVeDrScraperContent::cVeDrScraperContent(void) {
|
||||
recording = NULL;
|
||||
}
|
||||
|
||||
cVeDrScraperContent::~cVeDrScraperContent(void) {
|
||||
}
|
||||
|
||||
void cVeDrScraperContent::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineStringToken("{posterpath}", (int)eScraperPosterBannerST::posterpath);
|
||||
tokenContainer->DefineStringToken("{bannerpath}", (int)eScraperPosterBannerST::bannerpath);
|
||||
tokenContainer->DefineStringToken("{mediapath}", (int)eScraperPosterBannerST::mediapath);
|
||||
tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperPosterBannerIT::posterwidth);
|
||||
tokenContainer->DefineIntToken("{posterheight}", (int)eScraperPosterBannerIT::posterheight);
|
||||
tokenContainer->DefineIntToken("{hasPoster}", (int)eScraperPosterBannerIT::hasposter);
|
||||
tokenContainer->DefineIntToken("{bannerwidth}", (int)eScraperPosterBannerIT::bannerwidth);
|
||||
tokenContainer->DefineIntToken("{bannerheight}", (int)eScraperPosterBannerIT::bannerheight);
|
||||
tokenContainer->DefineIntToken("{hasBanner}", (int)eScraperPosterBannerIT::hasbanner);
|
||||
tokenContainer->DefineIntToken("{mediawidth}", (int)eScraperPosterBannerIT::mediawidth);
|
||||
tokenContainer->DefineIntToken("{mediaheight}", (int)eScraperPosterBannerIT::mediaheight);
|
||||
tokenContainer->DefineIntToken("{isbanner}", (int)eScraperPosterBannerIT::isbanner);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDrScraperContent::Set(const cRecording *recording) {
|
||||
this->recording = recording;
|
||||
}
|
||||
|
||||
bool cVeDrScraperContent::Parse(bool force) {
|
||||
if (!cViewElement::Parse(force))
|
||||
return false;
|
||||
if (!recording)
|
||||
return false;
|
||||
SetPosterBanner(tokenContainer, NULL, recording);
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
206
coreengine/viewelementsdisplayreplay.h
Normal file
206
coreengine/viewelementsdisplayreplay.h
Normal file
@@ -0,0 +1,206 @@
|
||||
#ifndef __VIEWELEMENTSDR_H
|
||||
#define __VIEWELEMENTSDR_H
|
||||
|
||||
#include "viewelement.h"
|
||||
#include "../extensions/scrapmanager.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrRecTitle
|
||||
******************************************************************/
|
||||
class cVeDrRecTitle : public cViewElement {
|
||||
private:
|
||||
const cRecording *recording;
|
||||
char *title;
|
||||
public:
|
||||
cVeDrRecTitle(void);
|
||||
virtual ~cVeDrRecTitle(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cRecording *recording);
|
||||
void Set(const char *title);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrRecInfo
|
||||
******************************************************************/
|
||||
class cVeDrRecInfo : public cViewElement {
|
||||
private:
|
||||
const cRecording *recording;
|
||||
public:
|
||||
cVeDrRecInfo(void);
|
||||
virtual ~cVeDrRecInfo(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cRecording *recording);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrCurrentTime
|
||||
******************************************************************/
|
||||
class cVeDrCurrentTime : public cViewElement {
|
||||
private:
|
||||
bool changed;
|
||||
char *current;
|
||||
public:
|
||||
cVeDrCurrentTime(void);
|
||||
virtual ~cVeDrCurrentTime(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const char *current);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrTotalTime
|
||||
******************************************************************/
|
||||
class cVeDrTotalTime : public cViewElement {
|
||||
private:
|
||||
bool changed;
|
||||
char *total;
|
||||
bool timeshiftActive;
|
||||
char *timeshiftDuration;
|
||||
public:
|
||||
cVeDrTotalTime(void);
|
||||
virtual ~cVeDrTotalTime(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const char *total, bool timeshiftActive, const char *timeshiftDuration);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrEndTime
|
||||
******************************************************************/
|
||||
class cVeDrEndTime : public cViewElement {
|
||||
private:
|
||||
cString end;
|
||||
bool changed;
|
||||
public:
|
||||
cVeDrEndTime(void);
|
||||
virtual ~cVeDrEndTime(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(cString end);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrProgressBar
|
||||
******************************************************************/
|
||||
class cVeDrProgressBar : public cViewElement {
|
||||
private:
|
||||
int current;
|
||||
int total;
|
||||
bool timeshiftActive;
|
||||
int timeshiftTotal;
|
||||
bool changed;
|
||||
public:
|
||||
cVeDrProgressBar(void);
|
||||
virtual ~cVeDrProgressBar(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(int current, int total, bool timeshiftActive, int timeshiftTotal);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrCutMarks
|
||||
******************************************************************/
|
||||
class cVeDrCutMarks : public cViewElement {
|
||||
private:
|
||||
int cutmarksIndex;
|
||||
const cMarks *marks;
|
||||
int current;
|
||||
int total;
|
||||
bool timeshiftActive;
|
||||
int timeshiftTotal;
|
||||
int numMarksLast;
|
||||
int *lastMarks;
|
||||
int markActive;
|
||||
bool MarksChanged(void);
|
||||
void RememberMarks(void);
|
||||
public:
|
||||
cVeDrCutMarks(void);
|
||||
virtual ~cVeDrCutMarks(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cMarks *marks, int current, int total, bool timeshiftActive, int timeshiftTotal);
|
||||
void Reset(void);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrControlIcons
|
||||
******************************************************************/
|
||||
class cVeDrControlIcons : public cViewElement {
|
||||
private:
|
||||
bool play;
|
||||
bool forward;
|
||||
int speed;
|
||||
bool changed;
|
||||
public:
|
||||
cVeDrControlIcons(void);
|
||||
virtual ~cVeDrControlIcons(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(bool play, bool forward, int speed);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrProgressModeonly
|
||||
******************************************************************/
|
||||
class cVeDrProgressModeonly : public cViewElement {
|
||||
private:
|
||||
double fps;
|
||||
int current;
|
||||
int total;
|
||||
bool changed;
|
||||
public:
|
||||
cVeDrProgressModeonly(void);
|
||||
virtual ~cVeDrProgressModeonly(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(double fps, int current, int total);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrJump
|
||||
******************************************************************/
|
||||
class cVeDrJump : public cViewElement {
|
||||
private:
|
||||
char *jump;
|
||||
bool changed;
|
||||
public:
|
||||
cVeDrJump(void);
|
||||
virtual ~cVeDrJump(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const char *jump);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrOnPause
|
||||
******************************************************************/
|
||||
class cVeDrOnPause : public cViewElement, public cScrapManager {
|
||||
private:
|
||||
int actorsIndex;
|
||||
char *recfilename;
|
||||
public:
|
||||
cVeDrOnPause(void);
|
||||
virtual ~cVeDrOnPause(void);
|
||||
int Delay(void) { return attribs->Delay() * 1000; };
|
||||
void SetTokenContainer(void);
|
||||
void Set(const char *recfilename);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDrScraperContent
|
||||
******************************************************************/
|
||||
class cVeDrScraperContent : public cViewElement, public cScrapManager {
|
||||
private:
|
||||
const cRecording *recording;
|
||||
public:
|
||||
cVeDrScraperContent(void);
|
||||
virtual ~cVeDrScraperContent(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(const cRecording *recording);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
#endif //__VIEWELEMENTSDR_H
|
||||
84
coreengine/viewelementsdisplaytracks.c
Normal file
84
coreengine/viewelementsdisplaytracks.c
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "viewelementsdisplaytracks.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDtBackground
|
||||
******************************************************************/
|
||||
cVeDtBackground::cVeDtBackground(void) {
|
||||
numTracks = 0;
|
||||
}
|
||||
|
||||
cVeDtBackground::~cVeDtBackground(void) {
|
||||
}
|
||||
|
||||
void cVeDtBackground::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{numtracks}", (int)eDTBackgroundIT::numtracks);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDtBackground::Set(int numTracks) {
|
||||
this->numTracks = numTracks;
|
||||
}
|
||||
|
||||
bool cVeDtBackground::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced))
|
||||
return false;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDTBackgroundIT::numtracks, numTracks);
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cVeDtHeader
|
||||
******************************************************************/
|
||||
cVeDtHeader::cVeDtHeader(void) {
|
||||
title = NULL;
|
||||
audioChannel = 0;
|
||||
numTracks = 0;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
cVeDtHeader::~cVeDtHeader(void) {
|
||||
free(title);
|
||||
}
|
||||
|
||||
void cVeDtHeader::SetTokenContainer(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{numtracks}", (int)eDTHeaderIT::numtracks);
|
||||
tokenContainer->DefineIntToken("{isstereo}", (int)eDTHeaderIT::isstereo);
|
||||
tokenContainer->DefineIntToken("{isac3}", (int)eDTHeaderIT::isac3);
|
||||
tokenContainer->DefineStringToken("{title}", (int)eDTHeaderST::title);
|
||||
InheritTokenContainer();
|
||||
}
|
||||
|
||||
void cVeDtHeader::SetTitle(const char *title) {
|
||||
if (!title)
|
||||
return;
|
||||
free(this->title);
|
||||
this->title = strdup(title);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void cVeDtHeader::SetNumtracks(int numTracks) {
|
||||
this->numTracks = numTracks;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void cVeDtHeader::SetAudiochannel(int audioChannel) {
|
||||
this->audioChannel = audioChannel;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
bool cVeDtHeader::Parse(bool forced) {
|
||||
if (!cViewElement::Parse(forced) || !changed)
|
||||
return false;
|
||||
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken((int)eDTHeaderIT::numtracks, numTracks);
|
||||
tokenContainer->AddIntToken((int)eDTHeaderIT::isstereo, (audioChannel < 0) ? false : true);
|
||||
tokenContainer->AddIntToken((int)eDTHeaderIT::isac3, (audioChannel < 0) ? true : false);
|
||||
tokenContainer->AddStringToken((int)eDTHeaderST::title, title);
|
||||
SetDirty();
|
||||
return true;
|
||||
}
|
||||
40
coreengine/viewelementsdisplaytracks.h
Normal file
40
coreengine/viewelementsdisplaytracks.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef __VIEWELEMENTSDT_H
|
||||
#define __VIEWELEMENTSDT_H
|
||||
|
||||
#include <vdr/menu.h>
|
||||
#include "viewelement.h"
|
||||
|
||||
/******************************************************************
|
||||
* cVeDtBackground
|
||||
******************************************************************/
|
||||
class cVeDtBackground : public cViewElement {
|
||||
private:
|
||||
int numTracks;
|
||||
public:
|
||||
cVeDtBackground(void);
|
||||
virtual ~cVeDtBackground(void);
|
||||
void SetTokenContainer(void);
|
||||
void Set(int numTracks);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* cVeDtHeader
|
||||
******************************************************************/
|
||||
class cVeDtHeader : public cViewElement {
|
||||
private:
|
||||
char *title;
|
||||
int audioChannel;
|
||||
int numTracks;
|
||||
bool changed;
|
||||
public:
|
||||
cVeDtHeader(void);
|
||||
virtual ~cVeDtHeader(void);
|
||||
void SetTokenContainer(void);
|
||||
void SetTitle(const char *title);
|
||||
void SetNumtracks(int numTracks);
|
||||
void SetAudiochannel(int audioChannel);
|
||||
bool Parse(bool forced = false);
|
||||
};
|
||||
|
||||
#endif //__VIEWELEMENTSDT_H
|
||||
188
coreengine/viewgrid.c
Normal file
188
coreengine/viewgrid.c
Normal file
@@ -0,0 +1,188 @@
|
||||
#include "viewgrid.h"
|
||||
#include "../extensions/helpers.h"
|
||||
|
||||
cViewGrid::cViewGrid(void) {
|
||||
id = -1;
|
||||
plugId = -1;
|
||||
viewId = -1;
|
||||
globals = NULL;
|
||||
attribs = new cViewElementAttribs((int)eViewElementAttribs::count);
|
||||
gridTpl = NULL;
|
||||
gridsize = GRIDSIZE;
|
||||
grid = new cGridElement*[gridsize];
|
||||
for (int i=0; i < gridsize; i++) {
|
||||
grid[i] = NULL;
|
||||
}
|
||||
gridMin = 0;
|
||||
gridMax = -1;
|
||||
}
|
||||
|
||||
cViewGrid::~cViewGrid(void) {
|
||||
delete attribs;
|
||||
delete gridTpl;
|
||||
}
|
||||
|
||||
void cViewGrid::SetGlobals(cGlobals *globals) {
|
||||
this->globals = globals;
|
||||
}
|
||||
|
||||
void cViewGrid::SetContainer(int x, int y, int width, int height) {
|
||||
container.SetX(x);
|
||||
container.SetY(y);
|
||||
container.SetWidth(width);
|
||||
container.SetHeight(height);
|
||||
}
|
||||
|
||||
void cViewGrid::SetAttributes(vector<stringpair> &attributes) {
|
||||
attribs->Set(attributes);
|
||||
}
|
||||
|
||||
void cViewGrid::AddGridElement(cGridElement *gridElement) {
|
||||
gridTpl = gridElement;
|
||||
}
|
||||
|
||||
const char *cViewGrid::Name(void) {
|
||||
return attribs->Name();
|
||||
}
|
||||
|
||||
void cViewGrid::SetTokenContainer(void) {
|
||||
if (!gridTpl)
|
||||
return;
|
||||
gridTpl->SetId(id);
|
||||
gridTpl->SetPluginId(plugId);
|
||||
gridTpl->SetViewId(viewId);
|
||||
gridTpl->SetTokenContainer();
|
||||
}
|
||||
|
||||
void cViewGrid::PreCache(void) {
|
||||
attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->SetGlobals(globals);
|
||||
attribs->Cache();
|
||||
gridTpl->SetGlobals(globals);
|
||||
gridTpl->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
gridTpl->Cache();
|
||||
|
||||
}
|
||||
|
||||
void cViewGrid::CheckSize(int id) {
|
||||
if (id < gridsize)
|
||||
return;
|
||||
int newgridsize = gridsize + GRIDSIZE;
|
||||
while (newgridsize < id)
|
||||
newgridsize += gridsize;
|
||||
cGridElement **gridNew = new cGridElement*[newgridsize];
|
||||
int i=0;
|
||||
bool foundFirst = false;
|
||||
for (; i < gridsize; i++) {
|
||||
if (!foundFirst && grid[i]) {
|
||||
foundFirst = true;
|
||||
gridMin = i;
|
||||
}
|
||||
gridNew[i] = grid[i];
|
||||
}
|
||||
gridsize = newgridsize;
|
||||
for (; i < gridsize; i++) {
|
||||
gridNew[i] = NULL;
|
||||
}
|
||||
delete[] grid;
|
||||
grid = gridNew;
|
||||
}
|
||||
|
||||
void cViewGrid::SetTokens(int gId, skindesignerapi::cTokenContainer *tk) {
|
||||
if (!grid[gId]) {
|
||||
return;
|
||||
}
|
||||
grid[gId]->Set(tk);
|
||||
}
|
||||
|
||||
void cViewGrid::PositionGrid(int gId, double x, double y, double width, double height) {
|
||||
int gridX = attribs->X() + x * attribs->Width();
|
||||
int gridY = attribs->Y() + y * attribs->Height();
|
||||
int gridWidth = width * attribs->Width();
|
||||
int gridHeight = height * attribs->Height();
|
||||
if (!grid[gId]) {
|
||||
if (gId >= gridMax)
|
||||
gridMax = gId+1;
|
||||
grid[gId] = CreateGrid(gridX, gridY, gridWidth, gridHeight);
|
||||
} else {
|
||||
if (grid[gId]->Width() == gridWidth && grid[gId]->Height() == gridHeight) {
|
||||
grid[gId]->SetPosition(gridX, gridY, gridWidth, gridHeight);
|
||||
} else {
|
||||
cGridElement *ge = CreateGrid(gridX, gridY, gridWidth, gridHeight);
|
||||
ge->Set(grid[gId]->GetTokenContainer());
|
||||
grid[gId]->Close();
|
||||
delete grid[gId];
|
||||
grid[gId] = ge;
|
||||
}
|
||||
grid[gId]->SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewGrid::SetCurrentGrid(int gId, bool current) {
|
||||
if (gId >= 0 && grid[gId]) {
|
||||
grid[gId]->SetCurrent(current);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewGrid::DeleteGrid(int gId) {
|
||||
if (!grid[gId])
|
||||
return;
|
||||
grid[gId]->Close();
|
||||
delete grid[gId];
|
||||
grid[gId] = NULL;
|
||||
}
|
||||
|
||||
void cViewGrid::ClearGrids(void) {
|
||||
for (int i = 0; i < gridsize; i++) {
|
||||
if (!grid[i])
|
||||
continue;
|
||||
grid[i]->Close();
|
||||
delete grid[i];
|
||||
grid[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cViewGrid::Render(void) {
|
||||
for (int i = gridMin; i < gridMax; i++) {
|
||||
if (grid[i] && grid[i]->Parse()) {
|
||||
grid[i]->Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cGridElement *cViewGrid::CreateGrid(int x, int y, int width, int height) {
|
||||
cGridElement *ge = new cGridElement(*gridTpl);
|
||||
ge->SetAreaX(x);
|
||||
ge->SetAreaY(y);
|
||||
ge->SetAreaWidth(width);
|
||||
ge->SetAreaHeight(height);
|
||||
return ge;
|
||||
}
|
||||
|
||||
void cViewGrid::Close(void) {
|
||||
ClearGrids();
|
||||
gridsize = GRIDSIZE;
|
||||
delete[] grid;
|
||||
grid = new cGridElement*[gridsize];
|
||||
for (int i=0; i < gridsize; i++) {
|
||||
grid[i] = NULL;
|
||||
}
|
||||
gridMin = 0;
|
||||
gridMax = -1;
|
||||
}
|
||||
|
||||
void cViewGrid::Hide(void) {
|
||||
for (int i = 0; i < gridsize; i++) {
|
||||
if (grid[i]) {
|
||||
grid[i]->Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewGrid::Show(void) {
|
||||
for (int i = 0; i < gridsize; i++) {
|
||||
if (grid[i]) {
|
||||
grid[i]->Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
47
coreengine/viewgrid.h
Normal file
47
coreengine/viewgrid.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef __VIEWGRID_H
|
||||
#define __VIEWGRID_H
|
||||
|
||||
#define GRIDSIZE 500
|
||||
|
||||
#include "gridelement.h"
|
||||
|
||||
class cViewGrid {
|
||||
protected:
|
||||
cRect container;
|
||||
cGlobals *globals;
|
||||
cViewElementAttribs *attribs;
|
||||
cGridElement *gridTpl;
|
||||
int gridsize;
|
||||
cGridElement **grid;
|
||||
int gridMin;
|
||||
int gridMax;
|
||||
int id;
|
||||
int viewId;
|
||||
int plugId;
|
||||
cGridElement *CreateGrid(int x, int y, int width, int height);
|
||||
public:
|
||||
cViewGrid(void);
|
||||
virtual ~cViewGrid(void);
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void SetContainer(int x, int y, int width, int height);
|
||||
void SetAttributes(vector<stringpair> &attributes);
|
||||
void SetId(int id) { this->id = id; };
|
||||
void SetPluginId(int plugId) { this->plugId = plugId; };
|
||||
void SetViewId(int viewId) { this->viewId = viewId; };
|
||||
void AddGridElement(cGridElement *gridElement);
|
||||
const char *Name(void);
|
||||
void SetTokenContainer(void);
|
||||
void PreCache(void);
|
||||
void CheckSize(int id);
|
||||
void SetTokens(int gId, skindesignerapi::cTokenContainer *tk);
|
||||
void PositionGrid(int gId, double x, double y, double width, double height);
|
||||
void SetCurrentGrid(int gId, bool current);
|
||||
void DeleteGrid(int gId);
|
||||
void ClearGrids(void);
|
||||
void Render(void);
|
||||
void Close(void);
|
||||
void Hide(void);
|
||||
void Show(void);
|
||||
};
|
||||
|
||||
#endif //__VIEWGRID_H
|
||||
899
coreengine/viewlist.c
Normal file
899
coreengine/viewlist.c
Normal file
@@ -0,0 +1,899 @@
|
||||
#include "viewlist.h"
|
||||
|
||||
cViewList::cViewList(void) {
|
||||
globals = NULL;
|
||||
attribs = new cViewListAttribs((int)eViewListAttribs::count);
|
||||
numElements = 0;
|
||||
listElement = NULL;
|
||||
currentElement = NULL;
|
||||
listElements = NULL;
|
||||
plugId = -1;
|
||||
plugMenuId = -1;
|
||||
}
|
||||
|
||||
cViewList::~cViewList(void) {
|
||||
delete attribs;
|
||||
delete listElement;
|
||||
delete currentElement;
|
||||
if (listElements) {
|
||||
for (int i=0; i < numElements; ++i) {
|
||||
if (listElements[i]) {
|
||||
delete listElements[i];
|
||||
listElements[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] listElements;
|
||||
}
|
||||
|
||||
void cViewList::SetGlobals(cGlobals *globals) {
|
||||
this->globals = globals;
|
||||
if (listElement)
|
||||
listElement->SetGlobals(globals);
|
||||
if (currentElement)
|
||||
currentElement->SetGlobals(globals);
|
||||
}
|
||||
|
||||
void cViewList::SetContainer(int x, int y, int width, int height) {
|
||||
container.SetX(x);
|
||||
container.SetY(y);
|
||||
container.SetWidth(width);
|
||||
container.SetHeight(height);
|
||||
}
|
||||
|
||||
void cViewList::SetAttributes(vector<stringpair> &attributes) {
|
||||
attribs->Set(attributes);
|
||||
}
|
||||
|
||||
cViewList *cViewList::CreateViewList(const char *name) {
|
||||
cViewList *l = NULL;
|
||||
if (!strcmp(name, "menudefault"))
|
||||
l = new cViewListDefault();
|
||||
else if (!strcmp(name, "menumain"))
|
||||
l = new cViewListMain();
|
||||
else if (!strcmp(name, "menusetup"))
|
||||
l = new cViewListMain();
|
||||
else if (!strcmp(name, "menuschedules"))
|
||||
l = new cViewListSchedules();
|
||||
else if (!strcmp(name, "menutimers"))
|
||||
l = new cViewListTimers();
|
||||
else if (!strcmp(name, "menuchannels"))
|
||||
l = new cViewListChannels();
|
||||
else if (!strcmp(name, "menurecordings"))
|
||||
l = new cViewListRecordings();
|
||||
else if (!strcmp(name, "displayaudiotracks"))
|
||||
l = new cViewListAudioTracks();
|
||||
else if (startswith(name, "menuplugin"))
|
||||
l = new cViewListPlugin();
|
||||
else
|
||||
esyslog("skindesigner: unknown viewlist %s", name);
|
||||
return l;
|
||||
}
|
||||
|
||||
cViewElement *cViewList::CreateListElement(const char *name) {
|
||||
cViewElement *le = NULL;
|
||||
if (!strcmp(name, "menudefault"))
|
||||
le = new cLeMenuDefault();
|
||||
else if (!strcmp(name, "menumain"))
|
||||
le = new cLeMenuMain();
|
||||
else if (!strcmp(name, "menusetup"))
|
||||
le = new cLeMenuMain();
|
||||
else if (!strcmp(name, "menuschedules"))
|
||||
le = new cLeMenuSchedules();
|
||||
else if (!strcmp(name, "menutimers"))
|
||||
le = new cLeMenuTimers();
|
||||
else if (!strcmp(name, "menuchannels"))
|
||||
le = new cLeMenuChannels();
|
||||
else if (!strcmp(name, "menurecordings"))
|
||||
le = new cLeMenuRecordings();
|
||||
else if (!strcmp(name, "displayaudiotracks"))
|
||||
le = new cLeAudioTracks();
|
||||
else if (startswith(name, "menuplugin"))
|
||||
le = new cLeMenuPlugin();
|
||||
else
|
||||
esyslog("skindesigner: unknown viewlist %s", name);
|
||||
return le;
|
||||
}
|
||||
|
||||
cViewElement *cViewList::CreateCurrentElement(const char *name) {
|
||||
cViewElement *ce = NULL;
|
||||
if (!strcmp(name, "menumain"))
|
||||
ce = new cCeMenuMain();
|
||||
else if (!strcmp(name, "menusetup"))
|
||||
ce = new cCeMenuMain();
|
||||
else if (!strcmp(name, "menuschedules"))
|
||||
ce = new cCeMenuSchedules();
|
||||
else if (!strcmp(name, "menutimers"))
|
||||
ce = new cCeMenuTimers();
|
||||
else if (!strcmp(name, "menuchannels"))
|
||||
ce = new cCeMenuChannels();
|
||||
else if (!strcmp(name, "menurecordings"))
|
||||
ce = new cCeMenuRecordings();
|
||||
else if (startswith(name, "menuplugin"))
|
||||
ce = new cCeMenuPlugin();
|
||||
else
|
||||
esyslog("skindesigner: unknown viewlist %s", name);
|
||||
return ce;
|
||||
}
|
||||
|
||||
void cViewList::AddListElement(cViewElement *listElement) {
|
||||
this->listElement = listElement;
|
||||
listElement->SetTokenContainer();
|
||||
}
|
||||
|
||||
void cViewList::AddCurrentElement(cViewElement *currentElement) {
|
||||
this->currentElement = currentElement;
|
||||
currentElement->SetTokenContainer();
|
||||
}
|
||||
|
||||
void cViewList::PreCache(void) {
|
||||
attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->SetGlobals(globals);
|
||||
attribs->Cache();
|
||||
numElements = attribs->NumListElements();
|
||||
orientation = attribs->Orientation();
|
||||
eAlign align = attribs->Align();
|
||||
int x = attribs->X();
|
||||
int y = attribs->Y();
|
||||
int width = attribs->Width();
|
||||
int height = attribs->Height();
|
||||
|
||||
int step = 0;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
step = height / numElements;
|
||||
} else {
|
||||
step = width / numElements;
|
||||
}
|
||||
|
||||
int start = 0;
|
||||
if (align == eAlign::center) {
|
||||
if (orientation == eOrientation::vertical) {
|
||||
start = y + (height - numElements * step) / 2;
|
||||
} else {
|
||||
start = x + (width - numElements * step) / 2;
|
||||
}
|
||||
} else if (align == eAlign::bottom) {
|
||||
start = y + height - numElements * step;
|
||||
} else if (align == eAlign::right) {
|
||||
start = x + width - numElements * step;
|
||||
}
|
||||
Prepare(start, step);
|
||||
}
|
||||
|
||||
int cViewList::NumItems(void) {
|
||||
return numElements;
|
||||
}
|
||||
|
||||
eOrientation cViewList::Orientation(void) {
|
||||
return attribs->Orientation();
|
||||
}
|
||||
|
||||
void cViewList::Draw(eMenuCategory menuCat) {
|
||||
int current = -1;
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listElements[i]->SetMenuCategory(menuCat);
|
||||
if (listElements[i]->Parse()) {
|
||||
listElements[i]->Render();
|
||||
if (listElements[i]->Current()) {
|
||||
listElements[i]->RenderCurrent();
|
||||
current = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current >= 0 && listElements[current]) {
|
||||
listElements[current]->WakeCurrent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void cViewList::Clear(void) {
|
||||
if (!listElements)
|
||||
return;
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listElements[i]->StopScrolling();
|
||||
listElements[i]->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewList::Close(void) {
|
||||
if (!listElements)
|
||||
return;
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listElements[i]->StopScrolling();
|
||||
listElements[i]->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void cViewList::SetTransparency(int transparency) {
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
if (listElements[i]) {
|
||||
listElements[i]->SetTransparency(transparency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewList::Debug(void) {
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewListDefault
|
||||
******************************************************************/
|
||||
cViewListDefault::cViewListDefault(void) {
|
||||
listDefault = NULL;
|
||||
colX = NULL;
|
||||
colWidths = NULL;
|
||||
avrgFontWidth = 0;
|
||||
listFont = NULL;
|
||||
plugName = NULL;
|
||||
}
|
||||
|
||||
cViewListDefault::~cViewListDefault(void) {
|
||||
delete[] listDefault;
|
||||
delete[] colX;
|
||||
delete[] colWidths;
|
||||
}
|
||||
|
||||
void cViewListDefault::Prepare(int start, int step) {
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
cLeMenuDefault *tpl = dynamic_cast<cLeMenuDefault*>(listElement);
|
||||
if (!tpl) return;
|
||||
listDefault = new cLeMenuDefault*[numElements];
|
||||
listElements = new cListElement*[numElements];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listDefault[i] = new cLeMenuDefault(*tpl);
|
||||
listElements[i] = listDefault[i];
|
||||
listDefault[i]->SetNumber(i);
|
||||
listDefault[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listDefault[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listDefault[i]->SetAreaWidth(width);
|
||||
}
|
||||
listDefault[i]->SetContainer(x, y, width, height);
|
||||
listDefault[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
|
||||
//Setting average font width
|
||||
avrgFontWidth = 20;
|
||||
const char *determinateFont = attribs->DeterminateFont();
|
||||
if (!determinateFont) {
|
||||
return;
|
||||
}
|
||||
cFunction *f = listDefault[0]->GetFunction(determinateFont);
|
||||
if (!f)
|
||||
return;
|
||||
cFuncDrawText *fdt = dynamic_cast<cFuncDrawText*>(f);
|
||||
if (!fdt) {
|
||||
return;
|
||||
}
|
||||
avrgFontWidth = fdt->AvrgFontWidth();
|
||||
listFont = fdt->GetFont();
|
||||
colX = new int[MAX_TABS];
|
||||
colWidths = new int[MAX_TABS];
|
||||
for (int i=0; i < MAX_TABS; i++) {
|
||||
colX[i] = 0;
|
||||
colWidths[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listDefault[i]->SetListInfo(colX, colWidths);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListDefault::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
|
||||
int itemWidth = attribs->MenuItemWidth();
|
||||
if (!tab1) {
|
||||
colX[0] = 0;
|
||||
colWidths[0] = itemWidth;
|
||||
for (int i = 1; i < MAX_TABS; i++) {
|
||||
colX[i] = 0;
|
||||
colWidths[i] = 0;
|
||||
}
|
||||
} else {
|
||||
colX[0] = 0;
|
||||
colX[1] = tab1 ? colX[0] + tab1 : 0;
|
||||
colX[2] = tab2 ? colX[1] + tab2 : 0;
|
||||
colX[3] = tab3 ? colX[2] + tab3 : 0;
|
||||
colX[4] = tab4 ? colX[3] + tab4 : 0;
|
||||
colX[5] = tab5 ? colX[4] + tab5 : 0;
|
||||
for (int i = 1; i < MAX_TABS; i++)
|
||||
colX[i] *= avrgFontWidth;
|
||||
|
||||
bool end = false;
|
||||
for (int i = 0; i < MAX_TABS; i++) {
|
||||
if ( i < MAX_TABS -1 && colX[i+1] > 0) {
|
||||
colWidths[i] = colX[i+1] - colX[i];
|
||||
} else if (!end) {
|
||||
end = true;
|
||||
colWidths[i] = itemWidth - colX[i];
|
||||
} else {
|
||||
colWidths[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListDefault::Set(const char *text, int index, bool current, bool selectable) {
|
||||
if (!current)
|
||||
listDefault[index]->StopScrolling();
|
||||
listDefault[index]->SetCurrent(current);
|
||||
listDefault[index]->SetSelectable(selectable);
|
||||
listDefault[index]->SetPlugin(plugName);
|
||||
listDefault[index]->SetText(text);
|
||||
}
|
||||
|
||||
const cFont *cViewListDefault::GetListFont(void) {
|
||||
return listFont;
|
||||
};
|
||||
|
||||
int cViewListDefault::GetListWidth(void) {
|
||||
return attribs->MenuItemWidth();
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewListMain
|
||||
******************************************************************/
|
||||
cViewListMain::cViewListMain(void) {
|
||||
listMain = NULL;
|
||||
currentMain = NULL;
|
||||
}
|
||||
|
||||
cViewListMain::~cViewListMain(void) {
|
||||
delete[] listMain;
|
||||
}
|
||||
|
||||
void cViewListMain::Prepare(int start, int step) {
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
cLeMenuMain *tpl = dynamic_cast<cLeMenuMain*>(listElement);
|
||||
if (!tpl) return;
|
||||
|
||||
listMain = new cLeMenuMain*[numElements];
|
||||
listElements = new cListElement*[numElements];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listMain[i] = new cLeMenuMain(*tpl);
|
||||
listElements[i] = listMain[i];
|
||||
listMain[i]->SetNumber(i);
|
||||
listMain[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listMain[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listMain[i]->SetAreaWidth(width);
|
||||
}
|
||||
listMain[i]->SetContainer(x, y, width, height);
|
||||
listMain[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
|
||||
if (!currentElement) return;
|
||||
currentMain = dynamic_cast<cCeMenuMain*>(currentElement);
|
||||
if (!currentMain) return;
|
||||
|
||||
currentMain->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
currentMain->SetDetached();
|
||||
currentMain->Cache();
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listMain[i]->SetCurrentElement(currentMain);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListMain::Set(const char *text, int index, bool current, bool selectable) {
|
||||
if (!current)
|
||||
listMain[index]->StopScrolling();
|
||||
listMain[index]->SetCurrent(current);
|
||||
listMain[index]->ClearCurrentElement();
|
||||
listMain[index]->SetSelectable(selectable);
|
||||
listMain[index]->SetText(text);
|
||||
}
|
||||
|
||||
const char *cViewListMain::GetPlugin(void) {
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
if (listMain[i] && listMain[i]->Current()) {
|
||||
return listMain[i]->PluginName();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/******************************************************************
|
||||
* cViewListSchedules
|
||||
******************************************************************/
|
||||
cViewListSchedules::cViewListSchedules(void) {
|
||||
listSchedules = NULL;
|
||||
currentSchedules = NULL;
|
||||
epgSearchFav = false;
|
||||
}
|
||||
|
||||
cViewListSchedules::~cViewListSchedules(void) {
|
||||
delete[] listSchedules;
|
||||
}
|
||||
|
||||
void cViewListSchedules::Prepare(int start, int step) {
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
cLeMenuSchedules *tpl = dynamic_cast<cLeMenuSchedules*>(listElement);
|
||||
if (!tpl) return;
|
||||
|
||||
listSchedules = new cLeMenuSchedules*[numElements];
|
||||
listElements = new cListElement*[numElements];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listSchedules[i] = new cLeMenuSchedules(*tpl);
|
||||
listElements[i] = listSchedules[i];
|
||||
listSchedules[i]->SetNumber(i);
|
||||
listSchedules[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listSchedules[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listSchedules[i]->SetAreaWidth(width);
|
||||
}
|
||||
listSchedules[i]->SetContainer(x, y, width, height);
|
||||
listSchedules[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
|
||||
if (!currentElement) return;
|
||||
currentSchedules = dynamic_cast<cCeMenuSchedules*>(currentElement);
|
||||
if (!currentSchedules) return;
|
||||
|
||||
currentSchedules->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
currentSchedules->SetDetached();
|
||||
currentSchedules->Cache();
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listSchedules[i]->SetCurrentElement(currentSchedules);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListSchedules::Set(const cEvent *event, int index, bool current, bool selectable,
|
||||
const cChannel *channel, bool withDate, eTimerMatch timerMatch) {
|
||||
if (!current)
|
||||
listSchedules[index]->StopScrolling();
|
||||
listSchedules[index]->SetCurrent(current);
|
||||
listSchedules[index]->ClearCurrentElement();
|
||||
listSchedules[index]->SetSelectable(selectable);
|
||||
listSchedules[index]->SetEpgSearchFav(epgSearchFav);
|
||||
listSchedules[index]->Set(event, channel, withDate, timerMatch);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewListTimers
|
||||
******************************************************************/
|
||||
cViewListTimers::cViewListTimers(void) {
|
||||
listTimers = NULL;
|
||||
currentTimer = NULL;
|
||||
}
|
||||
|
||||
cViewListTimers::~cViewListTimers(void) {
|
||||
delete[] listTimers;
|
||||
}
|
||||
|
||||
void cViewListTimers::Prepare(int start, int step) {
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
cLeMenuTimers *tpl = dynamic_cast<cLeMenuTimers*>(listElement);
|
||||
if (!tpl) return;
|
||||
|
||||
listTimers = new cLeMenuTimers*[numElements];
|
||||
listElements = new cListElement*[numElements];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listTimers[i] = new cLeMenuTimers(*tpl);
|
||||
listElements[i] = listTimers[i];
|
||||
listTimers[i]->SetNumber(i);
|
||||
listTimers[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listTimers[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listTimers[i]->SetAreaWidth(width);
|
||||
}
|
||||
listTimers[i]->SetContainer(x, y, width, height);
|
||||
listTimers[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
|
||||
if (!currentElement) return;
|
||||
currentTimer = dynamic_cast<cCeMenuTimers*>(currentElement);
|
||||
if (!currentTimer) return;
|
||||
|
||||
currentTimer->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
currentTimer->SetDetached();
|
||||
currentTimer->Cache();
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listTimers[i]->SetCurrentElement(currentTimer);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListTimers::Set(const cTimer *timer, int index, bool current, bool selectable) {
|
||||
if (!current)
|
||||
listTimers[index]->StopScrolling();
|
||||
listTimers[index]->SetCurrent(current);
|
||||
listTimers[index]->ClearCurrentElement();
|
||||
listTimers[index]->SetSelectable(selectable);
|
||||
listTimers[index]->Set(timer);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewListChannels
|
||||
******************************************************************/
|
||||
cViewListChannels::cViewListChannels(void) {
|
||||
listChannels = NULL;
|
||||
currentChannel = NULL;
|
||||
}
|
||||
|
||||
cViewListChannels::~cViewListChannels(void) {
|
||||
delete[] listChannels;
|
||||
}
|
||||
|
||||
void cViewListChannels::Prepare(int start, int step) {
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
cLeMenuChannels *tpl = dynamic_cast<cLeMenuChannels*>(listElement);
|
||||
if (!tpl) return;
|
||||
|
||||
listChannels = new cLeMenuChannels*[numElements];
|
||||
listElements = new cListElement*[numElements];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listChannels[i] = new cLeMenuChannels(*tpl);
|
||||
listElements[i] = listChannels[i];
|
||||
listChannels[i]->SetNumber(i);
|
||||
listChannels[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listChannels[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listChannels[i]->SetAreaWidth(width);
|
||||
}
|
||||
listChannels[i]->SetContainer(x, y, width, height);
|
||||
listChannels[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
|
||||
if (!currentElement) return;
|
||||
currentChannel = dynamic_cast<cCeMenuChannels*>(currentElement);
|
||||
if (!currentChannel) return;
|
||||
|
||||
currentChannel->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
currentChannel->SetDetached();
|
||||
currentChannel->Cache();
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listChannels[i]->SetCurrentElement(currentChannel);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListChannels::Set(const cChannel *channel, int index, bool current, bool selectable, bool withProvider) {
|
||||
if (!current)
|
||||
listChannels[index]->StopScrolling();
|
||||
listChannels[index]->SetCurrent(current);
|
||||
listChannels[index]->ClearCurrentElement();
|
||||
listChannels[index]->SetSelectable(selectable);
|
||||
listChannels[index]->Set(channel, withProvider);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewListRecordings
|
||||
******************************************************************/
|
||||
cViewListRecordings::cViewListRecordings(void) {
|
||||
listRecordings = NULL;
|
||||
currentRecording = NULL;
|
||||
}
|
||||
|
||||
cViewListRecordings::~cViewListRecordings(void) {
|
||||
delete[] listRecordings;
|
||||
}
|
||||
|
||||
void cViewListRecordings::Prepare(int start, int step) {
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
cLeMenuRecordings *tpl = dynamic_cast<cLeMenuRecordings*>(listElement);
|
||||
if (!tpl) return;
|
||||
|
||||
listRecordings = new cLeMenuRecordings*[numElements];
|
||||
listElements = new cListElement*[numElements];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listRecordings[i] = new cLeMenuRecordings(*tpl);
|
||||
listElements[i] = listRecordings[i];
|
||||
listRecordings[i]->SetNumber(i);
|
||||
listRecordings[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listRecordings[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listRecordings[i]->SetAreaWidth(width);
|
||||
}
|
||||
listRecordings[i]->SetContainer(x, y, width, height);
|
||||
listRecordings[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
|
||||
if (!currentElement) return;
|
||||
currentRecording = dynamic_cast<cCeMenuRecordings*>(currentElement);
|
||||
if (!currentRecording) return;
|
||||
|
||||
currentRecording->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
currentRecording->SetDetached();
|
||||
currentRecording->Cache();
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listRecordings[i]->SetCurrentElement(currentRecording);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListRecordings::Set(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New) {
|
||||
if (!current)
|
||||
listRecordings[index]->StopScrolling();
|
||||
listRecordings[index]->SetCurrent(current);
|
||||
listRecordings[index]->ClearCurrentElement();
|
||||
listRecordings[index]->SetSelectable(selectable);
|
||||
listRecordings[index]->Set(recording, level, total, New);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewListPlugin
|
||||
******************************************************************/
|
||||
cViewListPlugin::cViewListPlugin(void) {
|
||||
listPlugin = NULL;
|
||||
currentPlugin = NULL;
|
||||
}
|
||||
|
||||
cViewListPlugin::~cViewListPlugin(void) {
|
||||
delete[] listPlugin;
|
||||
}
|
||||
|
||||
void cViewListPlugin::Prepare(int start, int step) {
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
if (!listElement)
|
||||
return;
|
||||
|
||||
cLeMenuPlugin *tpl = dynamic_cast<cLeMenuPlugin*>(listElement);
|
||||
if (!tpl) return;
|
||||
|
||||
listPlugin = new cLeMenuPlugin*[numElements];
|
||||
listElements = new cListElement*[numElements];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listPlugin[i] = new cLeMenuPlugin(*tpl);
|
||||
listElements[i] = listPlugin[i];
|
||||
listPlugin[i]->SetNumber(i);
|
||||
listPlugin[i]->SetPlugId(plugId);
|
||||
listPlugin[i]->SetPlugMenuId(plugMenuId);
|
||||
listPlugin[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listPlugin[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listPlugin[i]->SetAreaWidth(width);
|
||||
}
|
||||
listPlugin[i]->SetContainer(x, y, width, height);
|
||||
listPlugin[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
|
||||
if (!currentElement) return;
|
||||
currentPlugin = dynamic_cast<cCeMenuPlugin*>(currentElement);
|
||||
if (!currentPlugin) return;
|
||||
|
||||
currentPlugin->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
|
||||
currentPlugin->SetPlugId(plugId);
|
||||
currentPlugin->SetPlugMenuId(plugMenuId);
|
||||
currentPlugin->SetTokenContainer();
|
||||
currentPlugin->SetDetached();
|
||||
currentPlugin->Cache();
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
listPlugin[i]->SetCurrentElement(currentPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListPlugin::Set(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable) {
|
||||
if (!current)
|
||||
listPlugin[index]->StopScrolling();
|
||||
listPlugin[index]->SetCurrent(current);
|
||||
listPlugin[index]->ClearCurrentElement();
|
||||
listPlugin[index]->SetSelectable(selectable);
|
||||
listPlugin[index]->Set(tk);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* cViewListAudioTracks
|
||||
******************************************************************/
|
||||
cViewListAudioTracks::cViewListAudioTracks(void) {
|
||||
listAudioTracks = NULL;
|
||||
numTracks = 0;
|
||||
tokenContainer = NULL;
|
||||
}
|
||||
|
||||
cViewListAudioTracks::~cViewListAudioTracks(void) {
|
||||
delete[] listAudioTracks;
|
||||
delete tokenContainer;
|
||||
}
|
||||
|
||||
void cViewListAudioTracks::Close(void) {
|
||||
if (!listElements)
|
||||
return;
|
||||
for (int i = 0; i < numElements; i++) {
|
||||
delete listAudioTracks[i];
|
||||
}
|
||||
delete[] listAudioTracks;
|
||||
listAudioTracks = NULL;
|
||||
}
|
||||
|
||||
void cViewListAudioTracks::PreCache(void) {
|
||||
tokenContainer = new skindesignerapi::cTokenContainer();
|
||||
tokenContainer->DefineIntToken("{numelements}", 0);
|
||||
tokenContainer->CreateContainers();
|
||||
attribs->SetTokenContainer(tokenContainer);
|
||||
attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
|
||||
attribs->SetGlobals(globals);
|
||||
attribs->Cache();
|
||||
}
|
||||
|
||||
void cViewListAudioTracks::SetNumtracks(int numTracks) {
|
||||
this->numTracks = numTracks;
|
||||
tokenContainer->Clear();
|
||||
tokenContainer->AddIntToken(0, numTracks);
|
||||
}
|
||||
|
||||
void cViewListAudioTracks::SetTracks(const char * const *tracks) {
|
||||
if (numTracks <= 0)
|
||||
return;
|
||||
orientation = attribs->Orientation();
|
||||
eAlign align = attribs->Align();
|
||||
int x = attribs->X();
|
||||
int y = attribs->Y();
|
||||
int width = attribs->Width();
|
||||
int height = attribs->Height();
|
||||
|
||||
int step = 0;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
step = height / numTracks;
|
||||
} else {
|
||||
step = width / numTracks;
|
||||
}
|
||||
|
||||
int start = 0;
|
||||
if (align == eAlign::center) {
|
||||
if (orientation == eOrientation::vertical) {
|
||||
start = y + (height - numTracks * step) / 2;
|
||||
} else {
|
||||
start = x + (width - numTracks * step) / 2;
|
||||
}
|
||||
} else if (align == eAlign::bottom) {
|
||||
start = y + height - numTracks * step;
|
||||
} else if (align == eAlign::right) {
|
||||
start = x + width - numTracks * step;
|
||||
} else if (align == eAlign::top) {
|
||||
start = y;
|
||||
}
|
||||
|
||||
cLeAudioTracks *tpl = dynamic_cast<cLeAudioTracks*>(listElement);
|
||||
if (!tpl) return;
|
||||
|
||||
listAudioTracks = new cLeAudioTracks*[numTracks];
|
||||
listElements = new cListElement*[numTracks];
|
||||
int pos = start;
|
||||
|
||||
for (int i = 0; i < numTracks; i++) {
|
||||
listAudioTracks[i] = new cLeAudioTracks(*tpl);
|
||||
listElements[i] = listAudioTracks[i];
|
||||
listAudioTracks[i]->SetNumber(i);
|
||||
listAudioTracks[i]->SetTokenContainer();
|
||||
int x, y, width, height;
|
||||
if (orientation == eOrientation::vertical) {
|
||||
x = attribs->X();
|
||||
y = pos;
|
||||
width = attribs->Width();
|
||||
height = step;
|
||||
listAudioTracks[i]->SetAreaHeight(height);
|
||||
} else {
|
||||
x = pos;
|
||||
y = attribs->Y();
|
||||
width = step;
|
||||
height = attribs->Height();
|
||||
listAudioTracks[i]->SetAreaWidth(width);
|
||||
}
|
||||
listAudioTracks[i]->SetContainer(x, y, width, height);
|
||||
listAudioTracks[i]->Cache();
|
||||
pos += step;
|
||||
}
|
||||
for (int i=0; i < numTracks; i++) {
|
||||
listAudioTracks[i]->Set(tracks[i]);
|
||||
listAudioTracks[i]->SetSelectable(true);
|
||||
}
|
||||
}
|
||||
|
||||
void cViewListAudioTracks::SetCurrentTrack(int index) {
|
||||
for (int i = 0; i < numTracks; i++) {
|
||||
if (i != index) {
|
||||
listAudioTracks[i]->SetCurrent(false);
|
||||
listAudioTracks[i]->SetDirty();
|
||||
listAudioTracks[i]->StopScrolling();
|
||||
}
|
||||
}
|
||||
listAudioTracks[index]->SetCurrent(true);
|
||||
listAudioTracks[index]->SetDirty();
|
||||
}
|
||||
|
||||
void cViewListAudioTracks::Draw(void) {
|
||||
for (int i = 0; i < numTracks; i++) {
|
||||
if (listAudioTracks[i]->Parse()) {
|
||||
listAudioTracks[i]->Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
155
coreengine/viewlist.h
Normal file
155
coreengine/viewlist.h
Normal file
@@ -0,0 +1,155 @@
|
||||
#ifndef __VIEWLIST_H
|
||||
#define __VIEWLIST_H
|
||||
|
||||
#include "globals.h"
|
||||
#include "../libskindesignerapi/tokencontainer.h"
|
||||
#include "listelements.h"
|
||||
#include "area.h"
|
||||
|
||||
class cViewList {
|
||||
protected:
|
||||
int plugId;
|
||||
int plugMenuId;
|
||||
cViewListAttribs *attribs;
|
||||
cRect container;
|
||||
cGlobals *globals;
|
||||
int numElements;
|
||||
eOrientation orientation;
|
||||
cViewElement *listElement;
|
||||
cViewElement *currentElement;
|
||||
cListElement **listElements;
|
||||
virtual void Prepare(int start, int step) {};
|
||||
public:
|
||||
cViewList(void);
|
||||
virtual ~cViewList(void);
|
||||
void SetGlobals(cGlobals *globals);
|
||||
void SetContainer(int x, int y, int width, int height);
|
||||
void SetAttributes(vector<stringpair> &attributes);
|
||||
void SetPlugId(int id) { plugId = id; };
|
||||
void SetPlugMenuId(int id) { plugMenuId = id; };
|
||||
static cViewList *CreateViewList(const char *name);
|
||||
static cViewElement *CreateListElement(const char *name);
|
||||
static cViewElement *CreateCurrentElement(const char *name);
|
||||
void AddListElement(cViewElement *listElement);
|
||||
void AddCurrentElement(cViewElement *currentElement);
|
||||
virtual void PreCache(void);
|
||||
int NumItems(void);
|
||||
eOrientation Orientation(void);
|
||||
void Draw(eMenuCategory menuCat);
|
||||
void Clear(void);
|
||||
virtual void Close(void);
|
||||
void SetTransparency(int transparency);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
class cViewListDefault : public cViewList {
|
||||
private:
|
||||
cLeMenuDefault **listDefault;
|
||||
int avrgFontWidth;
|
||||
const cFont *listFont;
|
||||
int *colX;
|
||||
int *colWidths;
|
||||
const char *plugName;
|
||||
protected:
|
||||
void Prepare(int start, int step);
|
||||
public:
|
||||
cViewListDefault(void);
|
||||
virtual ~cViewListDefault(void);
|
||||
void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
|
||||
void SetPlugin(const char *plugName) { this->plugName = plugName; };
|
||||
void Set(const char *text, int index, bool current, bool selectable);
|
||||
const cFont *GetListFont(void);
|
||||
int GetListWidth(void);
|
||||
};
|
||||
|
||||
class cViewListMain : public cViewList {
|
||||
private:
|
||||
cLeMenuMain **listMain;
|
||||
cCeMenuMain *currentMain;
|
||||
protected:
|
||||
void Prepare(int start, int step);
|
||||
public:
|
||||
cViewListMain(void);
|
||||
virtual ~cViewListMain(void);
|
||||
void Set(const char *text, int index, bool current, bool selectable);
|
||||
const char *GetPlugin(void);
|
||||
};
|
||||
|
||||
class cViewListSchedules : public cViewList {
|
||||
private:
|
||||
cLeMenuSchedules **listSchedules;
|
||||
cCeMenuSchedules *currentSchedules;
|
||||
bool epgSearchFav;
|
||||
protected:
|
||||
void Prepare(int start, int step);
|
||||
public:
|
||||
cViewListSchedules(void);
|
||||
virtual ~cViewListSchedules(void);
|
||||
void IsEpgSearchFav(bool isFav) { epgSearchFav = isFav; };
|
||||
void Set(const cEvent *event, int index, bool current, bool selectable, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
|
||||
};
|
||||
|
||||
class cViewListTimers : public cViewList {
|
||||
private:
|
||||
cLeMenuTimers **listTimers;
|
||||
cCeMenuTimers *currentTimer;
|
||||
protected:
|
||||
void Prepare(int start, int step);
|
||||
public:
|
||||
cViewListTimers(void);
|
||||
virtual ~cViewListTimers(void);
|
||||
void Set(const cTimer *timer, int index, bool current, bool selectable);
|
||||
};
|
||||
|
||||
class cViewListChannels : public cViewList {
|
||||
private:
|
||||
cLeMenuChannels **listChannels;
|
||||
cCeMenuChannels *currentChannel;
|
||||
protected:
|
||||
void Prepare(int start, int step);
|
||||
public:
|
||||
cViewListChannels(void);
|
||||
virtual ~cViewListChannels(void);
|
||||
void Set(const cChannel *channel, int index, bool current, bool selectable, bool withProvider);
|
||||
};
|
||||
|
||||
class cViewListRecordings : public cViewList {
|
||||
private:
|
||||
cLeMenuRecordings **listRecordings;
|
||||
cCeMenuRecordings *currentRecording;
|
||||
protected:
|
||||
void Prepare(int start, int step);
|
||||
public:
|
||||
cViewListRecordings(void);
|
||||
virtual ~cViewListRecordings(void);
|
||||
void Set(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New);
|
||||
};
|
||||
|
||||
class cViewListPlugin : public cViewList {
|
||||
private:
|
||||
cLeMenuPlugin **listPlugin;
|
||||
cCeMenuPlugin *currentPlugin;
|
||||
protected:
|
||||
void Prepare(int start, int step);
|
||||
public:
|
||||
cViewListPlugin(void);
|
||||
virtual ~cViewListPlugin(void);
|
||||
void Set(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable);
|
||||
};
|
||||
|
||||
class cViewListAudioTracks : public cViewList {
|
||||
private:
|
||||
skindesignerapi::cTokenContainer *tokenContainer;
|
||||
int numTracks;
|
||||
cLeAudioTracks **listAudioTracks;
|
||||
public:
|
||||
cViewListAudioTracks(void);
|
||||
virtual ~cViewListAudioTracks(void);
|
||||
void Close(void);
|
||||
void PreCache(void);
|
||||
void SetNumtracks(int numTracks);
|
||||
void SetTracks(const char * const *tracks);
|
||||
void SetCurrentTrack(int index);
|
||||
void Draw(void);
|
||||
};
|
||||
#endif //__VIEWLIST_H
|
||||
744
coreengine/xmlparser.c
Normal file
744
coreengine/xmlparser.c
Normal file
@@ -0,0 +1,744 @@
|
||||
#include "xmlparser.h"
|
||||
#include "../config.h"
|
||||
#include "../extensions/helpers.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
cXmlParser::cXmlParser(void) {
|
||||
sdOsd = NULL;
|
||||
view = NULL;
|
||||
globals = NULL;
|
||||
skinSetup = NULL;
|
||||
}
|
||||
|
||||
cXmlParser::~cXmlParser() {
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC Functions
|
||||
*********************************************************************/
|
||||
bool cXmlParser::ReadView(cView *view, string xmlFile) {
|
||||
if (!view)
|
||||
return false;
|
||||
this->view = view;
|
||||
string xmlPath = GetPath(xmlFile);
|
||||
if (! ReadXMLFile(xmlPath.c_str()) )
|
||||
return false;
|
||||
if (! Validate() )
|
||||
return false;
|
||||
if (! SetDocument() )
|
||||
return false;
|
||||
if (! CheckNodeName( view->GetViewName() ))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ParseView(void) {
|
||||
if (!view)
|
||||
return false;
|
||||
vector<stringpair> rootAttribs = ParseAttributes();
|
||||
view->SetAttributes(rootAttribs);
|
||||
|
||||
cViewMenu *menuView = dynamic_cast<cViewMenu*>(view);
|
||||
cViewTracks *tracksView = dynamic_cast<cViewTracks*>(view);
|
||||
|
||||
if (!LevelDown())
|
||||
return false;
|
||||
|
||||
do {
|
||||
if (view->ValidViewElement(NodeName())) {
|
||||
ParseViewElement(NodeName());
|
||||
} else if (menuView) {
|
||||
if (menuView->ValidSubView(NodeName())) {
|
||||
ParseSubView(NodeName());
|
||||
} else if (view->ValidViewList(NodeName())) {
|
||||
ParseViewList();
|
||||
} else {
|
||||
esyslog("skindesigner: unknown node %s", NodeName());
|
||||
return false;
|
||||
}
|
||||
} else if (tracksView) {
|
||||
if (view->ValidViewList(NodeName())) {
|
||||
ParseViewList();
|
||||
} else {
|
||||
esyslog("skindesigner: unknown node %s", NodeName());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
esyslog("skindesigner: unknown view %s", NodeName());
|
||||
return false;
|
||||
}
|
||||
} while (NextNode());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ParsePluginView(void) {
|
||||
if (!view)
|
||||
return false;
|
||||
vector<stringpair> rootAttribs = ParseAttributes();
|
||||
view->SetAttributes(rootAttribs);
|
||||
|
||||
if (!LevelDown())
|
||||
return false;
|
||||
|
||||
do {
|
||||
if (CheckNodeName("viewelement")) {
|
||||
ParsePluginViewElement();
|
||||
} else if (CheckNodeName("grid")) {
|
||||
ParseGrid();
|
||||
} else if (CheckNodeName("tab")) {
|
||||
ParseViewTabPlugin();
|
||||
} else if (CheckNodeName("scrollbar")) {
|
||||
ParsePluginViewElement(true, false);
|
||||
} else if (CheckNodeName("tablabels")) {
|
||||
ParsePluginViewElement(false, true);
|
||||
} else {
|
||||
esyslog("skindesigner: unknown node %s in plugin view", NodeName());
|
||||
}
|
||||
} while (NextNode());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ReadPluginView(string templateName) {
|
||||
string xmlPath = GetPath(templateName);
|
||||
DeleteDocument();
|
||||
if (! ReadXMLFile(xmlPath.c_str()) )
|
||||
return false;
|
||||
if (! Validate() )
|
||||
return false;
|
||||
if (! SetDocument() )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ParsePluginView(string plugName, int plugId, int menuNumber, int menuType) {
|
||||
if (!view)
|
||||
return false;
|
||||
cViewMenu *menuView = dynamic_cast<cViewMenu*>(view);
|
||||
if (!menuView) {
|
||||
return false;
|
||||
}
|
||||
vector<pair<string, string> > attribs = ParseAttributes();
|
||||
|
||||
if (!LevelDown())
|
||||
return false;
|
||||
|
||||
cSubView *plugView = cViewMenu::CreatePluginview(plugName.c_str(), plugId, menuNumber, menuType);
|
||||
plugView->SetAttributes(attribs);
|
||||
menuView->AddPluginview(plugView);
|
||||
do {
|
||||
if (plugView->ValidViewElement(NodeName())) {
|
||||
ParseViewElement(NodeName(), plugView);
|
||||
} else if (plugView->ValidViewList(NodeName())) {
|
||||
ParseViewList(plugView);
|
||||
} else if (CheckNodeName("tab")) {
|
||||
ParseViewTab(plugView);
|
||||
} else {
|
||||
esyslog("skindesigner: error - unknown %s", NodeName());
|
||||
return false;
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ReadGlobals(cGlobals *globals, string xmlFile) {
|
||||
this->globals = globals;
|
||||
string xmlPath = GetPath(xmlFile);
|
||||
DeleteDocument();
|
||||
if (! ReadXMLFile(xmlPath.c_str()) )
|
||||
return false;
|
||||
if (! Validate() )
|
||||
return false;
|
||||
if (! SetDocument() )
|
||||
return false;
|
||||
if (! CheckNodeName("globals") )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ParseGlobals(void) {
|
||||
if (!LevelDown())
|
||||
return false;
|
||||
do {
|
||||
if (CheckNodeName("colors")) {
|
||||
ParseGlobalColors();
|
||||
} else if (CheckNodeName("variables")) {
|
||||
ParseGlobalVariables();
|
||||
} else if (CheckNodeName("fonts")) {
|
||||
ParseGlobalFonts();
|
||||
} else if (CheckNodeName("translations")) {
|
||||
ParseTranslations();
|
||||
}
|
||||
} while (NextNode());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string xmlFile) {
|
||||
this->skinSetup = skinSetup;
|
||||
if (! ReadXMLFile(xmlFile.c_str()) )
|
||||
return false;
|
||||
if (! Validate() )
|
||||
return false;
|
||||
if (! SetDocument() )
|
||||
return false;
|
||||
if (! CheckNodeName("setup") )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ParseSkinSetup(string skin) {
|
||||
if (!LevelDown())
|
||||
return false;
|
||||
do {
|
||||
if (CheckNodeName("menu")) {
|
||||
ParseSetupMenu();
|
||||
} else if (CheckNodeName("translations")) {
|
||||
ParseTranslations();
|
||||
}
|
||||
} while (NextNode());
|
||||
return true;
|
||||
}
|
||||
/*********************************************************************
|
||||
* PRIVATE Functions
|
||||
*********************************************************************/
|
||||
bool cXmlParser::ParseSubView(string name) {
|
||||
if (!view)
|
||||
return false;
|
||||
cViewMenu *menuView = dynamic_cast<cViewMenu*>(view);
|
||||
if (!menuView) {
|
||||
return false;
|
||||
}
|
||||
vector<pair<string, string> > attribs = ParseAttributes();
|
||||
|
||||
if (!LevelDown())
|
||||
return false;
|
||||
|
||||
cSubView *subView = cViewMenu::CreateSubview(name.c_str());
|
||||
subView->SetAttributes(attribs);
|
||||
menuView->AddSubview(name.c_str(), subView);
|
||||
|
||||
do {
|
||||
if (subView->ValidViewElement(NodeName())) {
|
||||
ParseViewElement(NodeName(), subView);
|
||||
} else if (subView->ValidViewList(NodeName())) {
|
||||
ParseViewList(subView);
|
||||
} else if (CheckNodeName("tab")) {
|
||||
ParseViewTab(subView);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
void cXmlParser::ParseViewElement(string name, cView *subView) {
|
||||
if (!view)
|
||||
return;
|
||||
const char *viewElementName = NodeName();
|
||||
vector<stringpair> attributes = ParseAttributes();
|
||||
|
||||
if (!LevelDown())
|
||||
return;
|
||||
|
||||
//correct detailheader name
|
||||
if (subView) {
|
||||
if (!strcmp(subView->GetViewName(), "menudetailedepg") && !name.compare("detailheader")) {
|
||||
name = "detailheaderepg";
|
||||
} else if (!strcmp(subView->GetViewName(), "menudetailedrecording") && !name.compare("detailheader")) {
|
||||
name = "detailheaderrec";
|
||||
} else if (startswith(subView->GetViewName(), "menuplugin") && !name.compare("detailheader")) {
|
||||
name = "detailheaderplugin";
|
||||
}
|
||||
}
|
||||
|
||||
cViewElement *viewElement = cViewElement::CreateViewElement(name.c_str(), view->GetViewName());
|
||||
if (!viewElement) {
|
||||
LevelUp();
|
||||
return;
|
||||
}
|
||||
|
||||
viewElement->SetOsd(sdOsd);
|
||||
viewElement->SetAttributes(attributes);
|
||||
do {
|
||||
if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) {
|
||||
esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName());
|
||||
continue;
|
||||
}
|
||||
cAreaNode *area = NULL;
|
||||
if (CheckNodeName("area") || CheckNodeName("areascroll")) {
|
||||
area = ParseArea();
|
||||
} else {
|
||||
area = ParseAreaContainer();
|
||||
}
|
||||
viewElement->AddArea(area);
|
||||
} while (NextNode());
|
||||
|
||||
LevelUp();
|
||||
|
||||
if (subView)
|
||||
subView->AddViewElement(viewElementName, viewElement);
|
||||
else
|
||||
view->AddViewElement(viewElementName, viewElement);
|
||||
|
||||
}
|
||||
|
||||
void cXmlParser::ParsePluginViewElement(bool isScrollbar, bool isTabLabels) {
|
||||
if (!view)
|
||||
return;
|
||||
cViewPlugin *pluginView = dynamic_cast<cViewPlugin*>(view);
|
||||
if (!pluginView)
|
||||
return;
|
||||
|
||||
vector<stringpair> attributes = ParseAttributes();
|
||||
|
||||
if (!LevelDown())
|
||||
return;
|
||||
|
||||
cViewElement *viewElement = NULL;
|
||||
if (isScrollbar) {
|
||||
viewElement = new cVeDmScrollbar();
|
||||
} else if (isTabLabels) {
|
||||
viewElement = new cVeDmTablabels();
|
||||
} else {
|
||||
viewElement = new cVePlugin();
|
||||
}
|
||||
|
||||
viewElement->SetOsd(sdOsd);
|
||||
viewElement->SetAttributes(attributes);
|
||||
do {
|
||||
if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) {
|
||||
esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName());
|
||||
continue;
|
||||
}
|
||||
cAreaNode *area = NULL;
|
||||
if (CheckNodeName("area") || CheckNodeName("areascroll")) {
|
||||
area = ParseArea();
|
||||
} else {
|
||||
area = ParseAreaContainer();
|
||||
}
|
||||
viewElement->AddArea(area);
|
||||
} while (NextNode());
|
||||
|
||||
LevelUp();
|
||||
|
||||
if (isScrollbar) {
|
||||
pluginView->AddScrollbar(dynamic_cast<cVeDmScrollbar*>(viewElement));
|
||||
} else if (isTabLabels) {
|
||||
pluginView->AddTablabels(dynamic_cast<cVeDmTablabels*>(viewElement));
|
||||
} else {
|
||||
pluginView->AddViewElement(dynamic_cast<cVePlugin*>(viewElement));
|
||||
}
|
||||
}
|
||||
|
||||
void cXmlParser::ParseViewList(cView *subView) {
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
const char *name = NULL;
|
||||
if (subView)
|
||||
name = subView->GetViewName();
|
||||
else
|
||||
name = view->GetViewName();
|
||||
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
cViewList *viewList = cViewList::CreateViewList(name);
|
||||
viewList->SetAttributes(attribs);
|
||||
|
||||
if (!LevelDown())
|
||||
return;
|
||||
|
||||
do {
|
||||
if (CheckNodeName("currentelement")) {
|
||||
cViewElement *currentElement = cViewList::CreateCurrentElement(name);
|
||||
currentElement->SetOsd(sdOsd);
|
||||
vector<stringpair> attribsList = ParseAttributes();
|
||||
currentElement->SetAttributes(attribsList);
|
||||
if (!LevelDown())
|
||||
continue;
|
||||
do {
|
||||
if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) {
|
||||
esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName());
|
||||
continue;
|
||||
}
|
||||
cAreaNode *area = NULL;
|
||||
if (CheckNodeName("area") || CheckNodeName("areascroll")) {
|
||||
area = ParseArea();
|
||||
} else {
|
||||
area = ParseAreaContainer();
|
||||
}
|
||||
currentElement->AddArea(area);
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
viewList->AddCurrentElement(currentElement);
|
||||
} else if (CheckNodeName("listelement")) {
|
||||
cViewElement *listElement = cViewList::CreateListElement(name);
|
||||
listElement->SetOsd(sdOsd);
|
||||
vector<stringpair> attribsList = ParseAttributes();
|
||||
listElement->SetAttributes(attribsList);
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) {
|
||||
esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName());
|
||||
continue;
|
||||
}
|
||||
cAreaNode *area = NULL;
|
||||
if (CheckNodeName("area") || CheckNodeName("areascroll")) {
|
||||
area = ParseArea();
|
||||
} else {
|
||||
area = ParseAreaContainer();
|
||||
}
|
||||
listElement->AddArea(area);
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
viewList->AddListElement(listElement);
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
|
||||
if (subView)
|
||||
subView->AddViewList(viewList);
|
||||
else
|
||||
view->AddViewList(viewList);
|
||||
|
||||
}
|
||||
|
||||
void cXmlParser::ParseViewTab(cView *subView) {
|
||||
if (!view || !subView)
|
||||
return;
|
||||
cSubView *menuSubView = dynamic_cast<cSubView*>(subView);
|
||||
if (!menuSubView) {
|
||||
return;
|
||||
}
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
cArea *tab = new cArea();
|
||||
tab->SetOsd(sdOsd);
|
||||
tab->SetTab();
|
||||
tab->SetAttributes(attribs);
|
||||
ParseFunctionCalls(tab);
|
||||
menuSubView->AddTab(tab);
|
||||
}
|
||||
|
||||
void cXmlParser::ParseViewTabPlugin(void) {
|
||||
if (!view)
|
||||
return;
|
||||
cViewPlugin *plugView = dynamic_cast<cViewPlugin*>(view);
|
||||
if (!plugView) {
|
||||
return;
|
||||
}
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
cArea *tab = new cArea();
|
||||
tab->SetOsd(sdOsd);
|
||||
tab->SetTab();
|
||||
tab->SetAttributes(attribs);
|
||||
ParseFunctionCalls(tab);
|
||||
plugView->AddTab(tab);
|
||||
}
|
||||
|
||||
void cXmlParser::ParseGrid(void) {
|
||||
if (!view)
|
||||
return;
|
||||
cViewPlugin *pluginView = dynamic_cast<cViewPlugin*>(view);
|
||||
if (!pluginView)
|
||||
return;
|
||||
|
||||
vector<stringpair> attributes = ParseAttributes();
|
||||
|
||||
if (!LevelDown())
|
||||
return;
|
||||
|
||||
cViewGrid *viewGrid = new cViewGrid();
|
||||
viewGrid->SetAttributes(attributes);
|
||||
cGridElement *gridElement = new cGridElement();
|
||||
gridElement->SetOsd(sdOsd);
|
||||
|
||||
do {
|
||||
if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) {
|
||||
esyslog("skindesigner: invalid tag \"%s\" in grid", NodeName());
|
||||
continue;
|
||||
}
|
||||
cAreaNode *area = NULL;
|
||||
if (CheckNodeName("area") || CheckNodeName("areascroll")) {
|
||||
area = ParseArea();
|
||||
} else {
|
||||
area = ParseAreaContainer();
|
||||
}
|
||||
gridElement->AddArea(area);
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
|
||||
viewGrid->AddGridElement(gridElement);
|
||||
pluginView->AddViewGrid(viewGrid);
|
||||
}
|
||||
|
||||
cArea *cXmlParser::ParseArea(void) {
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
cArea *area = new cArea();
|
||||
area->SetOsd(sdOsd);
|
||||
if (CheckNodeName("areascroll")) {
|
||||
area->SetScrolling();
|
||||
}
|
||||
area->SetAttributes(attribs);
|
||||
ParseFunctionCalls(area);
|
||||
return area;
|
||||
}
|
||||
|
||||
cAreaContainer *cXmlParser::ParseAreaContainer(void) {
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
|
||||
cAreaContainer *areaContainer = new cAreaContainer();
|
||||
areaContainer->SetAttributes(attribs);
|
||||
|
||||
if (!LevelDown())
|
||||
return areaContainer;
|
||||
do {
|
||||
if (!CheckNodeName("area") && !CheckNodeName("areascroll")) {
|
||||
esyslog("skindesigner: invalid tag \"%s\" in areacontainer", NodeName());
|
||||
continue;
|
||||
}
|
||||
cArea *area = ParseArea();
|
||||
areaContainer->AddArea(area);
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
return areaContainer;
|
||||
}
|
||||
|
||||
void cXmlParser::ParseFunctionCalls(cArea *area) {
|
||||
if (!view)
|
||||
return;
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (CheckNodeName("loop")) {
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
cFunction *f = area->AddFunction(NodeName(), attribs);
|
||||
cFuncLoop *loopFunc = dynamic_cast<cFuncLoop*>(f);
|
||||
if (!loopFunc)
|
||||
continue;
|
||||
ParseLoopFunctionCalls(area, loopFunc);
|
||||
} else if (area->ValidFunction(NodeName())) {
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
area->AddFunction(NodeName(), attribs);
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
}
|
||||
|
||||
void cXmlParser::ParseLoopFunctionCalls(cArea *area, cFuncLoop *loopFunc) {
|
||||
if (!view)
|
||||
return;
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (area->ValidFunction(NodeName())) {
|
||||
vector<stringpair> attribs = ParseAttributes();
|
||||
area->AddFunction(NodeName(), attribs, loopFunc);
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
}
|
||||
|
||||
void cXmlParser::ParseGlobalColors(void) {
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (!CheckNodeName("color")) {
|
||||
continue;
|
||||
}
|
||||
string attributeName = "name";
|
||||
string colorName = "";
|
||||
string colorValue = "";
|
||||
bool ok = GetAttribute(attributeName, colorName);
|
||||
if (ok) {
|
||||
ok = GetNodeValue(colorValue);
|
||||
if (ok)
|
||||
InsertColor(colorName, colorValue);
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
}
|
||||
|
||||
void cXmlParser::InsertColor(string name, string value) {
|
||||
if (value.size() != 8)
|
||||
return;
|
||||
std::stringstream str;
|
||||
str << value;
|
||||
tColor colVal;
|
||||
str >> std::hex >> colVal;
|
||||
globals->AddColor(name, colVal);
|
||||
}
|
||||
|
||||
void cXmlParser::ParseGlobalVariables(void) {
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (!CheckNodeName("var")) {
|
||||
continue;
|
||||
}
|
||||
string attributeName = "name";
|
||||
string attributeType = "type";
|
||||
string varName = "";
|
||||
string varType = "";
|
||||
string varValue = "";
|
||||
|
||||
bool ok1 = GetAttribute(attributeName, varName);
|
||||
bool ok2 = GetAttribute(attributeType, varType);
|
||||
|
||||
if (ok1 && ok2) {
|
||||
bool ok = GetNodeValue(varValue);
|
||||
if (ok)
|
||||
InsertVariable(varName, varType, varValue);
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
}
|
||||
|
||||
void cXmlParser::InsertVariable(string name, string type, string value) {
|
||||
if (!type.compare("int")) {
|
||||
int val = atoi(value.c_str());
|
||||
globals->AddInt(name, val);
|
||||
} else if (!type.compare("double")) {
|
||||
globals->AddDouble(name, value);
|
||||
} else if (!type.compare("string")) {
|
||||
globals->AddString(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
void cXmlParser::ParseGlobalFonts(void) {
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (!CheckNodeName("font")) {
|
||||
continue;
|
||||
}
|
||||
string attributeName = "name";
|
||||
string fontName = "";
|
||||
string fontValue = "";
|
||||
|
||||
bool ok = GetAttribute(attributeName, fontName);
|
||||
if (ok) {
|
||||
ok = GetNodeValue(fontValue);
|
||||
if (ok) {
|
||||
globals->AddFont(fontName, fontValue);
|
||||
}
|
||||
}
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
}
|
||||
|
||||
void cXmlParser::ParseTranslations(void) {
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (!CheckNodeName("token")) {
|
||||
continue;
|
||||
}
|
||||
string attributeName = "name";
|
||||
string tokenName = "";
|
||||
|
||||
if (!GetAttribute(attributeName, tokenName))
|
||||
continue;
|
||||
|
||||
if (!LevelDown())
|
||||
continue;
|
||||
|
||||
stringmap tokenTranslations;
|
||||
do {
|
||||
if (!CheckNodeName("trans")) {
|
||||
continue;
|
||||
}
|
||||
string attributeName = "lang";
|
||||
string language = "";
|
||||
if (!GetAttribute(attributeName, language))
|
||||
continue;
|
||||
string translation = "";
|
||||
if (!GetNodeValue(translation))
|
||||
continue;
|
||||
tokenTranslations.insert(stringpair(language, translation));
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
|
||||
if (globals) {
|
||||
globals->AddTranslation(tokenName, tokenTranslations);
|
||||
} else if (skinSetup) {
|
||||
skinSetup->SetTranslation(tokenName, tokenTranslations);
|
||||
}
|
||||
|
||||
} while (NextNode());
|
||||
LevelUp();
|
||||
}
|
||||
|
||||
void cXmlParser::ParseSetupMenu(void) {
|
||||
if (!skinSetup)
|
||||
return;
|
||||
if (!LevelDown())
|
||||
return;
|
||||
do {
|
||||
if (CheckNodeName("parameter")) {
|
||||
ParseSetupParameter();
|
||||
} else if (CheckNodeName("submenu")) {
|
||||
string attributeName = "name";
|
||||
string subMenuName = "";
|
||||
string attributeDisplayText = "displaytext";
|
||||
string subDisplayText = "";
|
||||
GetAttribute(attributeName, subMenuName);
|
||||
GetAttribute(attributeDisplayText, subDisplayText);
|
||||
skinSetup->SetSubMenu(subMenuName, subDisplayText);
|
||||
ParseSetupMenu();
|
||||
}
|
||||
} while (NextNode());
|
||||
skinSetup->SubMenuDone();
|
||||
LevelUp();
|
||||
}
|
||||
|
||||
void cXmlParser::ParseSetupParameter(void) {
|
||||
if (!skinSetup)
|
||||
return;
|
||||
string attributeType = "type";
|
||||
string paramType = "";
|
||||
string attributeName = "name";
|
||||
string paramName = "";
|
||||
string attributeDisplayText = "displaytext";
|
||||
string paramDisplayText = "";
|
||||
string attributeHelpText = "helptext";
|
||||
string paramHelpText = "";
|
||||
string attributeMin = "min";
|
||||
string paramMin = "";
|
||||
string attributeMax = "max";
|
||||
string paramMax = "";
|
||||
string paramValue = "";
|
||||
string attributeOptions = "options";
|
||||
string paramOptions="";
|
||||
|
||||
GetAttribute(attributeType, paramType);
|
||||
GetAttribute(attributeName, paramName);
|
||||
GetAttribute(attributeDisplayText, paramDisplayText);
|
||||
GetAttribute(attributeHelpText, paramHelpText);
|
||||
GetAttribute(attributeMin, paramMin);
|
||||
GetAttribute(attributeMax, paramMax);
|
||||
GetAttribute(attributeOptions, paramOptions);
|
||||
GetNodeValue(paramValue);
|
||||
|
||||
skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramHelpText, paramMin, paramMax, paramValue, paramOptions);
|
||||
}
|
||||
|
||||
string cXmlParser::GetPath(string xmlFile) {
|
||||
string activeSkin = Setup.OSDSkin;
|
||||
string activeTheme = Setup.OSDTheme;
|
||||
string path = "";
|
||||
if (!xmlFile.compare("globals.xml")) {
|
||||
path = *cString::sprintf("%s%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str());
|
||||
} else if (!xmlFile.compare("theme.xml")) {
|
||||
path = *cString::sprintf("%s%s/themes/%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), activeTheme.c_str(), xmlFile.c_str());
|
||||
} else if (!xmlFile.compare("setup.xml")) {
|
||||
path = *cString::sprintf("%s%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str());
|
||||
} else {
|
||||
path = *cString::sprintf("%s%s/xmlfiles/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str());
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
72
coreengine/xmlparser.h
Normal file
72
coreengine/xmlparser.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef __XMLPARSER_H
|
||||
#define __XMLPARSER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vdr/plugin.h>
|
||||
#include "../extensions/libxmlwrapper.h"
|
||||
#include "osdwrapper.h"
|
||||
#include "view.h"
|
||||
#include "viewlist.h"
|
||||
#include "../extensions/skinsetup.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// --- cXmlParser -------------------------------------------------------------
|
||||
|
||||
class cXmlParser : public cLibXMLWrapper {
|
||||
private:
|
||||
cSdOsd *sdOsd;
|
||||
cView *view;
|
||||
cGlobals *globals;
|
||||
cSkinSetup *skinSetup;
|
||||
//parsing views
|
||||
bool ParseSubView(string name);
|
||||
void ParseViewElement(string name, cView *subView = NULL);
|
||||
void ParsePluginViewElement(bool isScrollbar = false, bool isTabLabels = false);
|
||||
void ParseViewList(cView *subView = NULL);
|
||||
void ParseViewTab(cView *subView);
|
||||
void ParseViewTabPlugin(void);
|
||||
void ParseGrid(void);
|
||||
cArea *ParseArea(void);
|
||||
cAreaContainer *ParseAreaContainer(void);
|
||||
void ParseFunctionCalls(cArea *area);
|
||||
void ParseLoopFunctionCalls(cArea *area, cFuncLoop *loopFunc);
|
||||
//parsing globals
|
||||
void ParseGlobalColors(void);
|
||||
void InsertColor(string name, string value);
|
||||
void ParseGlobalVariables(void);
|
||||
void InsertVariable(string name, string type, string value);
|
||||
void ParseGlobalFonts(void);
|
||||
void ParseTranslations(void);
|
||||
//parsing skin setup
|
||||
void ParseSetupMenu(void);
|
||||
void ParseSetupParameter(void);
|
||||
//helpers
|
||||
string GetPath(string xmlFile);
|
||||
public:
|
||||
cXmlParser(void);
|
||||
virtual ~cXmlParser(void);
|
||||
void SetOsd(cSdOsd *osd) { sdOsd = osd; };
|
||||
//reading views
|
||||
bool ReadView(cView *view, string xmlFile);
|
||||
bool ParseView(void);
|
||||
//Parse advanced plugin view
|
||||
bool ParsePluginView(void);
|
||||
//reading basic plugin menu views
|
||||
bool ReadPluginView(string templateName);
|
||||
bool ParsePluginView(string plugName, int plugId, int menuNumber, int menuType);
|
||||
//reading globals
|
||||
bool ReadGlobals(cGlobals *globals, string xmlFile);
|
||||
bool ParseGlobals(void);
|
||||
//reading skin setups
|
||||
bool ReadSkinSetup(cSkinSetup *skinSetup, string xmlFile);
|
||||
bool ParseSkinSetup(string skin);
|
||||
};
|
||||
|
||||
#endif //__XMLPARSER_H
|
||||
Reference in New Issue
Block a user