summaryrefslogtreecommitdiff
path: root/texteffects.h
diff options
context:
space:
mode:
Diffstat (limited to 'texteffects.h')
-rw-r--r--texteffects.h146
1 files changed, 76 insertions, 70 deletions
diff --git a/texteffects.h b/texteffects.h
index ee7ed4b..e0b9922 100644
--- a/texteffects.h
+++ b/texteffects.h
@@ -1,5 +1,5 @@
/*
- * status.h: 'EnigmaNG' skin for the Video Disk Recorder
+ * texteffects.h: 'EnigmaNG' skin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
@@ -8,26 +8,14 @@
#ifndef __TEXTEFFECTS_H
#define __TEXTEFFECTS_H
+#include <semaphore.h>
+
#include "common.h"
#include "enigma.h"
-#ifndef DISABLE_ANIMATED_TEXT
#include <vector>
-#endif
#include <vdr/skins.h>
-
-#ifdef DISABLE_ANIMATED_TEXT
-#define TE_START(osd) ;
-#define TE_STOP ;
-#define TE_LOCK ;
-#define TE_UNLOCK ;
-#define TE_WAKEUP ;
-#define TE_MARQUEE(osd, id, x...) osd->DrawText(x)
-#define TE_BLINK(osd, id, x...) osd->DrawText(x)
-#define TE_TITLE(osd, id, s, Width, skin) osd->DrawTitle(s)
-
-#else // !DISABLE_ANIMATED_TEXT
#include <vdr/thread.h>
#define TE_START(osd) EnigmaTextEffects.Start(osd);
@@ -37,55 +25,87 @@
#define TE_WAKEUP EnigmaTextEffects.RefreshEffects();
#define TE_MARQUEE(osd, id, x...) EnigmaTextEffects.DrawAnimatedText(id, 0, x)
#define TE_BLINK(osd, id, x...) EnigmaTextEffects.DrawAnimatedText(id, 1, x)
-#define TE_TITLE(osd, id, x...) EnigmaTextEffects.DrawAnimatedTitle(id, 0, x)
-#endif //DISABLE_ANIMATED_TEXT
+class cEffect
+{
+protected:
+ bool Active;
+ cOsd *Osd;
+ int xOff;
+ int yOff;
+ int Width;
+ int Height;
+ int ColorDepth;
+ char *Text;
+
+ cTimeMs Time;
+ cBitmap *bmp;
+
+public:
+ cEffect(cOsd *osd, int x, int y, int width, int height = 0, int depth = 1, bool active = true);
+ virtual ~cEffect();
+ virtual bool SetText(const char *text, const cFont *font, int offset = 0) = 0;
+ virtual int DrawIfNeeded(int yMax) = 0;
+ bool changed;
+};
+
+class cEffectScroll : public cEffect
+{
+private:
+ tColor Fg;
+ tColor Bg;
+ int Alignment;
+ int Delay;
+
+ int pos;
+ int dir;
+ int delay;
+ int xOffset;
+ int DestWidth;
+
+ bool IsDrawNeeded(void);
+
+public:
+ cEffectScroll(cOsd *osd, int x, int y, int width, int height = 0, tColor fg = 0xFFFFFFFF, tColor bg = 0xFF000000, int alignment = taDefault, int depth = 1, bool active = true);
+ virtual ~cEffectScroll()
+ {};
+ virtual bool SetText(const char *text, const cFont *font, int offset = 0);
+ virtual int DrawIfNeeded(int yMax);
+};
+
+class cEffectBlink : public cEffect
+{
+private:
+ tColor Fg;
+ tColor Bg;
+ int Alignment;
+ int Delay;
+
+ bool shown;
+ int delay;
+ int xOffset;
+ int DestWidth;
+
+public:
+ cEffectBlink(cOsd *osd, int x, int y, int width, int height = 0, tColor fg = 0xFFFFFFFF, tColor bg = 0xFF000000, int alignment = taDefault, int depth = 1, bool active = true);
+ virtual ~cEffectBlink()
+ {};
+ virtual bool SetText(const char *text, const cFont *font, int offset = 0);
+ virtual int DrawIfNeeded(int yMax);
+};
-#ifdef DISABLE_ANIMATED_TEXT
-class cEnigmaTextEffects {
-#else
class cEnigmaTextEffects : public cThread {
-#endif
private:
cOsd *osd;
-#ifdef HAVE_FREETYPE
- char **availTTFs;
- int nMaxTTFs;
-#endif
-
-#ifndef DISABLE_ANIMATED_TEXT
int yMessageTop;
- struct tEffect {
- int nAction;
- uint nOffset;
- int nDirection;
- uint64_t nNextUpdate;
- std::string strText;
- int x, y, Width, Height;
- tColor ColorFg, ColorBg;
- const cFont *Font;
- int Alignment;
- cSkinEnigmaThreadedOsd *Skin;
-
- public:
- tEffect(void) : nAction(0), nOffset(0), nDirection(0),
- nNextUpdate(0), x(0), y(0), Width(0), Height(0),
- ColorFg(0), ColorBg(0), Font(NULL),
- Alignment(taDefault), Skin(NULL)
- {};
- };
-
- typedef std::vector<tEffect*> tEffects;
- tEffects vecEffects;
+ typedef std::vector<cEffect*> Effects_t;
+ Effects_t vecEffects;
cCondVar condSleep;
cMutex mutexSleep;
cMutex mutexRunning;
-
- void DoEffect(tEffect *e, uint64_t nNow = 0);
- void DoScroll(tEffect *e, uint64_t nNow, bool fDrawItem);
- void DoBlink(tEffect *e, uint64_t nNow, bool fDrawItem);
+ sem_t sem_update;
void Wakeup(void)
{
@@ -95,14 +115,8 @@ private:
mutexSleep.Unlock();
// printf("WAKE2: %lu\n", pthread_self());
}
-#endif //DISABLE_ANIMATED_TEXT
public:
-#ifdef DISABLE_ANIMATED_TEXT
- cEnigmaTextEffects(void);
- ~cEnigmaTextEffects(void);
-
-#else
cEnigmaTextEffects(const char *Description = NULL);
~cEnigmaTextEffects(void);
@@ -114,32 +128,24 @@ public:
void ResetText(int i, tColor ColorFg = 0, tColor ColorBg = 0, bool fDraw = true);
void PauseEffects(int y = 0);
- void UpdateTextWidth(int i, int Width);
- int DrawAnimatedTitle(int o_id, int action, const char *s, int Width, cSkinEnigmaThreadedOsd *skin);
- int DrawAnimatedText(int o_id, int action, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault);
+ int DrawAnimatedText(int o_id, int action, bool active, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int ColorDepth = 1, int Width = 0, int Height = 0, int Alignment = taDefault);
void UpdateLock(void)
{
// printf("LOCK1: %lu\n", pthread_self());
- Lock();
+ sem_wait(&sem_update);
// printf("LOCK2: %lu\n", pthread_self());
}
void UpdateUnlock(void)
{
// printf("UNLOCK1: %lu\n", pthread_self());
- Unlock();
+ sem_post(&sem_update);
// printf("UNLOCK2: %lu\n", pthread_self());
}
void RefreshEffects(void)
{ Wakeup(); }
-#endif //DISABLE_ANIMATED_TEXT
-
-#ifdef HAVE_FREETYPE
- int GetNumAvailTTFs(void) { return nMaxTTFs; }
- const char **GetAvailTTFs(void);
-#endif
};
extern cEnigmaTextEffects EnigmaTextEffects;