mirror of
https://projects.vdr-developer.org/git/vdr-plugin-tvguide.git
synced 2023-10-05 15:01:48 +02:00
Refactor Timeline
This commit is contained in:
parent
efe06b8e98
commit
c77f74321f
@ -35,7 +35,7 @@ bool cGeometryManager::SetGeometry(int osdWidth, int osdHeight, bool force) {
|
||||
if (config.displayMode == eVertical) {
|
||||
colWidth = (osdWidth - timeLineWidth) / config.channelCols;
|
||||
rowHeight = 0;
|
||||
minutePixel = (osdHeight - statusHeaderHeight - channelGroupsHeight - channelHeaderHeight - footerHeight) / config.displayTime;
|
||||
minutePixel = (double)(osdHeight - statusHeaderHeight - channelGroupsHeight - channelHeaderHeight - footerHeight) / (double)config.displayTime;
|
||||
channelLogoWidth = colWidth;
|
||||
channelLogoHeight = channelHeaderHeight;
|
||||
logoWidth = channelLogoWidth / 2 - 15;
|
||||
@ -49,7 +49,7 @@ bool cGeometryManager::SetGeometry(int osdWidth, int osdHeight, bool force) {
|
||||
} else if (config.displayMode == eHorizontal) {
|
||||
colWidth = 0;
|
||||
rowHeight = (osdHeight - statusHeaderHeight - timeLineHeight - footerHeight) / config.channelRows;
|
||||
minutePixel = (osdWidth - channelHeaderWidth - channelGroupsWidth) / config.displayHorizontalTime;
|
||||
minutePixel = (double)(osdWidth - channelHeaderWidth - channelGroupsWidth) / (double)config.displayHorizontalTime;
|
||||
channelLogoWidth = channelHeaderWidth;
|
||||
channelLogoHeight = rowHeight;
|
||||
logoWidth = channelLogoHeight * config.logoWidthRatio / config.logoHeightRatio;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
//Content
|
||||
int colWidth;
|
||||
int rowHeight;
|
||||
int minutePixel;
|
||||
double minutePixel;
|
||||
int channelLogoWidth;
|
||||
int channelLogoHeight;
|
||||
//Timeline
|
||||
|
127
timeline.c
127
timeline.c
@ -5,33 +5,28 @@ cTimeLine::cTimeLine(cTimeManager *timeManager) {
|
||||
this->timeManager = timeManager;
|
||||
lastClock = "";
|
||||
timeBase = NULL;
|
||||
int x11, x21, y11, y21, x12, x22, y12, y22;
|
||||
if (config.displayMode == eVertical) {
|
||||
dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(0,
|
||||
geoManager.statusHeaderHeight + geoManager.clockHeight,
|
||||
geoManager.dateVieverWidth,
|
||||
geoManager.dateVieverHeight)));
|
||||
timeline = osdManager.requestPixmap(2, cRect(0,
|
||||
geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight,
|
||||
geoManager.timeLineWidth,
|
||||
geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)
|
||||
, cRect(0,
|
||||
0,
|
||||
geoManager.timeLineWidth,
|
||||
1440 * geoManager.minutePixel));
|
||||
x11 = 0;
|
||||
x21 = geoManager.dateVieverWidth;
|
||||
y11 = geoManager.statusHeaderHeight + geoManager.clockHeight;
|
||||
y21 = geoManager.dateVieverHeight;
|
||||
x12 = 0;
|
||||
x22 = geoManager.timeLineWidth;
|
||||
y12 = geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight;
|
||||
y22 = geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight;
|
||||
} else if (config.displayMode == eHorizontal) {
|
||||
dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(geoManager.clockWidth,
|
||||
geoManager.statusHeaderHeight,
|
||||
geoManager.dateVieverWidth,
|
||||
geoManager.dateVieverHeight)));
|
||||
timeline = osdManager.requestPixmap(2, cRect(geoManager.channelHeaderWidth + geoManager.channelGroupsWidth,
|
||||
geoManager.statusHeaderHeight,
|
||||
geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth,
|
||||
geoManager.timeLineHeight)
|
||||
, cRect(0,
|
||||
0,
|
||||
1440 * geoManager.minutePixel,
|
||||
geoManager.timeLineHeight));
|
||||
x11 = geoManager.clockWidth;
|
||||
x21 = geoManager.dateVieverWidth;
|
||||
y11 = geoManager.statusHeaderHeight;
|
||||
y21 = geoManager.dateVieverHeight;
|
||||
x12 = geoManager.channelHeaderWidth + geoManager.channelGroupsWidth;
|
||||
x22 = geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth;
|
||||
y12 = geoManager.statusHeaderHeight;
|
||||
y22 = 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,
|
||||
geoManager.statusHeaderHeight,
|
||||
geoManager.clockWidth,
|
||||
@ -43,10 +38,11 @@ cTimeLine::~cTimeLine(void) {
|
||||
delete clock;
|
||||
osdManager.releasePixmap(timeBase);
|
||||
osdManager.releasePixmap(timeline);
|
||||
if (dateViewer)
|
||||
delete dateViewer;
|
||||
}
|
||||
|
||||
void cTimeLine::drawDateViewer() {
|
||||
void cTimeLine::DrawDateViewer(void) {
|
||||
cString weekDay = timeManager->GetWeekday();
|
||||
cString date = timeManager->GetDate();
|
||||
if (config.style != eStyleGraphical) {
|
||||
@ -80,8 +76,8 @@ void cTimeLine::drawDateViewer() {
|
||||
}
|
||||
}
|
||||
|
||||
void cTimeLine::drawTimeline() {
|
||||
timeline->SetTile(true);
|
||||
void cTimeLine::DrawTimeline(void) {
|
||||
// timeline->SetTile(true);
|
||||
timeline->Fill(clrTransparent);
|
||||
tColor colorFont, colorBackground;
|
||||
|
||||
@ -93,8 +89,8 @@ void cTimeLine::drawTimeline() {
|
||||
img1 = imgCache.GetOsdElement(oeTimeline1);
|
||||
img2 = imgCache.GetOsdElement(oeTimeline2);
|
||||
} else {
|
||||
img1 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline1), theme.Color(clrTimeline1Blending));
|
||||
img2 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline2), theme.Color(clrTimeline2Blending));
|
||||
img1 = CreateBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline1), theme.Color(clrTimeline1Blending));
|
||||
img2 = CreateBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline2), theme.Color(clrTimeline2Blending));
|
||||
}
|
||||
const cImage *img = NULL;
|
||||
if (!img1 || !img2)
|
||||
@ -102,8 +98,19 @@ void cTimeLine::drawTimeline() {
|
||||
int textWidth, posX, posY;
|
||||
char timetext[10];
|
||||
|
||||
for (int i=0; i<48; i++) {
|
||||
if (i%2==0) {
|
||||
int halfHours;
|
||||
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;
|
||||
colorFont = theme.Color(clrTimeline2);
|
||||
colorBackground = (config.style == eStyleFlat)?theme.Color(clrTimeline1):clrTransparent;
|
||||
@ -111,11 +118,11 @@ void cTimeLine::drawTimeline() {
|
||||
if (i == 0)
|
||||
sprintf(timetext, "12:00 PM");
|
||||
else if (i/2 < 13)
|
||||
sprintf(timetext, "%d:00 AM", i/2);
|
||||
sprintf(timetext, "%d:00 AM", i / 2);
|
||||
else
|
||||
sprintf(timetext, "%d:00 PM", i/2-12);
|
||||
sprintf(timetext, "%d:00 PM", i / 2 - 12);
|
||||
} else {
|
||||
sprintf(timetext, "%d:00", i/2);
|
||||
sprintf(timetext, "%d:00", i / 2);
|
||||
}
|
||||
} else {
|
||||
img = img2;
|
||||
@ -125,38 +132,38 @@ void cTimeLine::drawTimeline() {
|
||||
if (i == 1)
|
||||
sprintf(timetext, "12:30 PM");
|
||||
else if (i/2 < 13)
|
||||
sprintf(timetext, "%d:30 AM", i/2);
|
||||
sprintf(timetext, "%d:30 AM", i / 2);
|
||||
else
|
||||
sprintf(timetext, "%d:30 PM", i/2-12);
|
||||
sprintf(timetext, "%d:30 PM", i / 2 - 12);
|
||||
} else {
|
||||
sprintf(timetext, "%d:30", i/2);
|
||||
sprintf(timetext, "%d:30", i / 2);
|
||||
}
|
||||
}
|
||||
if (config.displayMode == eVertical) {
|
||||
posY = i*geoManager.minutePixel*30;
|
||||
posY = (j - x) * geoManager.minutePixel * 30;
|
||||
timeline->DrawImage(cPoint(0, posY), *img);
|
||||
if (config.style != eStyleGraphical) {
|
||||
decorateTile(0, posY, imgWidth+2, imgHeight);
|
||||
DecorateTile(0, posY, imgWidth + 2, imgHeight);
|
||||
}
|
||||
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) {
|
||||
posX = i*geoManager.minutePixel*30;
|
||||
posX = (j - x) * geoManager.minutePixel * 30;
|
||||
timeline->DrawImage(cPoint(posX, 0), *img);
|
||||
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) {
|
||||
delete img1;
|
||||
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,2,tileHeight), clrTransparent); //left
|
||||
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) {
|
||||
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+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 (timeBase)
|
||||
timeBase->Fill(clrTransparent);
|
||||
return;
|
||||
}
|
||||
int deltaTime = (time(0) - timeManager->GetStart()) / 60 * geoManager.minutePixel;
|
||||
osdManager.releasePixmap(timeBase);
|
||||
int deltaTime = (timeManager->GetNow() - timeManager->GetStart()) / 60 * geoManager.minutePixel;
|
||||
int x1, x2, y1, y2;
|
||||
if (config.displayMode == eVertical) {
|
||||
x1 = 0;
|
||||
@ -214,7 +223,7 @@ void cTimeLine::drawCurrentTimeBase(void) {
|
||||
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;
|
||||
if (config.style == eStyleBlendingDefault) {
|
||||
image = new cImage(cSize(width, height));
|
||||
@ -243,22 +252,7 @@ cImage *cTimeLine::createBackgroundImage(int width, int height, tColor clrBgr, t
|
||||
return image;
|
||||
}
|
||||
|
||||
void cTimeLine::setTimeline() {
|
||||
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() {
|
||||
bool cTimeLine::DrawClock(void) {
|
||||
cString currentTime = timeManager->GetCurrentTime();
|
||||
if (strcmp(currentTime, lastClock)) {
|
||||
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);
|
||||
lastClock = currentTime;
|
||||
DrawTimeIndicator();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
15
timeline.h
15
timeline.h
@ -14,17 +14,16 @@ private:
|
||||
cStyledPixmap *clock;
|
||||
cPixmap *timeBase;
|
||||
cString lastClock;
|
||||
void decorateTile(int posX, int posY, int tileWidth, int tileHeight);
|
||||
void drawRoundedCorners(int posX, int posY, int width, int height, int radius);
|
||||
cImage *createBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend);
|
||||
void DecorateTile(int posX, int posY, int tileWidth, int tileHeight);
|
||||
void DrawRoundedCorners(int posX, int posY, int width, int height, int radius);
|
||||
cImage *CreateBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend);
|
||||
public:
|
||||
cTimeLine(cTimeManager *timeManager);
|
||||
virtual ~cTimeLine(void);
|
||||
void setTimeline(void);
|
||||
void drawDateViewer(void);
|
||||
void drawTimeline(void);
|
||||
void drawCurrentTimeBase(void);
|
||||
bool drawClock();
|
||||
void DrawDateViewer(void);
|
||||
void DrawTimeline(void);
|
||||
void DrawTimeIndicator(void);
|
||||
bool DrawClock(void);
|
||||
};
|
||||
|
||||
#endif //__TVGUIDE_TIMELINE_H
|
||||
|
35
tvguideosd.c
35
tvguideosd.c
@ -112,9 +112,9 @@ void cTvGuideOsd::drawOsd() {
|
||||
statusHeader->ScaleVideo();
|
||||
}
|
||||
timeLine = new cTimeLine(timeManager);
|
||||
timeLine->drawDateViewer();
|
||||
timeLine->drawTimeline();
|
||||
timeLine->drawClock();
|
||||
timeLine->DrawDateViewer();
|
||||
timeLine->DrawTimeline();
|
||||
timeLine->DrawClock();
|
||||
channelGroups = new cChannelGroups();
|
||||
channelGroups->ReadChannelGroups();
|
||||
footer = new cFooter(channelGroups);
|
||||
@ -374,12 +374,12 @@ void cTvGuideOsd::ScrollForward() {
|
||||
timeManager->AddStep(config.stepMinutes);
|
||||
if (config.useHWAccel) {
|
||||
drawGridsTimeJump(true);
|
||||
timeLine->drawDateViewer();
|
||||
timeLine->drawClock();
|
||||
timeLine->setTimeline();
|
||||
timeLine->DrawDateViewer();
|
||||
timeLine->DrawClock();
|
||||
timeLine->DrawTimeline();
|
||||
} else {
|
||||
timeLine->drawDateViewer();
|
||||
timeLine->setTimeline();
|
||||
timeLine->DrawDateViewer();
|
||||
timeLine->DrawTimeline();
|
||||
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
||||
column->AddNewGridsAtEnd();
|
||||
column->ClearOutdatedStart();
|
||||
@ -413,12 +413,12 @@ void cTvGuideOsd::ScrollBack() {
|
||||
timeManager->DelStep(config.stepMinutes);
|
||||
if (config.useHWAccel) {
|
||||
drawGridsTimeJump();
|
||||
timeLine->drawDateViewer();
|
||||
timeLine->drawClock();
|
||||
timeLine->setTimeline();
|
||||
timeLine->DrawDateViewer();
|
||||
timeLine->DrawClock();
|
||||
timeLine->DrawTimeline();
|
||||
} else {
|
||||
timeLine->drawDateViewer();
|
||||
timeLine->setTimeline();
|
||||
timeLine->DrawDateViewer();
|
||||
timeLine->DrawTimeline();
|
||||
for (cChannelEpg *column = columns.First(); column; column = columns.Next(column)) {
|
||||
column->AddNewGridsAtStart();
|
||||
column->ClearOutdatedEnd();
|
||||
@ -672,9 +672,9 @@ void cTvGuideOsd::TimeJump(int mode) {
|
||||
return;
|
||||
}
|
||||
drawGridsTimeJump();
|
||||
timeLine->drawDateViewer();
|
||||
timeLine->drawClock();
|
||||
timeLine->setTimeline();
|
||||
timeLine->DrawDateViewer();
|
||||
timeLine->DrawClock();
|
||||
timeLine->DrawTimeline();
|
||||
osdManager.flush();
|
||||
}
|
||||
|
||||
@ -786,8 +786,7 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) {
|
||||
case kNone: if (channelJumper) CheckTimeout(); break;
|
||||
default: break;
|
||||
}
|
||||
if (timeLine->drawClock()) {
|
||||
timeLine->drawCurrentTimeBase();
|
||||
if (timeLine->DrawClock()) {
|
||||
osdManager.flush();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user