Go to the documentation of this file.
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;
100 #define NUMOSDIMAGES 16
101 #define NUMOSDIMAGEVARIANTS 8
111 for (
int x = 0; x < images[i]->
Width(); x++) {
112 for (
int y = 0; y < images[i]->
Height(); y++) {
114 (!x || !y || x == images[i]->Width() - 1 || y == images[i]->Height() - 1) ?
clrWhite :
115 (x > images[i]->Width() / 2 ?
150 virtual void Show(
void);
172 while (x1 > 0 && y1 > 0) {
173 tArea Area = { 0, 0, x1, y1, 4 };
208 default:
return state;
228 virtual void Action(
void);
233 virtual void Show(
void);
280 int ScrollWaitTime = 1000;
281 int ScrollLineTime = 200;
282 int ScrollTotalTime = 8000;
284 uint64_t ScrollStartTime = 0;
285 int ScrollLineNumber = 0;
286 cPoint MoveStart, MoveEnd;
287 cPoint TileStart, TileEnd;
288 cPoint ScrollStart, ScrollEnd;
290 int StartLine = Line;
295 bool Animated =
false;
298 double t =
min(
double(Now -
Start) / FadeTime, 1.0);
306 double t =
min(
double(Now -
Start) / FadeTime, 1.0);
310 FadeOutPixmap = NULL;
314 double t =
min(
double(Now -
Start) / MoveTime, 1.0);
315 int x = MoveStart.
X() + t * (MoveEnd.
X() - MoveStart.
X());
316 int y = MoveStart.
Y() + t * (MoveEnd.
Y() - MoveStart.
Y());
325 double t =
min(
double(Now -
Start) / TileTime, 1.0);
326 int x = TileStart.
X() + t * (TileEnd.
X() - TileStart.
X());
327 int y = TileStart.
Y() + t * (TileEnd.
Y() - TileStart.
Y());
336 if (
int(Now -
Start) > ScrollWaitTime) {
337 if (ScrollStartTime) {
338 double t =
min(
double(Now - ScrollStartTime) / ScrollLineTime, 1.0);
339 int x = ScrollStart.
X() + t * (ScrollEnd.
X() - ScrollStart.
X());
340 int y = ScrollStart.
Y() + t * (ScrollEnd.
Y() - ScrollStart.
Y());
343 if (
int(Now -
Start) < ScrollTotalTime) {
350 ScrollStartTime = Now;
353 FadeOutPixmap = ScrollPixmap;
360 ScrollStartTime = Now;
404 FadeInPixmap = NextPixmap;
417 for (
int y = 0; y < h; y++) {
418 for (
int x = 0; x < w; x++)
422 Pixmap->DrawImage(
cPoint(0, 0), Image);
430 MovePixmap = NextPixmap;
446 MovePixmap = TilePixmap;
455 const char *Text =
"Scrolling Pixmaps";
456 int w = OsdFont->
Width(Text);
457 int h = OsdFont->
Height();
463 ScrollPixmap = Pixmap;
464 ScrollStart.
Set(0, 0);
465 ScrollEnd.
Set(0, -h);
472 const char *Text =
"Animation";
473 const int Size = SmlFont->
Width(Text) + 10;
474 const int NumDots = 12;
475 const int AnimFrames = NumDots;
477 int Cols = (AnimFrames + Rows - 1) / Rows;
483 const int Diameter = Size / 5;
484 for (
int Frame = 0; Frame < AnimFrames; Frame++) {
485 int x0 = Frame / Rows * Size;
486 int y0 = Frame % Rows * Size;
488 int xc = x0 + Size / 2 - Diameter / 2;
489 int yc = y0 + Size / 2 - Diameter / 2;
491 int Delta = Color / NumDots / 3;
492 for (
int a = 0; a < NumDots; a++) {
493 double t = 2 * M_PI * (Frame + a) / NumDots;
494 int x = xc + ((Size - Diameter) / 2 - 5) * cos(t);
495 int y = yc + ((Size - Diameter) / 2 - 5) * sin(t);
502 FadeInPixmap = AnimPixmap;
516 if (
cursor != OldCursor) {
517 MovePixmap = AnimPixmap;
519 MoveEnd = OldCursor =
cursor;
530 if (Delta < FrameTime)
595 default:
return state;
614 virtual bool Start(
void);
cRect Grown(int Dw, int Dh) const
static int OsdWidth(void)
cPoint Shifted(int Dx, int Dy) const
void DrawSlopes(cOsd *Osd)
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.
static cString sprintf(const char *fmt,...) __attribute__((format(printf
static bool SupportsTrueColor(void)
Returns true if the current OSD provider is able to handle a true color OSD.
virtual void Clear(void)=0
Clears the pixmap's draw port by setting all pixels to be fully transparent.
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.
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty=true)
Sets the pixmap's draw port to the given Point.
virtual void SetLayer(int Layer)
Sets the layer of this pixmap to the given value.
virtual const char * MainMenuEntry(void)
static uint64_t Now(void)
The cOsd class is the interface to the "On Screen Display".
virtual cMenuSetupPage * SetupMenu(void)
virtual void SetAlpha(int Alpha)
Sets the alpha value of this pixmap to the given value.
static const char * MAINMENUENTRY
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 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 void SetViewPort(const cRect &Rect)
Sets the pixmap's view port to the given Rect.
virtual ~cPluginOsddemo()
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
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 void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
#define NUMOSDIMAGEVARIANTS
virtual cOsdObject * MainMenuAction(void)
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image on this OSD at the given Point.
virtual eOSState ProcessKey(eKeys Key)
virtual int Width(void) const
Returns the original character width as requested when the font was created, or 0 if the default widt...
cPixmap * toggleablePixmap
virtual const char * CommandLineHelp(void)
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...
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
virtual bool ProcessArgs(int argc, char *argv[])
static int OsdHeight(void)
char FontSml[MAXFONTNAME]
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
const cPoint & Point(void) const
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,...
static int StoreImage(const cImage &Image)
Stores the given Image for later use with DrawImage() on an OSD or pixmap.
virtual const char * Version(void)
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 eOSState ProcessKey(eKeys Key)
void Set(int X, int Y, int Width, int Height)
virtual const cSize & MaxPixmapSize(void) const
Returns the maximum possible size of a pixmap this OSD can create.
void Grow(int Dx, int Dy)
Grows the rectangle by the given number of pixels in either direction.
void Set(int Width, int Height)
void DrawEllipses(cOsd *Osd)
void SetBottom(int Bottom)
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
virtual ~cTrueColorDemo()
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...
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.
static const char * VERSION
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
const cRect & ViewPort(void) const
Returns the pixmap's view port, which is relative to the OSD's origin.
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.
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
virtual void Housekeeping(void)
cPixmap * CreateTextPixmap(const char *s, int Line, int Layer, tColor ColorFg, tColor ColorBg, const cFont *Font)
const cRect & DrawPort(void) const
Returns the pixmap's draw port, which is relative to the view port.
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
void DrawImages(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 eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
virtual int Width(void) const =0
Returns the original character width as requested when the font was created, or 0 if the default widt...
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
VDRPLUGINCREATOR(cPluginOsddemo)
cPixmap * destroyablePixmap
virtual eOSState ProcessKey(eKeys Key)
virtual int Height(void) const
Returns the height of this font in pixel (all characters have the same height).
virtual void SetTile(bool Tile)
Sets the tile property of this pixmap to the given value.
virtual void Flush(void)
Actually commits all data to the OSD hardware.
static const char * DESCRIPTION
char FontOsd[MAXFONTNAME]
virtual void DrawRectangle(const cRect &Rect, tColor Color)=0
Draws a filled rectangle with the given Color.
virtual const char * Description(void)
static const cCursesFont Font
virtual bool SetupParse(const char *Name, const char *Value)
static void DropImage(int ImageHandle)
Drops the image referenced by the given ImageHandle.