summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schirrmacher <vdr.skinflat@schirrmacher.eu>2013-08-20 21:23:53 +0200
committerMartin Schirrmacher <vdr.skinflat@schirrmacher.eu>2013-08-20 21:23:53 +0200
commit42659e5b1b4ba8e8fa8344310b1cb2b48cfed7df (patch)
treed1430f7232e9a0428b38a2941923bee90a626687
parent85e4985984c836c5800b7d548ec3ed84d523eb38 (diff)
downloadskin-flat-42659e5b1b4ba8e8fa8344310b1cb2b48cfed7df.tar.gz
skin-flat-42659e5b1b4ba8e8fa8344310b1cb2b48cfed7df.tar.bz2
first try menu itemchannel
-rw-r--r--displaymenu.c115
-rw-r--r--displaymenu.h6
2 files changed, 115 insertions, 6 deletions
diff --git a/displaymenu.c b/displaymenu.c
index 5ec1116..ce3f578 100644
--- a/displaymenu.c
+++ b/displaymenu.c
@@ -7,14 +7,15 @@ cFlatDisplayMenu::cFlatDisplayMenu(void) {
MessageCreate();
itemHeight = fontHeight + 2;
-
+ itemChannelHeight = fontHeight + 2;
+
scrollBarWidth = 20;
scrollBarHeight = osdHeight - (topBarHeight + buttonsHeight + marginItem*3 );
scrollBarTop = topBarHeight + marginItem;
menuWidth = osdWidth - scrollBarWidth;
-
- menuPixmap = osd->CreatePixmap(1, cRect(0, topBarHeight + marginItem, menuWidth, scrollBarHeight ));
+ menuTop = topBarHeight + marginItem;
+ menuPixmap = osd->CreatePixmap(1, cRect(0, menuTop, menuWidth, scrollBarHeight ));
contentTop = topBarHeight + marginItem + fontHeight + (fontSmlHeight*2) + marginItem*3;
ContentCreate(0, contentTop, menuWidth, scrollBarHeight - fontHeight - fontSmlHeight*2 - marginItem);
@@ -68,12 +69,19 @@ void cFlatDisplayMenu::Scroll(bool Up, bool Page) {
}
int cFlatDisplayMenu::MaxItems(void) {
+ if( menuCategory == mcChannel )
+ return scrollBarHeight / itemChannelHeight;
+
return scrollBarHeight / itemHeight;
}
int cFlatDisplayMenu::ItemsHeight(void) {
+ if( menuCategory == mcChannel )
+ return MaxItems() * itemChannelHeight;
+
return MaxItems() * itemHeight;
}
+
void cFlatDisplayMenu::Clear(void) {
textScroller.Reset();
menuPixmap->Fill(clrTransparent);
@@ -135,6 +143,107 @@ void cFlatDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool S
}
}
+bool cFlatDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider) {
+ cSchedulesLock schedulesLock;
+ const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
+
+ cString buffer;
+ int y = Index * itemChannelHeight;
+
+ tColor ColorFg, ColorBg;
+ if (Current) {
+ ColorFg = Theme.Color(clrItemCurrentFont);
+ ColorBg = Theme.Color(clrItemCurrentBg);
+ }
+ else {
+ if( Selectable ) {
+ ColorFg = Theme.Color(clrItemSelableFont);
+ ColorBg = Theme.Color(clrItemSelableBg);
+ } else {
+ ColorFg = Theme.Color(clrItemFont);
+ ColorBg = Theme.Color(clrItemBg);
+ }
+ }
+ menuPixmap->DrawRectangle(cRect(0, y, menuWidth, itemChannelHeight - 2), ColorBg);
+
+ // event from channel
+ const cSchedule *Schedule = schedules->GetSchedule( Channel->GetChannelID() );
+ if( Schedule ) {
+ const cEvent *Event = Schedule->GetPresentEvent();
+ if( Event ) {
+ // calculate progress bar
+ float progress = (int)roundf( (float)(time(NULL) - Event->StartTime()) / (float) (Event->Duration()) * 100.0);
+ if(progress < 0)
+ progress = 0.;
+ else if(progress > 100)
+ progress = 100;
+
+ if( WithProvider )
+ buffer = cString::sprintf("%d\t%s - %s", Channel->Number(), Channel->Provider(), Channel->Name());
+ else
+ buffer = cString::sprintf("%d\t%s", Channel->Number(), Channel->Name());
+
+ const char *s1 = GetTabbedText(buffer, 0);
+ if( s1 ) {
+ int xt = Tab(0);
+ menuPixmap->DrawText(cPoint(marginItem + xt, y), s1, ColorFg, ColorBg, font);
+ }
+ const char *s2 = GetTabbedText(buffer, 1);
+ if( s2 ) {
+ int xt = Tab(1);
+ int w = (menuWidth / 10 * 3) - marginItem;
+ menuPixmap->DrawText(cPoint(marginItem + xt, y), s2, ColorFg, ColorBg, font, w);
+ }
+/*
+ int progressTop = menuTop + y + (fontHeight / 2) - ProgressBarHeight() / 2;
+ ProgressBarCreate((menuWidth / 10 * 3) + marginItem, progressTop, menuWidth / 10,
+ Theme.Color(clrChannelProgressFg), Theme.Color(clrChannelProgressBarFg), clrTransparent);
+ ProgressBarDraw(progress, 100);
+*/
+ menuPixmap->DrawText(cPoint((menuWidth / 10 * 4) + marginItem*2, y), Event->Title(), ColorFg, ColorBg, font);
+
+ return true;
+ }
+ }
+
+ // without schedule, do it like vdr
+ if (!Channel->GroupSep()) {
+ if( WithProvider )
+ buffer = cString::sprintf("%d\t%s - %s", Channel->Number(), Channel->Provider(), Channel->Name());
+ else
+ buffer = cString::sprintf("%d\t%s", Channel->Number(), Channel->Name());
+
+ const char *s1 = GetTabbedText(buffer, 0);
+ if( s1 ) {
+ int xt = Tab(0);
+ menuPixmap->DrawText(cPoint(marginItem + xt, y), s1, ColorFg, ColorBg, font);
+ }
+ const char *s2 = GetTabbedText(buffer, 1);
+ if( s2 ) {
+ int xt = Tab(1);
+ int w = (menuWidth / 10 * 3) - marginItem;
+
+ menuPixmap->DrawText(cPoint(marginItem + xt, y), s2, ColorFg, ColorBg, font, w);
+ }
+ }
+ else {
+ buffer = cString::sprintf("---%s ----------------------------------------------------------------", Channel->Name());
+ menuPixmap->DrawText(cPoint(marginItem, y), buffer, ColorFg, ColorBg, font);
+ }
+
+ for (int i = 0; i < MaxTabs; i++)
+ {
+ const char *s = GetTabbedText(buffer, i);
+ if (s) {
+ int xt = Tab(i);
+ }
+ if (!Tab(i + 1))
+ break;
+ }
+
+ return true;
+}
+
void cFlatDisplayMenu::SetEvent(const cEvent *Event) {
if( !Event )
return;
diff --git a/displaymenu.h b/displaymenu.h
index 77ab33b..7298245 100644
--- a/displaymenu.h
+++ b/displaymenu.h
@@ -6,7 +6,7 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu {
private:
cPixmap *menuPixmap;
- int menuWidth;
+ int menuTop, menuWidth;
eMenuCategory menuCategory;
int VideoDiskUsageState = -1;
@@ -16,7 +16,7 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu {
cPixmap *scrollbarPixmap;
int scrollBarTop, scrollBarWidth, scrollBarHeight;
- int itemHeight;
+ int itemHeight, itemChannelHeight;
void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown);
int ItemsHeight(void);
@@ -37,7 +37,7 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu {
//virtual bool SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch);
//virtual bool SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable);
- //virtual bool SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider);
+ virtual bool SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider);
//virtual bool SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New);
virtual void SetScrollbar(int Total, int Offset);