summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--marquee.c49
-rw-r--r--marquee.h17
-rw-r--r--render.c94
-rw-r--r--render.h27
-rw-r--r--theme.c4
-rw-r--r--xml/display.h3
-rw-r--r--xml/function.h10
-rw-r--r--xml/object.c8
-rw-r--r--xml/object.h15
-rw-r--r--xml/parser.c24
-rw-r--r--xml/string.h6
12 files changed, 201 insertions, 60 deletions
diff --git a/Makefile b/Makefile
index 133e266..0bc7290 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ HAVE_FREETYPE=1
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING
# -------------------------------------------------------------
#
-# $Id: Makefile,v 1.1 2004/12/19 22:03:06 lordjaxom Exp $
+# $Id: Makefile,v 1.2 2004/12/28 01:24:35 lordjaxom Exp $
#
# The official name of this plugin.
@@ -55,7 +55,7 @@ PACKAGE = vdr-$(ARCHIVE)
OBJS = $(PLUGIN).o loader.o display.o render.o common.o bitmap.o \
file.o i18n.o theme.o cache.o setup.o status.o scroller.o screen.o \
- menu.o font.o quantize.o marquee.o \
+ menu.o font.o quantize.o \
\
xml/skin.o xml/parser.o xml/string.o xml/object.o xml/function.o \
xml/type.o xml/display.o xml/xml.o
diff --git a/marquee.c b/marquee.c
index 7305964..2708257 100644
--- a/marquee.c
+++ b/marquee.c
@@ -1,11 +1,12 @@
/*
- * $Id: marquee.c,v 1.2 2004/12/21 20:26:25 lordjaxom Exp $
+ * $Id: marquee.c,v 1.3 2004/12/28 01:24:35 lordjaxom Exp $
*/
#include "marquee.h"
#include "screen.h"
#include <vdr/tools.h>
+/*
cText2SkinMarquee::cText2SkinMarquee(const cText2SkinMarquee &Src):
mScreen(Src.mScreen),
mFont(Src.mFont),
@@ -49,7 +50,52 @@ void cText2SkinMarquee::Set(cText2SkinScreen *Screen, int Left, int Top, int Wid
mScrolling = mFont->Width(mText.c_str()) > mWidth;
DrawText(UpdateIn);
}
+*/
+
+void cText2SkinMarquee::DrawText(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height,
+ const std::string &Text, const cFont *Font, tColor ColorFg,
+ tColor ColorBg, uint Delay, int &Offset, int &Direction,
+ uint &NextTime)
+{
+ uint now = time_ms();
+ bool scrolling = Font->Width(Text.c_str()) > Width;
+
+ if (NextTime == 0)
+ NextTime = now + 1500;
+ else if (now >= NextTime) {
+ uint nextin = Delay;
+ if (Direction > 0) {
+ if (Font->Width(Text.c_str() + Offset) <= Width) {
+ --Direction;
+ nextin = 1500;
+ } else
+ ++Offset;
+ }
+ else {
+ if (Offset <= 0) {
+ ++Direction;
+ nextin = 1500;
+ } else
+ --Offset;
+ }
+ NextTime = now + nextin;
+ }
+
+ if (!scrolling)
+ NextTime = 0;
+
+ /*
+ if (scrolling) {
+ uint updatein = NextTime - now;
+ if (UpdateIn == 0 || updatein < UpdateIn)
+ UpdateIn = updatein;
+ }
+ */
+
+ Screen->DrawText(Left, Top, Text.c_str() + Offset, ColorFg, ColorBg, Font, Width, Height);
+}
+/*
void cText2SkinMarquee::DrawText(uint &UpdateIn)
{
uint now = time_ms();
@@ -85,3 +131,4 @@ void cText2SkinMarquee::DrawText(uint &UpdateIn)
mScreen->DrawText(mLeft, mTop, mText.c_str() + mOffset, mColorFg, mColorBg, mFont, mWidth,
mHeight);
}
+*/
diff --git a/marquee.h b/marquee.h
index e39443b..36561c4 100644
--- a/marquee.h
+++ b/marquee.h
@@ -1,5 +1,5 @@
/*
- * $Id: marquee.h,v 1.2 2004/12/21 20:26:25 lordjaxom Exp $
+ * $Id: marquee.h,v 1.3 2004/12/28 01:24:35 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_MARQUEE_H
@@ -13,6 +13,7 @@ class cText2SkinScreen;
class cText2SkinMarquee {
private:
+ /*
cText2SkinScreen *mScreen;
const cFont *mFont;
int mLeft;
@@ -33,14 +34,14 @@ public:
cText2SkinMarquee(const cText2SkinMarquee &Src);
cText2SkinMarquee(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height,
const std::string &Text, const cFont *Font, tColor ColorFg, tColor ColorBg,
- uint &UpdateIn);
-
- void Set(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height,
- const std::string &Text, const cFont *Font, tColor ColorFg, tColor ColorBg,
- uint &UpdateIn);
- void DrawText(uint &UpdateIn);
+ uint &UpdateIn);*/
+public:
+ static void DrawText(cText2SkinScreen *Screen, int Left, int Top, int Width, int Height,
+ const std::string &Text, const cFont *Font, tColor ColorFg, tColor ColorBg,
+ uint Delay, int &Offset, int &Direction, uint &NextTime);
+ //static void DrawText(uint &UpdateIn);
- const std::string &Text(void) const { return mText; }
+ //const std::string &Text(void) const { return mText; }
};
#endif // VDR_TEXT2SKIN_MARQUEE_H
diff --git a/render.c b/render.c
index 952dbbd..3a43b94 100644
--- a/render.c
+++ b/render.c
@@ -1,5 +1,5 @@
/*
- * $Id: render.c,v 1.3 2004/12/21 20:26:25 lordjaxom Exp $
+ * $Id: render.c,v 1.4 2004/12/28 01:24:35 lordjaxom Exp $
*/
#include "render.h"
@@ -33,6 +33,7 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, cxDisplay::eType Di
mDoUpdateMutex(),
mStarted(),
mUpdateIn(0),
+ mNow(0),
mBaseSize()
{
mRender = this;
@@ -108,10 +109,10 @@ cText2SkinRender::~cText2SkinRender()
Cancel(3);
}
delete mScroller;
- mMarquees.clear();
delete mScreen;
- mRender = NULL;
+
Text2SkinStatus.SetRender(NULL);
+ mRender = NULL;
}
void cText2SkinRender::Action(void)
@@ -126,6 +127,7 @@ void cText2SkinRender::Action(void)
if (!mActive) break; // fall out if thread to be stopped
mUpdateIn = 0; // has to be re-set within Update();
+ mNow = time_ms();
Update();
}
UpdateUnlock();
@@ -162,7 +164,12 @@ void cText2SkinRender::DrawObject(const cxObject *Object)
case cxObject::marquee:
DrawMarquee(Object->Pos(), Object->Size(), Object->Fg(), Object->Text(), Object->Font(),
- Object->Align(), Object->Index());
+ Object->Align(), Object->Delay(), Object->Index());
+ break;
+
+ case cxObject::blink:
+ DrawBlink(Object->Pos(), Object->Size(), Object->Fg(), Object->Bg(), Object->Text(),
+ Object->Font(), Object->Align(), Object->Delay(), Object->Index());
break;
case cxObject::rectangle:
@@ -218,7 +225,7 @@ void cText2SkinRender::DrawObject(const cxObject *Object)
int nexttab = GetTab(t + 1);
cxObject obj(*o);
- obj.SetIndex(i, t);
+ obj.SetListIndex(i, t);
if (obj.Condition() != NULL && !obj.Condition()->EvaluateToBool())
continue;
@@ -285,19 +292,72 @@ void cText2SkinRender::DrawText(const txPoint &Pos, const txSize &Size, const tC
void cText2SkinRender::DrawMarquee(const txPoint &Pos, const txSize &Size, const tColor *Fg,
const std::string &Text, const cFont *Font, int Align,
- uint Index)
+ uint Delay, uint Index)
{
- Dprintf("DrawMarquee %d -> %s\n", Index, Text.c_str());
- if (Index >= mMarquees.size()) {
- cText2SkinMarquee marquee(mScreen, Pos.x, Pos.y, Size.w, Size.h, Text, Font, Fg ? *Fg : 0,
- clrTransparent, mUpdateIn);
- mMarquees.push_back(marquee);
- }
- else if (Text != mMarquees[Index].Text())
- mMarquees[Index].Set(mScreen, Pos.x, Pos.y, Size.w, Size.h, Text, Font, Fg ? *Fg : 0,
- clrTransparent, mUpdateIn);
- else
- mMarquees[Index].DrawText(mUpdateIn);
+ bool scrolling = Font->Width(Text.c_str()) > Size.w;
+
+ tState &state = mStates[Index];
+ if (state.text != Text) {
+ state = tState();
+ state.text = Text;
+ }
+ Dprintf("drawMarquee state.text = %s, offset = %d\n", state.text.c_str(), state.offset);
+
+ if (state.nexttime == 0)
+ state.nexttime = mNow + 1500;
+ else if (mNow >= state.nexttime) {
+ uint nextin = Delay;
+ if (state.direction > 0) {
+ if (Font->Width(Text.c_str() + state.offset) <= Size.w) {
+ --state.direction;
+ nextin = 1500;
+ } else
+ ++state.offset;
+ }
+ else {
+ if (state.offset <= 0) {
+ ++state.direction;
+ nextin = 1500;
+ } else
+ --state.offset;
+ }
+ state.nexttime = mNow + nextin;
+ }
+
+ if (scrolling) {
+ uint updatein = state.nexttime - mNow;
+ if (mUpdateIn == 0 || updatein < mUpdateIn)
+ mUpdateIn = updatein;
+ }
+
+ mScreen->DrawText(Pos.x, Pos.y, Text.c_str() + state.offset, Fg ? *Fg : 0, clrTransparent, Font,
+ Size.w, Size.h);
+}
+
+void cText2SkinRender::DrawBlink(const txPoint &Pos, const txSize &Size, const tColor *Fg,
+ const tColor *Bg, const std::string &Text, const cFont *Font,
+ int Align, uint Delay, uint Index)
+{
+ tState &state = mStates[Index];
+ if (state.text != Text) {
+ state = tState();
+ state.text = Text;
+ }
+ Dprintf("drawBlink state.text = %s, offset = %d\n", state.text.c_str(), state.offset);
+
+ if (state.nexttime == 0 || mNow >= state.nexttime) {
+ state.nexttime = mNow + Delay;
+ state.offset = 1 - state.offset;
+ }
+
+ uint updatein = state.nexttime - mNow;
+ if (mUpdateIn == 0 || updatein < mUpdateIn)
+ mUpdateIn = updatein;
+
+ mScreen->DrawText(Pos.x, Pos.y, Text.c_str(), state.offset == 0
+ ? (Fg ? *Fg : 0)
+ : (Bg ? *Bg : 0),
+ clrTransparent, Font, Size.w, Size.h);
}
void cText2SkinRender::DrawRectangle(const txPoint &Pos, const txSize &Size, const tColor *Fg)
diff --git a/render.h b/render.h
index bb8331a..ed65d4c 100644
--- a/render.h
+++ b/render.h
@@ -1,5 +1,5 @@
/*
- * $Id: render.h,v 1.4 2004/12/21 20:26:25 lordjaxom Exp $
+ * $Id: render.h,v 1.5 2004/12/28 01:24:35 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_RENDER_H
@@ -35,7 +35,6 @@ class cText2SkinRender: public cThread {
private:
typedef std::map<txToken,cxType> tTokenCache;
- typedef std::vector<cText2SkinMarquee> tMarquees;
static cText2SkinRender *mRender;
@@ -45,7 +44,6 @@ private:
cText2SkinTheme *mTheme;
cText2SkinScreen *mScreen;
cText2SkinScroller *mScroller;
- tMarquees mMarquees;
tTokenCache mTokenCache;
std::string mBasePath;
@@ -58,10 +56,24 @@ private:
cMutex mDoUpdateMutex;
cCondVar mStarted;
uint mUpdateIn;
+ uint mNow; // timestamp to calculate update timings
// coordinate transformation
txSize mBaseSize;
+ // state information for marquee, blink, scroll
+ struct tState {
+ bool scrolling;
+ int offset;
+ int direction;
+ uint nexttime;
+ std::string text;
+
+ tState(void): scrolling(false), offset(0), direction(1), nexttime(0) {}
+ };
+ typedef std::map<uint,tState> tStates;
+ tStates mStates;
+
protected:
// Update thread
void UpdateLock(void) { mDoUpdateMutex.Lock(); }
@@ -77,9 +89,10 @@ protected:
void DrawText(const txPoint &Pos, const txSize &Size, const tColor *Fg, const std::string &Text,
const cFont *Font, int Align);
void DrawMarquee(const txPoint &Pos, const txSize &Size, const tColor *Fg,
- const std::string &Text, const cFont *Font, int Align, uint Index);
- void DrawRectangle(const txPoint &Pos, const txSize &Size,
- const tColor *Fg);
+ const std::string &Text, const cFont *Font, int Align, uint Delay, uint Index);
+ void DrawBlink(const txPoint &Pos, const txSize &Size, const tColor *Fg, const tColor *Bg,
+ const std::string &Text, const cFont *Font, int Align, uint Delay, uint Index);
+ void DrawRectangle(const txPoint &Pos, const txSize &Size, const tColor *Fg);
void DrawEllipse(const txPoint &Pos, const txSize &Size, const tColor *Fg, int Arc);
void DrawSlope(const txPoint &Pos, const txSize &Size, const tColor *Fg, int Arc);
void DrawProgressbar(const txPoint &Pos, const txSize &Size, int Current, int Total,
@@ -106,7 +119,7 @@ protected:
void Flush(bool Force = false);
void SetDirty(void) { mDirty = true; }
void Scroll(bool Up, bool Page) { if (mScroller) mScroller->Scroll(Up, Page); }
- void Clear(void) { DELETENULL(mScroller); mMarquees.clear(); }
+ void Clear(void) { DELETENULL(mScroller); }
public:
cText2SkinRender(cText2SkinLoader *Loader, cxDisplay::eType Section,
diff --git a/theme.c b/theme.c
index cf473e8..f4c614f 100644
--- a/theme.c
+++ b/theme.c
@@ -1,5 +1,5 @@
/*
- * $Id: theme.c,v 1.1 2004/12/19 22:03:19 lordjaxom Exp $
+ * $Id: theme.c,v 1.2 2004/12/28 01:24:35 lordjaxom Exp $
*/
#include "theme.h"
#include <vdr/osd.h>
@@ -22,7 +22,7 @@ bool cText2SkinTheme::Parse(const char *Text) {
mMap[name] = mTheme.AddColor(name.c_str(), value);
result = true;
} else
- esyslog("ERROR: text2skin: Parameters name and default must be present\n");
+ esyslog("ERROR: text2skin: Parameters name and default must be present");
} else
esyslog("ERROR: text2skin: syntax error");
}
diff --git a/xml/display.h b/xml/display.h
index b57f734..73a7269 100644
--- a/xml/display.h
+++ b/xml/display.h
@@ -1,5 +1,5 @@
/*
- * $Id: display.h,v 1.1 2004/12/19 22:03:25 lordjaxom Exp $
+ * $Id: display.h,v 1.2 2004/12/28 01:24:35 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_DISPLAY_H
@@ -31,6 +31,7 @@ private:
eType mType;
txWindow mWindows[MAXOSDAREAS];
int mNumWindows;
+ int mNumMarquees;
cxObjects mObjects;
cxSkin *mSkin;
diff --git a/xml/function.h b/xml/function.h
index a67163b..3b9155b 100644
--- a/xml/function.h
+++ b/xml/function.h
@@ -1,5 +1,5 @@
/*
- * $Id: function.h,v 1.1 2004/12/19 22:03:26 lordjaxom Exp $
+ * $Id: function.h,v 1.2 2004/12/28 01:24:35 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_FUNCTION_H
@@ -55,14 +55,14 @@ public:
std::string Evaluate(void) const;
bool EvaluateToBool(void);
- void SetIndex(uint Index, int Tab);
+ void SetListIndex(uint Index, int Tab);
};
-inline void cxFunction::SetIndex(uint Index, int Tab)
+inline void cxFunction::SetListIndex(uint Index, int Tab)
{
- mString.SetIndex(Index, Tab);
+ mString.SetListIndex(Index, Tab);
for (uint i = 0; i < mNumParams; ++i)
- mParams[i]->SetIndex(Index, Tab);
+ mParams[i]->SetListIndex(Index, Tab);
}
#endif // VDR_TEXT2SKIN_XML_FUNCTION_H
diff --git a/xml/object.c b/xml/object.c
index 159a9c7..1b8ac04 100644
--- a/xml/object.c
+++ b/xml/object.c
@@ -1,5 +1,5 @@
/*
- * $Id: object.c,v 1.2 2004/12/21 20:36:41 lordjaxom Exp $
+ * $Id: object.c,v 1.3 2004/12/28 01:24:35 lordjaxom Exp $
*/
#include "xml/object.h"
@@ -7,8 +7,8 @@
#include "font.h"
static const std::string ObjectNames[] =
- { "image", "text", "marquee", "rectangle", "ellipse", "slope", "progress", "scrolltext",
- "scrollbar", "block", "list", "item" };
+ { "image", "text", "marquee", "blink", "rectangle", "ellipse", "slope", "progress",
+ "scrolltext", "scrollbar", "block", "list", "item" };
cxObject::cxObject(cxDisplay *parent):
mType((eType)__COUNT_OBJECT__),
@@ -21,6 +21,7 @@ cxObject::cxObject(cxDisplay *parent):
mCondition(NULL),
mFontFace("Osd"),
mFontSize(0),
+ mDelay(150),
mIndex(0),
mObjects(NULL),
mDisplay(parent),
@@ -48,6 +49,7 @@ cxObject::cxObject(const cxObject &Src):
mTotal(Src.mTotal),
mFontFace(Src.mFontFace),
mFontSize(Src.mFontSize),
+ mDelay(0),
mObjects(NULL),
mDisplay(Src.mDisplay),
mSkin(Src.mSkin)
diff --git a/xml/object.h b/xml/object.h
index 4778b83..b7bd46c 100644
--- a/xml/object.h
+++ b/xml/object.h
@@ -1,5 +1,5 @@
/*
- * $Id: object.h,v 1.1 2004/12/19 22:03:27 lordjaxom Exp $
+ * $Id: object.h,v 1.2 2004/12/28 01:24:35 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_OBJECT_H
@@ -49,6 +49,7 @@ public:
image,
text,
marquee,
+ blink,
rectangle,
ellipse,
slope,
@@ -81,6 +82,7 @@ private:
cxString mTotal;
std::string mFontFace;
int mFontSize;
+ uint mDelay;
uint mIndex;
cxObjects *mObjects; // used for block objects such as <list>
cxDisplay *mDisplay;
@@ -96,7 +98,7 @@ public:
bool ParseAlignment(const std::string &Text);
bool ParseFontFace (const std::string &Text);
- void SetIndex(uint Index, int Tab);
+ void SetListIndex(uint Index, int Tab);
eType Type(void) const { return mType; }
cxFunction *Condition(void) const { return mCondition; }
@@ -108,6 +110,7 @@ public:
std::string Text(void) const { return mText.Evaluate(); }
int Current(void) const { return mCurrent.Evaluate(); }
int Total(void) const { return mTotal.Evaluate(); }
+ uint Delay(void) const { return mDelay; }
uint Index(void) const { return mIndex; }
cxDisplay *Display(void) const { return mDisplay; }
cxSkin *Skin(void) const { return mSkin; }
@@ -126,12 +129,12 @@ public:
const cxObject *GetObject(uint Index) const;
};
-inline void cxObject::SetIndex(uint Index, int Tab)
+inline void cxObject::SetListIndex(uint Index, int Tab)
{
- mText.SetIndex(Index, Tab);
- mPath.SetIndex(Index, Tab);
+ mText.SetListIndex(Index, Tab);
+ mPath.SetListIndex(Index, Tab);
if (mCondition != NULL)
- mCondition->SetIndex(Index, Tab);
+ mCondition->SetListIndex(Index, Tab);
}
class cxObjects: public std::vector<cxObject*> {
diff --git a/xml/parser.c b/xml/parser.c
index c6ba202..2f66300 100644
--- a/xml/parser.c
+++ b/xml/parser.c
@@ -1,5 +1,5 @@
/*
- * $Id: parser.c,v 1.2 2004/12/21 20:36:12 lordjaxom Exp $
+ * $Id: parser.c,v 1.3 2004/12/28 01:24:35 lordjaxom Exp $
*/
#include "xml/parser.h"
@@ -84,7 +84,7 @@ static cxSkin *skin = NULL;
static cxDisplay *display = NULL;
static cxObject *parent = NULL;
static cxObject *object = NULL;
-static uint mindex = 0;
+static uint oindex = 0;
bool xStartElem(const std::string &name, std::map<std::string,std::string> &attrs) {
//Dprintf("start element: %s\n", name.c_str());
@@ -148,13 +148,25 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr
}
else if (name == "text"
|| name == "marquee"
+ || name == "blink"
|| name == "scrolltext") {
ATTRIB_OPT_STRING("color", object->mFg);
ATTRIB_OPT_FUNC ("align", object->ParseAlignment);
ATTRIB_OPT_FUNC ("font", object->ParseFontFace);
- if (name == "marquee")
- object->mIndex = mindex++;
+ if (name == "blink") {
+ ATTRIB_OPT_STRING("blinkColor", object->mBg);
+ ATTRIB_OPT_NUMBER("delay", object->mDelay);
+
+ if (object->mDelay == 0)
+ object->mDelay = 1000;
+ }
+ else if (name == "marquee") {
+ ATTRIB_OPT_NUMBER("delay", object->mDelay);
+
+ if (object->mDelay == 0)
+ object->mDelay = 500;
+ }
}
else if (name == "rectangle") {
ATTRIB_OPT_STRING("color", object->mFg);
@@ -216,9 +228,10 @@ bool xEndElem(const std::string &name) {
//Dprintf("end element: %s\n", name.c_str());
if (context[context.size() - 1] == name) {
if (name == "display") {
+ //display->mNumMarquees = mindex;
skin->mDisplays[display->Type()] = display;
display = NULL;
- mindex = 0;
+ oindex = 0;
}
else if (object != NULL || parent != NULL) {
if (object == NULL) {
@@ -238,6 +251,7 @@ bool xEndElem(const std::string &name) {
}
}
+ object->mIndex = oindex++;
if (parent != NULL) {
//Dprintf("pushing to parent\n");
if (parent->mObjects == NULL)
diff --git a/xml/string.h b/xml/string.h
index b3b0c8d..f441c9f 100644
--- a/xml/string.h
+++ b/xml/string.h
@@ -1,5 +1,5 @@
/*
- * $Id: string.h,v 1.3 2004/12/21 20:26:25 lordjaxom Exp $
+ * $Id: string.h,v 1.4 2004/12/28 01:24:35 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_STRING_H
@@ -175,10 +175,10 @@ public:
bool Parse(const std::string &Text);
cxType Evaluate(void) const;
- void SetIndex(uint Index, int Tab);
+ void SetListIndex(uint Index, int Tab);
};
-inline void cxString::SetIndex(uint Index, int Tab)
+inline void cxString::SetListIndex(uint Index, int Tab)
{
for (uint i = 0; i < mTokens.size(); ++i) {
mTokens[i].Index = Index;