vdr  2.4.1
osddemo.c
Go to the documentation of this file.
1 /*
2  * osddemo.c: A plugin for the Video Disk Recorder
3  *
4  * See the README file for copyright information and how to reach the author.
5  *
6  * $Id: osddemo.c 4.4 2018/04/10 13:00:27 kls Exp $
7  */
8 
9 #include <vdr/osd.h>
10 #include <vdr/plugin.h>
11 
12 static const char *VERSION = "2.4.0";
13 static const char *DESCRIPTION = "Demo of arbitrary OSD setup";
14 static const char *MAINMENUENTRY = "Osd Demo";
15 
16 // --- DrawEllipses ----------------------------------------------------------
17 
18 void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
19 {
20  Osd->DrawRectangle(x1 + 2, y1 + 2, x2 - 2, y2 - 2, clrGreen);
21  Osd->DrawEllipse(x1 + 3, y1 + 3, x2 - 3, y2 - 3, clrRed, Quadrants);
22 }
23 
24 void DrawEllipses(cOsd *Osd)
25 {
26  int xa = 0;
27  int ya = 0;
28  int xb = Osd->Width() - 1;
29  int yb = Osd->Height() - 1;
30  int x0 = xa;
31  int x5 = xb;
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;
36  int y0 = ya;
37  int y4 = yb;
38  int y2 = (y0 + y4) / 2;
39  int y1 = (y0 + y2) / 2;
40  int y3 = (y2 + y4) / 2;
41  Osd->DrawRectangle(xa, ya, xb, yb, clrGray50);
42  DrawEllipse(Osd, x4, y0, x5, y4, 0);
43  DrawEllipse(Osd, x2, y1, x3, y2, 1);
44  DrawEllipse(Osd, x1, y1, x2, y2, 2);
45  DrawEllipse(Osd, x1, y2, x2, y3, 3);
46  DrawEllipse(Osd, x2, y2, x3, y3, 4);
47  DrawEllipse(Osd, x3, y1, x4, y3, 5);
48  DrawEllipse(Osd, x1, y0, x3, y1, 6);
49  DrawEllipse(Osd, x0, y1, x1, y3, 7);
50  DrawEllipse(Osd, x1, y3, x3, y4, 8);
51  DrawEllipse(Osd, x3, y0, x4, y1, -1);
52  DrawEllipse(Osd, x0, y0, x1, y1, -2);
53  DrawEllipse(Osd, x0, y3, x1, y4, -3);
54  DrawEllipse(Osd, x3, y3, x4, y4, -4);
55  Osd->Flush();
56 }
57 
58 // --- DrawSlopes ------------------------------------------------------------
59 
60 void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
61 {
62  Osd->DrawRectangle(x1 + 2, y1 + 2, x2 - 2, y2 - 2, clrGreen);
63  Osd->DrawSlope(x1 + 3, y1 + 3, x2 - 3, y2 - 3, clrRed, Type);
64 }
65 
66 void DrawSlopes(cOsd *Osd)
67 {
68  int xa = 0;
69  int ya = 0;
70  int xb = Osd->Width() - 1;
71  int yb = Osd->Height() - 1;
72  int x0 = xa;
73  int x4 = xb;
74  int x2 = (x0 + x4) / 2;
75  int x1 = (x0 + x2) / 2;
76  int x3 = (x2 + x4) / 2;
77  int y0 = ya;
78  int y3 = yb;
79  int y2 = (y0 + y3) / 2;
80  int y1 = (y0 + y2) / 2;
81  Osd->DrawRectangle(xa, ya, xb, yb, clrGray50);
82  DrawSlope(Osd, x0, y0, x2, y1, 0);
83  DrawSlope(Osd, x2, y0, x4, y1, 1);
84  DrawSlope(Osd, x0, y1, x2, y2, 2);
85  DrawSlope(Osd, x2, y1, x4, y2, 3);
86  DrawSlope(Osd, x0, y2, x1, y3, 4);
87  DrawSlope(Osd, x1, y2, x2, y3, 5);
88  DrawSlope(Osd, x2, y2, x3, y3, 6);
89  DrawSlope(Osd, x3, y2, x4, y3, 7);
90  Osd->Flush();
91 }
92 
93 // --- DrawImages ------------------------------------------------------------
94 
95 struct tOsdImageRef {
96  int image;
98  };
99 
100 #define NUMOSDIMAGES 16
101 #define NUMOSDIMAGEVARIANTS 8
102 
103 void DrawImages(cOsd *Osd)
104 {
105  // Create images:
106  cImage *images[NUMOSDIMAGEVARIANTS];
107  for (int i = 0; i < NUMOSDIMAGEVARIANTS; i++) {
108  images[i] = new cImage(cSize(
109  i == 0 || i == 1 ? Osd->MaxPixmapSize().Width() + 1 : rand() % Osd->Width(),
110  i == 0 || i == 2 ? Osd->MaxPixmapSize().Height() + 1 : rand() % Osd->Height()));
111  for (int x = 0; x < images[i]->Width(); x++) {
112  for (int y = 0; y < images[i]->Height(); y++) {
113  images[i]->SetPixel(cPoint(x, y),
114  (!x || !y || x == images[i]->Width() - 1 || y == images[i]->Height() - 1) ? clrWhite :
115  (x > images[i]->Width() / 2 ?
116  (y > images[i]->Height() / 2 ? clrBlue : clrGreen) :
117  (y > images[i]->Height() / 2 ? clrRed : clrYellow)));
118  }
119  }
120  }
121  // Store images:
122  tOsdImageRef osdImages[NUMOSDIMAGES];
123  for (int i = 0; i < NUMOSDIMAGES; i++) {
124  osdImages[i].image = cOsdProvider::StoreImage(*images[i % NUMOSDIMAGEVARIANTS]);
125  osdImages[i].size.Set(images[i % NUMOSDIMAGEVARIANTS]->Size());
126  }
127  // Delete images:
128  for (int i = 0; i < NUMOSDIMAGEVARIANTS; i++)
129  delete images[i];
130  // Draw images:
131  for (int i = 0; i < NUMOSDIMAGES; i++)
132  Osd->DrawImage(cPoint(rand() % (Osd->Width() + osdImages[i].size.Width()), rand() % (Osd->Height() + osdImages[i].size.Height())).Shifted(-osdImages[i].size.Width(), -osdImages[i].size.Height()), osdImages[i].image);
133  // Drop image references:
134  for (int i = 0; i < NUMOSDIMAGES; i++)
135  cOsdProvider::DropImage(osdImages[i].image);
136  Osd->Flush();
137 }
138 
139 // --- cLineGame -------------------------------------------------------------
140 
141 class cLineGame : public cOsdObject {
142 private:
144  int x;
145  int y;
147 public:
148  cLineGame(void);
149  virtual ~cLineGame();
150  virtual void Show(void);
151  virtual eOSState ProcessKey(eKeys Key);
152  };
153 
155 {
156  osd = NULL;
157  x = y = 0;
158  color = clrRed;
159 }
160 
162 {
163  delete osd;
164 }
165 
166 void cLineGame::Show(void)
167 {
169  if (osd) {
170  int x1 = cOsd::OsdWidth() - 1;
171  int y1 = cOsd::OsdHeight() - 1;
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);
177  osd->Flush();
178  x = osd->Width() / 2;
179  y = osd->Height() / 2;
180  break;
181  }
182  x1 = x1 * 9 / 10;
183  y1 = y1 * 9 / 10;
184  }
185  }
186 }
187 
189 {
190  eOSState state = cOsdObject::ProcessKey(Key);
191  if (state == osUnknown) {
192  const int d = 4;
193  switch (Key & ~k_Repeat) {
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;
198  case kRed: color = clrRed; break;
199  case kGreen: color = clrGreen; break;
200  case kYellow: color = clrYellow; break;
201  case kBlue: color = clrBlue; break;
202  case k1: DrawEllipses(osd);
203  return osContinue;
204  case k2: DrawSlopes(osd);
205  return osContinue;
206  case kBack:
207  case kOk: return osEnd;
208  default: return state;
209  }
210  osd->DrawRectangle(x, y, x + d - 1, y + d - 1, color);
211  osd->Flush();
212  state = osContinue;
213  }
214  return state;
215 }
216 
217 // --- cTrueColorDemo --------------------------------------------------------
218 
219 class cTrueColorDemo : public cOsdObject, public cThread {
220 private:
224  bool clockwise;
227  bool SetArea(void);
228  virtual void Action(void);
229  cPixmap *CreateTextPixmap(const char *s, int Line, int Layer, tColor ColorFg, tColor ColorBg, const cFont *Font);
230 public:
231  cTrueColorDemo(void);
232  virtual ~cTrueColorDemo();
233  virtual void Show(void);
234  virtual eOSState ProcessKey(eKeys Key);
235  };
236 
238 {
239  osd = NULL;
240  clockwise = true;
241  destroyablePixmap = NULL;
242  toggleablePixmap = NULL;
243 }
244 
246 {
247  Cancel(3);
248  delete osd;
249 }
250 
251 cPixmap *cTrueColorDemo::CreateTextPixmap(const char *s, int Line, int Layer, tColor ColorFg, tColor ColorBg, const cFont *Font)
252 {
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));
256  if (Pixmap) {
257  Pixmap->Clear();
258  Pixmap->SetAlpha(0);
259  Pixmap->DrawText(cPoint(0, 0), s, ColorFg, ColorBg, Font, w);
260  }
261  return Pixmap;
262 }
263 
265 {
266  cPixmap *FadeInPixmap = NULL;
267  cPixmap *FadeOutPixmap = NULL;
268  cPixmap *MovePixmap = NULL;
269  cPixmap *NextPixmap = NULL;
270  cPixmap *TilePixmap = NULL;
271  cPixmap *ScrollPixmap = NULL;
272  cPixmap *AnimPixmap = NULL;
275  cFont *LrgFont = cFont::CreateFont(Setup.FontOsd, osd->Height() / 10);
276  int FrameTime = 40; // ms
277  int FadeTime = 1000; // ms
278  int MoveTime = 4000; // ms
279  int TileTime = 6000; // ms
280  int ScrollWaitTime = 1000; // ms
281  int ScrollLineTime = 200; // ms
282  int ScrollTotalTime = 8000; // ms
283  uint64_t Start = 0;
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;
291  cPoint OldCursor;
292  int State = 0;
293  while (Running()) {
294  cPixmap::Lock();
295  bool Animated = false;
296  uint64_t Now = cTimeMs::Now();
297  if (FadeInPixmap) {
298  double t = min(double(Now - Start) / FadeTime, 1.0);
299  int Alpha = t * ALPHA_OPAQUE;
300  FadeInPixmap->SetAlpha(Alpha);
301  if (t >= 1)
302  FadeInPixmap = NULL;
303  Animated = true;
304  }
305  if (FadeOutPixmap) {
306  double t = min(double(Now - Start) / FadeTime, 1.0);
307  int Alpha = ALPHA_OPAQUE - t * ALPHA_OPAQUE;
308  FadeOutPixmap->SetAlpha(Alpha);
309  if (t >= 1)
310  FadeOutPixmap = NULL;
311  Animated = true;
312  }
313  if (MovePixmap) {
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());
317  cRect r = MovePixmap->ViewPort();
318  r.SetPoint(x, y);
319  MovePixmap->SetViewPort(r);
320  if (t >= 1)
321  MovePixmap = NULL;
322  Animated = true;
323  }
324  if (TilePixmap) {
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());
328  TilePixmap->SetDrawPortPoint(cPoint(x, y));
329  if (t >= 1) {
330  destroyablePixmap = TilePixmap;
331  TilePixmap = NULL;
332  }
333  Animated = true;
334  }
335  if (ScrollPixmap) {
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());
341  ScrollPixmap->SetDrawPortPoint(cPoint(x, y));
342  if (t >= 1) {
343  if (int(Now - Start) < ScrollTotalTime) {
344  cRect r = ScrollPixmap->DrawPort();
345  r.SetPoint(-r.X(), -r.Y());
346  ScrollPixmap->Pan(cPoint(0, 0), r);
347  cString s = cString::sprintf("Line %d", ++ScrollLineNumber);
348  ScrollPixmap->DrawRectangle(cRect(0, ScrollPixmap->ViewPort().Height(), ScrollPixmap->DrawPort().Width(), ScrollPixmap->DrawPort().Height()), clrTransparent);
349  ScrollPixmap->DrawText(cPoint(0, ScrollPixmap->ViewPort().Height()), s, clrYellow, clrTransparent, OsdFont);
350  ScrollStartTime = Now;
351  }
352  else {
353  FadeOutPixmap = ScrollPixmap;
354  ScrollPixmap = NULL;
355  Start = cTimeMs::Now();
356  }
357  }
358  }
359  else
360  ScrollStartTime = Now;
361  }
362  Animated = true;
363  }
364  if (AnimPixmap) {
365  int d = AnimPixmap->ViewPort().Height();
366  if (clockwise)
367  d = -d;
368  cPoint p = AnimPixmap->DrawPort().Point().Shifted(0, d);
369  if (clockwise && p.Y() <= -AnimPixmap->DrawPort().Height())
370  p.SetY(0);
371  else if (!clockwise && p.Y() > 0)
372  p.SetY(-(AnimPixmap->DrawPort().Height() - AnimPixmap->ViewPort().Height()));
373  AnimPixmap->SetDrawPortPoint(p);
374  }
375  if (!Animated) {
376  switch (State) {
377  case 0: {
378  FadeInPixmap = CreateTextPixmap("VDR", Line, 1, clrYellow, clrTransparent, LrgFont);
379  if (FadeInPixmap)
380  Line += FadeInPixmap->DrawPort().Height();
381  Start = cTimeMs::Now();
382  State++;
383  }
384  break;
385  case 1: {
386  FadeInPixmap = CreateTextPixmap("Video Disk Recorder", Line, 3, clrYellow, clrTransparent, OsdFont);
387  if (FadeInPixmap)
388  Line += FadeInPixmap->DrawPort().Height();
389  Start = cTimeMs::Now();
390  State++;
391  }
392  break;
393  case 2: {
394  FadeInPixmap = CreateTextPixmap("True Color OSD Demo", Line, 1, clrYellow, clrTransparent, OsdFont);
395  if (FadeInPixmap)
396  Line += FadeInPixmap->DrawPort().Height();
397  Start = cTimeMs::Now();
398  State++;
399  }
400  break;
401  case 3: {
402  NextPixmap = CreateTextPixmap("Millions of colors", Line, 1, clrYellow, clrTransparent, LrgFont);
403  if (NextPixmap) {
404  FadeInPixmap = NextPixmap;
405  Start = cTimeMs::Now();
406  StartLine = Line;
407  Line += NextPixmap->DrawPort().Height();
408  }
409  State++;
410  }
411  break;
412  case 4: {
413  Line += osd->Height() / 10;
414  int w = osd->Width() / 2;
415  int h = osd->Height() - Line - osd->Height() / 10;
416  cImage Image(cSize(w, h));
417  for (int y = 0; y < h; y++) {
418  for (int x = 0; x < w; x++)
419  Image.SetPixel(cPoint(x, y), HsvToColor(360 * double(x) / w, 1 - double(y) / h, 1) | 0xDF000000);
420  }
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;
424  }
425  State++;
426  }
427  break;
428  case 5: {
429  if (NextPixmap) {
430  MovePixmap = NextPixmap;
431  MoveStart = MovePixmap->ViewPort().Point();
432  MoveEnd.Set(osd->Width() - MovePixmap->ViewPort().Width(), osd->Height() - MovePixmap->ViewPort().Height());
433  Start = cTimeMs::Now();
434  }
435  State++;
436  }
437  break;
438  case 6: {
439  TilePixmap = CreateTextPixmap("Tiled Pixmaps", StartLine, 1, clrRed, clrWhite, OsdFont);
440  if (TilePixmap) {
441  TilePixmap->SetViewPort(TilePixmap->ViewPort().Grown(TilePixmap->DrawPort().Width(), TilePixmap->DrawPort().Height()));
442  TilePixmap->SetAlpha(200);
443  TilePixmap->SetTile(true);
444  TileStart = TilePixmap->DrawPort().Point();
445  TileEnd = TileStart.Shifted(TilePixmap->ViewPort().Width(), TilePixmap->ViewPort().Height());
446  MovePixmap = TilePixmap;
447  MoveStart = MovePixmap->ViewPort().Point();
448  MoveEnd.Set(10, osd->Height() - MovePixmap->ViewPort().Height() - 10);
449  Start = cTimeMs::Now();
450  }
451  State++;
452  }
453  break;
454  case 7: {
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))) {
459  Pixmap->Clear();
460  Pixmap->DrawText(cPoint(0, 0), Text, clrYellow, clrTransparent, OsdFont);
461  cString s = cString::sprintf("Line %d", ++ScrollLineNumber);
462  Pixmap->DrawText(cPoint(0, Pixmap->ViewPort().Height()), s, clrYellow, clrTransparent, OsdFont);
463  ScrollPixmap = Pixmap;
464  ScrollStart.Set(0, 0);
465  ScrollEnd.Set(0, -h);
466  Start = cTimeMs::Now();
467  }
468  State++;
469  }
470  break;
471  case 8: {
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;
478  // Temporarily using pixmap layer 0 to have the text alpha blended:
479  AnimPixmap = osd->CreatePixmap(0, cRect((osd->Width() - Size) / 2, StartLine, Size, Size), cRect(0, 0, Size * Cols, Size * Rows));
480  if (AnimPixmap) {
481  AnimPixmap->SetAlpha(0);
482  AnimPixmap->Clear();
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;
487  AnimPixmap->DrawEllipse(cRect(x0, y0, Size, Size), 0xDDFFFFFF);
488  int xc = x0 + Size / 2 - Diameter / 2;
489  int yc = y0 + Size / 2 - Diameter / 2;
490  int Color = 0xFF;
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);
496  AnimPixmap->DrawEllipse(cRect(x, y, Diameter, Diameter), ArgbToColor(0xFF, Color, Color, Color));
497  Color -= Delta;
498  }
499  AnimPixmap->DrawText(cPoint(x0, y0), Text, clrBlack, clrTransparent, SmlFont, Size, Size, taCenter);
500  }
501  AnimPixmap->SetLayer(3); // now setting the actual pixmap layer
502  FadeInPixmap = AnimPixmap;
503  LOCK_THREAD;
504  OldCursor = cursor = AnimPixmap->ViewPort().Point();
505  cursorLimits.Set(0, 0, osd->Width(), osd->Height());
508  cursorLimits.Grow(-10, -10);
509  Start = cTimeMs::Now();
510  }
511  State++;
512  }
513  break;
514  case 9: {
515  LOCK_THREAD;
516  if (cursor != OldCursor) {
517  MovePixmap = AnimPixmap;
518  MoveStart = MovePixmap->ViewPort().Point();
519  MoveEnd = OldCursor = cursor;
520  MoveTime = 500;
521  Start = cTimeMs::Now();
522  }
523  }
524  break;
525  }
526  }
527  osd->Flush();
528  cPixmap::Unlock();
529  int Delta = cTimeMs::Now() - Now;
530  if (Delta < FrameTime)
531  cCondWait::SleepMs(FrameTime - Delta);
532  }
533  destroyablePixmap = NULL;
534  toggleablePixmap = NULL;
535  delete OsdFont;
536  delete SmlFont;
537  delete LrgFont;
538 }
539 
541 {
542  if (osd) {
543  tArea Area = { 0, 0, cOsd::OsdWidth() - 1, cOsd::OsdHeight() - 1, 32 };
544  return osd->SetAreas(&Area, 1) == oeOk;
545  }
546  return false;
547 }
548 
550 {
552  if (osd) {
553  if (SetArea()) {
554  osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1, clrGray50);
555  osd->Flush();
556  Start();
557  }
558  }
559 }
560 
562 {
563  eOSState state = cOsdObject::ProcessKey(Key);
564  if (state == osUnknown) {
565  LOCK_PIXMAPS;
566  LOCK_THREAD;
567  const int d = 80;
568  switch (Key & ~k_Repeat) {
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) {
575  destroyablePixmap = NULL;
576  }
577  break;
578  case kGreen: if (toggleablePixmap)
580  break;
581  case k1: Cancel(3);
582  SetArea();
583  DrawEllipses(osd);
584  break;
585  case k2: Cancel(3);
586  SetArea();
587  DrawSlopes(osd);
588  break;
589  case k3: Cancel(3);
590  SetArea();
591  DrawImages(osd);
592  break;
593  case kBack:
594  case kOk: return osEnd;
595  default: return state;
596  }
597  state = osContinue;
598  }
599  return state;
600 }
601 
602 // --- cPluginOsddemo --------------------------------------------------------
603 
604 class cPluginOsddemo : public cPlugin {
605 private:
606  // Add any member variables or functions you may need here.
607 public:
608  cPluginOsddemo(void);
609  virtual ~cPluginOsddemo();
610  virtual const char *Version(void) { return VERSION; }
611  virtual const char *Description(void) { return DESCRIPTION; }
612  virtual const char *CommandLineHelp(void);
613  virtual bool ProcessArgs(int argc, char *argv[]);
614  virtual bool Start(void);
615  virtual void Housekeeping(void);
616  virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; }
617  virtual cOsdObject *MainMenuAction(void);
618  virtual cMenuSetupPage *SetupMenu(void);
619  virtual bool SetupParse(const char *Name, const char *Value);
620  };
621 
623 {
624  // Initialize any member variables here.
625  // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
626  // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
627 }
628 
630 {
631  // Clean up after yourself!
632 }
633 
635 {
636  // Return a string that describes all known command line options.
637  return NULL;
638 }
639 
640 bool cPluginOsddemo::ProcessArgs(int argc, char *argv[])
641 {
642  // Implement command line argument processing here if applicable.
643  return true;
644 }
645 
647 {
648  // Start any background activities the plugin shall perform.
649  return true;
650 }
651 
653 {
654  // Perform any cleanup or other regular tasks.
655 }
656 
658 {
659  // Perform the action when selected from the main VDR menu.
661  return new cTrueColorDemo;
662  return new cLineGame;
663 }
664 
666 {
667  // Return a setup menu in case the plugin supports one.
668  return NULL;
669 }
670 
671 bool cPluginOsddemo::SetupParse(const char *Name, const char *Value)
672 {
673  // Parse your own setup parameters and store their values.
674  return false;
675 }
676 
677 VDRPLUGINCREATOR(cPluginOsddemo); // Don't touch this!
cLineGame(void)
Definition: osddemo.c:154
virtual eOSState ProcessKey(eKeys Key)
Definition: osddemo.c:188
int Y(void) const
Definition: osd.h:366
static int OsdHeight(void)
Definition: osd.h:808
Definition: osd.h:36
virtual bool Start(void)
Definition: osddemo.c:646
Definition: osd.h:454
virtual const char * Version(void)
Definition: osddemo.c:610
void DrawSlopes(cOsd *Osd)
Definition: osddemo.c:66
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&#39;t g...
int image
Definition: osddemo.c:96
virtual void Housekeeping(void)
Definition: osddemo.c:652
virtual void SetViewPort(const cRect &Rect)
Sets the pixmap&#39;s view port to the given Rect.
Definition: osd.c:1068
virtual ~cTrueColorDemo()
Definition: osddemo.c:245
Definition: keys.h:23
virtual const cSize & MaxPixmapSize(void) const
Returns the maximum possible size of a pixmap this OSD can create.
Definition: osd.c:1711
cPoint cursor
Definition: osddemo.c:222
virtual bool SetupParse(const char *Name, const char *Value)
Definition: osddemo.c:671
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
Definition: osd.c:1831
const char * Name(void)
Definition: plugin.h:34
int Width(void) const
Definition: osd.h:341
static const char * MAINMENUENTRY
Definition: osddemo.c:14
cRect Grown(int Dw, int Dh) const
Definition: osd.h:396
static cString sprintf(const char *fmt,...) __attribute__((format(printf
Definition: tools.c:1127
Definition: osd.h:419
int Height(void) const
Definition: osd.h:368
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...
Definition: osd.c:1973
cPoint Shifted(int Dx, int Dy) const
Definition: osd.h:326
Definition: plugin.h:20
Definition: keys.h:17
Definition: keys.h:61
virtual const char * Description(void)
Definition: osddemo.c:611
cPixmap * CreateTextPixmap(const char *s, int Line, int Layer, tColor ColorFg, tColor ColorBg, const cFont *Font)
Definition: osddemo.c:251
#define NUMOSDIMAGEVARIANTS
Definition: osddemo.c:101
int Width(void) const
Definition: osd.h:367
cPluginOsddemo(void)
Definition: osddemo.c:622
char FontSml[MAXFONTNAME]
Definition: config.h:329
Definition: osd.h:306
T max(T a, T b)
Definition: tools.h:60
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty=true)
Sets the pixmap&#39;s draw port to the given Point.
Definition: osd.c:1085
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...
Definition: osd.c:1963
Definition: keys.h:27
const cRect & DrawPort(void) const
Returns the pixmap&#39;s draw port, which is relative to the view port.
Definition: osd.h:543
virtual eOSState ProcessKey(eKeys Key)
Definition: osddemo.c:561
virtual int Width(void) const
Returns the original character width as requested when the font was created, or 0 if the default widt...
Definition: skincurses.c:24
virtual bool ProcessArgs(int argc, char *argv[])
Definition: osddemo.c:640
int Height(void) const
Definition: osd.h:436
Definition: keys.h:25
T min(T a, T b)
Definition: tools.h:59
virtual void SetAlpha(int Alpha)
Sets the alpha value of this pixmap to the given value.
Definition: osd.c:1046
int Left(void) const
Definition: osd.h:369
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition: osd.c:1993
#define LOCK_PIXMAPS
Definition: osd.h:681
Definition: osd.h:158
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
Definition: osd.h:529
Definition: osd.h:34
virtual void Show(void)
Definition: osddemo.c:166
Definition: keys.h:28
cOsd * osd
Definition: osddemo.c:143
void SetX(int X)
Definition: osd.h:320
eOSState
Definition: osdbase.h:18
Definition: osd.h:33
void SetPoint(int X, int Y)
Definition: osd.h:377
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
int Right(void) const
Definition: osd.h:371
cSize size
Definition: osddemo.c:97
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...
int Layer(void) const
Definition: osd.h:536
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
Definition: osddemo.c:18
int y
Definition: osddemo.c:145
void DrawEllipses(cOsd *Osd)
Definition: osddemo.c:24
void Set(int Width, int Height)
Definition: osd.h:345
static int OsdWidth(void)
Definition: osd.h:807
const cPoint & Point(void) const
Definition: osd.h:373
Definition: osdbase.h:34
cRect cursorLimits
Definition: osddemo.c:223
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
Definition: osd.c:1728
int X(void) const
Definition: osd.h:365
Definition: osd.h:37
Definition: osd.h:39
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
Definition: osd.c:1809
Definition: osd.h:352
virtual const char * MainMenuEntry(void)
Definition: osddemo.c:616
int Bottom(void) const
Definition: osd.h:372
char FontOsd[MAXFONTNAME]
Definition: config.h:328
void SetBottom(int Bottom)
Definition: osd.h:388
cOsd * osd
Definition: osddemo.c:221
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
Definition: thread.c:72
void Set(int X, int Y, int Width, int Height)
Definition: osd.h:375
Definition: keys.h:18
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
Definition: thread.c:304
virtual ~cPluginOsddemo()
Definition: osddemo.c:629
static const cCursesFont Font
Definition: skincurses.c:32
bool clockwise
Definition: osddemo.c:224
Definition: keys.h:28
int Top(void) const
Definition: osd.h:370
The cOsd class is the interface to the "On Screen Display".
Definition: osd.h:724
Definition: osd.h:330
cSetup Setup
Definition: config.c:372
#define NUMOSDIMAGES
Definition: osddemo.c:100
Definition: keys.h:20
tColor color
Definition: osddemo.c:146
virtual ~cLineGame()
Definition: osddemo.c:161
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...
Definition: font.c:428
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
Definition: thread.h:101
static const char * VERSION
Definition: osddemo.c:12
Definition: keys.h:26
virtual void SetTile(bool Tile)
Sets the tile property of this pixmap to the given value.
Definition: osd.c:1057
static int OsdTop(void)
Definition: osd.h:806
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
Definition: osddemo.c:60
void Grow(int Dx, int Dy)
Grows the rectangle by the given number of pixels in either direction.
Definition: osd.c:892
int Height(void)
Definition: osd.h:822
void SetRight(int Right)
Definition: osd.h:387
static int OsdLeft(void)
Definition: osd.h:805
Definition: osd.h:41
Definition: keys.h:21
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
Definition: osd.h:58
void Set(int X, int Y)
Definition: osd.h:322
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).
Definition: osd.c:1716
virtual eOSState ProcessKey(eKeys Key)
Definition: osdbase.h:82
int X(void) const
Definition: osd.h:318
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
Definition: osddemo.c:264
virtual void Show(void)
Definition: osddemo.c:549
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 bool SupportsTrueColor(void)
Returns true if the current OSD provider is able to handle a true color OSD.
Definition: osd.c:2072
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.
Definition: osd.h:298
int Width(void)
Definition: osd.h:821
virtual cOsdObject * MainMenuAction(void)
Definition: osddemo.c:657
cPixmap * destroyablePixmap
Definition: osddemo.c:225
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image on this OSD at the given Point.
Definition: osd.c:1911
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...
Definition: osd.c:19
Definition: thread.h:79
int Y(void) const
Definition: osd.h:319
int FontOsdSize
Definition: config.h:334
Definition: osd.h:44
int x
Definition: osddemo.c:144
static int StoreImage(const cImage &Image)
Stores the given Image for later use with DrawImage() on an OSD or pixmap.
Definition: osd.c:2111
virtual void SetLayer(int Layer)
Sets the layer of this pixmap to the given value.
Definition: osd.c:1024
VDRPLUGINCREATOR(cPluginOsddemo)
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
Definition: osd.h:442
void SetY(int Y)
Definition: osd.h:321
static uint64_t Now(void)
Definition: tools.c:731
virtual void Clear(void)=0
Clears the pixmap&#39;s draw port by setting all pixels to be fully transparent.
int Height(void) const
Definition: osd.h:342
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...
Definition: osd.c:1983
cTrueColorDemo(void)
Definition: osddemo.c:237
virtual const char * CommandLineHelp(void)
Definition: osddemo.c:634
static void Unlock(void)
Definition: osd.h:535
void DrawImages(cOsd *Osd)
Definition: osddemo.c:103
int FontSmlSize
Definition: config.h:335
Definition: keys.h:24
#define LOCK_THREAD
Definition: thread.h:167
static void DropImage(int ImageHandle)
Drops the image referenced by the given ImageHandle.
Definition: osd.c:2118
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting &#39;running&#39; to false, so that the Action() loop can finish in an or...
Definition: thread.c:354
Definition: osd.h:35
eKeys
Definition: keys.h:16
const cRect & ViewPort(void) const
Returns the pixmap&#39;s view port, which is relative to the OSD&#39;s origin.
Definition: osd.h:539
int Width(void) const
Definition: osd.h:435
virtual int Height(void) const
Returns the height of this font in pixel (all characters have the same height).
Definition: skincurses.c:27
Definition: font.h:37
virtual cMenuSetupPage * SetupMenu(void)
Definition: osddemo.c:665
bool SetArea(void)
Definition: osddemo.c:540
Definition: tools.h:176
virtual void DrawRectangle(const cRect &Rect, tColor Color)=0
Draws a filled rectangle with the given Color.
#define ALPHA_OPAQUE
Definition: osd.h:26
Definition: keys.h:28
cPixmap * toggleablePixmap
Definition: osddemo.c:226
static const char * DESCRIPTION
Definition: osddemo.c:13
uint32_t tColor
Definition: font.h:29
Definition: keys.h:22
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...
Definition: osd.c:2017