summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brugger <brougs78@gmx.net>2006-02-04 11:49:02 +0100
committerThomas Günther <tom@toms-cafe.de>2009-06-03 02:58:17 +0200
commitc1bf83aec2961a4e84dbc1c36042bd985f044a91 (patch)
tree6ce0edea2a8cdf3e83ee897022f85261c6c15407
parentdaad17454a344d50150850fd9b9062b200982140 (diff)
downloadvdr-plugin-text2skin-c1bf83aec2961a4e84dbc1c36042bd985f044a91.tar.gz
vdr-plugin-text2skin-c1bf83aec2961a4e84dbc1c36042bd985f044a91.tar.bz2
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 - added the possibility to have a scrollbar in every menu - not fully implemented yet (to position in menu-lists is not necessarily correct, if there are more items with the same osd-text)
-rw-r--r--HISTORY7
-rw-r--r--common.c27
-rw-r--r--display.h3
-rw-r--r--render.c1
-rw-r--r--render.h13
-rw-r--r--status.c92
-rw-r--r--status.h43
7 files changed, 117 insertions, 69 deletions
diff --git a/HISTORY b/HISTORY
index 16d54d9..8e2ccb8 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,6 +1,13 @@
VDR Plugin 'text2skin' Revision History
---------------------------------------
+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
+- added the possibility to have a scrollbar in every menu - not fully
+ implemented yet (to position in menu-lists is not necessarily correct,
+ if there are more items with the same osd-text)
+
2006-01-10: Version 1.1-cvs_ext-0.6 (vdr-text2skin-1.1-cvs_ext-0.6.diff)
- updated to cvs-version of text2skin
diff --git a/common.c b/common.c
index 904c417..b9e1daf 100644
--- a/common.c
+++ b/common.c
@@ -121,6 +121,14 @@ const cRecording *GetRecordingByFileName(const char *FileName)
}
int GetRecordingSize(const char *FileName)
+#if VDRVERSNUM >= 10338
+// use VDR's routine
+{
+ const cRecording *rec = GetRecordingByFileName(FileName);
+ return (rec) ? DirSizeMB(FileName) : 0;
+}
+#else
+// use our own approach
{
if (FileName != NULL) {
bool bRet=false;
@@ -165,6 +173,7 @@ int GetRecordingSize(const char *FileName)
return 0;
}
}
+#endif
int GetRecordingLength(const char *FileName)
{
@@ -217,27 +226,9 @@ int GetRecordingCuttedLength(const char *FileName)
double length = 0;
int totalLength = GetRecordingLength(FileName);
const double diffIFrame = FRAMESPERSEC / 2; // approx. 1/2 sec.
- /*
- // not useful
- static std::string lastFileName = "";
- static uint64 nextUpdate = 0;
- static int totalLength = 0;
- const uint64 bufferTime = 30 * 1000; // [ms]
- */
-
marks.Load(FileName);
- /*
- // buffer the result of 'GetRecordingLength'
- if (FileName != lastFileName || time_ms() >= nextUpdate)
- {
- lastFileName = FileName;
- nextUpdate = time_ms() + bufferTime;
- totalLength = GetRecordingLength(FileName);
- }
- */
-
if (marks.Count())
{
int start = 1; // first frame
diff --git a/display.h b/display.h
index 9f592c2..3865431 100644
--- a/display.h
+++ b/display.h
@@ -169,7 +169,8 @@ protected:
virtual void SetEditableWidth(int Width) { cSkinDisplayMenu::SetEditableWidth(Width); }
virtual int MaxItems(void) { return mMaxItems; }
virtual void SetMaxItems(int MaxItems) { mMaxItems = MaxItems; }
-
+ virtual int GetMaxItems(void) { return mMaxItems; }
+
public:
cText2SkinDisplayMenu(cText2SkinLoader *Loader);
virtual ~cText2SkinDisplayMenu();
diff --git a/render.c b/render.c
index 78c5ac6..f523e63 100644
--- a/render.c
+++ b/render.c
@@ -263,6 +263,7 @@ void cText2SkinRender::DrawObject(const cxObject *Object)
// there is no "next tab", use the rightmost edge
obj.mPos2.x += Object->mPos1.x;
SetEditableWidth(obj.Size().w);
+ //printf("EditableWidth von '%s': %d Pixels\n", obj.Text().c_str(), obj.Size().w);
}
obj.mPos2.y += Object->mPos1.y + yoffset;
diff --git a/render.h b/render.h
index b0e50cf..4748a0d 100644
--- a/render.h
+++ b/render.h
@@ -134,8 +134,19 @@ public:
static bool ItemColor(const std::string &Color, tColor &Result);
static std::string ImagePath(const std::string &Filename);
static cxType GetToken(const txToken &Token);
+
+ // provide scrollbar in every menu
+ struct tMenuScrollbar
+ {
+ int current;
+ int total;
+ std::vector<std::string> items;
- // update infos
+ tMenuScrollbar(void) : current(0), total(0) {}
+ //bool available(void) { printf("%d / %d\n", total, GetMaxItems(); return total > GetMaxItems(); }
+ } mMenuScrollbar;
+
+ // update infos (e.g. timerConflict)
struct tUpdate
{
bool timerConflict;
diff --git a/status.c b/status.c
index 9155bf6..0616f7a 100644
--- a/status.c
+++ b/status.c
@@ -134,18 +134,56 @@ void cText2SkinStatus::OsdClear(void)
mLastLanguage = Setup.OSDLanguage;
cxString::Reparse();
}
+
+ if (mRender != NULL)
+ {
+ mRender->mMenuScrollbar.total = 0;
+ }
}
void cText2SkinStatus::OsdCurrentItem(const char *Text)
{
if (mRender != NULL)
{
+ // update infos
+ cText2SkinRender::tUpdate *u = &mRender->mUpdate;
static std::string lastItem;
- lastItem = mRender->mUpdate.currentItem;
- mRender->mUpdate.currentItem = Text;
- mRender->mUpdate.resetMarquee = true;
- mRender->mUpdate.foundFirstItem = false;
+ lastItem = u->currentItem;
+ u->currentItem = Text;
+ u->resetMarquee = true;
+ u->foundFirstItem = false;
+
+ // find current item in scrollbar
+ cText2SkinRender::tMenuScrollbar *sb = &mRender->mMenuScrollbar;
+ for (int i = 0; i < sb->total; i++)
+ {
+ if (sb->items[i] == Text)
+ {
+ sb->current = i;
+ break;
+ }
+ }
+ }
+}
+
+void cText2SkinStatus::OsdItem(const char *Text, int Index)
+{
+ if (mRender != NULL)
+ {
+ cText2SkinRender::tMenuScrollbar *sb = &mRender->mMenuScrollbar;
+
+ if ((unsigned int)Index < sb->items.size())
+ {
+ sb->items[Index] = Text;
+ }
+ else
+ {
+ sb->items.push_back(Text);
+ sb->total = Index + 1;
+ }
+
+ if (Index + 1 > sb->total) sb->total = Index + 1;
}
}
@@ -155,31 +193,21 @@ void cText2SkinStatus::UpdateEvents(void)
{
mRender->mUpdate.events = false;
- mEvents.clear();
+ mEvents.Clear();
Timers.IncBeingEdited();
- for (cTimer *tim = Timers.First(); tim != NULL; tim = Timers.Next(tim))
+ for (cTimer *tim = Timers.First(); tim; tim = Timers.Next(tim))
{
if (tim->HasFlags(tfActive))
{
int i = 0;
cTimer dummy;
- dummy = *tim; // copy the timer
+ dummy = *tim;
do
{
- tEvent ev;
+ mEvents.Add(new tEvent(&dummy));
- ev.title = dummy.File();
- ev.isRecording = dummy.Recording();
- ev.channelName = dummy.Channel()->Name();
- ev.channelNumber = dummy.Channel()->Number();
- ev.startTime = dummy.StartTime();
- ev.stopTime = dummy.StopTime();
- ev.priority = dummy.Priority();
-
- mEvents.push_back(ev);
-
if (!dummy.IsSingleEvent()) // add 4 additional rep. timer
{
do
@@ -195,13 +223,13 @@ void cText2SkinStatus::UpdateEvents(void)
}
Timers.DecBeingEdited();
- std::sort(mEvents.rbegin(), mEvents.rend());
+ mEvents.Sort();
}
}
cxType cText2SkinStatus::GetTokenData(const txToken &Token)
{
- uint event = 0;
+ int event = 0;
switch (Token.Type) {
case tReplayMode:
@@ -213,8 +241,8 @@ cxType cText2SkinStatus::GetTokenData(const txToken &Token)
event++;
case tCurrentEventsTitle1:
UpdateEvents();
- return mEvents.size() > event
- ? (cxType)mEvents[event].title.c_str()
+ return mEvents.Count() > event
+ ? (cxType)mEvents.Get(event)->title.c_str()
: (cxType)false;
case tCurrentEventsStartDateTime3:
@@ -223,8 +251,8 @@ cxType cText2SkinStatus::GetTokenData(const txToken &Token)
event++;
case tCurrentEventsStartDateTime1:
UpdateEvents();
- return mEvents.size() > event
- ? (cxType)TimeType(mEvents[event].startTime, Token.Attrib.Text)
+ return mEvents.Count() > event
+ ? (cxType)TimeType(mEvents.Get(event)->startTime, Token.Attrib.Text)
: (cxType)false;
case tCurrentEventsStopDateTime3:
@@ -233,8 +261,8 @@ cxType cText2SkinStatus::GetTokenData(const txToken &Token)
event++;
case tCurrentEventsStopDateTime1:
UpdateEvents();
- return mEvents.size() > event
- ? (cxType)TimeType(mEvents[event].stopTime, Token.Attrib.Text)
+ return mEvents.Count() > event
+ ? (cxType)TimeType(mEvents.Get(event)->stopTime, Token.Attrib.Text)
: (cxType)false;
case tCurrentEventsChannelNumber3:
@@ -243,8 +271,8 @@ cxType cText2SkinStatus::GetTokenData(const txToken &Token)
event++;
case tCurrentEventsChannelNumber1:
UpdateEvents();
- return mEvents.size() > event
- ? (cxType)mEvents[event].channelNumber
+ return mEvents.Count() > event
+ ? (cxType)mEvents.Get(event)->channelNumber
: (cxType)false;
case tCurrentEventsChannelName3:
@@ -253,8 +281,8 @@ cxType cText2SkinStatus::GetTokenData(const txToken &Token)
event++;
case tCurrentEventsChannelName1:
UpdateEvents();
- return mEvents.size() > event
- ? (cxType)mEvents[event].channelName.c_str()
+ return mEvents.Count() > event
+ ? (cxType)mEvents.Get(event)->channelName.c_str()
: (cxType)false;
case tCurrentEventsIsRecording3:
@@ -263,8 +291,8 @@ cxType cText2SkinStatus::GetTokenData(const txToken &Token)
event++;
case tCurrentEventsIsRecording1:
UpdateEvents();
- return mEvents.size() > event
- ? (cxType)mEvents[event].isRecording
+ return mEvents.Count() > event
+ ? (cxType)mEvents.Get(event)->isRecording
: (cxType)false;
case tTimerConflict:
diff --git a/status.h b/status.h
index 2047595..8bd0f96 100644
--- a/status.h
+++ b/status.h
@@ -5,8 +5,6 @@
#ifndef VDR_TEXT2SKIN_STATUS_H
#define VDR_TEXT2SKIN_STATUS_H
-#include <algorithm>
-#include <vector>
#include "common.h"
#include <vdr/status.h>
@@ -30,22 +28,32 @@ public:
typedef std::string tRecordingInfo;
typedef std::vector<tRecordingInfo> tRecordings;
- struct tEvent
+ struct tEvent : public cListObject
{
- std::string title;
- bool isRecording;
- std::string channelName;
- int channelNumber;
- time_t startTime;
- time_t stopTime;
- int priority;
+ time_t startTime;
+ time_t stopTime;
+ int channelNumber;
+ std::string channelName;
+ int priority;
+ bool isRecording;
+ std::string title;
- bool tEvent::operator< (const tEvent &b) const
+ tEvent(cTimer *timer) :
+ startTime(timer->StartTime()),
+ stopTime(timer->StopTime()),
+ channelNumber(timer->Channel()->Number()),
+ channelName(timer->Channel()->Name()),
+ priority(timer->Priority()),
+ isRecording(timer->Recording()),
+ title(timer->File()) {}
+
+ virtual int Compare(const cListObject &listObj) const
{
- int r = startTime - b.startTime;
- r = r == 0 ? b.priority - priority : r;
- return r > 0 ? true : false;
- };
+ tEvent *e = (tEvent *)&listObj;
+ int r = startTime - e->startTime;
+ if (r == 0) r = e->priority - priority;
+ return r;
+ }
};
typedef std::vector<tEvent> tEvents;
@@ -58,8 +66,8 @@ private:
bool mReplayIsLoop;
bool mReplayIsShuffle;
tRecordings mRecordings;
- tEvents mEvents;
const cRecording *mReplay;
+ cList<tEvent> mEvents;
cMutex mRecordingsLock;
uint mCurrentRecording;
uint mNextRecording;
@@ -76,7 +84,8 @@ protected:
#endif
virtual void OsdClear(void);
virtual void OsdCurrentItem(const char *Text);
-
+ virtual void OsdItem(const char *Text, int Index);
+
public:
cText2SkinStatus(void);