summaryrefslogtreecommitdiff
path: root/textwindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'textwindow.c')
-rw-r--r--textwindow.c149
1 files changed, 122 insertions, 27 deletions
diff --git a/textwindow.c b/textwindow.c
index 6e55ef9..013f19d 100644
--- a/textwindow.c
+++ b/textwindow.c
@@ -7,6 +7,7 @@ cNopacityTextWindow::cNopacityTextWindow(cOsd *osd, cFont *font, cRect *vidWin)
pixmapBackground = NULL;
pixmap = NULL;
scaledWindow = false;
+ hasPoster = false;
}
cNopacityTextWindow::~cNopacityTextWindow(void) {
@@ -32,16 +33,85 @@ cNopacityTextWindow::~cNopacityTextWindow(void) {
}
}
-bool cNopacityTextWindow::CreatePixmap(int border) {
+void cNopacityTextWindow::SetPoster(const cEvent *event, bool isRecording) {
+ static cPlugin *pTVScrapper = cPluginManager::GetPlugin("tvscrapper");
+ if (pTVScrapper && event) {
+ poster.event = event;
+ poster.isRecording = isRecording;
+ if (pTVScrapper->Service("TVScrapperGetPoster", &poster)) {
+ hasPoster = true;
+ int posterWidthOrig = poster.media.width;
+ int posterHeightOrig = poster.media.height;
+ posterHeight = geometry->Height() - 5;
+ posterWidth = posterWidthOrig * ((double)posterHeight / (double)posterHeightOrig);
+ } else {
+ hasPoster = false;
+ posterHeight = 0;
+ posterWidth = 0;
+ }
+ }
+}
+
+bool cNopacityTextWindow::SetTextScroller(int border, int left) {
int lineHeight = font->Height();
bool scrolling = false;
- twText.Set(*text, font, geometry->Width() - 2*border);
- int pixmapTotalHeight = lineHeight * (twText.Lines()+1);
- int drawportHeight = geometry->Height();
- if ((pixmapTotalHeight - (lineHeight/2)) > drawportHeight) {
- drawportHeight = pixmapTotalHeight;
- scrolling = true;
+ drawportHeight = geometry->Height();
+ if (!hasPoster) {
+ drawTextTall = false;
+ drawTextFull = true;
+ twTextTall.Set("", font, 5);
+ twTextFull.Set(*text, font, geometry->Width() - 2*border);
+ int pixmapTotalHeight = lineHeight * (twTextFull.Lines()+1);
+ if ((pixmapTotalHeight - (lineHeight/2)) > drawportHeight) {
+ drawportHeight = pixmapTotalHeight;
+ scrolling = true;
+ }
+ } else {
+ cTextWrapper test;
+ int widthTall = geometry->Width() - 2*border - left;
+ test.Set(*text, font, widthTall);
+ int linesTotal = test.Lines();
+ int textHeight = linesTotal * lineHeight;
+ if (textHeight > posterHeight) {
+ drawTextTall = true;
+ drawTextFull = true;
+ int lineSplit = posterHeight / lineHeight + 1;
+ std::stringstream textTall;
+ std::stringstream textFull;
+ for (int line = 0; line < linesTotal; line++) {
+ bool lineWrap = false;
+ if (font->Width(test.GetLine(line)) < (widthTall - 100))
+ lineWrap = true;
+ if (line < lineSplit) {
+ textTall << test.GetLine(line);
+ if (lineWrap)
+ textTall << "\n";
+ else
+ textTall << " ";
+ } else {
+ textFull << test.GetLine(line);
+ if (lineWrap)
+ textFull << "\n";
+ else
+ textFull << " ";
+ }
+ }
+ twTextTall.Set(textTall.str().c_str(), font, widthTall);
+ twTextFull.Set(textFull.str().c_str(), font, geometry->Width() - 2*border);
+ scrolling = true;
+ drawportHeight = lineHeight * (twTextTall.Lines() + twTextFull.Lines() + 1);
+ } else {
+ scrolling = false;
+ drawTextTall = true;
+ drawTextFull = false;
+ twTextTall.Set(*text, font, geometry->Width() - 2*border - left);
+ twTextFull.Set("", font, 5);
+ }
}
+ return scrolling;
+}
+
+void cNopacityTextWindow::CreatePixmap(void) {
cPixmap::Lock();
pixmapBackground = osd->CreatePixmap(4, cRect(geometry->X()-1, geometry->Y()-1, geometry->Width()+2, geometry->Height()+2));
pixmap = osd->CreatePixmap(5, cRect(geometry->X(), geometry->Y(), geometry->Width(), geometry->Height()),
@@ -52,27 +122,57 @@ bool cNopacityTextWindow::CreatePixmap(int border) {
pixmap->SetAlpha(0);
pixmap->Fill(Theme.Color(clrMenuBack));
cPixmap::Unlock();
- return scrolling;
}
-void cNopacityTextWindow::DrawText(int border) {
+void cNopacityTextWindow::DrawText(int border, int left) {
int lineHeight = font->Height();
int currentLineHeight = lineHeight/2;
tColor clrFontBack = (config.doBlending)?(clrTransparent):(Theme.Color(clrMenuBack));
cPixmap::Lock();
- for (int i=0; (i < twText.Lines()) && Running(); i++) {
- pixmap->DrawText(cPoint(border, currentLineHeight), twText.GetLine(i), Theme.Color(clrMenuFontDetailViewText), clrFontBack, font);
- currentLineHeight += lineHeight;
+ if (drawTextTall) {
+ for (int i=0; (i < twTextTall.Lines()) && Running(); i++) {
+ pixmap->DrawText(cPoint(border + left, currentLineHeight), twTextTall.GetLine(i), Theme.Color(clrMenuFontDetailViewText), clrFontBack, font);
+ currentLineHeight += lineHeight;
+ }
+ }
+ if (drawTextFull) {
+ for (int i=0; (i < twTextFull.Lines()) && Running(); i++) {
+ pixmap->DrawText(cPoint(border, currentLineHeight), twTextFull.GetLine(i), Theme.Color(clrMenuFontDetailViewText), clrFontBack, font);
+ currentLineHeight += lineHeight;
+ }
}
cPixmap::Unlock();
}
+void cNopacityTextWindow::DrawPoster(int border) {
+ cImageLoader imgLoader;
+ if (imgLoader.LoadPoster(poster.media.path.c_str(), posterWidth, posterHeight)) {
+ pixmap->DrawImage(cPoint(border, font->Height()), imgLoader.GetImage());
+ }
+}
+
void cNopacityTextWindow::DoSleep(int duration) {
int sleepSlice = 10;
for (int i = 0; Running() && (i*sleepSlice < duration); i++)
cCondWait::SleepMs(sleepSlice);
}
+void cNopacityTextWindow::ScaleVideoWindow(void) {
+ oldVidWin.SetX(vidWin->X());
+ oldVidWin.SetY(vidWin->Y());
+ oldVidWin.SetWidth(vidWin->Width());
+ oldVidWin.SetHeight(vidWin->Height());
+ cRect availableRect(vidWin->X(), vidWin->Y(), vidWin->Width(), vidWin->Height() - geometry->Height());
+ cRect vidWinNew = cDevice::PrimaryDevice()->CanScaleVideo(availableRect);
+ if (vidWinNew != cRect::Null) {
+ vidWin->SetX(vidWinNew.X());
+ vidWin->SetY(vidWinNew.Y());
+ vidWin->SetWidth(vidWinNew.Width());
+ vidWin->SetHeight(vidWinNew.Height());
+ scaledWindow = true;
+ }
+}
+
void cNopacityTextWindow::Action(void) {
if (! *text)
return;
@@ -80,28 +180,23 @@ void cNopacityTextWindow::Action(void) {
DoSleep(config.menuInfoTextDelay*1000);
if (config.scalePicture == 2) {
- oldVidWin.SetX(vidWin->X());
- oldVidWin.SetY(vidWin->Y());
- oldVidWin.SetWidth(vidWin->Width());
- oldVidWin.SetHeight(vidWin->Height());
- cRect availableRect(vidWin->X(), vidWin->Y(), vidWin->Width(), vidWin->Height() - geometry->Height());
- cRect vidWinNew = cDevice::PrimaryDevice()->CanScaleVideo(availableRect);
- if (vidWinNew != cRect::Null) {
- vidWin->SetX(vidWinNew.X());
- vidWin->SetY(vidWinNew.Y());
- vidWin->SetWidth(vidWinNew.Width());
- vidWin->SetHeight(vidWinNew.Height());
- scaledWindow = true;
- }
+ ScaleVideoWindow();
}
int border = 5;
+ int left = 0;
+ if (hasPoster)
+ left = 10 + posterWidth;
bool scrolling = false;
if (Running()) {
- scrolling = CreatePixmap(border);
+ scrolling = SetTextScroller(border, left);
+ CreatePixmap();
}
if (Running()) {
- DrawText(border);
+ DrawText(border, left);
+ }
+ if (Running() && hasPoster) {
+ DrawPoster(border);
}
//FadeIn
if (config.menuEPGWindowFadeTime) {