1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Implemented cSkin::SetScrollbar()

This commit is contained in:
Klaus Schmidinger 2008-02-17 12:31:16 +01:00
parent 28a82b3186
commit 54b4d4e4e7
7 changed files with 104 additions and 65 deletions

View File

@ -5579,7 +5579,7 @@ Video Disk Recorder Revision History
is not available, in order to allow staying on an encrypted channel that takes is not available, in order to allow staying on an encrypted channel that takes
a while for the CAM to start decrypting. a while for the CAM to start decrypting.
2008-02-16: Version 1.5.15 2008-02-17: Version 1.5.15
- Updated the Italian OSD texts (thanks to Diego Pierotto). - Updated the Italian OSD texts (thanks to Diego Pierotto).
- Added option -i to the pictures plugin's pic2mpg to ignore unknown file types. - Added option -i to the pictures plugin's pic2mpg to ignore unknown file types.
@ -5637,3 +5637,6 @@ Video Disk Recorder Revision History
(based on a patch from Benedikt Elser). (based on a patch from Benedikt Elser).
- Added new cStatus functions to the 'status' plugin. - Added new cStatus functions to the 'status' plugin.
- Added missing #include <limits.h> to epg.c and menuitems.h (thanks to Ville Skyttä). - Added missing #include <limits.h> to epg.c and menuitems.h (thanks to Ville Skyttä).
- The new function cSkin::SetScrollbar() can be implemented by skins to display
a scrollbar in every list menu. The 'classic' and 'sttng' skins have been
changed accordingly.

View File

