diff options
-rw-r--r-- | displaymenuview.c | 2 | ||||
-rw-r--r-- | imageloader.c | 36 | ||||
-rw-r--r-- | imageloader.h | 2 | ||||
-rw-r--r-- | menudetailview.c | 28 |
4 files changed, 64 insertions, 4 deletions
diff --git a/displaymenuview.c b/displaymenuview.c index fff3abf..70ae27c 100644 --- a/displaymenuview.c +++ b/displaymenuview.c @@ -620,7 +620,7 @@ void cNopacityDisplayMenuView::SetDetailViewSize(eDetailViewType detailViewType, detailHeaderHeight = max(config.detailViewLogoHeight, config.epgImageHeight)+4; break; case dvRecording: - detailHeaderHeight = contentHeight/5; + detailHeaderHeight = config.epgImageHeight + 4; break; case dvText: detailHeaderHeight = 0; diff --git a/imageloader.c b/imageloader.c index 3a9a0be..8b937fa 100644 --- a/imageloader.c +++ b/imageloader.c @@ -1,6 +1,8 @@ #include "imageloader.h" #include <math.h> #include <string> +#include <dirent.h> +#include <iostream> using namespace Magick; @@ -87,6 +89,22 @@ bool cImageLoader::LoadEPGImage(int eventID) { return true; } +bool cImageLoader::LoadRecordingImage(cString Path) { + int width = config.epgImageWidth; + int height = config.epgImageHeight; + if ((width == 0)||(height==0)) + return false; + cString recImage(""); + if (FirstImageInFolder(Path, "jpg", &recImage)) { + recImage = cString::sprintf("/%s", *recImage); + if (!LoadImage(*recImage, Path, "jpg")) + return false; + buffer.sample( Geometry(width, height)); + return true; + } + return false; +} + void cImageLoader::DrawBackground(tColor back, tColor blend, int width, int height) { Color Back = Argb2Color(back); Color Blend = Argb2Color(blend); @@ -155,3 +173,21 @@ bool cImageLoader::LoadImage(cString FileName, cString Path, cString Extension) } return true; } + +bool cImageLoader::FirstImageInFolder(cString Path, cString Extension, cString *recImage) { + DIR *folder; + struct dirent *file; + folder = opendir(Path); + while (file = readdir(folder)) { + if (endswith(file->d_name, *Extension)) { + std::string fileName = file->d_name; + if (fileName.length() > 4) + fileName = fileName.substr(0, fileName.length() - 4); + else + return false; + *recImage = fileName.c_str(); + return true; + } + } + return false; +}
\ No newline at end of file diff --git a/imageloader.h b/imageloader.h index 96d1fdd..5d22fd8 100644 --- a/imageloader.h +++ b/imageloader.h @@ -18,6 +18,7 @@ public: bool LoadIcon(const char *cIcon, int size); bool LoadIcon(const char *cIcon, int width, int height); bool LoadEPGImage(int eventID); + bool LoadRecordingImage(cString Path); void DrawBackground(tColor back, tColor blend, int width, int height); void DrawBackground2(tColor back, tColor blend, int width, int height); private: @@ -25,6 +26,7 @@ private: Color Argb2Color(tColor col); void toLowerCase(std::string &str); bool LoadImage(cString FileName, cString Path, cString Extension); + bool FirstImageInFolder(cString Path, cString Extension, cString *recImage); }; #endif //__NOPACITY_IMAGELOADER_H diff --git a/menudetailview.c b/menudetailview.c index 091a542..491da25 100644 --- a/menudetailview.c +++ b/menudetailview.c @@ -268,15 +268,37 @@ void cNopacityMenuDetailRecordingView::Render(void) { } void cNopacityMenuDetailRecordingView::DrawHeader(void) { + cImageLoader imgLoader; + int widthTextHeader = width - 4 * border; + if (imgLoader.LoadRecordingImage(recording->FileName())) { + pixmapHeader->DrawImage(cPoint(width - config.epgImageWidth - border, (headerHeight-config.epgImageHeight)/2), imgLoader.GetImage()); + widthTextHeader -= config.epgImageWidth; + } int lineHeight = fontHeaderLarge->Height(); cString dateTime = cString::sprintf("%s %s", *DateString(recording->Start()), *TimeString(recording->Start())); + pixmapHeader->DrawText(cPoint(2*border, (lineHeight - fontHeader->Height())/2), *dateTime, Theme.Color(clrMenuFontDetailViewHeader), clrTransparent, fontHeader); + const char *Title = info->Title(); if (isempty(Title)) Title = recording->Name(); - pixmapHeader->DrawText(cPoint(2*border, (lineHeight - fontHeader->Height())/2), *dateTime, Theme.Color(clrMenuFontDetailViewHeader), clrTransparent, fontHeader); - pixmapHeader->DrawText(cPoint(2*border, lineHeight), Title, Theme.Color(clrMenuFontDetailViewHeaderTitle), clrTransparent, fontHeaderLarge); + cTextWrapper title; + title.Set(Title, fontHeaderLarge, widthTextHeader); + int currentLineHeight = lineHeight; + for (int i=0; i < title.Lines(); i++) { + pixmapHeader->DrawText(cPoint(2*border, currentLineHeight), title.GetLine(i), Theme.Color(clrMenuFontDetailViewHeaderTitle), clrTransparent, fontHeaderLarge); + currentLineHeight += lineHeight; + } + if (!isempty(info->ShortText())) { - pixmapHeader->DrawText(cPoint(2*border, 2*lineHeight + (lineHeight - fontHeader->Height())/2), info->ShortText(), Theme.Color(clrMenuFontDetailViewHeader), clrTransparent, fontHeader); + cTextWrapper shortText; + shortText.Set(info->ShortText(), fontHeader, widthTextHeader); + for (int i=0; i < shortText.Lines(); i++) { + if ((currentLineHeight + fontHeader->Height()) < headerHeight) { + pixmapHeader->DrawText(cPoint(2*border, currentLineHeight), shortText.GetLine(i), Theme.Color(clrMenuFontDetailViewHeader), clrTransparent, fontHeader); + currentLineHeight += fontHeader->Height(); + } else + break; + } } } |