Optimize TimeJump

This commit is contained in:
kamel5 2020-01-06 12:51:49 +01:00
parent 2e4a43133e
commit 6540e21444
4 changed files with 43 additions and 41 deletions

View File

@ -8,7 +8,7 @@
#include "fontmanager.h" #include "fontmanager.h"
#include "imagecache.h" #include "imagecache.h"
enum { enum eTimeFormat {
e12Hours, e12Hours,
e24Hours e24Hours
}; };

View File

@ -3,6 +3,14 @@
#include "config.h" #include "config.h"
#include "timemanager.h" #include "timemanager.h"
cTimeManager::cTimeManager(void) {
if (config.displayMode == eVertical) {
displaySeconds = (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight) / geoManager.minutePixel * 60;
} else if (config.displayMode == eHorizontal) {
displaySeconds = (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth) / geoManager.minutePixel * 60;
}
}
cTimeManager::~cTimeManager(void) { cTimeManager::~cTimeManager(void) {
} }
@ -18,34 +26,26 @@ void cTimeManager::Now() {
t = time(0); t = time(0);
tStart = t; tStart = t;
tStart = GetRounded(); tStart = GetRounded();
if (config.displayMode == eVertical) { tEnd = tStart + displaySeconds;
tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60;
} else if (config.displayMode == eHorizontal) {
tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60;
}
} }
void cTimeManager::AddStep(int step) { void cTimeManager::AddStep(int step) {
tStart += step * 60; tStart += step * 60;
tEnd += step*60; tEnd = tStart + displaySeconds;
} }
bool cTimeManager::DelStep(int step) { void cTimeManager::DelStep(int step) {
if ((tStart - step * 60) + 30 * 60 < t) { if ((tStart - step * 60) + 30 * 60 < t) {
return true; Now();
} } else {
tStart -= step * 60; tStart -= step * 60;
tEnd -= step*60; tEnd = tStart + displaySeconds;
return false; }
} }
void cTimeManager::SetTime(time_t newTime) { void cTimeManager::SetTime(time_t newTime) {
tStart = newTime; tStart = newTime;
if (config.displayMode == eVertical) { tEnd = tStart + displaySeconds;
tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60;
} else if (config.displayMode == eHorizontal) {
tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60;
}
} }
time_t cTimeManager::getPrevPrimetime(time_t current) { time_t cTimeManager::getPrevPrimetime(time_t current) {

View File

@ -2,6 +2,7 @@
#define __TVGUIDE_TIMEMANAGER_H #define __TVGUIDE_TIMEMANAGER_H
#include <vdr/tools.h> #include <vdr/tools.h>
#include "config.h"
// --- cTimeManager ------------------------------------------------------------- // --- cTimeManager -------------------------------------------------------------
@ -10,14 +11,16 @@ class cTimeManager {
time_t t; time_t t;
time_t tStart; time_t tStart;
time_t tEnd; time_t tEnd;
int displaySeconds;
eTimeFormat timeFormat;
public: public:
cTimeManager(){}; cTimeManager();
virtual ~cTimeManager(void); virtual ~cTimeManager(void);
static cString printTime(time_t displayTime); static cString printTime(time_t displayTime);
void Now(); void Now();
time_t GetNow() { return t; }; time_t GetNow() { return t; };
void AddStep(int step); void AddStep(int step);
bool DelStep(int step); void DelStep(int step);
void SetTime(time_t newTime); void SetTime(time_t newTime);
time_t Get() {return t;}; time_t Get() {return t;};
time_t GetStart() {return tStart;}; time_t GetStart() {return tStart;};
@ -31,6 +34,7 @@ class cTimeManager {
int GetTimelineOffset(); int GetTimelineOffset();
time_t GetRounded(); time_t GetRounded();
bool NowVisible(void); bool NowVisible(void);
int GetDisplaySeconds(void) { return displaySeconds; };
void debug(); void debug();
}; };

View File

@ -410,9 +410,7 @@ void cTvGuideOsd::timeBack() {
} }
void cTvGuideOsd::ScrollBack() { void cTvGuideOsd::ScrollBack() {
bool tooFarInPast = timeManager->DelStep(config.stepMinutes); timeManager->DelStep(config.stepMinutes);
if (tooFarInPast)
return;
if (config.useHWAccel) { if (config.useHWAccel) {
drawGridsTimeJump(); drawGridsTimeJump();
timeLine->drawDateViewer(); timeLine->drawDateViewer();
@ -640,9 +638,7 @@ void cTvGuideOsd::processNumKey(int numKey) {
void cTvGuideOsd::TimeJump(int mode) { void cTvGuideOsd::TimeJump(int mode) {
switch (mode) { switch (mode) {
case 1: { case 1: {
bool tooFarInPast = timeManager->DelStep(config.bigStepHours*60); timeManager->DelStep(config.bigStepHours * 60);
if (tooFarInPast)
return;
} }
break; break;
case 3: { case 3: {
@ -650,9 +646,7 @@ void cTvGuideOsd::TimeJump(int mode) {
} }
break; break;
case 4: { case 4: {
bool tooFarInPast = timeManager->DelStep(config.hugeStepHours*60); timeManager->DelStep(config.hugeStepHours * 60);
if (tooFarInPast)
return;
} }
break; break;
case 6: { case 6: {
@ -785,6 +779,10 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) {
case kOk: state = processKeyOk(&alreadyUnlocked); break; case kOk: state = processKeyOk(&alreadyUnlocked); break;
case kBack: state = osEnd; break; case kBack: state = osEnd; break;
case k0 ... k9: processNumKey(Key - k0); break; case k0 ... k9: processNumKey(Key - k0); break;
case kFastRew: TimeJump(1); break; // Doesnt work, if used from timeshiftmode
case kFastFwd: TimeJump(3); break;
case kPrev: TimeJump(4); break;
case kNext: TimeJump(6); break;
case kNone: if (channelJumper) CheckTimeout(); break; case kNone: if (channelJumper) CheckTimeout(); break;
default: break; default: break;
} }