summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2015-05-14 10:09:34 +0200
committerlouis <louis.braun@gmx.de>2015-05-14 10:09:34 +0200
commit01b09d742440727661d69bed76710b9d79e2c912 (patch)
tree56e6557d0a0ef58153bc39b8312ee98f2f205d30
parente9ab094e966d53c7b4108cc52bfec60f08903701 (diff)
downloadvdr-plugin-skindesigner-01b09d742440727661d69bed76710b9d79e2c912.tar.gz
vdr-plugin-skindesigner-01b09d742440727661d69bed76710b9d79e2c912.tar.bz2
implemented shiftout for views
-rw-r--r--HISTORY3
-rw-r--r--libcore/pixmapcontainer.c122
-rw-r--r--libcore/pixmapcontainer.h4
-rw-r--r--views/displaychannelview.c2
-rw-r--r--views/displaymenutabview.c1
-rw-r--r--views/displaymenuview.c2
-rw-r--r--views/displaymessageview.c2
-rw-r--r--views/displaypluginview.c2
-rw-r--r--views/displayreplayview.c2
-rw-r--r--views/displayvolumeview.c2
-rw-r--r--views/view.c17
-rw-r--r--views/view.h2
12 files changed, 133 insertions, 28 deletions
diff --git a/HISTORY b/HISTORY
index 32255a9..991bf09 100644
--- a/HISTORY
+++ b/HISTORY
@@ -319,4 +319,5 @@ Version 0.4.5
- fixed bug that scrapercontent in displaychannel was not
updated if detached
- fixed bug that detached viewelements were not cleared
- correctly \ No newline at end of file
+ correctly
+- implemented shiftout for views
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);
diff --git a/views/displaychannelview.c b/views/displaychannelview.c
index 986ee39..28626f8 100644
--- a/views/displaychannelview.c
+++ b/views/displaychannelview.c
@@ -18,8 +18,6 @@ cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplVi
}
cDisplayChannelView::~cDisplayChannelView() {
- CancelSave();
- FadeOut();
}
bool cDisplayChannelView::createOsd(void) {
diff --git a/views/displaymenutabview.c b/views/displaymenutabview.c
index f9e03f9..ebf0097 100644
--- a/views/displaymenutabview.c
+++ b/views/displaymenutabview.c
@@ -5,7 +5,6 @@ cDisplayMenuTabView::cDisplayMenuTabView(cTemplateViewTab *tmplTab) : cView(tmpl
}
cDisplayMenuTabView::~cDisplayMenuTabView() {
- CancelSave();
}
void cDisplayMenuTabView::SetTokens(map < string, int > *intTokens, map < string, string > *stringTokens, map < string, vector< map< string, string > > > *loopTokens) {
diff --git a/views/displaymenuview.c b/views/displaymenuview.c
index 5a08844..a70535d 100644
--- a/views/displaymenuview.c
+++ b/views/displaymenuview.c
@@ -17,8 +17,6 @@ cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cVi
}
cDisplayMenuView::~cDisplayMenuView() {
- CancelSave();
- FadeOut();
}
bool cDisplayMenuView::DrawBackground(void) {
diff --git a/views/displaymessageview.c b/views/displaymessageview.c
index 25f41fb..85727cb 100644
--- a/views/displaymessageview.c
+++ b/views/displaymessageview.c
@@ -7,8 +7,6 @@ cDisplayMessageView::cDisplayMessageView(cTemplateView *tmplView) : cView(tmplVi
}
cDisplayMessageView::~cDisplayMessageView() {
- CancelSave();
- FadeOut();
}
bool cDisplayMessageView::createOsd(void) {
diff --git a/views/displaypluginview.c b/views/displaypluginview.c
index f057f69..67104af 100644
--- a/views/displaypluginview.c
+++ b/views/displaypluginview.c
@@ -17,8 +17,6 @@ cDisplayPluginView::cDisplayPluginView(cTemplateView *tmplView, bool isRootView)
}
cDisplayPluginView::~cDisplayPluginView() {
- CancelSave();
- FadeOut();
if (tabView)
delete tabView;
}
diff --git a/views/displayreplayview.c b/views/displayreplayview.c
index 3436d5b..4208438 100644
--- a/views/displayreplayview.c
+++ b/views/displayreplayview.c
@@ -21,8 +21,6 @@ cDisplayReplayView::~cDisplayReplayView() {
if (onPauseView) {
delete onPauseView;
}
- CancelSave();
- FadeOut();
}
bool cDisplayReplayView::createOsd(void) {
diff --git a/views/displayvolumeview.c b/views/displayvolumeview.c
index 94b073d..e7c8b1b 100644
--- a/views/displayvolumeview.c
+++ b/views/displayvolumeview.c
@@ -9,8 +9,6 @@ cDisplayVolumeView::cDisplayVolumeView(cTemplateView *tmplView) : cView(tmplView
}
cDisplayVolumeView::~cDisplayVolumeView() {
- CancelSave();
- FadeOut();
}
bool cDisplayVolumeView::createOsd(void) {
diff --git a/views/view.c b/views/view.c
index 185c8b9..1b9cc07 100644
--- a/views/view.c
+++ b/views/view.c
@@ -38,18 +38,29 @@ cView::cView(cTemplateViewTab *tmplTab) : cPixmapContainer(1) {
}
cView::~cView() {
+ CancelSave();
+
if (tvScaled) {
cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
}
+ //clear detached views
for (map<eViewElement,cViewElement*>::iterator dVeIt = detachedViewElements.begin(); dVeIt != detachedViewElements.end(); dVeIt++) {
cViewElement *ve = dVeIt->second;
delete ve;
}
+ //clear animations
for (multimap<int, cAnimation*>::iterator animIt = animations.begin(); animIt != animations.end(); animIt++) {
cAnimation *anim = animIt->second;
anim->Stop();
delete anim;
}
+ //shift or fade out
+ if (fadeOut) {
+ if (IsAnimated())
+ ShiftOut();
+ else
+ FadeOut();
+ }
}
void cView::DrawDebugGrid(void) {
@@ -59,6 +70,7 @@ void cView::DrawDebugGrid(void) {
}
void cView::Init(void) {
+ fadeOut = true;
viewInit = true;
scrolling = false;
veScroll = veUndefined;
@@ -1066,6 +1078,7 @@ cRect cView::CalculateAnimationClip(int numPix, cRect &pos) {
cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
init = true;
+ fadeOut = false;
ve = veUndefined;
helper = NULL;
SetTokens = NULL;
@@ -1080,6 +1093,7 @@ cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplVi
cViewElement::cViewElement(cTemplateViewElement *tmplViewElement, cViewHelpers *helper) : cView(tmplViewElement) {
init = true;
+ fadeOut = false;
ve = veUndefined;
this->helper = helper;
SetTokens = NULL;
@@ -1093,7 +1107,6 @@ cViewElement::cViewElement(cTemplateViewElement *tmplViewElement, cViewHelpers *
}
cViewElement::~cViewElement() {
- CancelSave();
}
bool cViewElement::Render(void) {
@@ -1148,6 +1161,7 @@ void cViewElement::ClearTokens(void) {
************************************************************************/
cViewListItem::cViewListItem(cTemplateViewElement *tmplItem) : cView(tmplItem) {
+ fadeOut = false;
pos = -1;
numTotal = 0;
align = alLeft;
@@ -1265,6 +1279,7 @@ void cViewListItem::SetListElementPosition(cTemplatePixmap *pix) {
************************************************************************/
cGrid::cGrid(cTemplateViewElement *tmplGrid) : cView(tmplGrid) {
+ fadeOut = false;
dirty = true;
moved = true;
resized = true;
diff --git a/views/view.h b/views/view.h
index 91af9ec..f7d2ab5 100644
--- a/views/view.h
+++ b/views/view.h
@@ -42,6 +42,8 @@ protected:
cRect scalingWindow;
bool tvScaled;
bool viewInit;
+ //do fadeout or shiftout only for views, not for childs
+ bool fadeOut;
//true if view is scrollable in general
bool scrolling;
//true if view is actually starting scrolling