diff options
author | louis <louis.braun@gmx.de> | 2015-05-03 11:22:01 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2015-05-03 11:22:01 +0200 |
commit | c5edc10fbd57d17e774a07b659996bdffe16242c (patch) | |
tree | cc9b5cfc4b38c7bb7f2743cba732d6e4200b5594 /libcore | |
parent | 918a331de3e0a6a31b2cd621ed628d53ac9fa2da (diff) | |
download | vdr-plugin-skindesigner-c5edc10fbd57d17e774a07b659996bdffe16242c.tar.gz vdr-plugin-skindesigner-c5edc10fbd57d17e774a07b659996bdffe16242c.tar.bz2 |
possibility to move viewelements when starting view
Diffstat (limited to 'libcore')
-rw-r--r-- | libcore/pixmapcontainer.c | 63 | ||||
-rw-r--r-- | libcore/pixmapcontainer.h | 7 |
2 files changed, 68 insertions, 2 deletions
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); |