diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2019-07-22 12:14:08 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2019-07-22 14:51:59 +0200 |
commit | 30a6ec85d3738fca98ce80ed305f0d83a81eb3e0 (patch) | |
tree | e6936da082f03d0cb488627b8cb4a0a171a73d86 | |
parent | 78733710efa56f01c759d3d3bf4749f6c8011aa6 (diff) | |
download | skin-lcarsng-30a6ec85d3738fca98ce80ed305f0d83a81eb3e0.tar.gz skin-lcarsng-30a6ec85d3738fca98ce80ed305f0d83a81eb3e0.tar.bz2 |
Separate displaytracks
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | displaytracks.c | 134 | ||||
-rw-r--r-- | displaytracks.h | 23 | ||||
-rw-r--r-- | lcarsng.c | 150 |
4 files changed, 159 insertions, 150 deletions
@@ -54,7 +54,7 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = displaychannel.o displaymenu.o displayreplay.o lcarsng.o $(PLUGIN).o +OBJS = displaychannel.o displaymenu.o displayreplay.o displaytracks.o lcarsng.o $(PLUGIN).o ### The main target: diff --git a/displaytracks.c b/displaytracks.c new file mode 100644 index 0000000..068f86a --- /dev/null +++ b/displaytracks.c @@ -0,0 +1,134 @@ +#include "lcarsng.h" +#include "displaytracks.h" +#include <vdr/font.h> + +// --- cLCARSNGDisplayTracks ----------------------------------------------- + +cBitmap cLCARSNGDisplayTracks::bmAudioLeft(audioleft_xpm); +cBitmap cLCARSNGDisplayTracks::bmAudioRight(audioright_xpm); +cBitmap cLCARSNGDisplayTracks::bmAudioStereo(audiostereo_xpm); + +cLCARSNGDisplayTracks::cLCARSNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) +{ + const cFont *font = cFont::GetFont(fontOsd); + lineHeight = font->Height(); + frameColor = Theme.Color(clrTrackFrameBg); + currentIndex = -1; + xt00 = 0; + xt01 = xt00 + lineHeight / 2; + xt02 = xt01 + Gap; + xt03 = xt00 + 2 * lineHeight; + int ItemsWidth = font->Width(Title) + xt03 - xt02; + for (int i = 0; i < NumTracks; i++) + ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]) + 2 * TextFrame); + xt04 = xt02 + ItemsWidth; + xt05 = xt04 + Gap; + xt06 = xt04 + lineHeight; + xt07 = xt05 + lineHeight; + xt08 = xt07 + lineHeight; + xt09 = xt08 + Gap; + xt10 = xt09 + lineHeight / 2; + xt11 = xt10 + Gap; + xt12 = xt11 + lineHeight; + yt00 = 0; + yt01 = yt00 + lineHeight; + yt02 = yt01 + lineHeight; + yt03 = yt02 + Gap; + yt04 = yt03 + NumTracks * lineHeight + (NumTracks - 1) * Gap; + yt05 = yt04 + Gap; + yt06 = yt05 + lineHeight; + yt07 = yt06 + lineHeight; + while (yt07 > cOsd::OsdHeight()) { + yt04 -= lineHeight + Gap; + yt05 = yt04 + Gap; + yt06 = yt05 + lineHeight; + yt07 = yt06 + lineHeight; + } + osd = CreateOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - yt07, xt00, yt00, xt12 - 1, yt07 - 1); + // The upper elbow: + osd->DrawRectangle(xt00, yt00, xt12 - 1, yt07 - 1, Theme.Color(clrBackground)); + osd->DrawRectangle(xt00, yt00, xt03 - 1, yt02 - 1, clrTransparent); + osd->DrawEllipse (xt00, yt00, xt03 - 1, yt02 - 1, frameColor, 2); + osd->DrawRectangle(xt03, yt00, xt04 - 1, yt02 - 1, frameColor); + osd->DrawRectangle(xt04, yt00, xt08 - 1, yt01 - 1, frameColor); + osd->DrawEllipse (xt04, yt01, xt06 - 1, yt02 - 1, frameColor, -2); + osd->DrawRectangle(xt09, yt00, xt10 - 1, yt01 - 1, frameColor); + osd->DrawRectangle(xt11, yt00, xt11 + lineHeight / 2 - 1, yt01 - 1, frameColor); + osd->DrawRectangle(xt11 + lineHeight / 2, yt00, xt12 - 1, yt00 + lineHeight / 2 - 1, clrTransparent); + osd->DrawEllipse (xt11 + lineHeight / 2, yt00, xt12 - 1, yt01 - 1, frameColor, 5); + osd->DrawText(xt03, yt00, Title, Theme.Color(clrTrackFrameFg), frameColor, font, xt04 - xt03, 0, taTop | taRight); + // The items: + for (int i = 0; i < NumTracks; i++) + SetItem(Tracks[i], i, false); + // The lower elbow: + osd->DrawRectangle(xt00, yt05, xt03 - 1, yt07 - 1, clrTransparent); + osd->DrawEllipse (xt00, yt05, xt03 - 1, yt07 - 1, frameColor, 3); + osd->DrawRectangle(xt03, yt05, xt04 - 1, yt07 - 1, frameColor); + osd->DrawRectangle(xt04, yt06, xt08 - 1, yt07 - 1, frameColor); + osd->DrawEllipse (xt04, yt05, xt06 - 1, yt06 - 1, frameColor, -3); + osd->DrawRectangle(xt09, yt06, xt10 - 1, yt07 - 1, frameColor); + osd->DrawRectangle(xt11, yt06, xt11 + lineHeight / 2 - 1, yt07 - 1, frameColor); + osd->DrawRectangle(xt11 + lineHeight / 2, yt06 + lineHeight / 2, xt12 - 1, yt07 - 1, clrTransparent); + osd->DrawEllipse (xt11 + lineHeight / 2, yt06, xt12 - 1, yt07 - 1, frameColor, 5); +} + +cLCARSNGDisplayTracks::~cLCARSNGDisplayTracks() +{ + delete osd; + cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); +} + +void cLCARSNGDisplayTracks::SetItem(const char *Text, int Index, bool Current) +{ + int y0 = yt03 + Index * (lineHeight + Gap); + int y1 = y0 + lineHeight; + if (y1 > yt04) + return; + tColor ColorFg, ColorBg; + if (Current) { + ColorFg = Theme.Color(clrTrackItemCurrentFg); + ColorBg = Theme.Color(clrTrackItemCurrentBg); + osd->DrawRectangle(xt00, y0, xt01 - 1, y1 - 1, frameColor); + osd->DrawRectangle(xt02, y0, xt04 - 1, y1 - 1, ColorBg); + osd->DrawRectangle(xt05, y0, xt05 + lineHeight / 2 - 1, y1 - 1, ColorBg); + osd->DrawEllipse (xt05 + lineHeight / 2, y0, xt07 - 1, y1 - 1, ColorBg, 5); + currentIndex = Index; + } + else { + ColorFg = Theme.Color(clrTrackItemFg); + ColorBg = Theme.Color(clrTrackItemBg); + osd->DrawRectangle(xt00, y0, xt01 - 1, y1 - 1, frameColor); + osd->DrawRectangle(xt02, y0, xt04 - 1, y1 - 1, ColorBg); + if (currentIndex == Index) + osd->DrawRectangle(xt05, y0, xt07 - 1, y1 - 1, Theme.Color(clrBackground)); + } + const cFont *font = cFont::GetFont(fontOsd); + osd->DrawText(xt02, y0, Text, ColorFg, ColorBg, font, xt04 - xt02, y1 - y0, taTop | taLeft | taBorder); +} + +void cLCARSNGDisplayTracks::SetTrack(int Index, const char * const *Tracks) +{ + if (currentIndex >= 0) + SetItem(Tracks[currentIndex], currentIndex, false); + SetItem(Tracks[Index], Index, true); +} + +void cLCARSNGDisplayTracks::SetAudioChannel(int AudioChannel) +{ + cBitmap *bm = NULL; + switch (AudioChannel) { + case 0: bm = &bmAudioStereo; break; + case 1: bm = &bmAudioLeft; break; + case 2: bm = &bmAudioRight; break; + default: ; + } + if (bm) + osd->DrawBitmap(xt04 - bm->Width(), (yt06 + yt07 - bm->Height()) / 2, *bm, Theme.Color(clrTrackFrameFg), frameColor); + else + osd->DrawRectangle(xt03, yt06, xt04 - 1, yt07 - 1, frameColor); +} + +void cLCARSNGDisplayTracks::Flush(void) +{ + osd->Flush(); +} diff --git a/displaytracks.h b/displaytracks.h new file mode 100644 index 0000000..12dbd56 --- /dev/null +++ b/displaytracks.h @@ -0,0 +1,23 @@ +#include "lcarsng.h" +#include <vdr/font.h> +#include <vdr/menu.h> + +// --- cLCARSNGDisplayTracks ----------------------------------------------- + +class cLCARSNGDisplayTracks : public cSkinDisplayTracks { +private: + cOsd *osd; + int xt00, xt01, xt02, xt03, xt04, xt05, xt06, xt07, xt08, xt09, xt10, xt11, xt12; + int yt00, yt01, yt02, yt03, yt04, yt05, yt06, yt07; + int lineHeight; + tColor frameColor; + int currentIndex; + static cBitmap bmAudioLeft, bmAudioRight, bmAudioStereo; + void SetItem(const char *Text, int Index, bool Current); +public: + cLCARSNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks); + virtual ~cLCARSNGDisplayTracks(); + virtual void SetTrack(int Index, const char * const *Tracks); + virtual void SetAudioChannel(int AudioChannel); + virtual void Flush(void); + }; @@ -27,6 +27,7 @@ #include "displaychannel.h" #include "displaymenu.h" #include "displayreplay.h" +#include "displaytracks.h" #include <vdr/font.h> #include <vdr/menu.h> #include <vdr/osd.h> @@ -339,155 +340,6 @@ void cLCARSNGDisplayVolume::Flush(void) osd->Flush(); } -// --- cLCARSNGDisplayTracks ----------------------------------------------- - -class cLCARSNGDisplayTracks : public cSkinDisplayTracks { -private: - cOsd *osd; - int xt00, xt01, xt02, xt03, xt04, xt05, xt06, xt07, xt08, xt09, xt10, xt11, xt12; - int yt00, yt01, yt02, yt03, yt04, yt05, yt06, yt07; - int lineHeight; - tColor frameColor; - int currentIndex; - static cBitmap bmAudioLeft, bmAudioRight, bmAudioStereo; - void SetItem(const char *Text, int Index, bool Current); -public: - cLCARSNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks); - virtual ~cLCARSNGDisplayTracks(); - virtual void SetTrack(int Index, const char * const *Tracks); - virtual void SetAudioChannel(int AudioChannel); - virtual void Flush(void); - }; - -cBitmap cLCARSNGDisplayTracks::bmAudioLeft(audioleft_xpm); -cBitmap cLCARSNGDisplayTracks::bmAudioRight(audioright_xpm); -cBitmap cLCARSNGDisplayTracks::bmAudioStereo(audiostereo_xpm); - -cLCARSNGDisplayTracks::cLCARSNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) -{ - const cFont *font = cFont::GetFont(fontOsd); - lineHeight = font->Height(); - frameColor = Theme.Color(clrTrackFrameBg); - currentIndex = -1; - xt00 = 0; - xt01 = xt00 + lineHeight / 2; - xt02 = xt01 + Gap; - xt03 = xt00 + 2 * lineHeight; - int ItemsWidth = font->Width(Title) + xt03 - xt02; - for (int i = 0; i < NumTracks; i++) - ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]) + 2 * TextFrame); - xt04 = xt02 + ItemsWidth; - xt05 = xt04 + Gap; - xt06 = xt04 + lineHeight; - xt07 = xt05 + lineHeight; - xt08 = xt07 + lineHeight; - xt09 = xt08 + Gap; - xt10 = xt09 + lineHeight / 2; - xt11 = xt10 + Gap; - xt12 = xt11 + lineHeight; - yt00 = 0; - yt01 = yt00 + lineHeight; - yt02 = yt01 + lineHeight; - yt03 = yt02 + Gap; - yt04 = yt03 + NumTracks * lineHeight + (NumTracks - 1) * Gap; - yt05 = yt04 + Gap; - yt06 = yt05 + lineHeight; - yt07 = yt06 + lineHeight; - while (yt07 > cOsd::OsdHeight()) { - yt04 -= lineHeight + Gap; - yt05 = yt04 + Gap; - yt06 = yt05 + lineHeight; - yt07 = yt06 + lineHeight; - } - osd = CreateOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - yt07, xt00, yt00, xt12 - 1, yt07 - 1); - // The upper elbow: - osd->DrawRectangle(xt00, yt00, xt12 - 1, yt07 - 1, Theme.Color(clrBackground)); - osd->DrawRectangle(xt00, yt00, xt03 - 1, yt02 - 1, clrTransparent); - osd->DrawEllipse (xt00, yt00, xt03 - 1, yt02 - 1, frameColor, 2); - osd->DrawRectangle(xt03, yt00, xt04 - 1, yt02 - 1, frameColor); - osd->DrawRectangle(xt04, yt00, xt08 - 1, yt01 - 1, frameColor); - osd->DrawEllipse (xt04, yt01, xt06 - 1, yt02 - 1, frameColor, -2); - osd->DrawRectangle(xt09, yt00, xt10 - 1, yt01 - 1, frameColor); - osd->DrawRectangle(xt11, yt00, xt11 + lineHeight / 2 - 1, yt01 - 1, frameColor); - osd->DrawRectangle(xt11 + lineHeight / 2, yt00, xt12 - 1, yt00 + lineHeight / 2 - 1, clrTransparent); - osd->DrawEllipse (xt11 + lineHeight / 2, yt00, xt12 - 1, yt01 - 1, frameColor, 5); - osd->DrawText(xt03, yt00, Title, Theme.Color(clrTrackFrameFg), frameColor, font, xt04 - xt03, 0, taTop | taRight); - // The items: - for (int i = 0; i < NumTracks; i++) - SetItem(Tracks[i], i, false); - // The lower elbow: - osd->DrawRectangle(xt00, yt05, xt03 - 1, yt07 - 1, clrTransparent); - osd->DrawEllipse (xt00, yt05, xt03 - 1, yt07 - 1, frameColor, 3); - osd->DrawRectangle(xt03, yt05, xt04 - 1, yt07 - 1, frameColor); - osd->DrawRectangle(xt04, yt06, xt08 - 1, yt07 - 1, frameColor); - osd->DrawEllipse (xt04, yt05, xt06 - 1, yt06 - 1, frameColor, -3); - osd->DrawRectangle(xt09, yt06, xt10 - 1, yt07 - 1, frameColor); - osd->DrawRectangle(xt11, yt06, xt11 + lineHeight / 2 - 1, yt07 - 1, frameColor); - osd->DrawRectangle(xt11 + lineHeight / 2, yt06 + lineHeight / 2, xt12 - 1, yt07 - 1, clrTransparent); - osd->DrawEllipse (xt11 + lineHeight / 2, yt06, xt12 - 1, yt07 - 1, frameColor, 5); -} - -cLCARSNGDisplayTracks::~cLCARSNGDisplayTracks() -{ - delete osd; - cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); -} - -void cLCARSNGDisplayTracks::SetItem(const char *Text, int Index, bool Current) -{ - int y0 = yt03 + Index * (lineHeight + Gap); - int y1 = y0 + lineHeight; - if (y1 > yt04) - return; - tColor ColorFg, ColorBg; - if (Current) { - ColorFg = Theme.Color(clrTrackItemCurrentFg); - ColorBg = Theme.Color(clrTrackItemCurrentBg); - osd->DrawRectangle(xt00, y0, xt01 - 1, y1 - 1, frameColor); - osd->DrawRectangle(xt02, y0, xt04 - 1, y1 - 1, ColorBg); - osd->DrawRectangle(xt05, y0, xt05 + lineHeight / 2 - 1, y1 - 1, ColorBg); - osd->DrawEllipse (xt05 + lineHeight / 2, y0, xt07 - 1, y1 - 1, ColorBg, 5); - currentIndex = Index; - } - else { - ColorFg = Theme.Color(clrTrackItemFg); - ColorBg = Theme.Color(clrTrackItemBg); - osd->DrawRectangle(xt00, y0, xt01 - 1, y1 - 1, frameColor); - osd->DrawRectangle(xt02, y0, xt04 - 1, y1 - 1, ColorBg); - if (currentIndex == Index) - osd->DrawRectangle(xt05, y0, xt07 - 1, y1 - 1, Theme.Color(clrBackground)); - } - const cFont *font = cFont::GetFont(fontOsd); - osd->DrawText(xt02, y0, Text, ColorFg, ColorBg, font, xt04 - xt02, y1 - y0, taTop | taLeft | taBorder); -} - -void cLCARSNGDisplayTracks::SetTrack(int Index, const char * const *Tracks) -{ - if (currentIndex >= 0) - SetItem(Tracks[currentIndex], currentIndex, false); - SetItem(Tracks[Index], Index, true); -} - -void cLCARSNGDisplayTracks::SetAudioChannel(int AudioChannel) -{ - cBitmap *bm = NULL; - switch (AudioChannel) { - case 0: bm = &bmAudioStereo; break; - case 1: bm = &bmAudioLeft; break; - case 2: bm = &bmAudioRight; break; - default: ; - } - if (bm) - osd->DrawBitmap(xt04 - bm->Width(), (yt06 + yt07 - bm->Height()) / 2, *bm, Theme.Color(clrTrackFrameFg), frameColor); - else - osd->DrawRectangle(xt03, yt06, xt04 - 1, yt07 - 1, frameColor); -} - -void cLCARSNGDisplayTracks::Flush(void) -{ - osd->Flush(); -} - // --- cLCARSNGDisplayMessage ---------------------------------------------- class cLCARSNGDisplayMessage : public cSkinDisplayMessage { |