@ -54,6 +54,7 @@ OSD:
the one that was created first will be displayed. the one that was created first will be displayed.
Plugins that provide an OSD need to adjust their cOsdProvider::CreateOsd() Plugins that provide an OSD need to adjust their cOsdProvider::CreateOsd()
function to hand through the Level. function to hand through the Level.
- Skins can now have scrollbars in all list menus.
Channels: Channels:

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osdbase.c 1.31 2007/06/09 10:07:46 kls Exp $ * $Id: osdbase.c 1.32 2008/02/17 11:33:04 kls Exp $
*/ */
#include "osdbase.h" #include "osdbase.h"
@ -236,6 +236,7 @@ void cOsdMenu::Display(void)
i++; i++;
} }
} }
displayMenu->SetScrollbar(count, first);
if (!isempty(status)) if (!isempty(status))
displayMenu->SetMessage(mtStatus, status); displayMenu->SetMessage(mtStatus, status);
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: skinclassic.c 1.21 2008/02/10 16:18:25 kls Exp $ * $Id: skinclassic.c 1.22 2008/02/17 12:24:15 kls Exp $
*/ */
#include "skinclassic.h" #include "skinclassic.h"
@ -164,12 +164,13 @@ void cSkinClassicDisplayChannel::Flush(void)
class cSkinClassicDisplayMenu : public cSkinDisplayMenu { class cSkinClassicDisplayMenu : public cSkinDisplayMenu {
private: private:
cOsd *osd; cOsd *osd;
int x0, x1; int x0, x1, x2, x3;
int y0, y1, y2, y3, y4, y5; int y0, y1, y2, y3, y4, y5;
int lineHeight; int lineHeight;
int dateWidth; int dateWidth;
cString lastDate; cString lastDate;
void SetScrollbar(void); void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown);
void SetTextScrollbar(void);
public: public:
cSkinClassicDisplayMenu(void); cSkinClassicDisplayMenu(void);
virtual ~cSkinClassicDisplayMenu(); virtual ~cSkinClassicDisplayMenu();
@ -180,6 +181,7 @@ public:
virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL); virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL);
virtual void SetMessage(eMessageType Type, const char *Text); virtual void SetMessage(eMessageType Type, const char *Text);
virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable); virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable);
virtual void SetScrollbar(int Total, int Offset);
virtual void SetEvent(const cEvent *Event); virtual void SetEvent(const cEvent *Event);
virtual void SetRecording(const cRecording *Recording); virtual void SetRecording(const cRecording *Recording);
virtual void SetText(const char *Text, bool FixedFont); virtual void SetText(const char *Text, bool FixedFont);
@ -194,7 +196,9 @@ cSkinClassicDisplayMenu::cSkinClassicDisplayMenu(void)
lineHeight = font->Height(); lineHeight = font->Height();
dateWidth = 0; dateWidth = 0;
x0 = 0; x0 = 0;
x1 = cOsd::OsdWidth(); x1 = x0 + 10;
x3 = cOsd::OsdWidth();
x2 = x3 - 2 * ScrollWidth;
y0 = 0; y0 = 0;
y1 = lineHeight; y1 = lineHeight;
y2 = y1 + lineHeight; y2 = y1 + lineHeight;
@ -202,22 +206,22 @@ cSkinClassicDisplayMenu::cSkinClassicDisplayMenu(void)
y4 = y5 - lineHeight; y4 = y5 - lineHeight;
y3 = y4 - lineHeight; y3 = y4 - lineHeight;
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop()); osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop());
tArea Areas[] = { { x0, y0, x1 - 1, y5 - 1, 8 } }; tArea Areas[] = { { x0, y0, x3 - 1, y5 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk) if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
else { else {
tArea Areas[] = { { x0, y0, x1 - 1, y5 - 1, 4 } }; tArea Areas[] = { { x0, y0, x3 - 1, y5 - 1, 4 } };
if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk) if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
else { else {
tArea Areas[] = { { x0, y0, x1 - 1, y1 - 1, 2 }, tArea Areas[] = { { x0, y0, x3 - 1, y1 - 1, 2 },
{ x0, y1, x1 - 1, y3 - 1, 2 }, { x0, y1, x3 - 1, y3 - 1, 2 },
{ x0, y3, x1 - 1, y5 - 1, 4 } { x0, y3, x3 - 1, y5 - 1, 4 }
}; };
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
} }
} }
osd->DrawRectangle(x0, y0, x1 - 1, y5 - 1, Theme.Color(clrBackground)); osd->DrawRectangle(x0, y0, x3 - 1, y5 - 1, Theme.Color(clrBackground));
} }
cSkinClassicDisplayMenu::~cSkinClassicDisplayMenu() cSkinClassicDisplayMenu::~cSkinClassicDisplayMenu()
@ -225,25 +229,31 @@ cSkinClassicDisplayMenu::~cSkinClassicDisplayMenu()
delete osd; delete osd;
} }
void cSkinClassicDisplayMenu::SetScrollbar(void) void cSkinClassicDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
{ {
if (textScroller.CanScroll()) { if (Total > 0 && Total > Shown) {
int yt = textScroller.Top(); int yt = Top;
int yb = yt + textScroller.Height(); int yb = yt + Height;
int st = yt; int st = yt;
int sb = yb; int sb = yb;
int tt = st + (sb - st) * textScroller.Offset() / textScroller.Total(); int tt = st + (sb - st) * Offset / Total;
int tb = tt + (sb - st) * textScroller.Shown() / textScroller.Total(); int tb = tt + (sb - st) * Shown / Total;
int xl = x1 - ScrollWidth; int xl = x3 - ScrollWidth;
osd->DrawRectangle(xl, st, x1 - 1, sb, Theme.Color(clrMenuScrollbarTotal)); osd->DrawRectangle(xl, st, x3 - 1, sb, Theme.Color(clrMenuScrollbarTotal));
osd->DrawRectangle(xl, tt, x1 - 1, tb, Theme.Color(clrMenuScrollbarShown)); osd->DrawRectangle(xl, tt, x3 - 1, tb, Theme.Color(clrMenuScrollbarShown));
} }
} }
void cSkinClassicDisplayMenu::SetTextScrollbar(void)
{
if (textScroller.CanScroll())
DrawScrollbar(textScroller.Total(), textScroller.Offset(), textScroller.Shown(), textScroller.Top(), textScroller.Height(), textScroller.CanScrollUp(), textScroller.CanScrollDown());
}
void cSkinClassicDisplayMenu::Scroll(bool Up, bool Page) void cSkinClassicDisplayMenu::Scroll(bool Up, bool Page)
{ {
cSkinDisplayMenu::Scroll(Up, Page); cSkinDisplayMenu::Scroll(Up, Page);
SetScrollbar(); SetTextScrollbar();
} }
int cSkinClassicDisplayMenu::MaxItems(void) int cSkinClassicDisplayMenu::MaxItems(void)
@ -254,24 +264,24 @@ int cSkinClassicDisplayMenu::MaxItems(void)
void cSkinClassicDisplayMenu::Clear(void) void cSkinClassicDisplayMenu::Clear(void)
{ {
textScroller.Reset(); textScroller.Reset();
osd->DrawRectangle(x0, y1, x1 - 1, y4 - 1, Theme.Color(clrBackground)); osd->DrawRectangle(x0, y1, x3 - 1, y4 - 1, Theme.Color(clrBackground));
} }
void cSkinClassicDisplayMenu::SetTitle(const char *Title) void cSkinClassicDisplayMenu::SetTitle(const char *Title)
{ {
const cFont *font = cFont::GetFont(fontOsd); const cFont *font = cFont::GetFont(fontOsd);
osd->DrawText(x0, y0, Title, Theme.Color(clrMenuTitleFg), Theme.Color(clrMenuTitleBg), font, x1 - x0 - dateWidth); osd->DrawText(x0, y0, Title, Theme.Color(clrMenuTitleFg), Theme.Color(clrMenuTitleBg), font, x3 - x0 - dateWidth);
} }
void cSkinClassicDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) void cSkinClassicDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue)
{ {
const cFont *font = cFont::GetFont(fontOsd); const cFont *font = cFont::GetFont(fontOsd);
int w = x1 - x0; int w = x3 - x0;
int t0 = x0; int t0 = x0;
int t1 = x0 + w / 4; int t1 = x0 + w / 4;
int t2 = x0 + w / 2; int t2 = x0 + w / 2;
int t3 = x1 - w / 4; int t3 = x3 - w / 4;
int t4 = x1; int t4 = x3;
osd->DrawText(t0, y4, Red, Theme.Color(clrButtonRedFg), Red ? Theme.Color(clrButtonRedBg) : Theme.Color(clrBackground), font, t1 - t0, 0, taCenter); osd->DrawText(t0, y4, Red, Theme.Color(clrButtonRedFg), Red ? Theme.Color(clrButtonRedBg) : Theme.Color(clrBackground), font, t1 - t0, 0, taCenter);
osd->DrawText(t1, y4, Green, Theme.Color(clrButtonGreenFg), Green ? Theme.Color(clrButtonGreenBg) : Theme.Color(clrBackground), font, t2 - t1, 0, taCenter); osd->DrawText(t1, y4, Green, Theme.Color(clrButtonGreenFg), Green ? Theme.Color(clrButtonGreenBg) : Theme.Color(clrBackground), font, t2 - t1, 0, taCenter);
osd->DrawText(t2, y4, Yellow, Theme.Color(clrButtonYellowFg), Yellow ? Theme.Color(clrButtonYellowBg) : Theme.Color(clrBackground), font, t3 - t2, 0, taCenter); osd->DrawText(t2, y4, Yellow, Theme.Color(clrButtonYellowFg), Yellow ? Theme.Color(clrButtonYellowBg) : Theme.Color(clrBackground), font, t3 - t2, 0, taCenter);
@ -282,9 +292,9 @@ void cSkinClassicDisplayMenu::SetMessage(eMessageType Type, const char *Text)
{ {
const cFont *font = cFont::GetFont(fontOsd); const cFont *font = cFont::GetFont(fontOsd);
if (Text) if (Text)
osd->DrawText(x0, y3, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x1 - x0, 0, taCenter); osd->DrawText(x0, y3, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x3 - x0, 0, taCenter);
else else
osd->DrawRectangle(x0, y3, x1 - 1, y4 - 1, Theme.Color(clrBackground)); osd->DrawRectangle(x0, y3, x3 - 1, y4 - 1, Theme.Color(clrBackground));
} }
void cSkinClassicDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) void cSkinClassicDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable)
@ -304,44 +314,47 @@ void cSkinClassicDisplayMenu::SetItem(const char *Text, int Index, bool Current,
const char *s = GetTabbedText(Text, i); const char *s = GetTabbedText(Text, i);
if (s) { if (s) {
int xt = x0 + Tab(i); int xt = x0 + Tab(i);
osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x1 - xt); osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x2 - xt);
} }
if (!Tab(i + 1)) if (!Tab(i + 1))
break; break;
} }
SetEditableWidth(x1 - x0 - Tab(1)); SetEditableWidth(x2 - x0 - Tab(1));
} }
void cSkinClassicDisplayMenu::SetScrollbar(int Total, int Offset)
{
DrawScrollbar(Total, Offset, MaxItems(), y2, MaxItems() * lineHeight, Offset > 0, Offset + MaxItems() < Total);
}
void cSkinClassicDisplayMenu::SetEvent(const cEvent *Event) void cSkinClassicDisplayMenu::SetEvent(const cEvent *Event)
{ {
if (!Event) if (!Event)
return; return;
const cFont *font = cFont::GetFont(fontOsd); const cFont *font = cFont::GetFont(fontOsd);
int xl = x0 + 10;
int y = y2; int y = y2;
cTextScroller ts; cTextScroller ts;
char t[32]; char t[32];
snprintf(t, sizeof(t), "%s %s - %s", *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString()); snprintf(t, sizeof(t), "%s %s - %s", *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString());
ts.Set(osd, xl, y, x1 - xl, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground)); ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
if (Event->Vps() && Event->Vps() != Event->StartTime()) { if (Event->Vps() && Event->Vps() != Event->StartTime()) {
cString buffer = cString::sprintf(" VPS: %s ", *Event->GetVpsString()); cString buffer = cString::sprintf(" VPS: %s ", *Event->GetVpsString());
const cFont *font = cFont::GetFont(fontSml); const cFont *font = cFont::GetFont(fontSml);
int w = font->Width(buffer); int w = font->Width(buffer);
osd->DrawText(x1 - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w); osd->DrawText(x3 - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
} }
y += ts.Height(); y += ts.Height();
y += font->Height(); y += font->Height();
ts.Set(osd, xl, y, x1 - xl, y3 - y, Event->Title(), font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground)); ts.Set(osd, x1, y, x2 - x1, y3 - y, Event->Title(), font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
y += ts.Height(); y += ts.Height();
if (!isempty(Event->ShortText())) { if (!isempty(Event->ShortText())) {
const cFont *font = cFont::GetFont(fontSml); const cFont *font = cFont::GetFont(fontSml);
ts.Set(osd, xl, y, x1 - xl, y3 - y, Event->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground)); ts.Set(osd, x1, y, x2 - x1, y3 - y, Event->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
y += ts.Height(); y += ts.Height();
} }
y += font->Height(); y += font->Height();
if (!isempty(Event->Description())) { if (!isempty(Event->Description())) {
textScroller.Set(osd, xl, y, x1 - xl - 2 * ScrollWidth, y3 - y, Event->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground)); textScroller.Set(osd, x1, y, x2 - x1, y3 - y, Event->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
SetScrollbar(); SetTextScrollbar();
} }
} }
@ -351,40 +364,39 @@ void cSkinClassicDisplayMenu::SetRecording(const cRecording *Recording)
return; return;
const cRecordingInfo *Info = Recording->Info(); const cRecordingInfo *Info = Recording->Info();
const cFont *font = cFont::GetFont(fontOsd); const cFont *font = cFont::GetFont(fontOsd);
int xl = x0 + 10;
int y = y2; int y = y2;
cTextScroller ts; cTextScroller ts;
char t[32]; char t[32];
snprintf(t, sizeof(t), "%s %s", *DateString(Recording->start), *TimeString(Recording->start)); snprintf(t, sizeof(t), "%s %s", *DateString(Recording->start), *TimeString(Recording->start));
ts.Set(osd, xl, y, x1 - xl, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground)); ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
y += ts.Height(); y += ts.Height();
y += font->Height(); y += font->Height();
const char *Title = Info->Title(); const char *Title = Info->Title();
if (isempty(Title)) if (isempty(Title))
Title = Recording->Name(); Title = Recording->Name();
ts.Set(osd, xl, y, x1 - xl, y3 - y, Title, font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground)); ts.Set(osd, x1, y, x2 - x1, y3 - y, Title, font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
y += ts.Height(); y += ts.Height();
if (!isempty(Info->ShortText())) { if (!isempty(Info->ShortText())) {
const cFont *font = cFont::GetFont(fontSml); const cFont *font = cFont::GetFont(fontSml);
ts.Set(osd, xl, y, x1 - xl, y3 - y, Info->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground)); ts.Set(osd, x1, y, x2 - x1, y3 - y, Info->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
y += ts.Height(); y += ts.Height();
} }
y += font->Height(); y += font->Height();
if (!isempty(Info->Description())) { if (!isempty(Info->Description())) {
textScroller.Set(osd, xl, y, x1 - xl - 2 * ScrollWidth, y3 - y, Info->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground)); textScroller.Set(osd, x1, y, x2 - x1, y3 - y, Info->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
SetScrollbar(); SetTextScrollbar();
} }
} }
void cSkinClassicDisplayMenu::SetText(const char *Text, bool FixedFont) void cSkinClassicDisplayMenu::SetText(const char *Text, bool FixedFont)
{ {
textScroller.Set(osd, x0, y2, GetTextAreaWidth(), y3 - y2, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground)); textScroller.Set(osd, x1, y2, GetTextAreaWidth(), y3 - y2, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground));
SetScrollbar(); SetTextScrollbar();
} }
int cSkinClassicDisplayMenu::GetTextAreaWidth(void) const int cSkinClassicDisplayMenu::GetTextAreaWidth(void) const
{ {
return x1 - x0 - 2 * ScrollWidth; return x2 - x1;
} }
const cFont *cSkinClassicDisplayMenu::GetTextAreaFont(bool FixedFont) const const cFont *cSkinClassicDisplayMenu::GetTextAreaFont(bool FixedFont) const
@ -398,7 +410,7 @@ void cSkinClassicDisplayMenu::Flush(void)
if (!lastDate || strcmp(date, lastDate)) { if (!lastDate || strcmp(date, lastDate)) {
const cFont *font = cFont::GetFont(fontOsd); const cFont *font = cFont::GetFont(fontOsd);
int w = font->Width(date); int w = font->Width(date);
osd->DrawText(x1 - w - 2, y0, date, Theme.Color(clrMenuDate), Theme.Color(clrMenuTitleBg), font, w); osd->DrawText(x3 - w - 2, y0, date, Theme.Color(clrMenuDate), Theme.Color(clrMenuTitleBg), font, w);
lastDate = date; lastDate = date;
dateWidth = max(w + 2, dateWidth); dateWidth = max(w + 2, dateWidth);
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: skins.c 1.13 2007/01/04 13:08:55 kls Exp $ * $Id: skins.c 1.14 2008/02/17 11:31:09 kls Exp $
*/ */
#include "skins.h" #include "skins.h"
@ -108,6 +108,10 @@ const char *cSkinDisplayMenu::GetTabbedText(const char *s, int Tab)
return buffer; return buffer;
} }
void cSkinDisplayMenu::SetScrollbar(int Total, int Offset)
{
}
int cSkinDisplayMenu::GetTextAreaWidth(void) const int cSkinDisplayMenu::GetTextAreaWidth(void) const
{ {
return 0; return 0;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: skins.h 1.15 2007/01/04 13:08:55 kls Exp $ * $Id: skins.h 1.16 2008/02/17 11:30:56 kls Exp $
*/ */
#ifndef __SKINS_H #ifndef __SKINS_H
@ -144,6 +144,11 @@ public:
virtual void SetItem(const cRecording *Recording, int Index, bool Current, bool Selectable); virtual void SetItem(const cRecording *Recording, int Index, bool Current, bool Selectable);
--> false: call SetItem(text) --> false: call SetItem(text)
*/ */
virtual void SetScrollbar(int Total, int Offset);
///< Sets the Total number of items in the currently displayed list, and the
///< Offset of the first item that is currently displayed (the skin knows how
///< many items it can display at once, see MaxItems()). This can be used to
///< display a scollbar.
virtual void SetEvent(const cEvent *Event) = 0; virtual void SetEvent(const cEvent *Event) = 0;
///< Sets the Event that shall be displayed, using the entire central area ///< Sets the Event that shall be displayed, using the entire central area
///< of the menu. The Event's 'description' shall be displayed using a ///< of the menu. The Event's 'description' shall be displayed using a

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: skinsttng.c 1.23 2008/02/10 16:18:55 kls Exp $ * $Id: skinsttng.c 1.24 2008/02/17 12:09:38 kls Exp $
*/ */
// Star Trek: The Next Generation® is a registered trademark of Paramount Pictures // Star Trek: The Next Generation® is a registered trademark of Paramount Pictures
@ -348,7 +348,8 @@ private:
int currentIndex; int currentIndex;
bool message; bool message;
cString lastDate; cString lastDate;
void SetScrollbar(void); void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown);
void SetTextScrollbar(void);
public: public:
cSkinSTTNGDisplayMenu(void); cSkinSTTNGDisplayMenu(void);
virtual ~cSkinSTTNGDisplayMenu(); virtual ~cSkinSTTNGDisplayMenu();
@ -359,6 +360,7 @@ public:
virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL); virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL);
virtual void SetMessage(eMessageType Type, const char *Text); virtual void SetMessage(eMessageType Type, const char *Text);
virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable); virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable);
virtual void SetScrollbar(int Total, int Offset);
virtual void SetEvent(const cEvent *Event); virtual void SetEvent(const cEvent *Event);
virtual void SetRecording(const cRecording *Recording); virtual void SetRecording(const cRecording *Recording);
virtual void SetText(const char *Text, bool FixedFont); virtual void SetText(const char *Text, bool FixedFont);
@ -435,37 +437,43 @@ cSkinSTTNGDisplayMenu::~cSkinSTTNGDisplayMenu()
delete osd; delete osd;
} }
void cSkinSTTNGDisplayMenu::SetScrollbar(void) void cSkinSTTNGDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
{ {
if (textScroller.CanScroll()) { if (Total > 0 && Total > Shown) {
int h = lineHeight; int h = lineHeight;
int yt = textScroller.Top(); int yt = Top;
int yb = yt + textScroller.Height(); int yb = yt + Height;
int st = yt + h + Gap; int st = yt + h + Gap;
int sb = yb - h - Gap; int sb = yb - h - Gap;
int tt = st + (sb - st) * textScroller.Offset() / textScroller.Total(); int tt = st + (sb - st) * Offset / Total;
int tb = tt + (sb - st) * textScroller.Shown() / textScroller.Total(); int tb = tt + (sb - st) * Shown / Total;
osd->DrawRectangle(x5, st, x5 + ScrollWidth - 1, sb, Theme.Color(clrMenuScrollbarTotal)); osd->DrawRectangle(x5, st, x5 + ScrollWidth - 1, sb, Theme.Color(clrMenuScrollbarTotal));
osd->DrawRectangle(x5, tt, x5 + ScrollWidth - 1, tb, Theme.Color(clrMenuScrollbarShown)); osd->DrawRectangle(x5, tt, x5 + ScrollWidth - 1, tb, Theme.Color(clrMenuScrollbarShown));
osd->DrawRectangle(x5, yt, x6 - 1, yt + h - 1, frameColor); osd->DrawRectangle(x5, yt, x6 - 1, yt + h - 1, frameColor);
osd->DrawEllipse (x6, yt, x7 - 1, yt + h - 1, frameColor, 5); osd->DrawEllipse (x6, yt, x7 - 1, yt + h - 1, frameColor, 5);
osd->DrawRectangle(x5, yb - h, x6 - 1, yb - 1, frameColor); osd->DrawRectangle(x5, yb - h, x6 - 1, yb - 1, frameColor);
osd->DrawEllipse (x6, yb - h, x7 - 1, yb - 1, frameColor, 5); osd->DrawEllipse (x6, yb - h, x7 - 1, yb - 1, frameColor, 5);
if (textScroller.CanScrollUp()) { if (CanScrollUp) {
cBitmap bm(arrowup_xpm); cBitmap bm(arrowup_xpm);
osd->DrawBitmap(x5 + (x7 - x5 - bm.Width()) / 2 - 2, yt + (h - bm.Height()) / 2, bm, Theme.Color(clrMenuScrollbarArrow), frameColor); osd->DrawBitmap(x5 + (x7 - x5 - bm.Width()) / 2 - 2, yt + (h - bm.Height()) / 2, bm, Theme.Color(clrMenuScrollbarArrow), frameColor);
} }
if (textScroller.CanScrollDown()) { if (CanScrollDown) {
cBitmap bm(arrowdown_xpm); cBitmap bm(arrowdown_xpm);
osd->DrawBitmap(x5 + (x7 - x5 - bm.Width()) / 2 - 2, yb - h + (h - bm.Height()) / 2, bm, Theme.Color(clrMenuScrollbarArrow), frameColor); osd->DrawBitmap(x5 + (x7 - x5 - bm.Width()) / 2 - 2, yb - h + (h - bm.Height()) / 2, bm, Theme.Color(clrMenuScrollbarArrow), frameColor);
} }
} }
}
void cSkinSTTNGDisplayMenu::SetTextScrollbar(void)
{
if (textScroller.CanScroll())
DrawScrollbar(textScroller.Total(), textScroller.Offset(), textScroller.Shown(), textScroller.Top(), textScroller.Height(), textScroller.CanScrollUp(), textScroller.CanScrollDown());
} }
void cSkinSTTNGDisplayMenu::Scroll(bool Up, bool Page) void cSkinSTTNGDisplayMenu::Scroll(bool Up, bool Page)
{ {
cSkinDisplayMenu::Scroll(Up, Page); cSkinDisplayMenu::Scroll(Up, Page);
SetScrollbar(); SetTextScrollbar();
} }
int cSkinSTTNGDisplayMenu::MaxItems(void) int cSkinSTTNGDisplayMenu::MaxItems(void)
@ -558,6 +566,11 @@ void cSkinSTTNGDisplayMenu::SetItem(const char *Text, int Index, bool Current, b
SetEditableWidth(x4 - x3 - 5 - Tab(1)); SetEditableWidth(x4 - x3 - 5 - Tab(1));
} }
void cSkinSTTNGDisplayMenu::SetScrollbar(int Total, int Offset)
{
DrawScrollbar(Total, Offset, MaxItems(), y3 + Roundness, MaxItems() * lineHeight, Offset > 0, Offset + MaxItems() < Total);
}
void cSkinSTTNGDisplayMenu::SetEvent(const cEvent *Event) void cSkinSTTNGDisplayMenu::SetEvent(const cEvent *Event)
{ {
if (!Event) if (!Event)
@ -596,7 +609,7 @@ void cSkinSTTNGDisplayMenu::SetEvent(const cEvent *Event)
osd->DrawEllipse (x1, yt - Roundness, x2, yt, frameColor, -3); osd->DrawEllipse (x1, yt - Roundness, x2, yt, frameColor, -3);
osd->DrawRectangle(x1, yt, x2, yb, frameColor); osd->DrawRectangle(x1, yt, x2, yb, frameColor);
osd->DrawEllipse (x1, yb, x2, yb + Roundness, frameColor, -2); osd->DrawEllipse (x1, yb, x2, yb + Roundness, frameColor, -2);
SetScrollbar(); SetTextScrollbar();
} }
} }
@ -633,14 +646,14 @@ void cSkinSTTNGDisplayMenu::SetRecording(const cRecording *Recording)
osd->DrawEllipse (x1, yt - Roundness, x2, yt, frameColor, -3); osd->DrawEllipse (x1, yt - Roundness, x2, yt, frameColor, -3);
osd->DrawRectangle(x1, yt, x2, yb, frameColor); osd->DrawRectangle(x1, yt, x2, yb, frameColor);
osd->DrawEllipse (x1, yb, x2, yb + Roundness, frameColor, -2); osd->DrawEllipse (x1, yb, x2, yb + Roundness, frameColor, -2);
SetScrollbar(); SetTextScrollbar();
} }
} }
void cSkinSTTNGDisplayMenu::SetText(const char *Text, bool FixedFont) void cSkinSTTNGDisplayMenu::SetText(const char *Text, bool FixedFont)
{ {
textScroller.Set(osd, x3, y3, GetTextAreaWidth(), y4 - y3, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground)); textScroller.Set(osd, x3, y3, GetTextAreaWidth(), y4 - y3, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground));
SetScrollbar(); SetTextScrollbar();
} }
int cSkinSTTNGDisplayMenu::GetTextAreaWidth(void) const int cSkinSTTNGDisplayMenu::GetTextAreaWidth(void) const