summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-12-22 15:58:13 +0100
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2022-01-14 12:57:27 +0100
commit1d757b0b808c3b5a1caa1fe6d20164c181f6a1aa (patch)
tree6f2db6835f491bb6268f6c3df60f7c3408177408
parent845d74476cce4ef9e640568e9adc352c0ae272f3 (diff)
downloadskin-lcarsng-1d757b0b808c3b5a1caa1fe6d20164c181f6a1aa.tar.gz
skin-lcarsng-1d757b0b808c3b5a1caa1fe6d20164c181f6a1aa.tar.bz2
Replace "[|| ]" with graphics if a item has tabbed text
-rw-r--r--displaymenu.c37
-rw-r--r--displaymenu.h1
2 files changed, 36 insertions, 2 deletions
diff --git a/displaymenu.c b/displaymenu.c
index eb2f1bd..77c8cae 100644
--- a/displaymenu.c
+++ b/displaymenu.c
@@ -1426,8 +1426,15 @@ void cLCARSNGDisplayMenu::SetItem(const char *Text, int Index, bool Current, boo
for (int i = 0; i < MaxTabs; i++) {
const char *s = GetTabbedText(Text, i);
if (s) {
- int xt = xi00 + TextSpacing + Tab(i);
- osd->DrawText(xt, y, s, ColorFg, ColorBg, font, xi01 - xt);
+ int xt = xi00 + 2 * TextSpacing + Tab(i);
+ int tabWidth = 0;
+ if (Tab(i + 1))
+ tabWidth = Tab(i + 1) - Tab(i);
+ else
+ tabWidth = xi01 - xt;
+ if (!DrawProgressBar(xt, y, tabWidth - TextSpacing, s, ColorFg, ColorBg)) {
+ osd->DrawText(xt, y, s, ColorFg, ColorBg, font, xi01 - xt);
+ }
}
if (!Tab(i + 1))
break;
@@ -1435,6 +1442,32 @@ void cLCARSNGDisplayMenu::SetItem(const char *Text, int Index, bool Current, boo
SetEditableWidth(xi02 - xi00 - TextSpacing - Tab(1));
}
+bool cLCARSNGDisplayMenu::DrawProgressBar(int x, int y, int width, const char *text, tColor ColorFg, tColor ColorBg) {
+ if (strlen(text) <= 5 || text[0] != '[' || text[strlen(text) - 1] != ']')
+ return false;
+ const char *p = text + 1;
+ int total = 0;
+ int now = 0;
+ for (; *p != ']'; ++p) {
+ if (*p == ' ' || *p == '|') {
+ ++total;
+ if (*p == '|')
+ ++now;
+ }
+ else {
+ return false;
+ }
+ }
+ int y0 = y + lineHeight / 4;
+ int y1 = y0 + lineHeight / 2;
+ osd->DrawRectangle(x, y, x + width, y + lineHeight - 1, ColorBg);
+ osd->DrawRectangle(x, y0, x + width, y1, ColorFg);
+ osd->DrawRectangle(x + 2, y0 + 2, x + width - 2, y1 - 2, ColorBg);
+ double progress = (double)now / (double)total;
+ osd->DrawRectangle(x + 3, y0 + 3, x + (width - 3) * progress, y1 - 3, ColorFg);
+ return true;
+}
+
void cLCARSNGDisplayMenu::SetScrollbar(int Total, int Offset)
{
DrawScrollbar(Total, Offset, MaxItems(), Offset > 0, Offset + MaxItems() < Total);
diff --git a/displaymenu.h b/displaymenu.h
index 5c1bc45..83b093c 100644
--- a/displaymenu.h
+++ b/displaymenu.h
@@ -141,6 +141,7 @@ private:
void DrawInfo(const cEvent *Event, bool WithTime);
void DrawSeen(int Current, int Total);
void DrawTextScrollbar(void);
+ bool DrawProgressBar(int x, int y, int width, const char *text, tColor ColorFg, tColor ColorBg);
public:
#ifdef DEPRECATED_SKIN_SETITEMEVENT
using cSkinDisplayMenu::SetItemEvent;