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 ?
146 int xb = Osd->
Width() - 1;
147 int yb = Osd->
Height() - 1;
153 for (
int i = 0; i < n; i++) {
164 for (
int i = 0; i < n; i++) {
176 for (
int i = 0; i < n; i++) {
188 for (
int i = 0; i < n; i++) {
200 for (
int i = 0; i < n; i++) {
212 for (
int i = 0; i < n; i++) {
235 virtual void Show(
void);
257 while (x1 > 0 && y1 > 0) {
258 tArea Area = { 0, 0, x1, y1, 4 };
293 default:
return state;
313 virtual void Action(
void);
318 virtual void Show(
void);
365 int ScrollWaitTime = 1000;
366 int ScrollLineTime = 200;
367 int ScrollTotalTime = 8000;
369 uint64_t ScrollStartTime = 0;
370 int ScrollLineNumber = 0;
371 cPoint MoveStart, MoveEnd;
372 cPoint TileStart, TileEnd;
373 cPoint ScrollStart, ScrollEnd;
375 int StartLine = Line;
380 bool Animated =
false;
383 double t =
min(
double(Now -
Start) / FadeTime, 1.0);
391 double t =
min(
double(Now -
Start) / FadeTime, 1.0);
395 FadeOutPixmap = NULL;
399 double t =
min(
double(Now -
Start) / MoveTime, 1.0);
400 int x = MoveStart.
X() + t * (MoveEnd.
X() - MoveStart.
X());
401 int y = MoveStart.
Y() + t * (MoveEnd.
Y() - MoveStart.
Y());
410 double t =
min(
double(Now -
Start) / TileTime, 1.0);
411 int x = TileStart.
X() + t * (TileEnd.
X() - TileStart.
X());
412 int y = TileStart.
Y() + t * (TileEnd.
Y() - TileStart.
Y());
421 if (
int(Now -
Start) > ScrollWaitTime) {
422 if (ScrollStartTime) {
423 double t =
min(
double(Now - ScrollStartTime) / ScrollLineTime, 1.0);
424 int x = ScrollStart.
X() + t * (ScrollEnd.
X() - ScrollStart.
X());
425 int y = ScrollStart.
Y() + t * (ScrollEnd.
Y() - ScrollStart.
Y());
428 if (
int(Now -
Start) < ScrollTotalTime) {
435 ScrollStartTime = Now;
438 FadeOutPixmap = ScrollPixmap;
445 ScrollStartTime = Now;
489 FadeInPixmap = NextPixmap;
502 for (
int y = 0; y < h; y++) {
503 for (
int x = 0; x < w; x++)
507 Pixmap->DrawImage(
cPoint(0, 0), Image);
515 MovePixmap = NextPixmap;
531 MovePixmap = TilePixmap;
540 const char *Text =
"Scrolling Pixmaps";
541 int w = OsdFont->
Width(Text);
542 int h = OsdFont->
Height();
548 ScrollPixmap = Pixmap;
549 ScrollStart.
Set(0, 0);
550 ScrollEnd.
Set(0, -h);
557 const char *Text =
"Animation";
558 const int Size = SmlFont->
Width(Text) + 10;
559 const int NumDots = 12;
560 const int AnimFrames = NumDots;
562 int Cols = (AnimFrames + Rows - 1) / Rows;
568 const int Diameter = Size / 5;
569 for (
int Frame = 0; Frame < AnimFrames; Frame++) {
570 int x0 = Frame / Rows * Size;
571 int y0 = Frame % Rows * Size;
573 int xc = x0 + Size / 2 - Diameter / 2;
574 int yc = y0 + Size / 2 - Diameter / 2;
576 int Delta = Color / NumDots / 3;
577 for (
int a = 0; a < NumDots; a++) {
578 double t = 2 * M_PI * (Frame + a) / NumDots;
579 int x = xc + ((Size - Diameter) / 2 - 5) * cos(t);
580 int y = yc + ((Size - Diameter) / 2 - 5) * sin(t);
587 FadeInPixmap = AnimPixmap;
601 if (
cursor != OldCursor) {
602 MovePixmap = AnimPixmap;
604 MoveEnd = OldCursor =
cursor;
615 if (Delta < FrameTime)
684 default:
return state;
703 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...
virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
Draws the given string at coordinates (x, y) with the given foreground and background color and font.
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)
void DrawEllipseAlignments(cOsd *Osd)
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.