10 #include <vdr/plugin.h>
13 static const char *
DESCRIPTION =
"Demo of arbitrary OSD setup";
28 int xb = Osd->
Width() - 1;
29 int yb = Osd->
Height() - 1;
32 int x1 = x0 + (xb - xa) / 5;
33 int x2 = x0 + (xb - xa) * 2 / 5;
34 int x3 = x0 + (xb - xa) * 3 / 5;
35 int x4 = x0 + (xb - xa) * 4 / 5;
38 int y2 = (y0 + y4) / 2;
39 int y1 = (y0 + y2) / 2;
40 int y3 = (y2 + y4) / 2;
70 int xb = Osd->
Width() - 1;
71 int yb = Osd->
Height() - 1;
74 int x2 = (x0 + x4) / 2;
75 int x1 = (x0 + x2) / 2;
76 int x3 = (x2 + x4) / 2;
79 int y2 = (y0 + y3) / 2;
80 int y1 = (y0 + y2) / 2;
104 virtual void Show(
void);
126 while (x1 > 0 && y1 > 0) {
127 tArea Area = { 0, 0, x1, y1, 4 };
162 default:
return state;
182 virtual void Action(
void);
187 virtual void Show(
void);
207 const int h = Font->
Height(s);
208 int w = Font->
Width(s);
234 int ScrollWaitTime = 1000;
235 int ScrollLineTime = 200;
236 int ScrollTotalTime = 8000;
238 uint64_t ScrollStartTime = 0;
239 int ScrollLineNumber = 0;
240 cPoint MoveStart, MoveEnd;
241 cPoint TileStart, TileEnd;
242 cPoint ScrollStart, ScrollEnd;
244 int StartLine = Line;
249 bool Animated =
false;
252 double t =
min(
double(Now - Start) / FadeTime, 1.0);
260 double t =
min(
double(Now - Start) / FadeTime, 1.0);
264 FadeOutPixmap = NULL;
268 double t =
min(
double(Now - Start) / MoveTime, 1.0);
269 int x = MoveStart.
X() + t * (MoveEnd.
X() - MoveStart.
X());
270 int y = MoveStart.
Y() + t * (MoveEnd.
Y() - MoveStart.
Y());
279 double t =
min(
double(Now - Start) / TileTime, 1.0);
280 int x = TileStart.
X() + t * (TileEnd.
X() - TileStart.
X());
281 int y = TileStart.
Y() + t * (TileEnd.
Y() - TileStart.
Y());
290 if (
int(Now - Start) > ScrollWaitTime) {
291 if (ScrollStartTime) {
292 double t =
min(
double(Now - ScrollStartTime) / ScrollLineTime, 1.0);
293 int x = ScrollStart.
X() + t * (ScrollEnd.
X() - ScrollStart.
X());
294 int y = ScrollStart.
Y() + t * (ScrollEnd.
Y() - ScrollStart.
Y());
297 if (
int(Now - Start) < ScrollTotalTime) {
304 ScrollStartTime = Now;
307 FadeOutPixmap = ScrollPixmap;
314 ScrollStartTime = Now;
358 FadeInPixmap = NextPixmap;
371 for (
int y = 0; y < h; y++) {
372 for (
int x = 0; x < w; x++)
376 Pixmap->DrawImage(
cPoint(0, 0), Image);
384 MovePixmap = NextPixmap;
400 MovePixmap = TilePixmap;
409 const char *Text =
"Scrolling Pixmaps";
410 int w = OsdFont->
Width(Text);
411 int h = OsdFont->
Height();
417 ScrollPixmap = Pixmap;
418 ScrollStart.
Set(0, 0);
419 ScrollEnd.
Set(0, -h);
426 const char *Text =
"Animation";
427 const int Size = SmlFont->
Width(Text) + 10;
428 const int NumDots = 12;
429 const int AnimFrames = NumDots;
435 const int Diameter = Size / 5;
436 int xc = Size / 2 - Diameter / 2;
437 for (
int Frame = 0; Frame < AnimFrames; Frame++) {
439 int yc = Frame * Size + Size / 2 - Diameter / 2;
441 int Delta = Color / NumDots / 3;
442 for (
int a = 0; a < NumDots; a++) {
443 double t = 2 * M_PI * (Frame + a) / NumDots;
444 int x = xc + ((Size - Diameter) / 2 - 5) * cos(t);
445 int y = yc + ((Size - Diameter) / 2 - 5) * sin(t);
452 FadeInPixmap = AnimPixmap;
466 if (
cursor != OldCursor) {
467 MovePixmap = AnimPixmap;
469 MoveEnd = OldCursor =
cursor;
480 if (Delta < FrameTime)
539 default:
return state;
558 virtual bool Start(
void);
virtual eOSState ProcessKey(eKeys Key)
static int OsdHeight(void)
virtual const char * Version(void)
void DrawSlopes(cOsd *Osd)
virtual void Pan(const cPoint &Dest, const cRect &Source=cRect::Null)=0
Does the same as Scroll(), but also shifts the draw port accordingly, so that the view port doesn't g...
virtual void Housekeeping(void)
virtual void SetViewPort(const cRect &Rect)
Sets the pixmap's view port to the given Rect.
virtual ~cTrueColorDemo()
virtual bool SetupParse(const char *Name, const char *Value)
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
static const char * MAINMENUENTRY
static cString sprintf(const char *fmt,...) __attribute__((format(printf
const cRect & DrawPort(void) const
Returns the pixmap's draw port, which is relative to the view port.
virtual void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants=0)
Draws a filled ellipse defined by the upper left (x1, y1) and lower right (x2, y2) corners with the g...
virtual const char * Description(void)
cPixmap * CreateTextPixmap(const char *s, int Line, int Layer, tColor ColorFg, tColor ColorBg, const cFont *Font)
char FontSml[MAXFONTNAME]
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty=true)
Sets the pixmap's draw port to the given Point.
virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
Draws a filled rectangle defined by the upper left (x1, y1) and lower right (x2, y2) corners with the...
virtual eOSState ProcessKey(eKeys Key)
virtual bool ProcessArgs(int argc, char *argv[])
virtual void SetAlpha(int Alpha)
Sets the alpha value of this pixmap to the given value.
virtual void Flush(void)
Actually commits all data to the OSD hardware.
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
const cRect & ViewPort(void) const
Returns the pixmap's view port, which is relative to the OSD's origin.
void SetPoint(int X, int Y)
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)=0
Draws the given string at Point with the given foreground and background color and font...
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
void DrawEllipses(cOsd *Osd)
static int OsdWidth(void)
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
virtual const char * MainMenuEntry(void)
char FontOsd[MAXFONTNAME]
void SetBottom(int Bottom)
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
void Set(int X, int Y, int Width, int Height)
void bool Start(void)
Actually starts the thread.
virtual ~cPluginOsddemo()
static const cCursesFont Font
The cOsd class is the interface to the "On Screen Display".
static cFont * CreateFont(const char *Name, int CharHeight, int CharWidth=0)
Creates a new font object with the given Name and makes its characters CharHeight pixels high...
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
static const char * VERSION
virtual void SetTile(bool Tile)
Sets the tile property of this pixmap to the given value.
const cPoint & Point(void) const
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
void Grow(int Dx, int Dy)
Grows the rectangle by the given number of pixels in either direction.
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
virtual cPixmap * CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort=cRect::Null)
Creates a new true color pixmap on this OSD (see cPixmap for details).
virtual eOSState ProcessKey(eKeys Key)
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
static bool SupportsTrueColor(void)
Returns true if the current OSD provider is able to handle a true color OSD.
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants=0)=0
Draws a filled ellipse with the given Color that fits into the given rectangle.
virtual cOsdObject * MainMenuAction(void)
cPixmap * destroyablePixmap
tColor HsvToColor(double H, double S, double V)
Converts the given Hue (0..360), Saturation (0..1) and Value (0..1) to an RGB tColor value...
virtual int Width(uint c) const =0
Returns the width of the given character in pixel.
virtual void SetLayer(int Layer)
Sets the layer of this pixmap to the given value.
VDRPLUGINCREATOR(cPluginOsddemo)
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
static uint64_t Now(void)
virtual void Clear(void)=0
Clears the pixmap's draw port by setting all pixels to be fully transparent.
virtual void DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type)
Draws a "slope" into the rectangle defined by the upper left (x1, y1) and lower right (x2...
virtual const char * CommandLineHelp(void)
cRect Grown(int Dw, int Dh) const
cPoint Shifted(int Dx, int Dy) const
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
virtual cMenuSetupPage * SetupMenu(void)
virtual void DrawRectangle(const cRect &Rect, tColor Color)=0
Draws a filled rectangle with the given Color.
cPixmap * toggleablePixmap
static const char * DESCRIPTION
static cOsd * NewOsd(int Left, int Top, uint Level=OSD_LEVEL_DEFAULT)
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates...