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 ?
125 osdImages[i].
size.
Set(images[i % NUMOSDIMAGEVARIANTS]->Size());
150 virtual void Show(
void);
172 while (x1 > 0 && y1 > 0) {
173 tArea Area = { 0, 0, x1, y1, 4 };
174 if (osd->CanHandleAreas(&Area, 1) ==
oeOk) {
175 osd->SetAreas(&Area, 1);
176 osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1,
clrGray50);
178 x = osd->
Width() / 2;
179 y = osd->Height() / 2;
194 case kUp: y =
max(0, y - d);
break;
195 case kDown: y =
min(osd->Height() - d, y + d);
break;
196 case kLeft: x =
max(0, x - d);
break;
197 case kRight: x =
min(osd->Width() - d, x + d);
break;
208 default:
return state;
210 osd->DrawRectangle(x, y, x + d - 1, y + d - 1, color);
228 virtual void Action(
void);
233 virtual void Show(
void);
241 destroyablePixmap = NULL;
242 toggleablePixmap = NULL;
253 const int h = Font->
Height(s);
254 int w = Font->
Width(s);
255 cPixmap *Pixmap = osd->CreatePixmap(Layer,
cRect((osd->Width() - w) / 2, Line, w, h));
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;
289 int Line = osd->Height() / 20;
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());
330 destroyablePixmap = TilePixmap;
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;
371 else if (!clockwise && p.
Y() > 0)
404 FadeInPixmap = NextPixmap;
413 Line += osd->Height() / 10;
414 int w = osd->Width() / 2;
415 int h = osd->Height() - Line - osd->Height() / 10;
417 for (
int y = 0; y < h; y++) {
418 for (
int x = 0; x < w; x++)
421 if (
cPixmap *Pixmap = osd->CreatePixmap(2,
cRect((osd->Width() - w) / 2, Line, w, h))) {
422 Pixmap->DrawImage(
cPoint(0, 0), Image);
423 toggleablePixmap = Pixmap;
430 MovePixmap = NextPixmap;
439 TilePixmap = CreateTextPixmap(
"Tiled Pixmaps", StartLine, 1,
clrRed,
clrWhite, OsdFont);
446 MovePixmap = TilePixmap;
455 const char *Text =
"Scrolling Pixmaps";
456 int w = OsdFont->
Width(Text);
457 int h = OsdFont->
Height();
458 if (
cPixmap *Pixmap = osd->CreatePixmap(2,
cRect((osd->Width() - w) / 2, StartLine, w, 2 * h),
cRect(0, 0, w, 3 * h))) {
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;
476 int Rows =
min(osd->MaxPixmapSize().Height() / Size, AnimFrames);
477 int Cols = (AnimFrames + Rows - 1) / Rows;
479 AnimPixmap = osd->CreatePixmap(0,
cRect((osd->Width() - Size) / 2, StartLine, Size, Size),
cRect(0, 0, Size * Cols, Size * 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;
505 cursorLimits.
Set(0, 0, osd->Width(), osd->Height());
506 cursorLimits.SetRight(cursorLimits.Right() - Size);
507 cursorLimits.SetBottom(cursorLimits.Bottom() - Size);
508 cursorLimits.Grow(-10, -10);
516 if (cursor != OldCursor) {
517 MovePixmap = AnimPixmap;
519 MoveEnd = OldCursor = cursor;
530 if (Delta < FrameTime)
533 destroyablePixmap = NULL;
534 toggleablePixmap = NULL;
544 return osd->SetAreas(&Area, 1) ==
oeOk;
554 osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1,
clrGray50);
569 case kUp: cursor.SetY(
max(cursorLimits.Top(), cursor.Y() - d)); clockwise =
false;
break;
570 case kDown: cursor.SetY(
min(cursorLimits.Bottom(), cursor.Y() + d)); clockwise =
true;
break;
571 case kLeft: cursor.SetX(
max(cursorLimits.Left(), cursor.X() - d)); clockwise =
false;
break;
572 case kRight: cursor.SetX(
min(cursorLimits.Right(), cursor.X() + d)); clockwise =
true;
break;
573 case kRed:
if (destroyablePixmap) {
574 osd->DestroyPixmap(destroyablePixmap);
575 destroyablePixmap = NULL;
578 case kGreen:
if (toggleablePixmap)
579 toggleablePixmap->SetLayer(-toggleablePixmap->Layer());
595 default:
return state;
612 virtual const char *CommandLineHelp(
void);
613 virtual bool ProcessArgs(
int argc,
char *argv[]);
614 virtual bool Start(
void);
615 virtual void Housekeeping(
void);
619 virtual bool SetupParse(
const char *Name,
const char *Value);
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)
static const char * MAINMENUENTRY
virtual const cSize & MaxPixmapSize(void) const
Returns the maximum possible size of a pixmap this OSD can create.
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)
#define NUMOSDIMAGEVARIANTS
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.
virtual int Width(void) const =0
Returns the original character width as requested when the font was created, or 0 if the default widt...
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 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)
void Set(int Width, int Height)
static int OsdWidth(void)
virtual const char * MainMenuEntry(void)
char FontOsd[MAXFONTNAME]
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
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...
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)
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
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
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image on this OSD at the given Point.
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 int StoreImage(const cImage &Image)
Stores the given Image for later use with DrawImage() on an OSD or pixmap.
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 int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
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
void DrawImages(cOsd *Osd)
static void DropImage(int ImageHandle)
Drops the image referenced by the given ImageHandle.
cPoint Shifted(int Dx, int Dy) const
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...