10#include <vdr/plugin.h>
13static 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)
override;
257 while (x1 > 0 && y1 > 0) {
258 tArea Area = { 0, 0, x1, y1, 4 };
259 if (
osd->CanHandleAreas(&Area, 1) ==
oeOk) {
260 osd->SetAreas(&Area, 1);
263 x =
osd->Width() / 2;
264 y =
osd->Height() / 2;
293 default:
return state;
313 virtual void Action(
void)
override;
318 virtual void Show(
void)
override;
338 const int h =
Font->Height(s);
339 int w =
Font->Width(s);
340 cPixmap *Pixmap =
osd->CreatePixmap(Layer,
cRect((
osd->Width() - w) / 2, Line, w, h));
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;
374 int Line =
osd->Height() / 20;
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;
498 Line +=
osd->Height() / 10;
499 int w =
osd->Width() / 2;
500 int h =
osd->Height() - Line -
osd->Height() / 10;
502 for (
int y = 0; y < h; y++) {
503 for (
int x = 0; x < w; x++)
506 if (
cPixmap *Pixmap =
osd->CreatePixmap(2,
cRect((
osd->Width() - w) / 2, Line, w, h))) {
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();
543 if (
cPixmap *Pixmap =
osd->CreatePixmap(2,
cRect((
osd->Width() - w) / 2, StartLine, w, 2 * h),
cRect(0, 0, w, 3 * h))) {
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;
561 int Rows =
min(
osd->MaxPixmapSize().Height() / Size, AnimFrames);
562 int Cols = (AnimFrames + Rows - 1) / Rows;
564 AnimPixmap =
osd->CreatePixmap(0,
cRect((
osd->Width() - Size) / 2, StartLine, Size, Size),
cRect(0, 0, Size * Cols, Size * 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)
629 return osd->SetAreas(&Area, 1) ==
oeOk;
684 default:
return state;
702 virtual bool ProcessArgs(
int argc,
char *argv[])
override;
703 virtual bool Start(
void)
override;
708 virtual bool SetupParse(
const char *
Name,
const char *Value)
override;
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
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 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.
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
virtual eOSState ProcessKey(eKeys Key) override
virtual ~cLineGame() override
virtual void Show(void) override
virtual eOSState ProcessKey(eKeys Key)
cOsdObject(bool FastResponse=false)
static void DropImage(int ImageHandle)
Drops the image referenced by the given ImageHandle.
static int StoreImage(const cImage &Image)
Stores the given Image for later use with DrawImage() on an OSD or pixmap.
static bool SupportsTrueColor(void)
Returns true if the current OSD provider is able to handle a true color 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.
The cOsd class is the interface to the "On Screen Display".
virtual const cSize & MaxPixmapSize(void) const
Returns the maximum possible size of a pixmap this OSD can create.
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image on this OSD at the given Point.
static int OsdHeight(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...
virtual void Flush(void)
Actually commits all data to the OSD hardware.
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 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 OsdWidth(void)
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.
const cRect & DrawPort(void) const
Returns the pixmap's draw port, which is relative to the view port.
virtual void SetViewPort(const cRect &Rect)
Sets the pixmap's view port to the given Rect.
virtual void Clear(void)=0
Clears the pixmap's draw port by setting all pixels to be fully transparent.
const cRect & ViewPort(void) const
Returns the pixmap's view port, which is relative to the OSD's origin.
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 DrawRectangle(const cRect &Rect, tColor Color)=0
Draws a filled rectangle with the given Color.
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty=true)
Sets the pixmap's draw port to the given Point.
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
virtual void SetLayer(int Layer)
Sets the layer of this pixmap to the given value.
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 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 SetAlpha(int Alpha)
Sets the alpha value of this pixmap to the given value.
virtual void SetTile(bool Tile)
Sets the tile property of this pixmap to the given value.
virtual ~cPluginOsddemo() override
virtual void Housekeeping(void) override
virtual cOsdObject * MainMenuAction(void) override
virtual const char * CommandLineHelp(void) override
virtual bool ProcessArgs(int argc, char *argv[]) override
virtual const char * Version(void) override
virtual bool Start(void) override
virtual cMenuSetupPage * SetupMenu(void) override
virtual const char * MainMenuEntry(void) override
virtual const char * Description(void) override
virtual bool SetupParse(const char *Name, const char *Value) override
cPoint Shifted(int Dx, int Dy) const
const cPoint & Point(void) const
void SetPoint(int X, int Y)
cRect Grown(int Dw, int Dh) const
void Set(int Width, int Height)
static cString sprintf(const char *fmt,...) __attribute__((format(printf
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
cThread(const char *Description=NULL, bool LowPriority=false)
Creates a new thread.
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
static uint64_t Now(void)
virtual eOSState ProcessKey(eKeys Key) override
virtual ~cTrueColorDemo() override
virtual void Show(void) override
cPixmap * destroyablePixmap
cPixmap * CreateTextPixmap(const char *s, int Line, int Layer, tColor ColorFg, tColor ColorBg, const cFont *Font)
cPixmap * toggleablePixmap
virtual void Action(void) override
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
static const char * VERSION
static const char * DESCRIPTION
static const char * MAINMENUENTRY
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.
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
static const char * VERSION
static const char * DESCRIPTION
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
void DrawEllipseAlignments(cOsd *Osd)
#define NUMOSDIMAGEVARIANTS
void DrawSlopes(cOsd *Osd)
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
void DrawImages(cOsd *Osd)
void DrawEllipses(cOsd *Osd)
static const char * MAINMENUENTRY
#define VDRPLUGINCREATOR(PluginClass)
static const cCursesFont Font