File: vdr-1.5.17-progressbar-support-0.0.1.diff

package info (click to toggle)
vdr-plugin-epgsearch 1.0.1~beta3-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,764 kB
  • ctags: 2,316
  • sloc: ansic: 23,300; perl: 1,330; sh: 608; makefile: 193
file content (106 lines) | stat: -rw-r--r-- 4,389 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
diff -Nru vdr-1.5.17-orig/skinclassic.c vdr-1.5.17-progressbar/skinclassic.c
--- vdr-1.5.17-orig/skinclassic.c
+++ vdr-1.5.17-progressbar/skinclassic.c
@@ -314,8 +314,47 @@
   for (int i = 0; i < MaxTabs; i++) {
       const char *s = GetTabbedText(Text, i);
       if (s) {
-         int xt = x0 + Tab(i);
-         osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x2 - xt);
+         bool isprogressbar = false;
+         int now = 0, total = 0;
+         // check if progress bar: "[|||||||   ]"
+         if ((strlen(s) > 5 && s[0] == '[' && s[strlen(s) - 1] == ']')) {
+            const char *p = s + 1;
+            // update status
+            isprogressbar = true;
+            for (; *p != ']'; ++p) {
+                // check if progressbar characters
+                if (*p == ' ' || *p == '|') {
+                   // update counters
+                   ++total;
+                   if (*p == '|')
+                      ++now;
+                   }
+                else {
+                   // wrong character detected; not a progressbar
+                   isprogressbar = false;
+                   break;
+                   }
+                }
+            }
+         int xt = x0 + Tab(i);
+         if (isprogressbar) {
+            // define x coordinates of progressbar
+            int px0 = xt;
+            int px1 = (Tab(i + 1)?Tab(i+1):x1) - 5;
+            int px = px0 + max((int)((float) now * (float) (px1 - px0) / (float) total), 1);
+            // define y coordinates of progressbar
+            int py0 = y + 4;
+            int py1 = y + lineHeight - 4;
+            // draw background
+            osd->DrawRectangle(px0, y, (Tab(i + 1)?Tab(i+1):x1) - 1, y + lineHeight - 1, ColorBg);
+            // draw progressbar
+            osd->DrawRectangle(px0,    py0, px,  py1, ColorFg);
+            osd->DrawRectangle(px + 1, py0, px1, py0 + 1, ColorFg);
+            osd->DrawRectangle(px + 1, py1 - 1, px1, py1, ColorFg);
+            osd->DrawRectangle(px1 - 1, py0, px1, py1, ColorFg);
+            }
+         else
+            osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x2 - xt);
          }
       if (!Tab(i + 1))
          break;
diff -Nru vdr-1.5.17-orig/skinsttng.c vdr-1.5.17-progressbar/skinsttng.c
--- vdr-1.5.17-orig/skinsttng.c
+++ vdr-1.5.17-progressbar/skinsttng.c
@@ -558,8 +558,47 @@
   for (int i = 0; i < MaxTabs; i++) {
       const char *s = GetTabbedText(Text, i);
       if (s) {
-         int xt = x3 + 5 + Tab(i);
-         osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x4 - xt);
+         bool isprogressbar = false;
+         int now = 0, total = 0;
+         // check if progress bar: "[|||||||   ]"
+         if ((strlen(s) > 5 && s[0] == '[' && s[strlen(s) - 1] == ']')) {
+            const char *p = s + 1;
+            // update status
+            isprogressbar = true;
+            for (; *p != ']'; ++p) {
+                // check if progressbar characters
+                if (*p == ' ' || *p == '|') {
+                   // update counters
+                   ++total;
+                   if (*p == '|')
+                      ++now;
+                   }
+                else {
+                   // wrong character detected; not a progressbar
+                   isprogressbar = false;
+                   break;
+                   }
+                }
+            }
+         int xt = x3 + 5 + Tab(i);
+         if (isprogressbar) {
+            // define x coordinates of progressbar
+            int px0 = xt;
+            int px1 = x3 + (Tab(i + 1)?Tab(i + 1):x4-x3-5) - 1;
+            int px = px0 + max((int)((float) now * (float) (px1 - px0) / (float) total), 1);
+            // define y coordinates of progressbar
+            int py0 = y + 4;
+            int py1 = y + lineHeight - 4;
+            // draw background
+            osd->DrawRectangle(px0, y, (Tab(i + 1)?Tab(i + 1):x4-x3-5) - 1, y + lineHeight - 1, ColorBg);
+            // draw progressbar
+            osd->DrawRectangle(px0,    py0, px,  py1, ColorFg);
+            osd->DrawRectangle(px + 1, py0, px1, py0 + 1, ColorFg);
+            osd->DrawRectangle(px + 1, py1 - 1, px1, py1, ColorFg);
+            osd->DrawRectangle(px1 - 1, py0, px1, py1, ColorFg);
+            }
+         else
+            osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x4 - xt);
          }
       if (!Tab(i + 1))
          break;