From f4a9b33b6d7c427595040314f12d224c4a4692eb Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 13 Feb 2010 13:48:19 +0100 Subject: Improved scalability of the default skins --- HISTORY | 1 + skinclassic.c | 26 ++++++++++--------- skinsttng.c | 80 ++++++++++++++++++++++++++++++----------------------------- 3 files changed, 56 insertions(+), 51 deletions(-) diff --git a/HISTORY b/HISTORY index 8f6d51c4..3b633708 100644 --- a/HISTORY +++ b/HISTORY @@ -6360,3 +6360,4 @@ Video Disk Recorder Revision History recording name was not visible at all. - Updated the Romanian OSD texts (thanks to Lucian Muresan). - Exported some libsi functions (thanks to Lucian Muresan). +- Improved scalability of the default skins. diff --git a/skinclassic.c b/skinclassic.c index 7b45b1bc..38520107 100644 --- a/skinclassic.c +++ b/skinclassic.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: skinclassic.c 2.3 2010/01/03 14:55:10 kls Exp $ + * $Id: skinclassic.c 2.4 2010/02/13 13:44:48 kls Exp $ */ #include "skinclassic.h" @@ -13,7 +13,9 @@ #include "osd.h" #include "themes.h" -#define ScrollWidth 5 +#define ScrollWidth (Setup.FontOsdSize / 4) +#define TextFrame (Setup.FontOsdSize / 10) +#define TextSpacing (Setup.FontOsdSize / 4) static cTheme Theme; @@ -94,7 +96,7 @@ cSkinClassicDisplayChannel::cSkinClassicDisplayChannel(bool WithInfo) lineHeight = font->Height(); message = false; osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + (Setup.ChannelInfoPos ? 0 : cOsd::OsdHeight() - Lines * lineHeight)); - timeWidth = font->Width("00:00") + 4; + timeWidth = font->Width("00:00") + 2 * TextFrame; tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, Lines * lineHeight - 1, 8 } }; if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk) osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); @@ -113,7 +115,7 @@ cSkinClassicDisplayChannel::~cSkinClassicDisplayChannel() void cSkinClassicDisplayChannel::SetChannel(const cChannel *Channel, int Number) { osd->DrawRectangle(0, 0, osd->Width() - 1, lineHeight - 1, Theme.Color(clrBackground)); - osd->DrawText(2, 0, ChannelString(Channel, Number), Theme.Color(clrChannelName), Theme.Color(clrBackground), cFont::GetFont(fontOsd)); + osd->DrawText(TextFrame, 0, ChannelString(Channel, Number), Theme.Color(clrChannelName), Theme.Color(clrBackground), cFont::GetFont(fontOsd)); lastDate = NULL; } @@ -124,9 +126,9 @@ void cSkinClassicDisplayChannel::SetEvents(const cEvent *Present, const cEvent * for (int i = 0; i < 2; i++) { const cEvent *e = !i ? Present : Following; if (e) { - osd->DrawText( 2, (2 * i + 1) * lineHeight, e->GetTimeString(), Theme.Color(clrChannelEpgTimeFg), Theme.Color(clrChannelEpgTimeBg), cFont::GetFont(fontOsd)); - osd->DrawText(timeWidth + 10, (2 * i + 1) * lineHeight, e->Title(), Theme.Color(clrChannelEpgTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd)); - osd->DrawText(timeWidth + 10, (2 * i + 2) * lineHeight, e->ShortText(), Theme.Color(clrChannelEpgShortText), Theme.Color(clrBackground), cFont::GetFont(fontSml)); + osd->DrawText( TextFrame, (2 * i + 1) * lineHeight, e->GetTimeString(), Theme.Color(clrChannelEpgTimeFg), Theme.Color(clrChannelEpgTimeBg), cFont::GetFont(fontOsd)); + osd->DrawText(timeWidth + 2 * TextSpacing, (2 * i + 1) * lineHeight, e->Title(), Theme.Color(clrChannelEpgTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd)); + osd->DrawText(timeWidth + 2 * TextSpacing, (2 * i + 2) * lineHeight, e->ShortText(), Theme.Color(clrChannelEpgShortText), Theme.Color(clrBackground), cFont::GetFont(fontSml)); } } } @@ -152,7 +154,7 @@ void cSkinClassicDisplayChannel::Flush(void) if (!*lastDate || strcmp(date, lastDate)) { const cFont *font = cFont::GetFont(fontSml); int w = font->Width(date); - osd->DrawText(osd->Width() - w - 2, 0, date, Theme.Color(clrChannelDate), Theme.Color(clrBackground), cFont::GetFont(fontSml), w); + osd->DrawText(osd->Width() - w - TextFrame, 0, date, Theme.Color(clrChannelDate), Theme.Color(clrBackground), cFont::GetFont(fontSml), w); lastDate = date; } } @@ -196,7 +198,7 @@ cSkinClassicDisplayMenu::cSkinClassicDisplayMenu(void) lineHeight = font->Height(); dateWidth = 0; x0 = 0; - x1 = x0 + 10; + x1 = x0 + 2 * TextSpacing; x3 = cOsd::OsdWidth(); x2 = x3 - 2 * ScrollWidth; y0 = 0; @@ -440,9 +442,9 @@ void cSkinClassicDisplayMenu::Flush(void) if (!*lastDate || strcmp(date, lastDate)) { const cFont *font = cFont::GetFont(fontOsd); int w = font->Width(date); - osd->DrawText(x3 - w - 2, y0, date, Theme.Color(clrMenuDate), Theme.Color(clrMenuTitleBg), font, w); + osd->DrawText(x3 - w - TextFrame, y0, date, Theme.Color(clrMenuDate), Theme.Color(clrMenuTitleBg), font, w); lastDate = date; - dateWidth = max(w + 2, dateWidth); + dateWidth = max(w + TextFrame, dateWidth); } osd->Flush(); } @@ -638,7 +640,7 @@ cSkinClassicDisplayTracks::cSkinClassicDisplayTracks(const char *Title, int NumT int ItemsWidth = font->Width(Title); for (int i = 0; i < NumTracks; i++) ItemsWidth = max(ItemsWidth, font->Width(Tracks[i])); - ItemsWidth += 10; + ItemsWidth += 2 * TextSpacing; x0 = 0; x1 = cOsd::OsdWidth(); int d = x1 - x0; diff --git a/skinsttng.c b/skinsttng.c index 55510917..b37a2e9d 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 2.4 2010/01/03 14:51:35 kls Exp $ + * $Id: skinsttng.c 2.5 2010/02/13 13:30:59 kls Exp $ */ // Star Trek: The Next Generation® is a registered trademark of Paramount Pictures @@ -49,9 +49,12 @@ #include "symbols/teletext.xpm" #include "symbols/volume.xpm" -#define Roundness 10 -#define Gap 5 -#define ScrollWidth 5 +#define Roundness (Setup.FontOsdSize / 2) +#define Gap (Setup.FontOsdSize / 5) +#define ScrollWidth (Setup.FontOsdSize / 4) +#define TextFrame (Setup.FontOsdSize / 10) +#define TextSpacing (Setup.FontOsdSize / 4) +#define SymbolSpacing (Setup.FontOsdSize / 4) static cTheme Theme; @@ -161,7 +164,7 @@ cSkinSTTNGDisplayChannel::cSkinSTTNGDisplayChannel(bool WithInfo) message = false; if (withInfo) { x0 = 0; - x1 = x0 + font->Width("00:00") + 4; + x1 = x0 + font->Width("00:00") + 2 * TextFrame; x2 = x1 + Roundness; x3 = x2 + Gap; x7 = cOsd::OsdWidth(); @@ -240,28 +243,27 @@ cSkinSTTNGDisplayChannel::~cSkinSTTNGDisplayChannel() void cSkinSTTNGDisplayChannel::SetChannel(const cChannel *Channel, int Number) { osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor); - int x = x4 - 5; + int x = x4 - SymbolSpacing; if (Channel && !Channel->GroupSep()) { - int d = 3; bool rec = cRecordControls::Active(); - x -= bmRecording.Width() + d; + x -= bmRecording.Width() + SymbolSpacing; osd->DrawBitmap(x, y0 + (y1 - y0 - bmRecording.Height()) / 2, bmRecording, Theme.Color(rec ? clrChannelSymbolRecFg : clrChannelSymbolOff), rec ? Theme.Color(clrChannelSymbolRecBg) : frameColor); - x -= bmEncrypted.Width() + d; + x -= bmEncrypted.Width() + SymbolSpacing; osd->DrawBitmap(x, y0 + (y1 - y0 - bmEncrypted.Height()) / 2, bmEncrypted, Theme.Color(Channel->Ca() ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor); - x -= bmDolbyDigital.Width() + d; + x -= bmDolbyDigital.Width() + SymbolSpacing; osd->DrawBitmap(x, y0 + (y1 - y0 - bmDolbyDigital.Height()) / 2, bmDolbyDigital, Theme.Color(Channel->Dpid(0) ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor); - x -= bmAudio.Width() + d; + x -= bmAudio.Width() + SymbolSpacing; osd->DrawBitmap(x, y0 + (y1 - y0 - bmAudio.Height()) / 2, bmAudio, Theme.Color(Channel->Apid(1) ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor); if (Channel->Vpid()) { - x -= bmTeletext.Width() + d; + x -= bmTeletext.Width() + SymbolSpacing; osd->DrawBitmap(x, y0 + (y1 - y0 - bmTeletext.Height()) / 2, bmTeletext, Theme.Color(Channel->Tpid() ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor); } else if (Channel->Apid(0)) { - x -= bmRadio.Width() + d; + x -= bmRadio.Width() + SymbolSpacing; osd->DrawBitmap(x, y0 + (y1 - y0 - bmRadio.Height()) / 2, bmRadio, Theme.Color(clrChannelSymbolOn), frameColor); } } - osd->DrawText(x3 + 2, y0, ChannelString(Channel, Number), Theme.Color(clrChannelName), frameColor, cFont::GetFont(fontOsd), x - x3 - 2); + osd->DrawText(x3 + TextFrame, y0, ChannelString(Channel, Number), Theme.Color(clrChannelName), frameColor, cFont::GetFont(fontOsd), x - x3 - TextFrame); } void cSkinSTTNGDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following) @@ -276,9 +278,9 @@ void cSkinSTTNGDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Fo for (int i = 0; i < 2; i++) { const cEvent *e = !i ? Present : Following; if (e) { - osd->DrawText(x0 + 2, y3 + 2 * i * lineHeight, e->GetTimeString(), Theme.Color(clrChannelEpgTime), frameColor, cFont::GetFont(fontOsd)); - osd->DrawText(x3 + 2, y3 + 2 * i * lineHeight, e->Title(), Theme.Color(clrChannelEpgTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x4 - x3 - 2); - osd->DrawText(x3 + 2, y3 + (2 * i + 1) * lineHeight, e->ShortText(), Theme.Color(clrChannelEpgShortText), Theme.Color(clrBackground), cFont::GetFont(fontSml), x4 - x3 - 2); + osd->DrawText(x0 + TextFrame, y3 + 2 * i * lineHeight, e->GetTimeString(), Theme.Color(clrChannelEpgTime), frameColor, cFont::GetFont(fontOsd)); + osd->DrawText(x3 + TextFrame, y3 + 2 * i * lineHeight, e->Title(), Theme.Color(clrChannelEpgTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x4 - x3 - TextFrame); + osd->DrawText(x3 + TextFrame, y3 + (2 * i + 1) * lineHeight, e->ShortText(), Theme.Color(clrChannelEpgShortText), Theme.Color(clrBackground), cFont::GetFont(fontSml), x4 - x3 - TextFrame); } } } @@ -309,13 +311,13 @@ void cSkinSTTNGDisplayChannel::Flush(void) cString date = DayDateTime(); int w = font->Width(date); if (!*lastDate || strcmp(date, lastDate)) { - osd->DrawText(x4 - w - 2, y7 - font->Height(), date, Theme.Color(clrChannelDate), frameColor, font, w); + osd->DrawText(x4 - w - TextFrame, y7 - font->Height(), date, Theme.Color(clrChannelDate), frameColor, font, w); lastDate = date; } cDevice *Device = cDevice::PrimaryDevice(); const tTrackId *Track = Device->GetTrack(Device->GetCurrentAudioTrack()); if (!Track && *lastTrackId.description || Track && strcmp(lastTrackId.description, Track->description)) { - osd->DrawText(x3 + 2, y6, Track ? Track->description : "", Theme.Color(clrChannelName), frameColor, font, x4 - x3 - w - 4); + osd->DrawText(x3 + TextFrame, y6, Track ? Track->description : "", Theme.Color(clrChannelName), frameColor, font, x4 - x3 - w - 2 * TextFrame); strn0cpy(lastTrackId.description, Track ? Track->description : "", sizeof(lastTrackId.description)); } } @@ -493,7 +495,7 @@ void cSkinSTTNGDisplayMenu::SetTitle(const char *Title) const cFont *font = cFont::GetFont(fontOsd); const char *VDR = " VDR"; int w = font->Width(VDR); - osd->DrawText(x3 + 5, y0, Title, Theme.Color(clrMenuTitle), frameColor, font, x4 - w - x3 - 5); + osd->DrawText(x3 + TextSpacing, y0, Title, Theme.Color(clrMenuTitle), frameColor, font, x4 - w - x3 - TextSpacing); osd->DrawText(x4 - w, y0, VDR, frameColor, clrBlack, font, w, lineHeight); } @@ -501,9 +503,9 @@ void cSkinSTTNGDisplayMenu::SetButtons(const char *Red, const char *Green, const { cString date = DayDateTime(); const cFont *font = cFont::GetFont(fontSml); - int d = 10; + int d = 2 * Gap; int d2 = d / 2; - int t4 = x4 - font->Width(date) - 2; + int t4 = x4 - font->Width(date) - TextFrame; int w = t4 - x3; int t0 = x3 + d2; int t1 = x3 + w / 4; @@ -558,13 +560,13 @@ void cSkinSTTNGDisplayMenu::SetItem(const char *Text, int Index, bool Current, b for (int i = 0; i < MaxTabs; i++) { const char *s = GetTabbedText(Text, i); if (s) { - int xt = x3 + 5 + Tab(i); + int xt = x3 + TextSpacing + Tab(i); osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x4 - xt); } if (!Tab(i + 1)) break; } - SetEditableWidth(x4 - x3 - 5 - Tab(1)); + SetEditableWidth(x4 - x3 - TextSpacing - Tab(1)); } void cSkinSTTNGDisplayMenu::SetScrollbar(int Total, int Offset) @@ -577,7 +579,7 @@ void cSkinSTTNGDisplayMenu::SetEvent(const cEvent *Event) if (!Event) return; const cFont *font = cFont::GetFont(fontOsd); - int xl = x3 + 5; + int xl = x3 + TextSpacing; int y = y3; cTextScroller ts; char t[32]; @@ -637,7 +639,7 @@ void cSkinSTTNGDisplayMenu::SetRecording(const cRecording *Recording) return; const cRecordingInfo *Info = Recording->Info(); const cFont *font = cFont::GetFont(fontOsd); - int xl = x3 + 5; + int xl = x3 + TextSpacing; int y = y3; cTextScroller ts; char t[32]; @@ -710,7 +712,7 @@ void cSkinSTTNGDisplayMenu::Flush(void) if (!*lastDate || strcmp(date, lastDate)) { const cFont *font = cFont::GetFont(fontSml); int w = font->Width(date); - osd->DrawText(x4 - w - 2, y7 - font->Height(), date, Theme.Color(clrMenuDate), frameColor, font, w); + osd->DrawText(x4 - w - TextFrame, y7 - font->Height(), date, Theme.Color(clrMenuDate), frameColor, font, w); lastDate = date; } } @@ -806,7 +808,7 @@ cSkinSTTNGDisplayReplay::~cSkinSTTNGDisplayReplay() void cSkinSTTNGDisplayReplay::SetTitle(const char *Title) { - osd->DrawText(x3 + 5, y0, Title, Theme.Color(clrReplayTitle), frameColor, cFont::GetFont(fontSml), x4 - x3 - 5); + osd->DrawText(x3 + TextSpacing, y0, Title, Theme.Color(clrReplayTitle), frameColor, cFont::GetFont(fontSml), x4 - x3 - TextSpacing); } static const char *const *ReplaySymbols[2][2][5] = { @@ -844,7 +846,7 @@ void cSkinSTTNGDisplayReplay::SetTotal(const char *Total) { const cFont *font = cFont::GetFont(fontSml); int w = font->Width(Total); - osd->DrawText(x4 - w - 5, y6, Total, Theme.Color(clrReplayTotal), frameColor, font, w); + osd->DrawText(x4 - w - TextSpacing, y6, Total, Theme.Color(clrReplayTotal), frameColor, font, w); } void cSkinSTTNGDisplayReplay::SetJump(const char *Jump) @@ -924,10 +926,10 @@ cSkinSTTNGDisplayVolume::~cSkinSTTNGDisplayVolume() void cSkinSTTNGDisplayVolume::SetVolume(int Current, int Total, bool Mute) { - int xl = x3 + 5; - int xr = x4 - 5; - int yt = y0 + 3; - int yb = y1 - 3; + 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; @@ -935,9 +937,9 @@ void cSkinSTTNGDisplayVolume::SetVolume(int Current, int Total, bool 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() + 5; + xl += bm.Width() + TextSpacing; int w = (y1 - y0) / 3; - int d = 3; + int d = TextFrame; int n = (xr - xl + d) / (w + d); int x = xr - n * (w + d); tColor Color = Theme.Color(clrVolumeBarLower); @@ -988,7 +990,7 @@ cSkinSTTNGDisplayTracks::cSkinSTTNGDisplayTracks(const char *Title, int NumTrack int ItemsWidth = font->Width(Title); for (int i = 0; i < NumTracks; i++) ItemsWidth = max(ItemsWidth, font->Width(Tracks[i])); - ItemsWidth += 10; + ItemsWidth += 2 * TextSpacing; x0 = 0; x1 = lineHeight / 2; x3 = (x1 + Roundness + Gap + 7) & ~0x07; // must be multiple of 8 @@ -1052,7 +1054,7 @@ cSkinSTTNGDisplayTracks::cSkinSTTNGDisplayTracks(const char *Title, int NumTrack 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); + osd->DrawText(x3 + TextSpacing, y0, Title, Theme.Color(clrMenuTitle), frameColor, font, x4 - x3 - TextSpacing); for (int i = 0; i < NumTracks; i++) SetItem(Tracks[i], i, false); } @@ -1084,7 +1086,7 @@ void cSkinSTTNGDisplayTracks::SetItem(const char *Text, int Index, bool Current) } } const cFont *font = cFont::GetFont(fontOsd); - int xt = x3 + 5; + int xt = x3 + TextSpacing; osd->DrawText(xt, y, Text, ColorFg, ColorBg, font, x4 - xt); } @@ -1105,7 +1107,7 @@ void cSkinSTTNGDisplayTracks::SetAudioChannel(int AudioChannel) default: ; } if (bm) - osd->DrawBitmap(x3 + 5, y6 + (y7 - y6 - bm->Height()) / 2, *bm, Theme.Color(clrChannelSymbolOn), frameColor); + osd->DrawBitmap(x3 + TextSpacing, y6 + (y7 - y6 - bm->Height()) / 2, *bm, Theme.Color(clrChannelSymbolOn), frameColor); else osd->DrawRectangle(x3, y6, x4 - 1, y7 - 1, frameColor); } -- cgit v1.2.3