diff options
author | louis <louis.braun@gmx.de> | 2015-05-14 10:09:34 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2015-05-14 10:09:34 +0200 |
commit | 01b09d742440727661d69bed76710b9d79e2c912 (patch) | |
tree | 56e6557d0a0ef58153bc39b8312ee98f2f205d30 /libcore | |
parent | e9ab094e966d53c7b4108cc52bfec60f08903701 (diff) | |
download | vdr-plugin-skindesigner-01b09d742440727661d69bed76710b9d79e2c912.tar.gz vdr-plugin-skindesigner-01b09d742440727661d69bed76710b9d79e2c912.tar.bz2 |
implemented shiftout for views
Diffstat (limited to 'libcore')
-rw-r--r-- | libcore/pixmapcontainer.c | 122 | ||||
-rw-r--r-- | libcore/pixmapcontainer.h | 4 |
2 files changed, 113 insertions, 13 deletions
diff --git a/libcore/pixmapcontainer.c b/libcore/pixmapcontainer.c index cab356e..0391a64 100644 --- a/libcore/pixmapcontainer.c +++ b/libcore/pixmapcontainer.c @@ -424,20 +424,23 @@ void cPixmapContainer::ShiftIn(void) { } } -void cPixmapContainer::ShiftInFromBorder(int frames, int frameTime) { - //calculating union rectangle of all pixmaps viewports - cRect unionArea; - bool isNew = true; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - if (isNew) { - unionArea = ViewPort(i); - isNew = false; - } else { - unionArea.Combine(ViewPort(i)); - } +void cPixmapContainer::ShiftOut(void) { + if (shiftTime < 1) + return; + + int frames = shiftTime * config.framesPerSecond / 1000; + if (frames <= 0) frames = 1; + int frameTime = shiftTime / frames; + + if (shiftType > stNone) { + ShiftOutToBorder(frames, frameTime); + } else { + ShiftOutToPoint(frames, frameTime); } +} + +void cPixmapContainer::ShiftInFromBorder(int frames, int frameTime) { + cRect unionArea = UnionPixmaps(); //shifthing all pixmaps to dedicated start positions cPoint startPositions[numPixmaps]; int osdWidth = osd->Width(); @@ -541,6 +544,80 @@ void cPixmapContainer::ShiftInFromBorder(int frames, int frameTime) { } } +void cPixmapContainer::ShiftOutToBorder(int frames, int frameTime) { + cRect unionArea = UnionPixmaps(); + //calculating end positions + cPoint startPositions[numPixmaps]; + int osdWidth = osd->Width(); + int osdHeight = osd->Height(); + for (int i = 0; i < numPixmaps; i++) { + if (!PixmapExists(i)) + continue; + cPoint pos; + Pos(i, pos); + startPositions[i] = pos; + } + //Calculating total shifting distance + int shiftTotal = 0; + switch (shiftType) { + case stLeft: + shiftTotal = unionArea.X() + unionArea.Width(); + break; + case stRight: + shiftTotal = unionArea.Width() + (osdWidth - (unionArea.X() + unionArea.Width())); + break; + case stTop: + shiftTotal = unionArea.Y() + unionArea.Height(); + break; + case stBottom: + shiftTotal = unionArea.Height() + (osdHeight - (unionArea.Y() + unionArea.Height())); + break; + default: + break; + } + //Moving Out + uint64_t Start = cTimeMs::Now(); + while (true) { + uint64_t Now = cTimeMs::Now(); + double t = min(double(Now - Start) / shiftTime, 1.0); + int xNew = 0; + int yNew = 0; + for (int i = 0; i < numPixmaps; i++) { + if (!PixmapExists(i)) + continue; + cRect r = ViewPort(i); + switch (shiftType) { + case stLeft: + xNew = startPositions[i].X() - t * shiftTotal; + r.SetPoint(xNew, r.Y()); + break; + case stRight: + xNew = startPositions[i].X() + t * shiftTotal; + r.SetPoint(xNew, r.Y()); + break; + case stTop: + yNew = startPositions[i].Y() - t * shiftTotal; + r.SetPoint(r.X(), yNew); + break; + case stBottom: + yNew = startPositions[i].Y() + t * shiftTotal; + r.SetPoint(r.X(), yNew); + break; + default: + break; + } + SetViewPort(i, r); + } + DoFlush(); + int Delta = cTimeMs::Now() - Now; + if ((Delta < frameTime)) { + cCondWait::SleepMs(frameTime - Delta); + } + if ((int)(Now - Start) > shiftTime) + break; + } +} + void cPixmapContainer::ShiftInFromPoint(int frames, int frameTime) { //store original positions of pixmaps and move to StartPosition cPoint destPos[numPixmaps]; @@ -579,6 +656,25 @@ void cPixmapContainer::ShiftInFromPoint(int frames, int frameTime) { } } +void cPixmapContainer::ShiftOutToPoint(int frames, int frameTime) { + //TODO +} + +cRect cPixmapContainer::UnionPixmaps(void) { + cRect unionArea; + bool isNew = true; + for (int i = 0; i < numPixmaps; i++) { + if (!PixmapExists(i)) + continue; + if (isNew) { + unionArea = ViewPort(i); + isNew = false; + } else { + unionArea.Combine(ViewPort(i)); + } + } + return unionArea; +} /***************************************** * scrollSpeed: 1 slow diff --git a/libcore/pixmapcontainer.h b/libcore/pixmapcontainer.h index e924126..20e2c66 100644 --- a/libcore/pixmapcontainer.h +++ b/libcore/pixmapcontainer.h @@ -29,7 +29,10 @@ private: cPoint startPos; bool deleteOsdOnExit; void ShiftInFromBorder(int frames, int frameTime); + void ShiftOutToBorder(int frames, int frameTime); void ShiftInFromPoint(int frames, int frameTime); + void ShiftOutToPoint(int frames, int frameTime); + cRect UnionPixmaps(void); protected: void SetInitFinished(void) { pixContainerInit = false; }; bool CreateOsd(int Left, int Top, int Width, int Height); @@ -72,6 +75,7 @@ protected: void FadeIn(void); void FadeOut(void); void ShiftIn(void); + void ShiftOut(void); void ScrollVertical(int num, int scrollDelay, int scrollSpeed); void ScrollHorizontal(int num, int scrollDelay, int scrollSpeed, int scrollMode); void CancelSave(void); |