possibility to move viewelements when starting view

This commit is contained in:
louis 2015-05-03 11:22:01 +02:00
parent 918a331de3
commit c5edc10fbd
11 changed files with 168 additions and 20 deletions

View File

@ -307,3 +307,5 @@ Version 0.4.3
- fixed bug that tokens in image pathes are not replaced correctly - fixed bug that tokens in image pathes are not replaced correctly
Version 0.4.4 Version 0.4.4
- feature: possibility to move viewelements when starting view

View File

@ -96,6 +96,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
mode CDATA #IMPLIED mode CDATA #IMPLIED
@ -106,6 +109,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -115,6 +121,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -124,6 +133,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -133,6 +145,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -148,6 +163,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >

View File

@ -63,6 +63,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -72,6 +75,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -81,6 +87,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
mode CDATA #IMPLIED mode CDATA #IMPLIED
@ -91,6 +100,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -100,6 +112,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -109,6 +124,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -118,6 +136,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -127,6 +148,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -136,6 +160,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -145,6 +172,9 @@
detached CDATA #IMPLIED detached CDATA #IMPLIED
delay CDATA #IMPLIED delay CDATA #IMPLIED
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >

View File

@ -20,6 +20,7 @@ cPixmapContainer::cPixmapContainer(int numPixmaps) {
mutex.Unlock(); mutex.Unlock();
checkRunning = false; checkRunning = false;
fadeTime = 0; fadeTime = 0;
shiftTime = 0;
deleteOsdOnExit = false; deleteOsdOnExit = false;
} }
@ -122,7 +123,7 @@ void cPixmapContainer::CreatePixmap(int num, int Layer, const cRect &ViewPort, c
if (!pixmaps[num]) if (!pixmaps[num])
return; return;
pixmaps[num]->Fill(clrTransparent); pixmaps[num]->Fill(clrTransparent);
if (pixContainerInit && fadeTime) { if (pixContainerInit && (fadeTime || shiftTime)) {
pixmaps[num]->SetAlpha(0); pixmaps[num]->SetAlpha(0);
} else if (pixmapsTransparency[num] > 0) { } else if (pixmapsTransparency[num] > 0) {
int alpha = (100 - pixmapsTransparency[num])*255/100; int alpha = (100 - pixmapsTransparency[num])*255/100;
@ -256,6 +257,16 @@ void cPixmapContainer::Pos(int num, cPoint &pos) {
pos.SetY(pixmaps[num]->ViewPort().Y()); pos.SetY(pixmaps[num]->ViewPort().Y());
} }
cRect cPixmapContainer::ViewPort(int num) {
cRect vp;
if (checkRunning && !Running())
return vp;
cMutexLock MutexLock(&mutex);
if (!pixmaps[num])
return vp;
return pixmaps[num]->ViewPort();
}
int cPixmapContainer::Width(int num) { int cPixmapContainer::Width(int num) {
if (checkRunning && !Running()) if (checkRunning && !Running())
return 0; return 0;
@ -331,8 +342,13 @@ void cPixmapContainer::SetDrawPortPoint(int num, const cPoint &Point) {
****************************************************************************/ ****************************************************************************/
void cPixmapContainer::FadeIn(void) { void cPixmapContainer::FadeIn(void) {
if (!fadeTime) if (!fadeTime) {
for (int i = 0; i < numPixmaps; i++) {
if (PixmapExists(i))
SetAlpha(i, ALPHA_OPAQUE);
}
return; return;
}
uint64_t Start = cTimeMs::Now(); uint64_t Start = cTimeMs::Now();
int FadeFrameTime = fadeTime / 10; int FadeFrameTime = fadeTime / 10;
while (Running()) { while (Running()) {
@ -386,6 +402,49 @@ void cPixmapContainer::FadeOut(void) {
} }
} }
void cPixmapContainer::ShiftIn(void) {
if (shiftTime < 1)
return;
cPoint destPos[numPixmaps];
for (int i = 0; i < numPixmaps; i++) {
if (!PixmapExists(i))
continue;
cPoint pos;
Pos(i, pos);
destPos[i] = pos;
cRect r = ViewPort(i);
r.SetPoint(startPos);
SetViewPort(i, r);
SetAlpha(i, ALPHA_OPAQUE);
}
DoFlush();
int frames = shiftTime / 20;
if (frames <= 0) frames = 1;
uint64_t Start = cTimeMs::Now();
int frameTime = shiftTime / frames;
while (true) {
uint64_t Now = cTimeMs::Now();
double t = min(double(Now - Start) / shiftTime, 1.0);
for (int i = 0; i < numPixmaps; i++) {
if (!PixmapExists(i))
continue;
int x = startPos.X() + t * (destPos[i].X() - startPos.X());
int y = startPos.Y() + t * (destPos[i].Y() - startPos.Y());
cRect r = ViewPort(i);
r.SetPoint(x, y);
SetViewPort(i, r);
}
DoFlush();
int Delta = cTimeMs::Now() - Now;
if (Delta < frameTime)
cCondWait::SleepMs(frameTime - Delta);
if ((int)(Now - Start) > shiftTime)
break;
}
}
/***************************************** /*****************************************
* scrollSpeed: 1 slow * scrollSpeed: 1 slow
* 2 medium * 2 medium

View File

@ -23,6 +23,8 @@ private:
int *pixmapsLayer; int *pixmapsLayer;
bool checkRunning; bool checkRunning;
int fadeTime; int fadeTime;
int shiftTime;
cPoint startPos;
bool deleteOsdOnExit; bool deleteOsdOnExit;
protected: protected:
void SetInitFinished(void) { pixContainerInit = false; }; void SetInitFinished(void) { pixContainerInit = false; };
@ -46,6 +48,7 @@ protected:
void SetViewPort(int num, const cRect &rect); void SetViewPort(int num, const cRect &rect);
int Layer(int num); int Layer(int num);
void Pos(int num, cPoint &pos); void Pos(int num, cPoint &pos);
cRect ViewPort(int num);
int Width(int num); int Width(int num);
int Height(int num); int Height(int num);
int DrawportWidth(int num); int DrawportWidth(int num);
@ -57,8 +60,12 @@ protected:
void UnsetCheckRunning(void) { checkRunning = false; }; void UnsetCheckRunning(void) { checkRunning = false; };
//HELPERS -- do not access the pixmaps array directly, use wrapper functions //HELPERS -- do not access the pixmaps array directly, use wrapper functions
void SetFadeTime(int fade) { fadeTime = fade; }; void SetFadeTime(int fade) { fadeTime = fade; };
void SetShiftTime(int shift) { shiftTime = shift; };
void SetStartPos(int posX, int posY) { startPos.SetX(posX); startPos.SetY(posY); };
bool IsAnimated(void) { return (shiftTime > 0); };
void FadeIn(void); void FadeIn(void);
void FadeOut(void); void FadeOut(void);
void ShiftIn(void);
void ScrollVertical(int num, int scrollDelay, int scrollSpeed); void ScrollVertical(int num, int scrollDelay, int scrollSpeed);
void ScrollHorizontal(int num, int scrollDelay, int scrollSpeed, int scrollMode); void ScrollHorizontal(int num, int scrollDelay, int scrollSpeed, int scrollMode);
void CancelSave(void); void CancelSave(void);

View File

@ -73,6 +73,12 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
p.first = ptDetached; p.first = ptDetached;
} else if (!name.compare("fadetime")) { } else if (!name.compare("fadetime")) {
p.first = ptFadeTime; p.first = ptFadeTime;
} else if (!name.compare("shifttime")) {
p.first = ptShiftTime;
} else if (!name.compare("startx")) {
p.first = ptStartX;
} else if (!name.compare("starty")) {
p.first = ptStartY;
} else if (!name.compare("imagetype")) { } else if (!name.compare("imagetype")) {
p.first = ptImageType; p.first = ptImageType;
} else if (!name.compare("path")) { } else if (!name.compare("path")) {
@ -230,7 +236,10 @@ bool cTemplateFunction::CalculateParameters(void) {
case ptHeight: case ptHeight:
case ptMenuItemWidth: case ptMenuItemWidth:
case ptFadeTime: case ptFadeTime:
case ptShiftTime:
case ptDelay: case ptDelay:
case ptStartX:
case ptStartY:
case ptFontSize: case ptFontSize:
case ptLayer: case ptLayer:
case ptTransparency: case ptTransparency:
@ -780,6 +789,7 @@ bool cTemplateFunction::SetNumericParameter(eParamType type, string value) {
param.SetGlobals(globals); param.SetGlobals(globals);
switch (type) { switch (type) {
case ptX: case ptX:
case ptStartX:
case ptWidth: case ptWidth:
case ptMenuItemWidth: case ptMenuItemWidth:
case ptScaleTvX: case ptScaleTvX:
@ -787,6 +797,7 @@ bool cTemplateFunction::SetNumericParameter(eParamType type, string value) {
param.SetHorizontal(); param.SetHorizontal();
break; break;
case ptY: case ptY:
case ptStartY:
case ptHeight: case ptHeight:
case ptScaleTvY: case ptScaleTvY:
case ptScaleTvHeight: case ptScaleTvHeight:
@ -1591,6 +1602,15 @@ string cTemplateFunction::GetParamName(eParamType pt) {
case ptFadeTime: case ptFadeTime:
name = "Fade Time"; name = "Fade Time";
break; break;
case ptShiftTime:
name = "Shift Time";
break;
case ptStartX:
name = "Startpos X";
break;
case ptStartY:
name = "Startpos Y";
break;
case ptDelay: case ptDelay:
name = "Delay"; name = "Delay";
break; break;

View File

@ -51,6 +51,9 @@ enum eParamType {
ptMenuItemWidth, ptMenuItemWidth,
ptDetached, ptDetached,
ptFadeTime, ptFadeTime,
ptShiftTime,
ptStartX,
ptStartY,
ptDelay, ptDelay,
ptImageType, ptImageType,
ptPath, ptPath,

View File

@ -667,6 +667,9 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("detached"); attributes.insert("detached");
attributes.insert("delay"); attributes.insert("delay");
attributes.insert("fadetime"); attributes.insert("fadetime");
attributes.insert("shifttime");
attributes.insert("startx");
attributes.insert("starty");
attributes.insert("name"); attributes.insert("name");
attributes.insert("condition"); attributes.insert("condition");
attributes.insert("mode"); attributes.insert("mode");

View File

@ -186,7 +186,7 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices condition="{showdevices}" detached="true" delay="100" fadetime="{fadetime}"> <devices condition="{showdevices}" detached="true" delay="300" shifttime="500" startx="100%" starty="30%">
<area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1" background="true"> <area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1" background="true">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>
@ -224,20 +224,20 @@
{pressure} pressure in HPo {pressure} pressure in HPo
{ozone} ozone value in DU {ozone} ozone value in DU
--> -->
<currentweather> <currentweather detached="true" delay="100" shifttime="300" startx="100%" starty="15%" >
<area background="true" x="70%" y="15%" width="30%" height="13%" layer="1"> <area background="true" x="70%" y="15%" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" /> <fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" /> <drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area> </area>
<area x="70%" y="15%" width="13%" height="13%" layer="2"> <area x="70%" y="15%" width="30%" height="13%" layer="2">
<drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/> <drawimage name="weathericon" imagetype="icon" path="{icon}" x="0.43*{areawidth}/2 - {width(weathericon)}/2" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/>
</area> </area>
<area x="85%" y="15%" width="13%" height="13%" layer="2"> <area x="70%" y="15%" width="30%" height="13%" layer="2">
<drawtext x="0" y="0" font="{light}" fontsize="25%" color="{clrWhite}" text="{mintemperature}°C" /> <drawtext x="50%" y="0" font="{light}" fontsize="25%" color="{clrWhite}" text="{mintemperature}°C" />
<drawtext x="0" y="75%" font="{light}" fontsize="25%" color="{clrWhite}" text="{maxtemperature}°C" /> <drawtext x="50%" y="75%" font="{light}" fontsize="25%" color="{clrWhite}" text="{maxtemperature}°C" />
</area> </area>
<area x="85%" y="15%" width="13%" height="13%" layer="3"> <area x="70%" y="15%" width="30%" height="13%" layer="3">
<drawtext align="right" valign="center" font="{light}" fontsize="60%" color="{clrWhite}" text="{temperature}°C" /> <drawtext x="50%" valign="center" font="{light}" fontsize="60%" color="{clrWhite}" text="{temperature}°C" />
</area> </area>
</currentweather> </currentweather>
@ -277,17 +277,17 @@
{monthnameshort} 3 letter abbrivation of month name {monthnameshort} 3 letter abbrivation of month name
{year} year in yyyy {year} year in yyyy
--> -->
<datetime> <datetime detached="true" delay="100" shifttime="300" startx="100%" starty="0">
<area background="true" x="70%" y="0" width="30%" height="13%" layer="1"> <area background="true" x="70%" y="0" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" /> <fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" /> <drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area> </area>
<area x="70%" y="0" width="13%" height="13%" layer="2"> <area x="70%" y="0" width="30%" height="13%" layer="2">
<drawtext align="right" y="0" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname}" /> <drawtext align="right" y="0" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname} " />
<drawtext align="right" y="48%" font="{light}" fontsize="50%" color="{clrWhite}" text="{day}. {monthnameshort}" /> <drawtext align="right" y="48%" font="{light}" fontsize="50%" color="{clrWhite}" text="{day}. {monthnameshort} " />
</area> </area>
<area x="85%" y="0" width="13%" height="13%" layer="2"> <area x="70%" y="0" width="30%" height="13%" layer="2">
<drawtext align="center" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{time}" /> <drawtext x="1%" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{time}" />
</area> </area>
</datetime> </datetime>
<!-- Available Variables message: <!-- Available Variables message:

View File

@ -121,7 +121,7 @@
{timers[channellogoexists]} true if channel logo exists {timers[channellogoexists]} true if channel logo exists
{timers[isremotetimer]} true if timer is a remote timer from remotetimers plugin {timers[isremotetimer]} true if timer is a remote timer from remotetimers plugin
--> -->
<timers detached="true" delay="100" fadetime="0"> <timers detached="true" delay="100" shifttime="500" startx="0" starty="100%">
<area x="0" y="75%" width="{areawidth}/8 - 5" height="25%" layer="1"> <area x="0" y="75%" width="{areawidth}/8 - 5" height="25%" layer="1">
<fill color="{clrTransBlack}" /> <fill color="{clrTransBlack}" />
</area> </area>

View File

@ -1048,6 +1048,8 @@ cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplVi
tmplViewElement->SetPixOffset(0); tmplViewElement->SetPixOffset(0);
delay = tmplViewElement->GetNumericParameter(ptDelay); delay = tmplViewElement->GetNumericParameter(ptDelay);
SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime)); SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
SetShiftTime(tmplViewElement->GetNumericParameter(ptShiftTime));
SetStartPos(tmplViewElement->GetNumericParameter(ptStartX), tmplViewElement->GetNumericParameter(ptStartY));
} }
cViewElement::~cViewElement() { cViewElement::~cViewElement() {
@ -1055,10 +1057,14 @@ cViewElement::~cViewElement() {
} }
void cViewElement::Action(void) { void cViewElement::Action(void) {
SetInitFinished();
DoSleep(delay); DoSleep(delay);
Render(); Render();
FadeIn(); SetInitFinished();
if (IsAnimated()) {
ShiftIn();
} else {
FadeIn();
}
DoFlush(); DoFlush();
if (scrolling) { if (scrolling) {
DoSleep(scrollDelay); DoSleep(scrollDelay);