From patchwork Mon Nov 12 18:12:42 2007 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Wieninger X-Patchwork-Id: 12548 Received: from mail.gmx.net ([213.165.64.20]) by www.linuxtv.org with smtp (Exim 4.63) (envelope-from ) id 1IrdmG-0000ka-1j for vdr@linuxtv.org; Mon, 12 Nov 2007 19:12:52 +0100 Received: (qmail invoked by alias); 12 Nov 2007 18:12:21 -0000 Received: from F5591.f.strato-dslnet.de (EHLO [192.168.178.23]) [195.4.85.145] by mail.gmx.net (mp024) with SMTP; 12 Nov 2007 19:12:21 +0100 X-Authenticated: #2425893 X-Provags-ID: V01U2FsdGVkX189iRVy6PQ9DeRgNRKa0+SrjnU15nJwppUFvtRY5d ggkP7bvWHPO7Mi Message-ID: <4738979A.9070308@gmx.de> Date: Mon, 12 Nov 2007 19:12:42 +0100 From: Christian Wieninger User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: VDR Mailinglist X-Y-GMX-Trusted: 0 Subject: [vdr] Progressbar support in skins classic and st:tng X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Nov 2007 18:12:52 -0000 Status: O X-Status: X-Keywords: X-UID: 14518 Hi, many skins (like text2skin, enigmang, soppalusikka, ... ) support displaying a graphical progressbar when a text like "[||| ]" appears in a menu item. Since runtime patching a font is not possible anymore I was wondering if also the skins classic and st:tng could support this. Here's a small patch (based on the sources of enigmang), that adds this functionality. Would be nice to have this in VDR core ;) Regards, Christian diff -Nru vdr-1.5.11-orig/skinclassic.c vdr-1.5.11-progressbar/skinclassic.c --- vdr-1.5.11-orig/skinclassic.c 2007-07-29 14:35:03.000000000 +0200 +++ vdr-1.5.11-progressbar/skinclassic.c 2007-11-12 18:46:54.000000000 +0100 @@ -295,13 +295,51 @@ const cFont *font = cFont::GetFont(fontOsd); 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, x1 - xt); - } - if (!Tab(i + 1)) - break; + 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, x1 - xt); } + if (!Tab(i + 1)) + break; + } SetEditableWidth(x1 - x0 - Tab(1)); } diff -Nru vdr-1.5.11-orig/skinsttng.c vdr-1.5.11-progressbar/skinsttng.c --- vdr-1.5.11-orig/skinsttng.c 2007-06-17 15:51:56.000000000 +0200 +++ vdr-1.5.11-progressbar/skinsttng.c 2007-11-12 18:47:01.000000000 +0100 @@ -545,9 +545,46 @@ 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; }