mirror of
https://projects.vdr-developer.org/git/vdr-plugin-tvguide.git
synced 2023-10-05 15:01:48 +02:00
Optimize TimeJump
This commit is contained in:
parent
2e4a43133e
commit
6540e21444
2
config.h
2
config.h
@ -8,7 +8,7 @@
|
|||||||
#include "fontmanager.h"
|
#include "fontmanager.h"
|
||||||
#include "imagecache.h"
|
#include "imagecache.h"
|
||||||
|
|
||||||
enum {
|
enum eTimeFormat {
|
||||||
e12Hours,
|
e12Hours,
|
||||||
e24Hours
|
e24Hours
|
||||||
};
|
};
|
||||||
|
@ -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,40 +26,32 @@ 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;
|
||||||
|
tEnd = tStart + displaySeconds;
|
||||||
}
|
}
|
||||||
tStart -= step*60;
|
|
||||||
tEnd -= step*60;
|
|
||||||
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) {
|
||||||
tm *st = localtime(¤t);
|
tm *st = localtime(¤t);
|
||||||
if (st->tm_hour < 21) {
|
if (st->tm_hour < 21) {
|
||||||
current -= 24 * 60* 60;
|
current -= 24 * 60 * 60;
|
||||||
st = localtime(¤t);
|
st = localtime(¤t);
|
||||||
}
|
}
|
||||||
st->tm_hour = 20;
|
st->tm_hour = 20;
|
||||||
@ -63,7 +63,7 @@ time_t cTimeManager::getPrevPrimetime(time_t current) {
|
|||||||
time_t cTimeManager::getNextPrimetime(time_t current){
|
time_t cTimeManager::getNextPrimetime(time_t current){
|
||||||
tm *st = localtime(¤t);
|
tm *st = localtime(¤t);
|
||||||
if (st->tm_hour > 19) {
|
if (st->tm_hour > 19) {
|
||||||
current += 24 * 60* 60;
|
current += 24 * 60 * 60;
|
||||||
st = localtime(¤t);
|
st = localtime(¤t);
|
||||||
}
|
}
|
||||||
st->tm_hour = 20;
|
st->tm_hour = 20;
|
||||||
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
22
tvguideosd.c
22
tvguideosd.c
@ -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,23 +638,19 @@ 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: {
|
||||||
timeManager->AddStep(config.bigStepHours*60);
|
timeManager->AddStep(config.bigStepHours * 60);
|
||||||
}
|
}
|
||||||
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: {
|
||||||
timeManager->AddStep(config.hugeStepHours*60);
|
timeManager->AddStep(config.hugeStepHours * 60);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7: {
|
case 7: {
|
||||||
@ -783,8 +777,12 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) {
|
|||||||
case kYellow: processKeyYellow(); break;
|
case kYellow: processKeyYellow(); break;
|
||||||
case kBlue: state = processKeyBlue(&alreadyUnlocked); break;
|
case kBlue: state = processKeyBlue(&alreadyUnlocked); break;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user