diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | displaymenu.c | 25 | ||||
-rw-r--r-- | displaymenu.h | 6 | ||||
-rw-r--r-- | displayvolume.c | 52 | ||||
-rw-r--r-- | displayvolume.h | 6 | ||||
-rw-r--r-- | skinlcarsng.c | 4 | ||||
-rw-r--r-- | status.c | 14 | ||||
-rw-r--r-- | status.h | 24 | ||||
-rw-r--r-- | volumebox.c | 66 | ||||
-rw-r--r-- | volumebox.h | 21 |
10 files changed, 168 insertions, 52 deletions
@@ -53,7 +53,7 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = config.o displaychannel.o displaymenu.o displaymessage.o displayreplay.o displaytracks.o displayvolume.o lcarsng.o setup.o $(PLUGIN).o +OBJS = config.o displaychannel.o displaymenu.o displaymessage.o displayreplay.o displaytracks.o displayvolume.o lcarsng.o setup.o status.o volumebox.o $(PLUGIN).o ### The main target: diff --git a/displaymenu.c b/displaymenu.c index 60b504d..648dd6b 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -1,6 +1,7 @@ #include "config.h" #include "lcarsng.h" #include "displaymenu.h" +#include "status.h" cBitmap cLCARSNGDisplayMenu::bmArrowUp(arrowup_xpm); cBitmap cLCARSNGDisplayMenu::bmArrowDown(arrowdown_xpm); @@ -49,6 +50,9 @@ cLCARSNGDisplayMenu::cLCARSNGDisplayMenu(void) currentIndex = -1; Margin = Config.Margin; drawDescription = NULL; + volumeBox = NULL; + lastVolume = statusMonitor->GetVolume(); + lastVolumeTime = time(NULL); // The outer frame: d = 5 * lineHeight; @@ -88,6 +92,7 @@ cLCARSNGDisplayMenu::cLCARSNGDisplayMenu(void) cLCARSNGDisplayMenu::~cLCARSNGDisplayMenu() { delete drawDescription; + delete volumeBox; delete tallFont; delete tinyFont; delete osd; @@ -1328,6 +1333,7 @@ void cLCARSNGDisplayMenu::SetMessage(eMessageType Type, const char *Text) { if (Text) { DELETENULL(drawDescription); + DELETENULL(volumeBox); message = true; tColor ColorFg = Theme.Color(clrMessageStatusFg + 2 * Type); tColor ColorBg = Theme.Color(clrMessageStatusBg + 2 * Type); @@ -1604,6 +1610,24 @@ const cFont *cLCARSNGDisplayMenu::GetTextAreaFont(bool FixedFont) const return font; } +void cLCARSNGDisplayMenu::DrawVolume(void) +{ + if (!message) { + int volume = statusMonitor->GetVolume(); + if (volume != lastVolume) { + if (!volumeBox) + volumeBox = new cLCARSNGVolumeBox(osd, cRect(0, yb15 - lineHeight, xa09, lineHeight)); + volumeBox->SetVolume(volume, MAXVOLUME, volume ? false : true); + lastVolumeTime = time(NULL); + lastVolume = volume; + } + else { + if (volumeBox && (time(NULL) - lastVolumeTime > 2)) + DELETENULL(volumeBox); + } + } +} + void cLCARSNGDisplayMenu::Flush(void) { int Width; @@ -1655,6 +1679,7 @@ void cLCARSNGDisplayMenu::Flush(void) DrawPlay(Control); } } + DrawVolume(); osd->Flush(); if (initial) { cDevice::PrimaryDevice()->ScaleVideo(availableRect); diff --git a/displaymenu.h b/displaymenu.h index 83b093c..1228adc 100644 --- a/displaymenu.h +++ b/displaymenu.h @@ -1,3 +1,5 @@ +#include "volumebox.h" + typedef struct { const cEvent *Event = NULL; const cTimer *Timer = NULL; @@ -112,7 +114,10 @@ private: cString lastHeader; int lastSeen; int Margin; + int lastVolume; + time_t lastVolumeTime; cDrawDescription *drawDescription; + cLCARSNGVolumeBox *volumeBox; static cBitmap bmArrowUp, bmArrowDown, bmTransferMode; void SetCoordinateY(int y); void DrawMainFrameUpper(tColor Color, tColor ColorBg); @@ -140,6 +145,7 @@ private: void DrawPlay(cControl *Control); void DrawInfo(const cEvent *Event, bool WithTime); void DrawSeen(int Current, int Total); + void DrawVolume(void); void DrawTextScrollbar(void); bool DrawProgressBar(int x, int y, int width, const char *text, tColor ColorFg, tColor ColorBg); public: diff --git a/displayvolume.c b/displayvolume.c index dcd3781..060a4dd 100644 --- a/displayvolume.c +++ b/displayvolume.c @@ -1,5 +1,6 @@ #include "lcarsng.h" #include "config.h" +#include "volumebox.h" #include "displayvolume.h" // --- cLCARSNGDisplayVolume ----------------------------------------------- @@ -8,62 +9,21 @@ cLCARSNGDisplayVolume::cLCARSNGDisplayVolume(void) { const cFont *font = cFont::GetFont(fontOsd); int lineHeight = font->Height(); - frameColor = Theme.Color(clrVolumeFrame); - mute = -1; - Margin = Config.Margin; - x0 = 0; - x1 = lineHeight / 2; - x2 = lineHeight; - x3 = x2 + Gap; - x7 = cOsd::OsdWidth(); - x6 = x7 - lineHeight / 2; - x5 = x6 - lineHeight / 2; - x4 = x5 - Gap; - y0 = 0; - y1 = lineHeight; - osd = CreateOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - y1, x0, y0, x7 - 1, y1 - 1); - osd->DrawRectangle(x0, y0, x7 - 1, y1 - 1, Theme.Color(clrBackground)); - osd->DrawRectangle(x0, y0, x1 - 1, y1 - 1, clrTransparent); - osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 7); - osd->DrawRectangle(x1, y0, x2 - 1, y1 - 1, frameColor); - osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor); - osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor); - osd->DrawRectangle(x6, y0, x7 - 1, y1 - 1, clrTransparent); - osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5); + + osd = CreateOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - lineHeight, 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1); + volumeBox = new cLCARSNGVolumeBox(osd, cRect(0, 0, cOsd::OsdWidth(), lineHeight)); } cLCARSNGDisplayVolume::~cLCARSNGDisplayVolume() { + delete volumeBox; delete osd; cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); } void cLCARSNGDisplayVolume::SetVolume(int Current, int Total, bool Mute) { - int xl = x3 + TextSpacing; - int xr = x4 - TextSpacing; - int yt = y0 + TextFrame; - int yb = y1 - TextFrame; - if (mute != Mute) { - osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor); - mute = Mute; - } - cBitmap bm(Mute ? mute_xpm : volume_xpm); - osd->DrawBitmap(xl, y0 + (y1 - y0 - bm.Height()) / 2, bm, Theme.Color(clrVolumeSymbol), frameColor); - if (!Mute) { - xl += bm.Width() + TextSpacing; - int w = (y1 - y0) / 3; - int d = TextFrame; - int n = (xr - xl + d) / (w + d); - int x = xr - n * (w + d); - tColor Color = Theme.Color(clrVolumeBarLower); - for (int i = 0; i < n; i++) { - if (Total * i >= Current * n) - Color = Theme.Color(clrVolumeBarUpper); - osd->DrawRectangle(x, yt, x + w - 1, yb - 1, Color); - x += w + d; - } - } + volumeBox->SetVolume(Current, Total, Mute); } void cLCARSNGDisplayVolume::Flush(void) diff --git a/displayvolume.h b/displayvolume.h index f440b89..08e8c8a 100644 --- a/displayvolume.h +++ b/displayvolume.h @@ -3,11 +3,7 @@ class cLCARSNGDisplayVolume : public cSkinDisplayVolume { private: cOsd *osd; - int Margin; - int x0, x1, x2, x3, x4, x5, x6, x7; - int y0, y1; - tColor frameColor; - int mute; + cLCARSNGVolumeBox *volumeBox; public: cLCARSNGDisplayVolume(void); virtual ~cLCARSNGDisplayVolume(); diff --git a/skinlcarsng.c b/skinlcarsng.c index 5a1b0c4..d0a2ffd 100644 --- a/skinlcarsng.c +++ b/skinlcarsng.c @@ -2,6 +2,7 @@ #include <vdr/plugin.h> #include "config.h" #include "setup.h" +#include "status.h" #include "lcarsng.h" #if defined(APIVERSNUM) && APIVERSNUM < 10734 @@ -39,9 +40,11 @@ class cPluginLCARSNG : public cPlugin { cPluginLCARSNG::cPluginLCARSNG(void) { lcarsng = NULL; + statusMonitor = NULL; } cPluginLCARSNG::~cPluginLCARSNG() { + delete statusMonitor; } const char *cPluginLCARSNG::CommandLineHelp(void) { @@ -64,6 +67,7 @@ bool cPluginLCARSNG::Start(void) { dsyslog("skinlcarsng: TrueColor OSD found"); cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); lcarsng = new cLCARSNG; + statusMonitor = new cLCARSNGStatusMonitor; return lcarsng; } diff --git a/status.c b/status.c new file mode 100644 index 0000000..8635347 --- /dev/null +++ b/status.c @@ -0,0 +1,14 @@ +/* + * status.c: Keeping track of several VDR status settings + */ + +#include "status.h" + +cLCARSNGStatusMonitor *statusMonitor; + +void cLCARSNGStatusMonitor::SetVolume(int volume, bool absolute) +{ // The volume has been set to the given value, either + // absolutely or relative to the current volume. + + Volume = absolute ? volume : Volume + volume; +} diff --git a/status.h b/status.h new file mode 100644 index 0000000..4a2d864 --- /dev/null +++ b/status.h @@ -0,0 +1,24 @@ +/* + * status.h: Keeping track of several VDR status settings + */ + +#ifndef __STATUS_H_ +#define __STATUS_H_ + +#include <vdr/status.h> + +class cLCARSNGStatusMonitor : public cStatus +{ +private: + int Volume = 0; +protected: + virtual void SetVolume(int Volume, bool Absolute); +public: + cLCARSNGStatusMonitor(void) {}; + ~cLCARSNGStatusMonitor(void) {}; + int GetVolume(void) { return Volume; }; +}; + +extern cLCARSNGStatusMonitor *statusMonitor; + +#endif diff --git a/volumebox.c b/volumebox.c new file mode 100644 index 0000000..8f05ad0 --- /dev/null +++ b/volumebox.c @@ -0,0 +1,66 @@ +#include "config.h" +#include "lcarsng.h" +#include "volumebox.h" + +cLCARSNGVolumeBox::cLCARSNGVolumeBox(cOsd *Osd, const cRect &Rect) { + osd = Osd; + pixmap = osd->CreatePixmap(7, Rect); + pixmap->Fill(clrTransparent); + pixmapBackground = osd->CreatePixmap(6, Rect); + pixmapBackground->Fill(clrTransparent); + + const cFont *font = cFont::GetFont(fontOsd); + int lineHeight = font->Height(); + frameColor = Theme.Color(clrVolumeFrame); + mute = -1; + x0 = 0; + x1 = lineHeight / 2; + x2 = lineHeight; + x3 = x2 + Gap; + x7 = cOsd::OsdWidth(); + x6 = x7 - lineHeight / 2; + x5 = x6 - lineHeight / 2; + x4 = x5 - Gap; + y0 = 0; + y1 = lineHeight; + pixmapBackground->DrawRectangle(cRect(x0, y0, x7 - 1, y1), Theme.Color(clrBackground)); + pixmapBackground->DrawRectangle(cRect(x0, y0, x1 - 1, y1), clrTransparent); + pixmapBackground->DrawEllipse (cRect(x0, y0, x1, y1), frameColor, 7); + pixmapBackground->DrawRectangle(cRect(x1, y0, x1 - 1, y1), frameColor); + pixmapBackground->DrawRectangle(cRect(x3, y0, x4 - x3 - 1, y1), frameColor); + pixmapBackground->DrawRectangle(cRect(x5, y0, x6 - x5, y1), frameColor); + pixmapBackground->DrawRectangle(cRect(x6, y0, x7 - x6 - 1, y1), clrTransparent); + pixmapBackground->DrawEllipse (cRect(x6, y0, x7 - x6 - 1, y1), frameColor, 5); +} + +cLCARSNGVolumeBox::~cLCARSNGVolumeBox() { + osd->DestroyPixmap(pixmap); + osd->DestroyPixmap(pixmapBackground); +} + +void cLCARSNGVolumeBox::SetVolume(int Current, int Total, bool Mute) { + int xl = x3 + TextSpacing; + int xr = x4 - TextSpacing; + int yt = y0 + TextFrame; + int yb = y1 - TextFrame; + if (mute != Mute) { + pixmap->DrawRectangle(cRect(x3, y0, x4 - x3 - 1, y1), frameColor); + mute = Mute; + } + cBitmap bm(Mute ? mute_xpm : volume_xpm); + pixmap->DrawBitmap(cPoint(xl, (y1 - bm.Height()) / 2), bm, Theme.Color(clrVolumeSymbol), frameColor); + if (!Mute) { + xl += bm.Width() + TextSpacing; + int w = (y1 - y0) / 3; + int d = TextFrame; + int n = (xr - xl + d) / (w + d); + int x = xr - n * (w + d); + tColor Color = Theme.Color(clrVolumeBarLower); + for (int i = 0; i < n; i++) { + if (Total * i >= Current * n) + Color = Theme.Color(clrVolumeBarUpper); + pixmap->DrawRectangle(cRect(x, yt, w - 1, yb - yt - 1), Color); + x += w + d; + } + } +} diff --git a/volumebox.h b/volumebox.h new file mode 100644 index 0000000..73c2c06 --- /dev/null +++ b/volumebox.h @@ -0,0 +1,21 @@ +#ifndef __LCARSNG_VOLUMEBOX_H +#define __LCARSNG_VOLUMEBOX_H + +#include <vdr/skins.h> + +class cLCARSNGVolumeBox { +private: + cOsd *osd; + cPixmap *pixmap; + cPixmap *pixmapBackground; + int x0, x1, x2, x3, x4, x5, x6, x7; + int y0, y1; + tColor frameColor; + int mute; +public: + cLCARSNGVolumeBox(cOsd *Osd, const cRect &Rect); + ~cLCARSNGVolumeBox(); + void SetVolume(int Current = 0, int Total = 0, bool Mute = false); + }; + +#endif //__LCARSNG_VOLUMEBOX_H |