summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY5
-rw-r--r--display.c2
-rw-r--r--i18n.c25
-rw-r--r--menu.c2
-rw-r--r--render.c41
-rw-r--r--render.h17
-rw-r--r--setup.c4
-rw-r--r--setup.h3
-rw-r--r--status.c24
9 files changed, 103 insertions, 20 deletions
diff --git a/HISTORY b/HISTORY
index 8e2ccb8..bc2c26f 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,6 +1,11 @@
VDR Plugin 'text2skin' Revision History
---------------------------------------
+2006-02-04: Version 1.1-cvs_ext-0.8 (vdr-text2skin-1.1-cvs_ext-0.8.diff)
+
+- added a configuration option for showing the scrollbar in the menus and
+ finished implementation
+
2006-02-04: Version 1.1-cvs_ext-0.7 (vdr-text2skin-1.1-cvs_ext-0.7.diff)
- changed the routines to determine the next timers
diff --git a/display.c b/display.c
index 227b41a..7dc8f5c 100644
--- a/display.c
+++ b/display.c
@@ -873,6 +873,8 @@ void cText2SkinDisplayMenu::SetItem(const char *Text, int Index, bool Current, b
mCurrentItem = Index;
SetDirty();
}
+
+ if (Current) mRender->mMenuScrollbar.currentOnScreen = (uint)Index;
UpdateUnlock();
}
diff --git a/i18n.c b/i18n.c
index ab583fc..295c677 100644
--- a/i18n.c
+++ b/i18n.c
@@ -129,6 +129,31 @@ const tI18nPhrase Phrases[] = {
"",
#endif
},
+ { "Show scrollbar in the menus",
+ "Zeige Bildlaufleiste in Menüs",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+#if VDRVERSNUM >= 10313
+ "",
+#endif
+#if VDRVERSNUM >= 10316
+ "",
+#endif
+ },
{ "Reset Marquee for new item",
"Marquee für neues Item zurücksetzen",
"",
diff --git a/menu.c b/menu.c
index 47ca136..e8f2306 100644
--- a/menu.c
+++ b/menu.c
@@ -9,6 +9,7 @@
cText2SkinSetupPage::cText2SkinSetupPage(void) {
mData = Text2SkinSetup;
+ Add(new cMenuEditBoolItem(tr("Show scrollbar in the menus"), &mData.MenuScrollbar, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Scrolling behaviour"), &mData.MarqueeLeftRight, tr("to the left"), tr("left and right")));
Add(new cMenuEditBoolItem(tr("Reset Marquee for new item"), &mData.MarqueeReset, tr("no"), tr("yes")));
#if VDRVERSNUM >= 10330
@@ -22,6 +23,7 @@ cText2SkinSetupPage::~cText2SkinSetupPage() {
}
void cText2SkinSetupPage::Store(void) {
+ SetupStore("MenuScrollbar", mData.MenuScrollbar);
SetupStore("MarqueeLeftRight", mData.MarqueeLeftRight);
SetupStore("MarqueeReset", mData.MarqueeReset);
#if VDRVERSNUM >= 10330
diff --git a/render.c b/render.c
index f523e63..06096b1 100644
--- a/render.c
+++ b/render.c
@@ -11,7 +11,6 @@
#include "screen.h"
#include "display.h"
#include "scroller.h"
-#include "setup.h"
#include "xml/display.h"
#include <vdr/channels.h>
#include <vdr/epg.h>
@@ -222,7 +221,8 @@ void cText2SkinRender::DrawObject(const cxObject *Object)
uint itemheight = item->Size().h;
uint maxitems = areasize.h / itemheight;
uint yoffset = 0;
-
+
+ mMenuScrollbar.maxItems = maxitems;
SetMaxItems(maxitems); //Dprintf("setmaxitems %d\n", maxitems);
for (uint i = 0; i < maxitems; ++i, yoffset += itemheight) {
for (uint j = 1; j < Object->Objects(); ++j) {
@@ -564,6 +564,29 @@ void cText2SkinRender::DrawScrollbar(const txPoint &Pos, const txSize &Size, con
DrawRectangle(sp, ss, Fg);
}
}
+ else if (mMenuScrollbar.Available())
+ {
+ DrawRectangle(Pos, Size, Bg);
+ txPoint sbPoint = Pos;
+ txSize sbSize = Size;
+ if (sbSize.h > sbSize.w)
+ {
+ // -1 to get at least 1 pixel height
+ double top = double(mMenuScrollbar.Top()) / mMenuScrollbar.total * (sbSize.h - 1);
+ double bottom = double(mMenuScrollbar.Bottom()) / mMenuScrollbar.total * (sbSize.h - 1);
+ sbPoint.y += (uint)top;
+ sbSize.h -= (uint)top + (uint)bottom;
+ }
+ else
+ {
+ // -1 to get at least 1 pixel height
+ double left = double(mMenuScrollbar.Top()) / mMenuScrollbar.total * (sbSize.w - 1);
+ double right = double(mMenuScrollbar.Bottom()) / mMenuScrollbar.total * (sbSize.w - 1);
+ sbPoint.x += (uint)left;
+ sbSize.w -= (uint)left + (uint)right;
+ }
+ DrawRectangle(sbPoint, sbSize, Fg);
+ }
}
txPoint cText2SkinRender::Transform(const txPoint &Pos)
@@ -675,9 +698,19 @@ cxType cText2SkinRender::GetTokenData(const txToken &Token)
case tDateTime: return TimeType(time(NULL), Token.Attrib.Text);
- case tCanScrollUp: return mScroller != NULL && mScroller->CanScrollUp();
+ case tCanScrollUp:
+ {
+ if (mScroller) return mScroller->CanScrollUp();
+ else if (mMenuScrollbar.Available()) return mMenuScrollbar.CanScrollUp();
+ else return false;
+ }
- case tCanScrollDown: return mScroller != NULL && mScroller->CanScrollDown();
+ case tCanScrollDown:
+ {
+ if (mScroller) return mScroller->CanScrollDown();
+ else if (mMenuScrollbar.Available()) return mMenuScrollbar.CanScrollDown();
+ else return false;
+ }
case tIsRecording: return cRecordControls::Active();
diff --git a/render.h b/render.h
index 4748a0d..cee31ab 100644
--- a/render.h
+++ b/render.h
@@ -7,6 +7,7 @@
#include "common.h"
#include "scroller.h"
+#include "setup.h"
#include "xml/skin.h"
#include "xml/type.h"
#include <vdr/osd.h>
@@ -47,6 +48,7 @@ private:
std::string mBasePath;
bool mDirty;
+ uint mMaxItems;
cSkin *mFallback;
// update thread
@@ -115,6 +117,7 @@ protected:
virtual bool HasTabText(int Index, int n) { return false; }
virtual void SetEditableWidth(int Width) {}
virtual void SetMaxItems(int MaxItems) {}
+ inline int GetmMaxItems(void) { return mMaxItems; }
// functions for display renderer to control behaviour
void Flush(bool Force = false);
@@ -138,12 +141,18 @@ public:
// provide scrollbar in every menu
struct tMenuScrollbar
{
- int current;
- int total;
+ uint current; // overall (0 ... toal-1)
+ uint currentOnScreen; // on the current screen (0 ... maxItems-1)
+ uint total;
+ uint maxItems; // viewable on current screen
std::vector<std::string> items;
- tMenuScrollbar(void) : current(0), total(0) {}
- //bool available(void) { printf("%d / %d\n", total, GetMaxItems(); return total > GetMaxItems(); }
+ tMenuScrollbar(void) : current(0), currentOnScreen(0), total(0), maxItems(0) {}
+ bool Available(void) { return Text2SkinSetup.MenuScrollbar ? total > maxItems : false; }
+ uint Top(void) { return current - currentOnScreen; }
+ uint Bottom(void) { return total - Top() - maxItems; }
+ bool CanScrollUp(void) { return Text2SkinSetup.MenuScrollbar ? Top() > 0 : false; }
+ bool CanScrollDown(void) { return Text2SkinSetup.MenuScrollbar ? Bottom() > 0 : false; }
} mMenuScrollbar;
// update infos (e.g. timerConflict)
diff --git a/setup.c b/setup.c
index 504c4e4..a2ea090 100644
--- a/setup.c
+++ b/setup.c
@@ -9,6 +9,7 @@ cText2SkinSetup Text2SkinSetup;
// --- cText2SkinSetup --------------------------------------------------------
cText2SkinSetup::cText2SkinSetup(void) {
+ MenuScrollbar = false;
MarqueeLeftRight = true;
MarqueeReset = false;
CheckTimerConflict = false;
@@ -16,7 +17,8 @@ cText2SkinSetup::cText2SkinSetup(void) {
}
bool cText2SkinSetup::SetupParse(const char *Name, const char *Value) {
- if (strcmp(Name, "MarqueeLeftRight") == 0) MarqueeLeftRight = atoi(Value);
+ if (strcmp(Name, "MenuScrollbar") == 0) MenuScrollbar = atoi(Value);
+ else if (strcmp(Name, "MarqueeLeftRight") == 0) MarqueeLeftRight = atoi(Value);
else if (strcmp(Name, "MarqueeReset") == 0) MarqueeReset = atoi(Value);
else if (strcmp(Name, "CheckTimerConflict") == 0) CheckTimerConflict = atoi(Value);
else if (strcmp(Name, "MaxCacheFill") == 0) MaxCacheFill = atoi(Value);
diff --git a/setup.h b/setup.h
index a21b15e..cee476a 100644
--- a/setup.h
+++ b/setup.h
@@ -12,7 +12,8 @@ public:
cText2SkinSetup(void);
bool SetupParse(const char *Name, const char *Value);
-
+
+ int MenuScrollbar;
int MarqueeLeftRight;
int MarqueeReset;
int CheckTimerConflict;
diff --git a/status.c b/status.c
index 0616f7a..95e4bec 100644
--- a/status.c
+++ b/status.c
@@ -155,13 +155,16 @@ void cText2SkinStatus::OsdCurrentItem(const char *Text)
u->foundFirstItem = false;
// find current item in scrollbar
- cText2SkinRender::tMenuScrollbar *sb = &mRender->mMenuScrollbar;
- for (int i = 0; i < sb->total; i++)
+ if (Text2SkinSetup.MenuScrollbar)
{
- if (sb->items[i] == Text)
+ cText2SkinRender::tMenuScrollbar *sb = &mRender->mMenuScrollbar;
+ for (uint i = 0; i < sb->total; i++)
{
- sb->current = i;
- break;
+ if (sb->items[i] == Text)
+ {
+ sb->current = i;
+ break;
+ }
}
}
}
@@ -169,21 +172,22 @@ void cText2SkinStatus::OsdCurrentItem(const char *Text)
void cText2SkinStatus::OsdItem(const char *Text, int Index)
{
- if (mRender != NULL)
+ if (mRender && Text2SkinSetup.MenuScrollbar)
{
+ uint curr = (uint)Index;
cText2SkinRender::tMenuScrollbar *sb = &mRender->mMenuScrollbar;
- if ((unsigned int)Index < sb->items.size())
+ if (curr < sb->items.size())
{
- sb->items[Index] = Text;
+ sb->items[curr] = Text;
}
else
{
sb->items.push_back(Text);
- sb->total = Index + 1;
+ sb->total = curr + 1;
}
- if (Index + 1 > sb->total) sb->total = Index + 1;
+ if (curr + 1 > sb->total) sb->total = curr + 1;
}
}