2013-12-07 15:51:50 +01:00
|
|
|
#include "tools.h"
|
|
|
|
#include "services/tvscraper.h"
|
|
|
|
#include "imageloader.h"
|
2013-05-20 11:37:37 +02:00
|
|
|
#include "statusheader.h"
|
|
|
|
|
|
|
|
cStatusHeader::cStatusHeader(void) {
|
|
|
|
color = theme.Color(clrStatusHeader);
|
|
|
|
colorBlending = theme.Color(clrStatusHeaderBlending);
|
2013-12-21 11:25:03 +01:00
|
|
|
height = geoManager.statusHeaderHeight;
|
|
|
|
width = geoManager.statusHeaderContentWidth;
|
|
|
|
tvFrameWidth = geoManager.tvFrameWidth;
|
2013-05-20 11:37:37 +02:00
|
|
|
pixmap = osdManager.requestPixmap(1, cRect(0, 0, width, height));
|
|
|
|
pixmapText = osdManager.requestPixmap(2, cRect(0, 0, width, height));
|
2013-05-24 16:23:23 +02:00
|
|
|
pixmapTVFrame = osdManager.requestPixmap(1, cRect(width, 0, tvFrameWidth, height));
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cStatusHeader::~cStatusHeader(void) {
|
2013-05-24 16:23:23 +02:00
|
|
|
osdManager.releasePixmap(pixmapText);
|
|
|
|
osdManager.releasePixmap(pixmapTVFrame);
|
2013-05-20 11:37:37 +02:00
|
|
|
if (tvguideConfig.scaleVideo) {
|
|
|
|
cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(cRect::Null);
|
|
|
|
cDevice::PrimaryDevice()->ScaleVideo(vidWin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-21 11:25:03 +01:00
|
|
|
void cStatusHeader::Draw(void) {
|
|
|
|
pixmapText->Fill(clrTransparent);
|
|
|
|
pixmapTVFrame->Fill(clrTransparent);
|
|
|
|
if (tvguideConfig.style == eStyleGraphical) {
|
|
|
|
if (tvguideConfig.scaleVideo) {
|
|
|
|
drawBackgroundGraphical(bgStatusHeaderWindowed);
|
|
|
|
cImage *tvFrameBack = imgCache.GetOsdElement(oeStatusHeaderTVFrame);
|
|
|
|
if (tvFrameBack)
|
|
|
|
pixmapTVFrame->DrawImage(cPoint(0,0), *tvFrameBack);
|
|
|
|
} else {
|
|
|
|
drawBackgroundGraphical(bgStatusHeaderFull);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (tvguideConfig.decorateVideo) {
|
|
|
|
DecorateVideoFrame();
|
|
|
|
}
|
|
|
|
drawBackground();
|
|
|
|
drawBorder();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-20 11:37:37 +02:00
|
|
|
void cStatusHeader::ScaleVideo(void) {
|
|
|
|
if (tvguideConfig.scaleVideo) {
|
|
|
|
int width = height * 16 / 9;
|
2013-12-21 11:25:03 +01:00
|
|
|
int x = osdManager.Left() + geoManager.osdWidth - width;
|
2013-05-26 11:58:11 +02:00
|
|
|
int y = osdManager.Top();
|
2013-05-20 11:37:37 +02:00
|
|
|
cRect availableRect(x, y, width, height);
|
|
|
|
cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(availableRect);
|
|
|
|
cDevice::PrimaryDevice()->ScaleVideo(vidWin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cStatusHeader::DrawInfoText(cGrid *grid) {
|
2013-06-02 10:36:57 +02:00
|
|
|
int border = 10;
|
2013-12-21 11:25:03 +01:00
|
|
|
int textWidth = width - 2 * border - geoManager.clockWidth - 2;
|
|
|
|
tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent;
|
2013-05-20 11:37:37 +02:00
|
|
|
pixmapText->Fill(clrTransparent);
|
|
|
|
int x = border;
|
|
|
|
int y = border;
|
|
|
|
if (!grid->isDummy()) {
|
2013-08-25 13:57:10 +02:00
|
|
|
const cEvent *event = grid->GetEvent();
|
|
|
|
int newX = DrawPoster(event, x, y, height-2*border, border);
|
|
|
|
if (newX > 0) {
|
|
|
|
textWidth -= (newX - x);
|
|
|
|
x += newX;
|
|
|
|
}
|
2013-05-20 11:37:37 +02:00
|
|
|
cString time = grid->getTimeString();
|
|
|
|
cString title("");
|
|
|
|
title = cString::sprintf(": %s", event->Title());
|
|
|
|
cString header = cString::sprintf("%s%s", *time, *title);
|
2013-12-21 11:25:03 +01:00
|
|
|
header = CutText(*header, textWidth, fontManager.FontStatusHeaderLarge).c_str();
|
|
|
|
pixmapText->DrawText(cPoint(x,y), *header, theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeaderLarge);
|
|
|
|
y += fontManager.FontStatusHeaderLarge->Height() + border;
|
2013-05-20 11:37:37 +02:00
|
|
|
int heightText = pixmapText->ViewPort().Height() - y;
|
|
|
|
cTextWrapper description;
|
2013-12-21 11:25:03 +01:00
|
|
|
description.Set(event->Description(), fontManager.FontStatusHeader, textWidth);
|
|
|
|
int lineHeight = fontManager.FontStatusHeader->Height();
|
2013-05-20 11:37:37 +02:00
|
|
|
int textLines = description.Lines();
|
|
|
|
int maxLines = heightText / lineHeight;
|
|
|
|
int lines = min(textLines, maxLines);
|
|
|
|
for (int i = 0; i < lines-1; i++) {
|
2013-12-21 11:25:03 +01:00
|
|
|
pixmapText->DrawText(cPoint(x,y), description.GetLine(i), theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeader);
|
2013-05-20 11:37:37 +02:00
|
|
|
y += lineHeight;
|
|
|
|
}
|
|
|
|
cString lastLine = description.GetLine(lines-1);
|
|
|
|
if (textLines > maxLines) {
|
|
|
|
lastLine = cString::sprintf("%s...", *lastLine);
|
|
|
|
}
|
2013-12-21 11:25:03 +01:00
|
|
|
pixmapText->DrawText(cPoint(x,y), *lastLine, theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeader);
|
2013-05-20 11:37:37 +02:00
|
|
|
} else {
|
|
|
|
int heightText = pixmapText->ViewPort().Height() - y;
|
2013-12-21 11:25:03 +01:00
|
|
|
y += (heightText - fontManager.FontStatusHeaderLarge->Height() - 2*border)/2;
|
|
|
|
pixmapText->DrawText(cPoint(x,y), *grid->getText(), theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeaderLarge);
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
2013-05-24 16:23:23 +02:00
|
|
|
}
|
2013-08-25 13:57:10 +02:00
|
|
|
|
|
|
|
int cStatusHeader::DrawPoster(const cEvent *event, int x, int y, int height, int border) {
|
|
|
|
bool hasPoster = false;
|
|
|
|
TVScraperGetPoster poster;
|
|
|
|
int posterWidth = 0;
|
|
|
|
int posterHeight = 0;
|
|
|
|
if (event) {
|
|
|
|
static cPlugin *pTVScraper = cPluginManager::GetPlugin("tvscraper");
|
|
|
|
if (pTVScraper) {
|
|
|
|
poster.event = event;
|
|
|
|
poster.isRecording = false;
|
|
|
|
if (pTVScraper->Service("TVScraperGetPoster", &poster)) {
|
|
|
|
hasPoster = true;
|
|
|
|
int posterWidthOrig = poster.media.width;
|
|
|
|
int posterHeightOrig = poster.media.height;
|
|
|
|
if ((posterWidthOrig > 10) && (posterHeightOrig > 10)) {
|
|
|
|
posterHeight = height;
|
|
|
|
posterWidth = posterWidthOrig * ((double)posterHeight / (double)posterHeightOrig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasPoster) {
|
|
|
|
cImageLoader imgLoader;
|
|
|
|
if (imgLoader.LoadPoster(poster.media.path.c_str(), posterWidth, posterHeight)) {
|
|
|
|
pixmapText->DrawImage(cPoint(x, y), imgLoader.GetImage());
|
|
|
|
return posterWidth + border;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-21 11:25:03 +01:00
|
|
|
|
|
|
|
void cStatusHeader::DecorateVideoFrame(void) {
|
|
|
|
int radius = 16;
|
|
|
|
int frame = 10;
|
|
|
|
pixmapTVFrame->DrawRectangle(cRect(0, 0, tvFrameWidth, frame), theme.Color(clrBackground));
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(frame,frame,radius,radius), theme.Color(clrBackground), -2);
|
|
|
|
pixmapTVFrame->DrawRectangle(cRect(tvFrameWidth - frame, frame, frame, height - 2*frame), theme.Color(clrBackground));
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius - frame, frame, radius, radius), theme.Color(clrBackground), -1);
|
|
|
|
pixmapTVFrame->DrawRectangle(cRect(0, frame, frame, height - 2*frame), theme.Color(clrBackground));
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(frame, height - radius - frame, radius, radius), theme.Color(clrBackground), -3);
|
|
|
|
pixmapTVFrame->DrawRectangle(cRect(0, height - frame, tvFrameWidth, frame), theme.Color(clrBackground));
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius - frame, height - radius - frame, radius, radius), theme.Color(clrBackground), -4);
|
|
|
|
}
|