From c5edc10fbd57d17e774a07b659996bdffe16242c Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 3 May 2015 11:22:01 +0200 Subject: [PATCH] possibility to move viewelements when starting view --- HISTORY | 2 + dtd/displaychannel.dtd | 18 ++++++ dtd/displaymenu.dtd | 30 ++++++++++ libcore/pixmapcontainer.c | 63 ++++++++++++++++++++- libcore/pixmapcontainer.h | 7 +++ libtemplate/templatefunction.c | 20 +++++++ libtemplate/templatefunction.h | 3 + libtemplate/templateview.c | 3 + skins/metrixhd/xmlfiles/displaychannel.xml | 30 +++++----- skins/metrixhd/xmlfiles/displaymenumain.xml | 2 +- views/view.c | 10 +++- 11 files changed, 168 insertions(+), 20 deletions(-) diff --git a/HISTORY b/HISTORY index a4ec9f5..43671d1 100644 --- a/HISTORY +++ b/HISTORY @@ -307,3 +307,5 @@ Version 0.4.3 - fixed bug that tokens in image pathes are not replaced correctly Version 0.4.4 + +- feature: possibility to move viewelements when starting view diff --git a/dtd/displaychannel.dtd b/dtd/displaychannel.dtd index 2038d12..94b736d 100644 --- a/dtd/displaychannel.dtd +++ b/dtd/displaychannel.dtd @@ -96,6 +96,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED mode CDATA #IMPLIED @@ -106,6 +109,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -115,6 +121,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -124,6 +133,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -133,6 +145,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -148,6 +163,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > diff --git a/dtd/displaymenu.dtd b/dtd/displaymenu.dtd index de4a813..8626689 100644 --- a/dtd/displaymenu.dtd +++ b/dtd/displaymenu.dtd @@ -63,6 +63,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -72,6 +75,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -81,6 +87,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED mode CDATA #IMPLIED @@ -91,6 +100,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -100,6 +112,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -109,6 +124,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -118,6 +136,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -127,6 +148,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -136,6 +160,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > @@ -145,6 +172,9 @@ detached CDATA #IMPLIED delay CDATA #IMPLIED fadetime CDATA #IMPLIED + shifttime CDATA #IMPLIED + startx CDATA #IMPLIED + starty CDATA #IMPLIED debug CDATA #IMPLIED condition CDATA #IMPLIED > diff --git a/libcore/pixmapcontainer.c b/libcore/pixmapcontainer.c index 81cc8ff..2f498e0 100644 --- a/libcore/pixmapcontainer.c +++ b/libcore/pixmapcontainer.c @@ -20,6 +20,7 @@ cPixmapContainer::cPixmapContainer(int numPixmaps) { mutex.Unlock(); checkRunning = false; fadeTime = 0; + shiftTime = 0; deleteOsdOnExit = false; } @@ -122,7 +123,7 @@ void cPixmapContainer::CreatePixmap(int num, int Layer, const cRect &ViewPort, c if (!pixmaps[num]) return; pixmaps[num]->Fill(clrTransparent); - if (pixContainerInit && fadeTime) { + if (pixContainerInit && (fadeTime || shiftTime)) { pixmaps[num]->SetAlpha(0); } else if (pixmapsTransparency[num] > 0) { int alpha = (100 - pixmapsTransparency[num])*255/100; @@ -256,6 +257,16 @@ void cPixmapContainer::Pos(int num, cPoint &pos) { 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) { if (checkRunning && !Running()) return 0; @@ -331,8 +342,13 @@ void cPixmapContainer::SetDrawPortPoint(int num, const cPoint &Point) { ****************************************************************************/ void cPixmapContainer::FadeIn(void) { - if (!fadeTime) + if (!fadeTime) { + for (int i = 0; i < numPixmaps; i++) { + if (PixmapExists(i)) + SetAlpha(i, ALPHA_OPAQUE); + } return; + } uint64_t Start = cTimeMs::Now(); int FadeFrameTime = fadeTime / 10; 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 * 2 medium diff --git a/libcore/pixmapcontainer.h b/libcore/pixmapcontainer.h index eeff8cb..d17753c 100644 --- a/libcore/pixmapcontainer.h +++ b/libcore/pixmapcontainer.h @@ -23,6 +23,8 @@ private: int *pixmapsLayer; bool checkRunning; int fadeTime; + int shiftTime; + cPoint startPos; bool deleteOsdOnExit; protected: void SetInitFinished(void) { pixContainerInit = false; }; @@ -46,6 +48,7 @@ protected: void SetViewPort(int num, const cRect &rect); int Layer(int num); void Pos(int num, cPoint &pos); + cRect ViewPort(int num); int Width(int num); int Height(int num); int DrawportWidth(int num); @@ -57,8 +60,12 @@ protected: void UnsetCheckRunning(void) { checkRunning = false; }; //HELPERS -- do not access the pixmaps array directly, use wrapper functions 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 FadeOut(void); + void ShiftIn(void); void ScrollVertical(int num, int scrollDelay, int scrollSpeed); void ScrollHorizontal(int num, int scrollDelay, int scrollSpeed, int scrollMode); void CancelSave(void); diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c index e186621..9855066 100644 --- a/libtemplate/templatefunction.c +++ b/libtemplate/templatefunction.c @@ -73,6 +73,12 @@ void cTemplateFunction::SetParameters(vector > params) { p.first = ptDetached; } else if (!name.compare("fadetime")) { 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")) { p.first = ptImageType; } else if (!name.compare("path")) { @@ -230,7 +236,10 @@ bool cTemplateFunction::CalculateParameters(void) { case ptHeight: case ptMenuItemWidth: case ptFadeTime: + case ptShiftTime: case ptDelay: + case ptStartX: + case ptStartY: case ptFontSize: case ptLayer: case ptTransparency: @@ -780,6 +789,7 @@ bool cTemplateFunction::SetNumericParameter(eParamType type, string value) { param.SetGlobals(globals); switch (type) { case ptX: + case ptStartX: case ptWidth: case ptMenuItemWidth: case ptScaleTvX: @@ -787,6 +797,7 @@ bool cTemplateFunction::SetNumericParameter(eParamType type, string value) { param.SetHorizontal(); break; case ptY: + case ptStartY: case ptHeight: case ptScaleTvY: case ptScaleTvHeight: @@ -1591,6 +1602,15 @@ string cTemplateFunction::GetParamName(eParamType pt) { case ptFadeTime: name = "Fade Time"; break; + case ptShiftTime: + name = "Shift Time"; + break; + case ptStartX: + name = "Startpos X"; + break; + case ptStartY: + name = "Startpos Y"; + break; case ptDelay: name = "Delay"; break; diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h index c781568..508615d 100644 --- a/libtemplate/templatefunction.h +++ b/libtemplate/templatefunction.h @@ -51,6 +51,9 @@ enum eParamType { ptMenuItemWidth, ptDetached, ptFadeTime, + ptShiftTime, + ptStartX, + ptStartY, ptDelay, ptImageType, ptPath, diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index ddd6094..2e7782b 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -667,6 +667,9 @@ void cTemplateView::SetFunctionDefinitions(void) { attributes.insert("detached"); attributes.insert("delay"); attributes.insert("fadetime"); + attributes.insert("shifttime"); + attributes.insert("startx"); + attributes.insert("starty"); attributes.insert("name"); attributes.insert("condition"); attributes.insert("mode"); diff --git a/skins/metrixhd/xmlfiles/displaychannel.xml b/skins/metrixhd/xmlfiles/displaychannel.xml index 6851c6c..14547f8 100644 --- a/skins/metrixhd/xmlfiles/displaychannel.xml +++ b/skins/metrixhd/xmlfiles/displaychannel.xml @@ -186,7 +186,7 @@ {devices[channelid]} ID of the currently tuned channel {devices[source]} source of the currently tuned channel --> - + @@ -224,20 +224,20 @@ {pressure} pressure in HPo {ozone} ozone value in DU --> - + - - + + - - - + + + - - + + @@ -277,17 +277,17 @@ {monthnameshort} 3 letter abbrivation of month name {year} year in yyyy --> - + - - - + + + - - + + - + diff --git a/views/view.c b/views/view.c index 077931a..0bdf019 100644 --- a/views/view.c +++ b/views/view.c @@ -1048,6 +1048,8 @@ cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplVi tmplViewElement->SetPixOffset(0); delay = tmplViewElement->GetNumericParameter(ptDelay); SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime)); + SetShiftTime(tmplViewElement->GetNumericParameter(ptShiftTime)); + SetStartPos(tmplViewElement->GetNumericParameter(ptStartX), tmplViewElement->GetNumericParameter(ptStartY)); } cViewElement::~cViewElement() { @@ -1055,10 +1057,14 @@ cViewElement::~cViewElement() { } void cViewElement::Action(void) { - SetInitFinished(); DoSleep(delay); Render(); - FadeIn(); + SetInitFinished(); + if (IsAnimated()) { + ShiftIn(); + } else { + FadeIn(); + } DoFlush(); if (scrolling) { DoSleep(scrollDelay);