implemented shiftout for views

This commit is contained in:
louis 2015-05-14 10:09:34 +02:00
parent e9ab094e96
commit 01b09d7424
12 changed files with 133 additions and 28 deletions

View File

@ -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
correctly
- implemented shiftout for views

View File

@ -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

View File

@ -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);

View File

@ -18,8 +18,6 @@ cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplVi
}
cDisplayChannelView::~cDisplayChannelView() {
CancelSave();
FadeOut();
}
bool cDisplayChannelView::createOsd(void) {

View File

@ -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) {

View File

@ -17,8 +17,6 @@ cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cVi
}
cDisplayMenuView::~cDisplayMenuView() {
CancelSave();
FadeOut();
}
bool cDisplayMenuView::DrawBackground(void) {

View File

@ -7,8 +7,6 @@ cDisplayMessageView::cDisplayMessageView(cTemplateView *tmplView) : cView(tmplVi
}
cDisplayMessageView::~cDisplayMessageView() {
CancelSave();
FadeOut();
}
bool cDisplayMessageView::createOsd(void) {

View File

@ -17,8 +17,6 @@ cDisplayPluginView::cDisplayPluginView(cTemplateView *tmplView, bool isRootView)
}
cDisplayPluginView::~cDisplayPluginView() {
CancelSave();
FadeOut();
if (tabView)
delete tabView;
}

View File

@ -21,8 +21,6 @@ cDisplayReplayView::~cDisplayReplayView() {
if (onPauseView) {
delete onPauseView;
}
CancelSave();
FadeOut();
}
bool cDisplayReplayView::createOsd(void) {

View File

@ -9,8 +9,6 @@ cDisplayVolumeView::cDisplayVolumeView(cTemplateView *tmplView) : cView(tmplView
}
cDisplayVolumeView::~cDisplayVolumeView() {
CancelSave();
FadeOut();
}
bool cDisplayVolumeView::createOsd(void) {

View File

@ -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;

View File

@ -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