summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schirrmacher <vdr.skinflat@schirrmacher.eu>2013-09-01 18:37:51 +0200
committerMartin Schirrmacher <vdr.skinflat@schirrmacher.eu>2013-09-01 18:37:51 +0200
commitef02cd5f6349846b2d37e14794518a6217b83ffc (patch)
tree034421513c52a9ae03bb0defa888fae7c9813bee
parent672ec8b7e10375d178c4803c958c49e816fd673e (diff)
downloadskin-flat-ef02cd5f6349846b2d37e14794518a6217b83ffc.tar.gz
skin-flat-ef02cd5f6349846b2d37e14794518a6217b83ffc.tar.bz2
support for progressbar for menuitem textbars
-rw-r--r--displaymenu.c134
-rw-r--r--displaymenu.h2
-rw-r--r--flat.h13
3 files changed, 49 insertions, 100 deletions
diff --git a/displaymenu.c b/displaymenu.c
index e8493a2..dd8f232 100644
--- a/displaymenu.c
+++ b/displaymenu.c
@@ -138,112 +138,60 @@ void cFlatDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool S
const char *s = GetTabbedText(Text, i);
if (s) {
int xt = Tab(i);
- menuPixmap->DrawText(cPoint(xt, y), s, ColorFg, ColorBg, font, menuWidth - xt);
+ if( CheckProgressBar( s ) ) {
+ int colWidth = Tab(i+1) - Tab(i);
+
+ tColor ColorFg = Theme.Color(clrMenuItemProgressFg);
+ tColor ColorBarFg = Theme.Color(clrMenuItemProgressBarFg);
+ tColor ColorBg = Theme.Color(clrMenuItemProgressBg);
+ if( Current ) {
+ ColorFg = Theme.Color(clrMenuItemCurProgressFg);
+ ColorBarFg = Theme.Color(clrMenuItemCurProgressBarFg);
+ ColorBg = Theme.Color(clrMenuItemCurProgressBg);
+ }
+ menuPixmap->DrawRectangle(cRect(xt - 10, y, 10, itemHeight-2), ColorBg);
+ DrawProgressBarFromText(y + (itemHeight-2)/2 - (itemHeight-2)/2, xt, colWidth, s, ColorFg, ColorBarFg, ColorBg);
+ } else {
+ menuPixmap->DrawText(cPoint(xt, y), s, ColorFg, ColorBg, font, menuWidth - xt);
+ }
}
if (!Tab(i + 1))
break;
}
-
SetEditableWidth(menuWidth - Tab(1));
}
-/*
-bool cFlatDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider) {
- cSchedulesLock schedulesLock;
- const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
+bool cFlatDisplayMenu::CheckProgressBar(const char *text) {
+ if (strlen(text) > 5
+ && text[0] == '['
+ && ((text[1] == '|')||(text[1] == ' '))
+ && ((text[2] == '|')||(text[2] == ' '))
+ && text[strlen(text) - 1] == ']')
+ return true;
+ return false;
+}
- 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);
+void cFlatDisplayMenu::DrawProgressBarFromText(int Top, int Left, int Width, const char *bar, tColor ColorFg, tColor ColorBarFg, tColor ColorBg) {
+ const char *p = bar + 1;
+ bool isProgressbar = true;
+ int total = 0;
+ int now = 0;
+ for (; *p != ']'; ++p) {
+ if (*p == ' ' || *p == '|') {
+ ++total;
+ if (*p == '|')
+ ++now;
} 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);
- }
-
- menuPixmap->DrawRectangle(cRect( (menuWidth/10*3) + marginItem, y, marginItem, fontHeight), ColorBg);
-
- if( Current )
- ProgressBarDrawInline(menuPixmap, (menuWidth/10*3) + marginItem*2, y, menuWidth/10 - marginItem, fontHeight,
- progress, 100, Theme.Color(clrMenuItemChanCurProgressFg), Theme.Color(clrMenuItemChanCurProgressBarFg),
- Theme.Color(clrMenuItemChanCurProgressBg));
- else
- ProgressBarDrawInline(menuPixmap, (menuWidth/10*3) + marginItem*2, y, menuWidth/10 - marginItem, fontHeight,
- progress, 100, Theme.Color(clrMenuItemChanProgressFg), Theme.Color(clrMenuItemChanProgressBarFg),
- Theme.Color(clrMenuItemChanProgressBg));
- 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);
+ isProgressbar = false;
+ break;
}
}
- else {
- buffer = cString::sprintf("---%s ----------------------------------------------------------------", Channel->Name());
- menuPixmap->DrawText(cPoint(marginItem, y), buffer, ColorFg, ColorBg, font);
+ if (isProgressbar) {
+ double progress = (double)now/(double)total;
+ ProgressBarDrawInline(menuPixmap, Left, Top, Width, itemHeight-2, progress*total, total,
+ ColorFg, ColorBarFg, ColorBg);
}
-
- return true;
}
-*/
void cFlatDisplayMenu::SetEvent(const cEvent *Event) {
if( !Event )
diff --git a/displaymenu.h b/displaymenu.h
index 96e993f..e3be9fc 100644
--- a/displaymenu.h
+++ b/displaymenu.h
@@ -20,6 +20,8 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu {
void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown);
int ItemsHeight(void);
+ bool CheckProgressBar(const char *text);
+ void DrawProgressBarFromText(int Top, int Left, int Width, const char *bar, tColor ColorFg, tColor ColorBarFg, tColor ColorBg);
public:
cFlatDisplayMenu(void);
virtual ~cFlatDisplayMenu();
diff --git a/flat.h b/flat.h
index 1a14adf..506557c 100644
--- a/flat.h
+++ b/flat.h
@@ -76,13 +76,12 @@ THEME_CLR(Theme, clrMenuTextBg, 0xB0101010);
THEME_CLR(Theme, clrMenuTextFont, 0xFFEEEEEE);
// Menu Items
-THEME_CLR(Theme, clrMenuItemChanProgressFg, 0xFF3090B0);
-THEME_CLR(Theme, clrMenuItemChanProgressBarFg, 0xFF3090B0);
-THEME_CLR(Theme, clrMenuItemChanProgressBg, 0xB0101010);
-
-THEME_CLR(Theme, clrMenuItemChanCurProgressFg, 0xFFEEEEEE);
-THEME_CLR(Theme, clrMenuItemChanCurProgressBarFg, 0xFFEEEEEE);
-THEME_CLR(Theme, clrMenuItemChanCurProgressBg, 0xB03090B0);
+THEME_CLR(Theme, clrMenuItemProgressFg, 0xFFEEEEEE);
+THEME_CLR(Theme, clrMenuItemProgressBarFg, 0xFFEEEEEE);
+THEME_CLR(Theme, clrMenuItemProgressBg, 0xB0101010);
+THEME_CLR(Theme, clrMenuItemCurProgressFg, 0xFFEEEEEE);
+THEME_CLR(Theme, clrMenuItemCurProgressBarFg, 0xFFEEEEEE);
+THEME_CLR(Theme, clrMenuItemCurProgressBg, 0xB03090B0);
// Replay
THEME_CLR(Theme, clrReplayBg, 0xB0101010);