summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY2
-rw-r--r--Makefile1
-rw-r--r--dtd/functions.dtd12
-rw-r--r--libcore/pixmapcontainer.c19
-rw-r--r--libcore/pixmapcontainer.h2
-rw-r--r--libtemplate/templatefunction.c34
-rw-r--r--libtemplate/templatefunction.h10
-rw-r--r--libtemplate/templateview.c12
-rw-r--r--skins/blackhole/xmlfiles/displaychannel.xml2
-rw-r--r--skins/blackhole/xmlfiles/displaymenumain.xml4
-rw-r--r--views/animation.c110
-rw-r--r--views/animation.h68
-rw-r--r--views/view.c163
-rw-r--r--views/view.h9
14 files changed, 434 insertions, 14 deletions
diff --git a/HISTORY b/HISTORY
index de6930e..b98e802 100644
--- a/HISTORY
+++ b/HISTORY
@@ -290,4 +290,6 @@ Version 0.4.2
- fixed bug that string tokens are not evaluated in area conditions
- added possibility to draw a debug grid in views
- added more info if debugImage is activted in config
+- added possibility for blinking images, texts, rectangles, ellipses
+ and slopes
diff --git a/Makefile b/Makefile
index d7db2cb..cc1c790 100644
--- a/Makefile
+++ b/Makefile
@@ -88,6 +88,7 @@ OBJS = $(PLUGIN).o \
libtemplate/templatefunction.o \
libtemplate/templateloopfunction.o \
libtemplate/xmlparser.o \
+ views/animation.o \
views/view.o \
views/viewgrid.o \
views/viewhelpers.o \
diff --git a/dtd/functions.dtd b/dtd/functions.dtd
index 7ea61b6..50198f4 100644
--- a/dtd/functions.dtd
+++ b/dtd/functions.dtd
@@ -73,6 +73,8 @@
name NMTOKEN #IMPLIED
text CDATA #REQUIRED
condition CDATA #IMPLIED
+ animtype CDATA #IMPLIED
+ animfreq CDATA #IMPLIED
debug (true|false) #IMPLIED
>
@@ -110,6 +112,8 @@
text CDATA #REQUIRED
direction (bottomup|topdown) #IMPLIED
condition CDATA #IMPLIED
+ animtype CDATA #IMPLIED
+ animfreq CDATA #IMPLIED
debug (true|false) #IMPLIED
>
@@ -124,6 +128,8 @@
color CDATA #REQUIRED
name NMTOKEN #IMPLIED
condition CDATA #IMPLIED
+ animtype CDATA #IMPLIED
+ animfreq CDATA #IMPLIED
debug NMTOKEN #IMPLIED
>
@@ -139,6 +145,8 @@
quadrant CDATA #REQUIRED
name NMTOKEN #IMPLIED
condition CDATA #IMPLIED
+ animtype CDATA #IMPLIED
+ animfreq CDATA #IMPLIED
debug NMTOKEN #IMPLIED
>
@@ -154,6 +162,8 @@
type CDATA #REQUIRED
name NMTOKEN #IMPLIED
condition CDATA #IMPLIED
+ animtype CDATA #IMPLIED
+ animfreq CDATA #IMPLIED
debug NMTOKEN #IMPLIED
>
@@ -170,5 +180,7 @@
path CDATA #REQUIRED
name CDATA #IMPLIED
condition CDATA #IMPLIED
+ animtype CDATA #IMPLIED
+ animfreq CDATA #IMPLIED
debug NMTOKEN #IMPLIED
>
diff --git a/libcore/pixmapcontainer.c b/libcore/pixmapcontainer.c
index 90c733a..81cc8ff 100644
--- a/libcore/pixmapcontainer.c
+++ b/libcore/pixmapcontainer.c
@@ -237,6 +237,25 @@ void cPixmapContainer::SetViewPort(int num, const cRect &rect) {
pixmaps[num]->SetViewPort(rect);
}
+int cPixmapContainer::Layer(int num) {
+ if (checkRunning && !Running())
+ return 0;
+ cMutexLock MutexLock(&mutex);
+ if (!pixmaps[num])
+ return 0;
+ return pixmaps[num]->Layer();
+}
+
+void cPixmapContainer::Pos(int num, cPoint &pos) {
+ if (checkRunning && !Running())
+ return;
+ cMutexLock MutexLock(&mutex);
+ if (!pixmaps[num])
+ return;
+ pos.SetX(pixmaps[num]->ViewPort().X());
+ pos.SetY(pixmaps[num]->ViewPort().Y());
+}
+
int cPixmapContainer::Width(int num) {
if (checkRunning && !Running())
return 0;
diff --git a/libcore/pixmapcontainer.h b/libcore/pixmapcontainer.h
index 3b367c8..eeff8cb 100644
--- a/libcore/pixmapcontainer.h
+++ b/libcore/pixmapcontainer.h
@@ -44,6 +44,8 @@ protected:
void SetTransparency(int num, int Transparency);
void SetLayer(int num, int Layer);
void SetViewPort(int num, const cRect &rect);
+ int Layer(int num);
+ void Pos(int num, cPoint &pos);
int Width(int num);
int Height(int num);
int DrawportWidth(int num);
diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c
index 7b76539..c99fa37 100644
--- a/libtemplate/templatefunction.c
+++ b/libtemplate/templatefunction.c
@@ -143,6 +143,10 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
p.first = ptDeterminateFont;
} else if (!name.compare("direction")) {
p.first = ptDirection;
+ } else if (!name.compare("animtype")) {
+ p.first = ptAnimType;
+ } else if (!name.compare("animfreq")) {
+ p.first = ptAnimFreq;
} else {
p.first = ptNone;
}
@@ -242,6 +246,7 @@ bool cTemplateFunction::CalculateParameters(void) {
case ptScaleTvY:
case ptScaleTvWidth:
case ptScaleTvHeight:
+ case ptAnimFreq:
SetNumericParameter(type, value);
break;
case ptAlign:
@@ -287,6 +292,9 @@ bool cTemplateFunction::CalculateParameters(void) {
case ptDirection:
paramValid = SetDirection(value);
break;
+ case ptAnimType:
+ paramValid = SetAnimType(value);
+ break;
default:
paramValid = true;
break;
@@ -736,6 +744,16 @@ bool cTemplateFunction::DoExecute(void) {
return condParam->IsTrue();
}
+bool cTemplateFunction::IsAnimated(void) {
+ map< eParamType, int >::iterator hit = numericParameters.find(ptAnimType);
+ if (hit == numericParameters.end())
+ return false;
+ eAnimType type = (eAnimType)hit->second;
+ if (type > atNone)
+ return true;
+ return false;
+}
+
/*******************************************************************
* Private Functions
*******************************************************************/
@@ -1125,6 +1143,16 @@ bool cTemplateFunction::SetDirection(string value) {
return true;
}
+bool cTemplateFunction::SetAnimType(string value) {
+ int animType = atNone;
+ if (!value.compare("blink"))
+ animType = atBlink;
+ else if (!value.compare("animated"))
+ animType = atAnimated;
+ numericParameters.insert(pair<eParamType, int>(ptAnimType, animType));
+ return true;
+}
+
void cTemplateFunction::SetDebugGrid(string value) {
int numGridsX = 0;
int numGridsY = 0;
@@ -1653,6 +1681,12 @@ string cTemplateFunction::GetParamName(eParamType pt) {
case ptDirection:
name = "Text Direction";
break;
+ case ptAnimType:
+ name = "Animation Type";
+ break;
+ case ptAnimFreq:
+ name = "Animation Frequency";
+ break;
default:
name = "Unknown";
break;
diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h
index fdc66b0..c781568 100644
--- a/libtemplate/templatefunction.h
+++ b/libtemplate/templatefunction.h
@@ -86,6 +86,8 @@ enum eParamType {
ptCache,
ptDeterminateFont,
ptDirection,
+ ptAnimType,
+ ptAnimFreq,
ptNone
};
@@ -98,6 +100,12 @@ enum eImageType {
itImage
};
+enum eAnimType {
+ atNone,
+ atBlink,
+ atAnimated
+};
+
enum eFloatType {
flNone,
flTopLeft,
@@ -168,6 +176,7 @@ protected:
bool SetDetached(string value);
bool SetBackground(string value);
bool SetDirection(string value);
+ bool SetAnimType(string value);
void SetDebugGrid(string value);
void ParseStringParameters(void);
void ParseNumericalParameters(void);
@@ -232,6 +241,7 @@ public:
bool ParsedCompletely(void) { return parsedCompletely; };
bool DoExecute(void);
bool Updated(void) { return updated; };
+ bool IsAnimated(void);
//Debug
void Debug(void);
};
diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c
index b7a4110..1117d10 100644
--- a/libtemplate/templateview.c
+++ b/libtemplate/templateview.c
@@ -744,6 +744,8 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("fontsize");
attributes.insert("color");
attributes.insert("text");
+ attributes.insert("animtype");
+ attributes.insert("animfreq");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "drawtextbox";
@@ -781,6 +783,8 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("fontsize");
attributes.insert("color");
attributes.insert("text");
+ attributes.insert("animtype");
+ attributes.insert("animfreq");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "drawimage";
@@ -799,6 +803,8 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("align");
attributes.insert("valign");
attributes.insert("cache");
+ attributes.insert("animtype");
+ attributes.insert("animfreq");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "drawrectangle";
@@ -813,6 +819,8 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("width");
attributes.insert("height");
attributes.insert("color");
+ attributes.insert("animtype");
+ attributes.insert("animfreq");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "drawellipse";
@@ -828,6 +836,8 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("height");
attributes.insert("color");
attributes.insert("quadrant");
+ attributes.insert("animtype");
+ attributes.insert("animfreq");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "drawslope";
@@ -843,6 +853,8 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("height");
attributes.insert("color");
attributes.insert("type");
+ attributes.insert("animtype");
+ attributes.insert("animfreq");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
}
diff --git a/skins/blackhole/xmlfiles/displaychannel.xml b/skins/blackhole/xmlfiles/displaychannel.xml
index add8fca..993d7eb 100644
--- a/skins/blackhole/xmlfiles/displaychannel.xml
+++ b/skins/blackhole/xmlfiles/displaychannel.xml
@@ -120,7 +120,7 @@
<drawimage condition="{isDolby}" imagetype="icon" path="ico_dolby" x="{areaheight}*6 + 20" y="0" width="{areaheight}*3" height="{areaheight}"/>
<drawimage condition="{hasVT}" imagetype="icon" path="ico_videotext" x="{areaheight}*9 + 30" y="0" width="{areaheight}" height="{areaheight}"/>
<drawimage condition="{isEncrypted}" imagetype="icon" path="ico_crypted" x="{areaheight}*10 + 40" y="0" width="{areaheight}*2" height="{areaheight}"/>
- <drawimage condition="{isRecording}" imagetype="icon" path="ico_rec_on" x="{areaheight}*12 + 50" y="0" width="{areaheight}" height="{areaheight}"/>
+ <drawimage condition="{isRecording}" animtype="blink" animfreq="500" imagetype="icon" path="ico_rec_on" x="{areaheight}*12 + 50" y="0" width="{areaheight}" height="{areaheight}"/>
</area>
</statusinfo>
diff --git a/skins/blackhole/xmlfiles/displaymenumain.xml b/skins/blackhole/xmlfiles/displaymenumain.xml
index c82faf9..acbd883 100644
--- a/skins/blackhole/xmlfiles/displaymenumain.xml
+++ b/skins/blackhole/xmlfiles/displaymenumain.xml
@@ -81,8 +81,8 @@
</area>
<area condition="{numtimers}" x="55%" y="71%" width="44%" height="19%" layer="2">
<loop name="timers" x="0" y="0" orientation="horizontal" columnwidth="{areawidth}/4" rowheight="{areaheight}" overflow="cut">
- <drawimage cache="true" name="logo" imagetype="channellogo" path="{timers[channelid]}" width="{columnwidth}-15" height="40%" align="center" y="10" />
- <drawrectangle condition="{timers[recording]}" x="0" y="{height(logo)}+10" width="{columnwidth}-5" height="{rowheight} - {height(logo)} - 20" color="{clrRedTrans}" />
+ <drawimage cache="true" name="logo" imagetype="channellogo" path="{timers[channelid]}" width="{columnwidth}-15" height="40%" align="center" y="10" />
+ <drawimage condition="{timers[recording]}" animtype="blink" animfreq="500" imagetype="icon" path="ico_rec_on" x="{columnwidth}*0.75" y="{columnwidth}*0.05" width="{columnwidth}*0.2" height="{columnwidth}*0.2"/>
<drawtextbox x="5" y="{height(logo)} + 10" width="{columnwidth}-10" align="center" maxlines="2" font="{regular}" fontsize="15%" color="{clrWhite}" text="{timers[title]}" />
<drawtext align="center" y="75%" font="{regular}" fontsize="20%" color="{clrWhite}" text="{timers[datetime]}" />
</loop>
diff --git a/views/animation.c b/views/animation.c
new file mode 100644
index 0000000..f7cedea
--- /dev/null
+++ b/views/animation.c
@@ -0,0 +1,110 @@
+#include "animation.h"
+
+using namespace std;
+
+cAnimation::cAnimation(eAnimType animType, int animFreq, cRect &pos, int layer) : cPixmapContainer(1) {
+ this->animType = animType;
+ this->animFreq = animFreq;
+ this->pos = pos;
+ this->layer = layer;
+ blinkOn = true;
+}
+
+cAnimation::~cAnimation() {
+}
+
+void cAnimation::Action(void) {
+ CreatePixmap(0, layer+1, pos);
+ bool init = true;
+ while (Running()) {
+ if (animType == atBlink) {
+ if (!blinkOn) {
+ Fill(0, clrTransparent);
+ blinkOn = true;
+ } else {
+ DrawBlink();
+ }
+ } else if (animType == atAnimated) {
+ esyslog("skindesigner: animationType atAnimated not implemented");
+ }
+ if (init)
+ FadeIn();
+ init = false;
+ DoFlush();
+ DoSleep(animFreq);
+ }
+}
+
+void cAnimation::Stop(void) {
+ CancelSave();
+}
+
+/********************************************************************************************
+* cAnimatedImage
+********************************************************************************************/
+cAnimatedImage::cAnimatedImage(eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
+ image = NULL;
+}
+
+cAnimatedImage::~cAnimatedImage() {
+ esyslog("skindesigner: killing animation");
+}
+
+void cAnimatedImage::DrawBlink(void) {
+ blinkOn = false;
+ if (!image)
+ return;
+
+ cPoint posImage(0,0);
+ if (Running())
+ DrawImage(0, posImage, *image);
+}
+
+/********************************************************************************************
+* cAnimatedText
+********************************************************************************************/
+cAnimatedText::cAnimatedText(eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
+ text = "";
+ fontName = "";
+ fontSize = 1;
+ fontColor = clrTransparent;
+}
+
+cAnimatedText::~cAnimatedText() {
+}
+
+void cAnimatedText::DrawBlink(void) {
+ blinkOn = false;
+ if (text.size() == 0)
+ return;
+
+ cPoint posText(0,0);
+ if (Running())
+ DrawText(0, posText, text.c_str(), fontColor, clrTransparent, fontName, fontSize);
+}
+
+/********************************************************************************************
+* cAnimatedOsdObject
+********************************************************************************************/
+cAnimatedOsdObject::cAnimatedOsdObject(eFuncType type, eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
+ this->type = type;
+ color = 0x00000000;
+ quadrant = 0;
+}
+
+cAnimatedOsdObject::~cAnimatedOsdObject() {
+}
+
+void cAnimatedOsdObject::DrawBlink(void) {
+ blinkOn = false;
+ cRect posObject(0, 0, pos.Width(), pos.Height());
+ if (Running()) {
+ if (type == ftDrawRectangle) {
+ DrawRectangle(0, posObject, color);
+ } else if (type == ftDrawEllipse) {
+ DrawEllipse(0, posObject, color, quadrant);
+ } else if (type == ftDrawSlope) {
+ DrawSlope(0, posObject, color, quadrant);
+ }
+ }
+}
diff --git a/views/animation.h b/views/animation.h
new file mode 100644
index 0000000..1647872
--- /dev/null
+++ b/views/animation.h
@@ -0,0 +1,68 @@
+#ifndef __ANIMATION_H
+#define __ANIMATION_H
+
+#include "string"
+#include "../libcore/pixmapcontainer.h"
+#include "../libtemplate/template.h"
+
+using namespace std;
+
+class cAnimation : public cPixmapContainer {
+protected:
+ eAnimType animType;
+ int animFreq;
+ cRect pos;
+ int layer;
+ bool blinkOn;
+ virtual void DrawBlink(void) {};
+ virtual void Action(void);
+public:
+ cAnimation(eAnimType animType, int animFreq, cRect &pos, int layer);
+ virtual ~cAnimation();
+ void SetAnimationFadeTime(int fadeTime) { SetFadeTime(fadeTime); };
+ virtual void Stop(void);
+};
+
+class cAnimatedImage : public cAnimation {
+private:
+ cImage *image;
+protected:
+ void DrawBlink(void);
+public:
+ cAnimatedImage(eAnimType animType, int animFreq, cRect &pos, int layer);
+ virtual ~cAnimatedImage();
+ void SetImage(cImage *i) { image = i; };
+};
+
+class cAnimatedText : public cAnimation {
+private:
+ string text;
+ string fontName;
+ int fontSize;
+ tColor fontColor;
+protected:
+ void DrawBlink(void);
+public:
+ cAnimatedText(eAnimType animType, int animFreq, cRect &pos, int layer);
+ virtual ~cAnimatedText();
+ void SetText(string &t) { text = t; };
+ void SetFont(string &font) { fontName = font; };
+ void SetFontSize(int size) { fontSize = size; };
+ void SetFontColor(tColor col) { fontColor = col; };
+};
+
+class cAnimatedOsdObject : public cAnimation {
+private:
+ eFuncType type;
+ tColor color;
+ int quadrant;
+protected:
+ void DrawBlink(void);
+public:
+ cAnimatedOsdObject(eFuncType type, eAnimType animType, int animFreq, cRect &pos, int layer);
+ virtual ~cAnimatedOsdObject();
+ void SetColor(tColor col) { color = col; };
+ void SetQuadrant(int q) { quadrant = q; };
+};
+
+#endif //__ANIMATION_H \ No newline at end of file
diff --git a/views/view.c b/views/view.c
index 1680379..077931a 100644
--- a/views/view.c
+++ b/views/view.c
@@ -40,6 +40,11 @@ cView::~cView() {
cViewElement *ve = dVeIt->second;
delete ve;
}
+ for (multimap<int, cAnimation*>::iterator animIt = animations.begin(); animIt != animations.end(); animIt++) {
+ cAnimation *anim = animIt->second;
+ anim->Stop();
+ delete anim;
+ }
}
void cView::DrawDebugGrid(void) {
@@ -57,6 +62,7 @@ void cView::Init(void) {
scrollDelay = 0;
scrollMode = smNone;
scrollSpeed = ssMedium;
+ animCat = 0;
currentlyScrolling = false;
}
@@ -85,8 +91,10 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
cTemplateViewElement *viewElement = NULL;
if (tmplViewElement) {
viewElement = tmplViewElement;
+ animCat = 0;
} else if (tmplView) {
viewElement = tmplView->GetViewElement(ve);
+ animCat = ve;
}
if (!viewElement)
return;
@@ -164,8 +172,10 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
void cView::ClearViewElement(eViewElement ve) {
cTemplateViewElement *viewElement = NULL;
+ int currentAnimCat = ve;
if (tmplViewElement) {
viewElement = tmplViewElement;
+ currentAnimCat = 0;
} else if (tmplView) {
viewElement = tmplView->GetViewElement(ve);
}
@@ -182,6 +192,7 @@ void cView::ClearViewElement(eViewElement ve) {
}
pixCurrent++;
}
+ ClearAnimations(currentAnimCat);
}
void cView::DestroyViewElement(eViewElement ve) {
@@ -199,6 +210,21 @@ void cView::DestroyViewElement(eViewElement ve) {
DestroyPixmap(pixCurrent);
pixCurrent++;
}
+ ClearAnimations(ve);
+}
+
+void cView::ClearAnimations(int cat) {
+ //stop and delete all animated elements from this viewelement
+ if (animations.size() == 0)
+ return;
+ pair<multimap<int,cAnimation*>::iterator, multimap<int,cAnimation*>::iterator> rangeAnims;
+ rangeAnims = animations.equal_range(cat);
+ for (multimap<int,cAnimation*>::iterator it = rangeAnims.first; it!=rangeAnims.second; ++it) {
+ cAnimation *anim = it->second;
+ anim->Stop();
+ delete anim;
+ }
+ animations.erase(cat);
}
void cView::ActivateScrolling(void) {
@@ -560,7 +586,11 @@ void cView::DoDrawText(int num, cTemplateFunction *func, int x0, int y0) {
} else {
text = func->GetText(false);
}
- DrawText(num, pos, text.c_str(), clr, clrBack, fontName, fontSize);
+ if (func->IsAnimated()) {
+ DrawAnimatedText(num, func, pos, text, clr, fontName, fontSize);
+ } else {
+ DrawText(num, pos, text.c_str(), clr, clrBack, fontName, fontSize);
+ }
}
void cView::DoDrawTextVertical(int num, cTemplateFunction *func, int x0, int y0) {
@@ -606,7 +636,13 @@ void cView::DoDrawTextVertical(int num, cTemplateFunction *func, int x0, int y0)
if (y < 0) y = func->GetContainerHeight() - textVertical->Height() - 5;
y += y0;
cPoint pos(x,y);
- DrawImage(num, pos, *textVertical);
+
+ if (func->IsAnimated()) {
+ cRect posAnim(x, y, textVertical->Width(), textVertical->Height());
+ DrawAnimatedImage(num, func, posAnim, textVertical);
+ } else {
+ DrawImage(num, pos, *textVertical);
+ }
}
void cView::DoDrawTextBox(int num, cTemplateFunction *func, int x0, int y0) {
@@ -804,7 +840,12 @@ void cView::DoDrawRectangle(int num, cTemplateFunction *func, int x0, int y0) {
int h = func->GetNumericParameter(ptHeight);
cRect size(x, y, w, h);
tColor clr = func->GetColorParameter(ptColor);
- DrawRectangle(num, size, clr);
+
+ if (func->IsAnimated()) {
+ DrawAnimatedOsdObject(num, func, size, clr, 0);
+ } else {
+ DrawRectangle(num, size, clr);
+ }
}
void cView::DoDrawEllipse(int num, cTemplateFunction *func, int x0, int y0) {
@@ -823,7 +864,12 @@ void cView::DoDrawEllipse(int num, cTemplateFunction *func, int x0, int y0) {
esyslog("skindesigner: wrong quadrant %d for drawellipse, allowed values are from -4 to 8", quadrant);
quadrant = 0;
}
- DrawEllipse(num, size, clr, quadrant);
+
+ if (func->IsAnimated()) {
+ DrawAnimatedOsdObject(num, func, size, clr, quadrant);
+ } else {
+ DrawEllipse(num, size, clr, quadrant);
+ }
}
void cView::DoDrawSlope(int num, cTemplateFunction *func, int x0, int y0) {
@@ -842,7 +888,11 @@ void cView::DoDrawSlope(int num, cTemplateFunction *func, int x0, int y0) {
esyslog("skindesigner: wrong type %d for drawslope, allowed values are from 0 to 7", type);
type = 0;
}
- DrawSlope(num, size, clr, type);
+ if (func->IsAnimated()) {
+ DrawAnimatedOsdObject(num, func, size, clr, type);
+ } else {
+ DrawSlope(num, size, clr, type);
+ }
}
void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) {
@@ -861,31 +911,56 @@ void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) {
case itChannelLogo: {
cImage *logo = imgCache->GetLogo(path, width, height);
if (logo) {
- DrawImage(num, pos, *logo);
+ if (func->IsAnimated()) {
+ cRect posAnim(x, y, width, height);
+ DrawAnimatedImage(num, func, posAnim, logo);
+ } else {
+ DrawImage(num, pos, *logo);
+ }
}
break; }
case itSepLogo: {
cImage *sepLogo = imgCache->GetSeparatorLogo(path, width, height);
if (sepLogo) {
- DrawImage(num, pos, *sepLogo);
+ if (func->IsAnimated()) {
+ cRect posAnim(x, y, width, height);
+ DrawAnimatedImage(num, func, posAnim, sepLogo);
+ } else {
+ DrawImage(num, pos, *sepLogo);
+ }
}
break; }
case itSkinPart: {
cImage *skinpart = imgCache->GetSkinpart(path, width, height);
if (skinpart) {
- DrawImage(num, pos, *skinpart);
+ if (func->IsAnimated()) {
+ cRect posAnim(x, y, width, height);
+ DrawAnimatedImage(num, func, posAnim, skinpart);
+ } else {
+ DrawImage(num, pos, *skinpart);
+ }
}
break; }
case itIcon: {
cImage *icon = imgCache->GetIcon(type, path, width, height);
if (icon) {
- DrawImage(num, pos, *icon);
+ if (func->IsAnimated()) {
+ cRect posAnim(x, y, width, height);
+ DrawAnimatedImage(num, func, posAnim, icon);
+ } else {
+ DrawImage(num, pos, *icon);
+ }
}
break; }
case itMenuIcon: {
cImage *icon = imgCache->GetIcon(type, path, width, height);
if (icon) {
- DrawImage(num, pos, *icon);
+ if (func->IsAnimated()) {
+ cRect posAnim(x, y, width, height);
+ DrawAnimatedImage(num, func, posAnim, icon);
+ } else {
+ DrawImage(num, pos, *icon);
+ }
}
break; }
case itImage: {
@@ -901,6 +976,70 @@ void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) {
}
}
+void cView::DrawAnimatedImage(int numPix, cTemplateFunction *func, cRect &pos, cImage *image) {
+ int layer = Layer(numPix);
+ cRect posAnim = CalculateAnimationClip(numPix, pos);
+ eAnimType animType = (eAnimType)func->GetNumericParameter(ptAnimType);
+ int animFreq = func->GetNumericParameter(ptAnimFreq);
+
+ cAnimatedImage *anim = new cAnimatedImage(animType, animFreq, posAnim, layer);
+ animations.insert(pair<int, cAnimation*>(animCat, anim));
+ if (tmplView) {
+ anim->SetAnimationFadeTime(tmplView->GetNumericParameter(ptFadeTime));
+ }
+ anim->SetImage(image);
+ anim->Start();
+}
+
+void cView::DrawAnimatedText(int numPix, cTemplateFunction *func, cPoint &pos, string text, tColor col, string fontName, int fontSize) {
+ int layer = Layer(numPix);
+ int textWidth = fontManager->Width(fontName, fontSize, text.c_str());
+ int textHeight = fontManager->Height(fontName, fontSize);
+ cRect posOrig(pos.X(), pos.Y(), textWidth, textHeight);
+ cRect posAnim = CalculateAnimationClip(numPix, posOrig);
+ eAnimType animType = (eAnimType)func->GetNumericParameter(ptAnimType);
+ int animFreq = func->GetNumericParameter(ptAnimFreq);
+
+ cAnimatedText *anim = new cAnimatedText(animType, animFreq, posAnim, layer);
+ animations.insert(pair<int, cAnimation*>(animCat, anim));
+ if (tmplView) {
+ anim->SetAnimationFadeTime(tmplView->GetNumericParameter(ptFadeTime));
+ }
+ anim->SetText(text);
+ anim->SetFont(fontName);
+ anim->SetFontSize(fontSize);
+ anim->SetFontColor(col);
+ anim->Start();
+}
+
+void cView::DrawAnimatedOsdObject(int numPix, cTemplateFunction *func, cRect &pos, tColor col, int quadrant) {
+ int layer = Layer(numPix);
+ cRect posAnim = CalculateAnimationClip(numPix, pos);
+ eFuncType funcType = func->GetType();
+ eAnimType animType = (eAnimType)func->GetNumericParameter(ptAnimType);
+ int animFreq = func->GetNumericParameter(ptAnimFreq);
+
+ cAnimatedOsdObject *anim = new cAnimatedOsdObject(funcType, animType, animFreq, posAnim, layer);
+ animations.insert(pair<int, cAnimation*>(animCat, anim));
+ if (tmplView) {
+ anim->SetAnimationFadeTime(tmplView->GetNumericParameter(ptFadeTime));
+ }
+ anim->SetColor(col);
+ anim->SetQuadrant(quadrant);
+ anim->Start();
+}
+
+cRect cView::CalculateAnimationClip(int numPix, cRect &pos) {
+ cPoint posPix;
+ Pos(numPix, posPix);
+ cRect posAnim;
+ posAnim.SetX(posPix.X() + pos.X());
+ posAnim.SetY(posPix.Y() + pos.Y());
+ posAnim.SetWidth(pos.Width());
+ posAnim.SetHeight(pos.Height());
+ return posAnim;
+}
+
/***********************************************************************
* cViewElement
************************************************************************/
@@ -1021,6 +1160,7 @@ void cViewListItem::ClearListItem(void) {
for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
Fill(pixCurrent, clrTransparent);
}
+ ClearAnimations(0);
}
void cViewListItem::SetListElementPosition(cTemplatePixmap *pix) {
@@ -1069,7 +1209,6 @@ cGrid::cGrid(cTemplateViewElement *tmplGrid) : cView(tmplGrid) {
}
cGrid::~cGrid() {
-
}
void cGrid::Set(double x, double y, double width, double height,
@@ -1175,6 +1314,7 @@ void cGrid::Clear(void) {
for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
Fill(pixCurrent, clrTransparent);
}
+ ClearAnimations(0);
}
void cGrid::DeletePixmaps(void) {
@@ -1182,6 +1322,7 @@ void cGrid::DeletePixmaps(void) {
for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
DestroyPixmap(pixCurrent);
}
+ ClearAnimations(0);
}
void cGrid::PositionPixmap(cTemplatePixmap *pix) {
diff --git a/views/view.h b/views/view.h
index e6ee909..b7918ca 100644
--- a/views/view.h
+++ b/views/view.h
@@ -5,6 +5,7 @@
#include "map"
#include "../libcore/pixmapcontainer.h"
#include "../libtemplate/template.h"
+#include "animation.h"
using namespace std;
@@ -23,6 +24,10 @@ private:
void DoDrawEllipse(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
void DoDrawSlope(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
void DoDrawImage(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
+ void DrawAnimatedImage(int numPix, cTemplateFunction *func, cRect &pos, cImage *image);
+ void DrawAnimatedText(int numPix, cTemplateFunction *func, cPoint &pos, string text, tColor col, string fontName, int fontSize);
+ void DrawAnimatedOsdObject(int numPix, cTemplateFunction *func, cRect &pos, tColor col, int quadrant);
+ cRect CalculateAnimationClip(int numPix, cRect &pos);
void ActivateScrolling(void);
protected:
cTemplateView *tmplView;
@@ -30,6 +35,8 @@ protected:
cTemplateViewTab *tmplTab;
//detached viewelements
map < eViewElement, cViewElement* > detachedViewElements;
+ //animated elements
+ multimap < int, cAnimation* > animations;
//scaling window
cRect scalingWindow;
bool tvScaled;
@@ -44,9 +51,11 @@ protected:
int scrollDelay;
int scrollMode;
int scrollSpeed;
+ int animCat;
void DrawViewElement(eViewElement ve, map <string,string> *stringTokens = NULL, map <string,int> *intTokens = NULL, map < string, vector< map< string, string > > > *loopTokens = NULL);
void ClearViewElement(eViewElement ve);
void DestroyViewElement(eViewElement ve);
+ void ClearAnimations(int cat);
bool ExecuteViewElement(eViewElement ve);
bool DetachViewElement(eViewElement ve);
bool ViewElementScrolls(eViewElement ve);