summaryrefslogtreecommitdiff
path: root/skinsttng.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-01-02 15:11:44 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2005-01-02 15:11:44 +0100
commit0b3a801ab463186519e9e1c14ea891924c64dff5 (patch)
tree9795fd31fa77a909b5a9cd19ee89a7062d381685 /skinsttng.c
parent286af66cfb787b76ee7289c920a75a3dd21ce795 (diff)
downloadvdr-0b3a801ab463186519e9e1c14ea891924c64dff5.tar.gz
vdr-0b3a801ab463186519e9e1c14ea891924c64dff5.tar.bz2
Implemented audio track menu
Diffstat (limited to 'skinsttng.c')
-rw-r--r--skinsttng.c141
1 files changed, 140 insertions, 1 deletions
diff --git a/skinsttng.c b/skinsttng.c
index 844cd29f..8ae0180a 100644
--- a/skinsttng.c
+++ b/skinsttng.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: skinsttng.c 1.9 2004/12/26 11:34:29 kls Exp $
+ * $Id: skinsttng.c 1.10 2005/01/02 14:41:49 kls Exp $
*/
// Star Trek: The Next Generation® is a registered trademark of Paramount Pictures
@@ -822,6 +822,140 @@ void cSkinSTTNGDisplayVolume::Flush(void)
osd->Flush();
}
+// --- cSkinSTTNGDisplayTracks -----------------------------------------------
+
+class cSkinSTTNGDisplayTracks : public cSkinDisplayTracks {
+private:
+ cOsd *osd;
+ int x0, x1, x2, x3, x4, x5, x6, x7;
+ int y0, y1, y2, y3, y4, y5, y6, y7;
+ int lineHeight;
+ tColor frameColor;
+ int currentIndex;
+ void SetItem(const char *Text, int Index, bool Current);
+public:
+ cSkinSTTNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
+ virtual ~cSkinSTTNGDisplayTracks();
+ virtual void SetTrack(int Index, const char * const *Tracks);
+ virtual void Flush(void);
+ };
+
+cSkinSTTNGDisplayTracks::cSkinSTTNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
+{
+ const cFont *font = cFont::GetFont(fontOsd);
+ lineHeight = font->Height();
+ frameColor = Theme.Color(clrMenuFrame);
+ currentIndex = -1;
+ int ItemsWidth = font->Width(Title);
+ for (int i = 0; i < NumTracks; i++)
+ ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]));
+ ItemsWidth += 10;
+ x0 = 0;
+ x1 = lineHeight / 2;
+ x3 = (x1 + Roundness + Gap + 7) & ~0x07; // must be multiple of 8
+ x2 = x3 - Gap;
+ x7 = Setup.OSDWidth;
+ x6 = x7 - lineHeight / 2;
+ x4 = (x6 - lineHeight / 2 - Gap) & ~0x07; // must be multiple of 8
+ x5 = x4 + Gap;
+ int d = x4 - x3;
+ if (d > ItemsWidth) {
+ d = (d - ItemsWidth) & ~0x07; // must be multiple of 8
+ x4 -= d;
+ x5 -= d;
+ x6 -= d;
+ x7 -= d;
+ }
+ y0 = 0;
+ y1 = lineHeight;
+ y2 = y1 + Roundness;
+ y3 = y2 + Gap;
+ // limit to Setup.OSDHeight? - what if height is too big???
+ y4 = y3 + NumTracks * lineHeight + 2 * Roundness;
+ y5 = y4 + Gap;
+ y6 = y5 + Roundness;
+ y7 = y6 + cFont::GetFont(fontSml)->Height();
+ int yt = (y0 + y1) / 2;
+ int yb = (y6 + y7) / 2;
+ osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y7);
+ tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 4 } };
+ if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
+ osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
+ else {
+ tArea Areas[] = { { x0, y0, x7 - 1, y3 - 1, 2 },
+ { x0, y3, x3 - 1, y4 - 1, 1 },
+ { x3, y3, x4 - 1, y4 - 1, 2 },
+ { x4, y3, x7 - 1, y4 - 1, 2 },
+ { x0, y4, x7 - 1, y7 - 1, 4 }
+ };
+ osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
+ }
+ osd->DrawRectangle(x0, y0, x7 - 1, y7 - 1, Theme.Color(clrBackground));
+ osd->DrawRectangle(x0, y0, x1 - 1, y1 - 1, clrTransparent);
+ osd->DrawRectangle(x0, y6, x1 - 1, y7 - 1, clrTransparent);
+ osd->DrawRectangle(x6, y0, x7 - 1, yt - 1, clrTransparent);
+ osd->DrawRectangle(x6, yb, x7 - 1, y7 - 1, clrTransparent);
+ osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 2);
+ 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->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
+ osd->DrawRectangle(x0, y1, x1 - 1, y6 - 1, frameColor);
+ osd->DrawEllipse (x1, y1, x2 - 1, y2 - 1, frameColor, -2);
+ osd->DrawEllipse (x1, y5, x2 - 1, y6 - 1, frameColor, -3);
+ osd->DrawEllipse (x0, y6, x1 - 1, y7 - 1, frameColor, 3);
+ osd->DrawRectangle(x1, y6, x2 - 1, y7 - 1, frameColor);
+ osd->DrawRectangle(x3, y6, x4 - 1, y7 - 1, frameColor);
+ osd->DrawRectangle(x5, y6, x6 - 1, y7 - 1, frameColor);
+ osd->DrawEllipse (x6, y6, x7 - 1, y7 - 1, frameColor, 5);
+ osd->DrawText(x3 + 5, y0, Title, Theme.Color(clrMenuTitle), frameColor, font, x4 - x3 - 5);
+ for (int i = 0; i < NumTracks; i++)
+ SetItem(Tracks[i], i, false);
+}
+
+cSkinSTTNGDisplayTracks::~cSkinSTTNGDisplayTracks()
+{
+ delete osd;
+}
+
+void cSkinSTTNGDisplayTracks::SetItem(const char *Text, int Index, bool Current)
+{
+ int y = y3 + Roundness + Index * lineHeight;
+ tColor ColorFg, ColorBg;
+ if (Current) {
+ ColorFg = Theme.Color(clrMenuItemCurrentFg);
+ ColorBg = Theme.Color(clrMenuItemCurrentBg);
+ osd->DrawEllipse (x1, y - Roundness, x2 - 1, y - 1, frameColor, -3);
+ osd->DrawRectangle(x1, y, x2 - 1, y + lineHeight - 1, frameColor);
+ osd->DrawEllipse (x1, y + lineHeight, x2 - 1, y + lineHeight + Roundness - 1, frameColor, -2);
+ osd->DrawRectangle(x3, y, x4 - 1, y + lineHeight - 1, ColorBg);
+ currentIndex = Index;
+ }
+ else {
+ ColorFg = Theme.Color(clrMenuItemSelectable);
+ ColorBg = Theme.Color(clrBackground);
+ if (currentIndex == Index) {
+ osd->DrawRectangle(x1, y - Roundness, x2 - 1, y + lineHeight + Roundness - 1, Theme.Color(clrBackground));
+ osd->DrawRectangle(x3, y, x4 - 1, y + lineHeight - 1, Theme.Color(clrBackground));
+ }
+ }
+ const cFont *font = cFont::GetFont(fontOsd);
+ int xt = x3 + 5;
+ osd->DrawText(xt, y, Text, ColorFg, ColorBg, font, x4 - xt);
+}
+
+void cSkinSTTNGDisplayTracks::SetTrack(int Index, const char * const *Tracks)
+{
+ if (currentIndex >= 0)
+ SetItem(Tracks[currentIndex], currentIndex, false);
+ SetItem(Tracks[Index], Index, true);
+}
+
+void cSkinSTTNGDisplayTracks::Flush(void)
+{
+ osd->Flush();
+}
+
// --- cSkinSTTNGDisplayMessage ----------------------------------------------
class cSkinSTTNGDisplayMessage : public cSkinDisplayMessage {
@@ -909,6 +1043,11 @@ cSkinDisplayVolume *cSkinSTTNG::DisplayVolume(void)
return new cSkinSTTNGDisplayVolume;
}
+cSkinDisplayTracks *cSkinSTTNG::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
+{
+ return new cSkinSTTNGDisplayTracks(Title, NumTracks, Tracks);
+}
+
cSkinDisplayMessage *cSkinSTTNG::DisplayMessage(void)
{
return new cSkinSTTNGDisplayMessage;