Refactor Timeline

This commit is contained in:
kamel5 2020-01-06 14:09:56 +01:00
parent efe06b8e98
commit c77f74321f
5 changed files with 90 additions and 97 deletions

View File

@ -35,7 +35,7 @@ bool cGeometryManager::SetGeometry(int osdWidth, int osdHeight, bool force) {
if (config.displayMode == eVertical) { if (config.displayMode == eVertical) {
colWidth = (osdWidth - timeLineWidth) / config.channelCols; colWidth = (osdWidth - timeLineWidth) / config.channelCols;
rowHeight = 0; rowHeight = 0;
minutePixel = (osdHeight - statusHeaderHeight - channelGroupsHeight - channelHeaderHeight - footerHeight) / config.displayTime; minutePixel = (double)(osdHeight - statusHeaderHeight - channelGroupsHeight - channelHeaderHeight - footerHeight) / (double)config.displayTime;
channelLogoWidth = colWidth; channelLogoWidth = colWidth;
channelLogoHeight = channelHeaderHeight; channelLogoHeight = channelHeaderHeight;
logoWidth = channelLogoWidth / 2 - 15; logoWidth = channelLogoWidth / 2 - 15;
@ -49,7 +49,7 @@ bool cGeometryManager::SetGeometry(int osdWidth, int osdHeight, bool force) {
} else if (config.displayMode == eHorizontal) { } else if (config.displayMode == eHorizontal) {
colWidth = 0; colWidth = 0;
rowHeight = (osdHeight - statusHeaderHeight - timeLineHeight - footerHeight) / config.channelRows; rowHeight = (osdHeight - statusHeaderHeight - timeLineHeight - footerHeight) / config.channelRows;
minutePixel = (osdWidth - channelHeaderWidth - channelGroupsWidth) / config.displayHorizontalTime; minutePixel = (double)(osdWidth - channelHeaderWidth - channelGroupsWidth) / (double)config.displayHorizontalTime;
channelLogoWidth = channelHeaderWidth; channelLogoWidth = channelHeaderWidth;
channelLogoHeight = rowHeight; channelLogoHeight = rowHeight;
logoWidth = channelLogoHeight * config.logoWidthRatio / config.logoHeightRatio; logoWidth = channelLogoHeight * config.logoWidthRatio / config.logoHeightRatio;

View File

@ -24,7 +24,7 @@ public:
//Content //Content
int colWidth; int colWidth;
int rowHeight; int rowHeight;
int minutePixel; double minutePixel;
int channelLogoWidth; int channelLogoWidth;
int channelLogoHeight; int channelLogoHeight;
//Timeline //Timeline

View File

@ -5,33 +5,28 @@ cTimeLine::cTimeLine(cTimeManager *timeManager) {
this->timeManager = timeManager; this->timeManager = timeManager;
lastClock = ""; lastClock = "";
timeBase = NULL; timeBase = NULL;
int x11, x21, y11, y21, x12, x22, y12, y22;
if (config.displayMode == eVertical) { if (config.displayMode == eVertical) {
dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(0, x11 = 0;
geoManager.statusHeaderHeight + geoManager.clockHeight, x21 = geoManager.dateVieverWidth;
geoManager.dateVieverWidth, y11 = geoManager.statusHeaderHeight + geoManager.clockHeight;
geoManager.dateVieverHeight))); y21 = geoManager.dateVieverHeight;
timeline = osdManager.requestPixmap(2, cRect(0, x12 = 0;
geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight, x22 = geoManager.timeLineWidth;
geoManager.timeLineWidth, y12 = geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight;
geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight) y22 = geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight;
, cRect(0,
0,
geoManager.timeLineWidth,
1440 * geoManager.minutePixel));
} else if (config.displayMode == eHorizontal) { } else if (config.displayMode == eHorizontal) {
dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(geoManager.clockWidth, x11 = geoManager.clockWidth;
geoManager.statusHeaderHeight, x21 = geoManager.dateVieverWidth;
geoManager.dateVieverWidth, y11 = geoManager.statusHeaderHeight;
geoManager.dateVieverHeight))); y21 = geoManager.dateVieverHeight;
timeline = osdManager.requestPixmap(2, cRect(geoManager.channelHeaderWidth + geoManager.channelGroupsWidth, x12 = geoManager.channelHeaderWidth + geoManager.channelGroupsWidth;
geoManager.statusHeaderHeight, x22 = geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth;
geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth, y12 = geoManager.statusHeaderHeight;
geoManager.timeLineHeight) y22 = geoManager.timeLineHeight;
, cRect(0,
0,
1440 * geoManager.minutePixel,
geoManager.timeLineHeight));
} }
dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(x11, y11, x21, y21)));
timeline = osdManager.requestPixmap(2, cRect(x12, y12, x22, y22));
clock = new cStyledPixmap(osdManager.requestPixmap(3, cRect(0, clock = new cStyledPixmap(osdManager.requestPixmap(3, cRect(0,
geoManager.statusHeaderHeight, geoManager.statusHeaderHeight,
geoManager.clockWidth, geoManager.clockWidth,
@ -43,10 +38,11 @@ cTimeLine::~cTimeLine(void) {
delete clock; delete clock;
osdManager.releasePixmap(timeBase); osdManager.releasePixmap(timeBase);
osdManager.releasePixmap(timeline); osdManager.releasePixmap(timeline);
delete dateViewer; if (dateViewer)
delete dateViewer;
} }
void cTimeLine::drawDateViewer() { void cTimeLine::DrawDateViewer(void) {
cString weekDay = timeManager->GetWeekday(); cString weekDay = timeManager->GetWeekday();
cString date = timeManager->GetDate(); cString date = timeManager->GetDate();
if (config.style != eStyleGraphical) { if (config.style != eStyleGraphical) {
@ -80,8 +76,8 @@ void cTimeLine::drawDateViewer() {
} }
} }
void cTimeLine::drawTimeline() { void cTimeLine::DrawTimeline(void) {
timeline->SetTile(true); // timeline->SetTile(true);
timeline->Fill(clrTransparent); timeline->Fill(clrTransparent);
tColor colorFont, colorBackground; tColor colorFont, colorBackground;
@ -93,8 +89,8 @@ void cTimeLine::drawTimeline() {
img1 = imgCache.GetOsdElement(oeTimeline1); img1 = imgCache.GetOsdElement(oeTimeline1);
img2 = imgCache.GetOsdElement(oeTimeline2); img2 = imgCache.GetOsdElement(oeTimeline2);
} else { } else {
img1 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline1), theme.Color(clrTimeline1Blending)); img1 = CreateBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline1), theme.Color(clrTimeline1Blending));
img2 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline2), theme.Color(clrTimeline2Blending)); img2 = CreateBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline2), theme.Color(clrTimeline2Blending));
} }
const cImage *img = NULL; const cImage *img = NULL;
if (!img1 || !img2) if (!img1 || !img2)
@ -102,8 +98,19 @@ void cTimeLine::drawTimeline() {
int textWidth, posX, posY; int textWidth, posX, posY;
char timetext[10]; char timetext[10];
for (int i=0; i<48; i++) { int halfHours;
if (i%2==0) { if (config.displayMode == eVertical)
halfHours = config.displayTime / 30 + 1;
else
halfHours = config.displayHorizontalTime / 30 + 1;
time_t tStart = timeManager->GetStart();
tm *t = localtime ( &tStart );
int x = 2 * t->tm_hour + ((t->tm_min == 0) ? 0 : 1);
for (int j = x; j < (x + halfHours); j++) {
int i = (j >= 48) ? (j - 48) : j;
if (i % 2 == 0) {
img = img1; img = img1;
colorFont = theme.Color(clrTimeline2); colorFont = theme.Color(clrTimeline2);
colorBackground = (config.style == eStyleFlat)?theme.Color(clrTimeline1):clrTransparent; colorBackground = (config.style == eStyleFlat)?theme.Color(clrTimeline1):clrTransparent;
@ -111,11 +118,11 @@ void cTimeLine::drawTimeline() {
if (i == 0) if (i == 0)
sprintf(timetext, "12:00 PM"); sprintf(timetext, "12:00 PM");
else if (i/2 < 13) else if (i/2 < 13)
sprintf(timetext, "%d:00 AM", i/2); sprintf(timetext, "%d:00 AM", i / 2);
else else
sprintf(timetext, "%d:00 PM", i/2-12); sprintf(timetext, "%d:00 PM", i / 2 - 12);
} else { } else {
sprintf(timetext, "%d:00", i/2); sprintf(timetext, "%d:00", i / 2);
} }
} else { } else {
img = img2; img = img2;
@ -125,38 +132,38 @@ void cTimeLine::drawTimeline() {
if (i == 1) if (i == 1)
sprintf(timetext, "12:30 PM"); sprintf(timetext, "12:30 PM");
else if (i/2 < 13) else if (i/2 < 13)
sprintf(timetext, "%d:30 AM", i/2); sprintf(timetext, "%d:30 AM", i / 2);
else else
sprintf(timetext, "%d:30 PM", i/2-12); sprintf(timetext, "%d:30 PM", i / 2 - 12);
} else { } else {
sprintf(timetext, "%d:30", i/2); sprintf(timetext, "%d:30", i / 2);
} }
} }
if (config.displayMode == eVertical) { if (config.displayMode == eVertical) {
posY = i*geoManager.minutePixel*30; posY = (j - x) * geoManager.minutePixel * 30;
timeline->DrawImage(cPoint(0, posY), *img); timeline->DrawImage(cPoint(0, posY), *img);
if (config.style != eStyleGraphical) { if (config.style != eStyleGraphical) {
decorateTile(0, posY, imgWidth+2, imgHeight); DecorateTile(0, posY, imgWidth + 2, imgHeight);
} }
textWidth = fontManager.FontTimeLineTime->Width(timetext); textWidth = fontManager.FontTimeLineTime->Width(timetext);
timeline->DrawText(cPoint((geoManager.timeLineWidth-textWidth)/2, posY + 5), timetext, colorFont, colorBackground, fontManager.FontTimeLineTime); timeline->DrawText(cPoint((geoManager.timeLineWidth-textWidth) / 2, posY + 5), timetext, colorFont, colorBackground, fontManager.FontTimeLineTime);
} else if (config.displayMode == eHorizontal) { } else if (config.displayMode == eHorizontal) {
posX = i*geoManager.minutePixel*30; posX = (j - x) * geoManager.minutePixel * 30;
timeline->DrawImage(cPoint(posX, 0), *img); timeline->DrawImage(cPoint(posX, 0), *img);
if (config.style != eStyleGraphical) { if (config.style != eStyleGraphical) {
decorateTile(posX, 0, imgWidth, imgHeight+2); DecorateTile(posX, 0, imgWidth, imgHeight + 2);
} }
timeline->DrawText(cPoint(posX + 15, (dateViewer->Height() - fontManager.FontTimeLineTimeHorizontal->Height())/2), timetext, colorFont, colorBackground, fontManager.FontTimeLineTimeHorizontal); timeline->DrawText(cPoint(posX + 15, (dateViewer->Height() - fontManager.FontTimeLineTimeHorizontal->Height()) / 2), timetext, colorFont, colorBackground, fontManager.FontTimeLineTimeHorizontal);
} }
} }
setTimeline(); DrawTimeIndicator();
if (config.style != eStyleGraphical) { if (config.style != eStyleGraphical) {
delete img1; delete img1;
delete img2; delete img2;
} }
} }
void cTimeLine::decorateTile(int posX, int posY, int tileWidth, int tileHeight) { void cTimeLine::DecorateTile(int posX, int posY, int tileWidth, int tileHeight) {
timeline->DrawRectangle(cRect(posX,posY,tileWidth,2), clrTransparent); //top timeline->DrawRectangle(cRect(posX,posY,tileWidth,2), clrTransparent); //top
timeline->DrawRectangle(cRect(posX,posY,2,tileHeight), clrTransparent); //left timeline->DrawRectangle(cRect(posX,posY,2,tileHeight), clrTransparent); //left
timeline->DrawRectangle(cRect(posX,posY + tileHeight-2,tileWidth,2), clrTransparent); //bottom timeline->DrawRectangle(cRect(posX,posY + tileHeight-2,tileWidth,2), clrTransparent); //bottom
@ -169,11 +176,11 @@ void cTimeLine::decorateTile(int posX, int posY, int tileWidth, int tileHeight)
if (config.roundedCorners) { if (config.roundedCorners) {
int borderRadius = 12; int borderRadius = 12;
drawRoundedCorners(posX, posY, tileWidth, tileHeight, borderRadius); DrawRoundedCorners(posX, posY, tileWidth, tileHeight, borderRadius);
} }
} }
void cTimeLine::drawRoundedCorners(int posX, int posY, int width, int height, int radius) { void cTimeLine::DrawRoundedCorners(int posX, int posY, int width, int height, int radius) {
timeline->DrawEllipse(cRect(posX+2,posY+2,radius,radius), theme.Color(clrBorder), -2); timeline->DrawEllipse(cRect(posX+2,posY+2,radius,radius), theme.Color(clrBorder), -2);
timeline->DrawEllipse(cRect(posX+1,posY+1,radius,radius), clrTransparent, -2); timeline->DrawEllipse(cRect(posX+1,posY+1,radius,radius), clrTransparent, -2);
@ -189,14 +196,16 @@ void cTimeLine::drawRoundedCorners(int posX, int posY, int width, int height, in
} }
} }
void cTimeLine::drawCurrentTimeBase(void) { void cTimeLine::DrawTimeIndicator(void) {
if (!config.displayTimeBase)
return;
if (!timeManager->NowVisible()) { if (!timeManager->NowVisible()) {
if (timeBase) if (timeBase)
timeBase->Fill(clrTransparent); timeBase->Fill(clrTransparent);
return; return;
} }
int deltaTime = (time(0) - timeManager->GetStart()) / 60 * geoManager.minutePixel;
osdManager.releasePixmap(timeBase); osdManager.releasePixmap(timeBase);
int deltaTime = (timeManager->GetNow() - timeManager->GetStart()) / 60 * geoManager.minutePixel;
int x1, x2, y1, y2; int x1, x2, y1, y2;
if (config.displayMode == eVertical) { if (config.displayMode == eVertical) {
x1 = 0; x1 = 0;
@ -214,7 +223,7 @@ void cTimeLine::drawCurrentTimeBase(void) {
timeBase->DrawRectangle(cRect(0, 0, timeBase->ViewPort().Width(), timeBase->ViewPort().Height()), theme.Color(clrTimeBase)); timeBase->DrawRectangle(cRect(0, 0, timeBase->ViewPort().Width(), timeBase->ViewPort().Height()), theme.Color(clrTimeBase));
} }
cImage *cTimeLine::createBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend) { cImage *cTimeLine::CreateBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend) {
cImage *image = NULL; cImage *image = NULL;
if (config.style == eStyleBlendingDefault) { if (config.style == eStyleBlendingDefault) {
image = new cImage(cSize(width, height)); image = new cImage(cSize(width, height));
@ -243,22 +252,7 @@ cImage *cTimeLine::createBackgroundImage(int width, int height, tColor clrBgr, t
return image; return image;
} }
void cTimeLine::setTimeline() { bool cTimeLine::DrawClock(void) {
int offset = timeManager->GetTimelineOffset();
int xNew, yNew;
if (config.displayMode == eVertical) {
xNew = 0;
yNew = -offset*geoManager.minutePixel;
} else if (config.displayMode == eHorizontal) {
xNew = -offset*geoManager.minutePixel;
yNew = 0;
}
timeline->SetDrawPortPoint(cPoint(xNew, yNew));
if (config.displayTimeBase)
drawCurrentTimeBase();
}
bool cTimeLine::drawClock() {
cString currentTime = timeManager->GetCurrentTime(); cString currentTime = timeManager->GetCurrentTime();
if (strcmp(currentTime, lastClock)) { if (strcmp(currentTime, lastClock)) {
clock->Fill(clrTransparent); clock->Fill(clrTransparent);
@ -275,6 +269,7 @@ bool cTimeLine::drawClock() {
} }
clock->DrawText(cPoint((geoManager.clockWidth - clockTextWidth) / 2, (geoManager.clockHeight - textHeight) / 2), *currentTime, theme.Color(clrFont), colorFontBack, font); clock->DrawText(cPoint((geoManager.clockWidth - clockTextWidth) / 2, (geoManager.clockHeight - textHeight) / 2), *currentTime, theme.Color(clrFont), colorFontBack, font);
lastClock = currentTime; lastClock = currentTime;
DrawTimeIndicator();
return true; return true;
} }
return false; return false;

View File

@ -14,17 +14,16 @@ private:
cStyledPixmap *clock; cStyledPixmap *clock;
cPixmap *timeBase; cPixmap *timeBase;
cString lastClock; cString lastClock;
void decorateTile(int posX, int posY, int tileWidth, int tileHeight); void DecorateTile(int posX, int posY, int tileWidth, int tileHeight);
void drawRoundedCorners(int posX, int posY, int width, int height, int radius); void DrawRoundedCorners(int posX, int posY, int width, int height, int radius);
cImage *createBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend); cImage *CreateBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend);
public: public:
cTimeLine(cTimeManager *timeManager); cTimeLine(cTimeManager *timeManager);
virtual ~cTimeLine(void); virtual ~cTimeLine(void);
void setTimeline(void); void DrawDateViewer(void);
void drawDateViewer(void); void DrawTimeline(void);
void drawTimeline(void); void DrawTimeIndicator(void);
void drawCurrentTimeBase(void); bool DrawClock(void);
bool drawClock();
}; };
#endif //__TVGUIDE_TIMELINE_H #endif //__TVGUIDE_TIMELINE_H

View File

@ -112,9 +112,9 @@ void cTvGuideOsd::drawOsd() {
statusHeader->ScaleVideo(); statusHeader->ScaleVideo();
} }
timeLine = new cTimeLine(timeManager); timeLine = new cTimeLine(timeManager);
timeLine->drawDateViewer(); timeLine->DrawDateViewer();
timeLine->drawTimeline(); timeLine->DrawTimeline();
timeLine->drawClock(); timeLine->DrawClock();
channelGroups = new cChannelGroups(); channelGroups = new cChannelGroups();
channelGroups->ReadChannelGroups(); channelGroups->ReadChannelGroups();
footer = new cFooter(channelGroups); footer = new cFooter(channelGroups);
@ -374,12 +374,12 @@ void cTvGuideOsd::ScrollForward() {
timeManager->AddStep(config.stepMinutes); timeManager->AddStep(config.stepMinutes);
if (config.useHWAccel) { if (config.useHWAccel) {
drawGridsTimeJump(true); drawGridsTimeJump(true);
timeLine->drawDateViewer(); timeLine->DrawDateViewer();
timeLine->drawClock(); timeLine->DrawClock();
timeLine->setTimeline(); timeLine->DrawTimeline();
} else { } else {
timeLine->drawDateViewer(); timeLine->DrawDateViewer();
timeLine->setTimeline(); timeLine->DrawTimeline();
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) { for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
column->AddNewGridsAtEnd(); column->AddNewGridsAtEnd();
column->ClearOutdatedStart(); column->ClearOutdatedStart();
@ -413,12 +413,12 @@ void cTvGuideOsd::ScrollBack() {
timeManager->DelStep(config.stepMinutes); timeManager->DelStep(config.stepMinutes);
if (config.useHWAccel) { if (config.useHWAccel) {
drawGridsTimeJump(); drawGridsTimeJump();
timeLine->drawDateViewer(); timeLine->DrawDateViewer();
timeLine->drawClock(); timeLine->DrawClock();
timeLine->setTimeline(); timeLine->DrawTimeline();
} else { } else {
timeLine->drawDateViewer(); timeLine->DrawDateViewer();
timeLine->setTimeline(); timeLine->DrawTimeline();
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) { for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
column->AddNewGridsAtStart(); column->AddNewGridsAtStart();
column->ClearOutdatedEnd(); column->ClearOutdatedEnd();
@ -672,9 +672,9 @@ void cTvGuideOsd::TimeJump(int mode) {
return; return;
} }
drawGridsTimeJump(); drawGridsTimeJump();
timeLine->drawDateViewer(); timeLine->DrawDateViewer();
timeLine->drawClock(); timeLine->DrawClock();
timeLine->setTimeline(); timeLine->DrawTimeline();
osdManager.flush(); osdManager.flush();
} }
@ -786,10 +786,9 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) {
case kNone: if (channelJumper) CheckTimeout(); break; case kNone: if (channelJumper) CheckTimeout(); break;
default: break; default: break;
} }
if (timeLine->drawClock()) { if (timeLine->DrawClock()) {
timeLine->drawCurrentTimeBase();
osdManager.flush(); osdManager.flush();
} }
} }
if (!alreadyUnlocked) { if (!alreadyUnlocked) {
cPixmap::Unlock(); cPixmap::Unlock();