diff options
-rw-r--r-- | HISTORY | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | baserender.c | 2 | ||||
-rw-r--r-- | config.c | 7 | ||||
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | displaychannel.c | 3 | ||||
-rw-r--r-- | displaymenu.c | 97 | ||||
-rw-r--r-- | displaymenu.h | 2 | ||||
-rw-r--r-- | displayreplay.c | 3 | ||||
-rw-r--r-- | flat.h | 22 | ||||
-rw-r--r-- | icons/default/1080.png | bin | 1133 -> 0 bytes | |||
-rw-r--r-- | icons/default/480.png | bin | 1026 -> 0 bytes | |||
-rw-r--r-- | icons/default/576.png | bin | 1005 -> 0 bytes | |||
-rw-r--r-- | icons/default/704x576.png | bin | 0 -> 1200 bytes | |||
-rw-r--r-- | icons/default/720.png | bin | 944 -> 0 bytes | |||
-rw-r--r-- | imagecache.c | 2 | ||||
-rw-r--r-- | imageloader.c | 57 | ||||
-rw-r--r-- | setup.c | 2 |
18 files changed, 166 insertions, 38 deletions
@@ -20,6 +20,8 @@ VDR Plugin 'skinflatplus' Revision History - [add] add support for menu SetItemRecording (program menu) - [add] imagescaler from skin nopacity (thank you!) - [add] imagecache for faster image loading +- [add] option MenuItemRecordingClearPercent set to 1 to clear the '%' in recording names (you have an cut icon to detect cutted recordings) +- [add] option MenuItemRecordingShowFolderDate to show the date in the folder item from the newest/oldest recording in that folder (0 = disable, 1 = newest recording date, 2 = oldest recording date) 2013-11-24: Version 0.1.0 - MegaV0lt Version Special thanks to MegaV0lt@VDR-Portal for @@ -64,7 +64,7 @@ INCLUDES += $(shell pkg-config --cflags Magick++) # vdrlogo_yavdr VDRLOGO = vdrlogo_default -DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DVDRLOGO=\"$(VDRLOGO)\" +DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DVDRLOGO=\"$(VDRLOGO)\" -DDEBUGIMAGELOADTIME LIBS += $(shell pkg-config --libs Magick++) diff --git a/baserender.c b/baserender.c index 36935904..1204c530 100644 --- a/baserender.c +++ b/baserender.c @@ -859,7 +859,7 @@ void cFlatBaseRender::ProgressBarDrawMarks(int Current, int Total, const cMarks } int cFlatBaseRender::ProgressBarMarkPos(int P, int Total) { - return P * progressBarWidth / Total; + return (int64_t)P * progressBarWidth / Total; } void cFlatBaseRender::ProgressBarDrawMark(int posMark, int posMarkLast, int posCurrent, bool Start, bool isCurrent) @@ -47,6 +47,9 @@ cFlatConfig::cFlatConfig(void) { MenuEventView = 1; MenuRecordingView = 1; + MenuItemRecordingClearPercent = 1; + MenuItemRecordingShowFolderDate = 1; + decorBorderChannelByTheme = 1; decorBorderChannelTypeUser = 0; decorBorderChannelSizeUser = 0; @@ -186,7 +189,9 @@ bool cFlatConfig::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "MenuRecordingView") == 0) MenuRecordingView = atoi(Value); else if (strcmp(Name, "ChannelSimpleAspectFormat") == 0) ChannelSimpleAspectFormat = atoi(Value); else if (strcmp(Name, "RecordingSimpleAspectFormat") == 0) RecordingSimpleAspectFormat = atoi(Value); - + else if (strcmp(Name, "MenuItemRecordingClearPercent") == 0) MenuItemRecordingClearPercent = atoi(Value); + else if (strcmp(Name, "MenuItemRecordingShowFolderDate") == 0) MenuItemRecordingShowFolderDate = atoi(Value); + else return false; return true; @@ -182,5 +182,8 @@ class cFlatConfig int MenuEventView; int MenuRecordingView; + int MenuItemRecordingClearPercent; + int MenuItemRecordingShowFolderDate; // 0 = disable, 1 = newest recording date, 2 = oldest recording date + int DecorIndex; }; diff --git a/displaychannel.c b/displaychannel.c index 5bf02c55..6b579874 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -209,6 +209,9 @@ void cFlatDisplayChannel::ChannelIconsDraw(const cChannel *Channel, bool Resolut case 960: // 960x720 (HD720 DV) res = "960x720"; break; + case 704: // 704x576 (PAL) + res = "704x576"; + break; case 720: // 720x576 (PAL) res = "720x576"; break; diff --git a/displaymenu.c b/displaymenu.c index 3bdab0c6..f83a97c3 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -1373,26 +1373,6 @@ bool cFlatDisplayMenu::SetItemEvent(const cEvent *Event, int Index, bool Current return true; } -const char * cFlatDisplayMenu::GetRecordingName(const cRecording *Recording, int Level, bool isFolder) { - std::string recNamePart; - std::string recName = Recording->Name(); - try { - std::vector<std::string> tokens; - std::istringstream f(recName.c_str()); - std::string s; - while (std::getline(f, s, FOLDERDELIMCHAR)) { - tokens.push_back(s); - } - recNamePart = tokens.at(Level); - if(!isFolder && Recording->IsEdited() ) { - recNamePart = recNamePart.substr(1); - } - } catch (...) { - recNamePart = recName.c_str(); - } - return recNamePart.c_str(); -} - bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New) { if( Config.MenuRecordingView == 0 ) return false; @@ -1427,7 +1407,7 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, ColorBg = Theme.Color(clrItemBg); } } - + menuPixmap->DrawRectangle(cRect(Config.decorBorderMenuItemSize, y, menuItemWidth, Height), ColorBg); cImage *img = NULL; cImage *imgRecNew = imgLoader.LoadIcon("recording_new", fontHeight, fontHeight); @@ -1478,9 +1458,9 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, Left += img->Width() + marginItem; } - buffer = cString::sprintf("%d ", Total); - menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, font, menuItemWidth - Left - marginItem); - Left += font->Width( buffer ); + buffer = cString::sprintf(" %d", Total); + menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, font, font->Width(" 9999"), fontHeight, taRight); + Left += font->Width(" 9999 "); if( imgRecNew ) menuIconsPixmap->DrawImage( cPoint(Left, Top), *imgRecNew ); @@ -1488,11 +1468,13 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, buffer = cString::sprintf("%d", New); menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, font, menuItemWidth - Left - marginItem); Left += font->Width( buffer ); + if( Config.MenuItemRecordingShowFolderDate != 0 ) { + buffer = cString::sprintf(" (%s)", *ShortDateString(GetLastRecTimeFromFolder(Recording, Level))); + menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorExtraTextFg, ColorBg, font, menuItemWidth - Left - marginItem); + } menuPixmap->DrawText(cPoint(LeftWidth, Top), RecName, ColorFg, ColorBg, font, menuItemWidth - LeftWidth - marginItem); LeftWidth += font->Width(RecName) + marginItem*2; - buffer = cString::sprintf("(%s)", *ShortDateString(Recording->Start())); - menuPixmap->DrawText(cPoint(LeftWidth, Top), buffer, ColorExtraTextFg, ColorBg, font, menuItemWidth - LeftWidth - marginItem); } else if( Total == -1 ) { img = imgLoader.LoadIcon("folder", fontHeight, fontHeight); if( img ) { @@ -1544,21 +1526,23 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, Left += img->Width() + marginItem; } menuPixmap->DrawText(cPoint(Left, Top), RecName, ColorFg, ColorBg, font, menuItemWidth - Left - marginItem); - Left += font->Width(RecName) + marginItem*2; - buffer = cString::sprintf("(%s)", *ShortDateString(Recording->Start())); - menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorExtraTextFg, ColorBg, font, menuItemWidth - Left - marginItem); - Left -= font->Width(RecName) + marginItem*2; Top += fontHeight; - buffer = cString::sprintf("%d ", Total); - menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, fontSml, menuItemWidth - Left - marginItem); - Left += fontSml->Width( buffer ); + buffer = cString::sprintf(" %d", Total); + menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, fontSml, fontSml->Width(" 9999"), fontSmlHeight, taRight); + Left += fontSml->Width(" 9999 "); if( imgRecNewSml ) menuIconsPixmap->DrawImage( cPoint(Left, Top), *imgRecNewSml ); Left += imgRecNewSml->Width() + marginItem; buffer = cString::sprintf("%d", New); menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, fontSml, menuItemWidth - Left - marginItem); + Left += fontSml->Width( buffer ); + + if( Config.MenuItemRecordingShowFolderDate != 0 ) { + buffer = cString::sprintf(" (%s)", *ShortDateString(GetLastRecTimeFromFolder(Recording, Level))); + menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorExtraTextFg, ColorBg, fontSml, menuItemWidth - Left - marginItem); + } } else if( Total == -1 ) { img = imgLoader.LoadIcon("folder", fontHeight, fontHeight); if( img ) { @@ -2332,6 +2316,26 @@ void cFlatDisplayMenu::ItemBorderClear(void) { ItemsBorder.clear(); } +time_t cFlatDisplayMenu::GetLastRecTimeFromFolder(const cRecording *Recording, int Level) { + std::string RecFolder = GetRecordingName(Recording, Level, true); + time_t RecStart = Recording->Start(); + + for(cRecording *rec = Recordings.First(); rec; rec = Recordings.Next(rec)) { + std::string RecFolder2 = GetRecordingName(rec, Level, true); + if( RecFolder == RecFolder2 ) { // recordings must be in the same folder + time_t RecStart2 = rec->Start(); + if( Config.MenuItemRecordingShowFolderDate == 1) { // newest + if( RecStart2 > RecStart ) + RecStart = RecStart2; + } else if( Config.MenuItemRecordingShowFolderDate == 2 ) // oldest + if( RecStart2 < RecStart ) + RecStart = RecStart2; + } + } + + return RecStart; +} + // returns the string between start and end or an empty string if not found string cFlatDisplayMenu::xml_substring(string source, const char* str_start, const char* str_end) { size_t start = source.find(str_start); @@ -2343,3 +2347,30 @@ string cFlatDisplayMenu::xml_substring(string source, const char* str_start, con return string(); } + +const char * cFlatDisplayMenu::GetRecordingName(const cRecording *Recording, int Level, bool isFolder) { + std::string recNamePart; + std::string recName = Recording->Name(); + try { + std::vector<std::string> tokens; + std::istringstream f(recName.c_str()); + std::string s; + while (std::getline(f, s, FOLDERDELIMCHAR)) { + tokens.push_back(s); + } + recNamePart = tokens.at(Level); + if(!isFolder && Recording->IsEdited() ) { + recNamePart = recNamePart.substr(1); + } + } catch (...) { + recNamePart = recName.c_str(); + } + + if( Config.MenuItemRecordingClearPercent && isFolder ) { + if( recNamePart[0] == '%' ) { + recNamePart.erase(0, 1); + } + } + + return recNamePart.c_str(); +} diff --git a/displaymenu.h b/displaymenu.h index e88ef20e..52f82e3c 100644 --- a/displaymenu.h +++ b/displaymenu.h @@ -47,6 +47,8 @@ class cFlatDisplayMenu : public cFlatBaseRender, public cSkinDisplayMenu { const char * GetRecordingName(const cRecording *Recording, int Level, bool isFolder); string xml_substring(string source, const char* str_start, const char* str_end); + time_t GetLastRecTimeFromFolder(const cRecording *Recording, int Level); + void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown, bool isContent = false); int ItemsHeight(void); bool CheckProgressBar(const char *text); diff --git a/displayreplay.c b/displayreplay.c index c6ec4225..91b2b6a6 100644 --- a/displayreplay.c +++ b/displayreplay.c @@ -205,6 +205,9 @@ void cFlatDisplayReplay::ResolutionAspectDraw(void) { case 960: // 960x720 (HD720 DV) res = "960x720"; break; + case 704: // 704x576 (PAL) + res = "704x576"; + break; case 720: // 720x576 (PAL) res = "720x576"; break; @@ -1,5 +1,11 @@ #pragma once +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <unistd.h> +#include <stdint.h> + #include <vdr/skins.h> #include <vdr/videodir.h> @@ -183,3 +189,19 @@ class cFlat : public cSkin { virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks); virtual cSkinDisplayMessage *DisplayMessage(void); }; + +static inline uint32_t GetMsTicks(void) +{ +#ifdef CLOCK_MONOTONIC + struct timespec tspec; + + clock_gettime(CLOCK_MONOTONIC, &tspec); + return (tspec.tv_sec * 1000) + (tspec.tv_nsec / (1000 * 1000)); +#else + struct timeval tval; + + if (gettimeofday(&tval, NULL) < 0) + eturn 0; + return (tval.tv_sec * 1000) + (tval.tv_usec / 1000); +#endif +} diff --git a/icons/default/1080.png b/icons/default/1080.png Binary files differdeleted file mode 100644 index 8b8dffd6..00000000 --- a/icons/default/1080.png +++ /dev/null diff --git a/icons/default/480.png b/icons/default/480.png Binary files differdeleted file mode 100644 index acfcdadd..00000000 --- a/icons/default/480.png +++ /dev/null diff --git a/icons/default/576.png b/icons/default/576.png Binary files differdeleted file mode 100644 index d96f0ae9..00000000 --- a/icons/default/576.png +++ /dev/null diff --git a/icons/default/704x576.png b/icons/default/704x576.png Binary files differnew file mode 100644 index 00000000..1f204682 --- /dev/null +++ b/icons/default/704x576.png diff --git a/icons/default/720.png b/icons/default/720.png Binary files differdeleted file mode 100644 index 12fe7634..00000000 --- a/icons/default/720.png +++ /dev/null diff --git a/imagecache.c b/imagecache.c index 1ddc3e24..5453d7e2 100644 --- a/imagecache.c +++ b/imagecache.c @@ -29,7 +29,9 @@ void cImageCache::Clear(void) { } cImage* cImageCache::GetImage(std::string Name, int Width, int Height) { + //dsyslog("imagecache search for image %s Width %d Height %d", Name.c_str(), Width, Height); for(int index = 0; index < MAX_IMAGE_CACHE; index++ ) { + //dsyslog("imagecache index %d image %s Width %d Height %d", index, CacheName[index].c_str(), CacheWidth[index], CacheHeight[index]); if( CacheName[index] == Name && CacheWidth[index] == Width && CacheHeight[index] == Height ) return CacheImage[index]; } diff --git a/imageloader.c b/imageloader.c index 248ca671..24134531 100644 --- a/imageloader.c +++ b/imageloader.c @@ -21,22 +21,42 @@ cImage* cImageLoader::LoadLogo(const char *logo, int width, int height) { std::string logoLower = logo; toLowerCase(logoLower); cString File = cString::sprintf("%s/%s.%s", *Config.logoPath, logoLower.c_str(), *logoExtension); + #ifdef DEBUGIMAGELOADTIME + dsyslog("imageloader load logo %s", *File); + #endif cImage *img; + uint32_t tick1 = GetMsTicks(); img = imgCache.GetImage( *File, width, height ); + uint32_t tick2 = GetMsTicks(); + #ifdef DEBUGIMAGELOADTIME + dsyslog(" search in cache: %d ms", tick2 - tick1); + #endif if( img != NULL ) return img; + uint32_t tick3 = GetMsTicks(); bool success = LoadImage(File); + uint32_t tick4 = GetMsTicks(); if( !success ) { dsyslog("imageloader LoadLogo: %s could not be loaded", *File); return NULL; } + #ifdef DEBUGIMAGELOADTIME + dsyslog(" load file from disk: %d ms", tick4 - tick3); + #endif + uint32_t tick5 = GetMsTicks(); img = CreateImage(width, height); + uint32_t tick6 = GetMsTicks(); if( img == NULL ) return NULL; - imgCache.InsertImage(img, logoLower, width, height); + + #ifdef DEBUGIMAGELOADTIME + dsyslog(" scale logo: %d ms", tick6 - tick5); + #endif + + imgCache.InsertImage(img, *File, width, height); return img; } @@ -46,28 +66,61 @@ cImage* cImageLoader::LoadIcon(const char *cIcon, int width, int height, bool pr cString File = cString::sprintf("%s%s/%s.%s", *Config.iconPath, Setup.OSDTheme, cIcon, *logoExtension); + #ifdef DEBUGIMAGELOADTIME + dsyslog("imageloader load icon %s", *File); + #endif + cImage *img; + uint32_t tick1 = GetMsTicks(); img = imgCache.GetImage( *File, width, height ); + uint32_t tick2 = GetMsTicks(); + #ifdef DEBUGIMAGELOADTIME + dsyslog(" search in cache: %d ms", tick2 - tick1); + #endif if( img != NULL ) return img; + uint32_t tick3 = GetMsTicks(); bool success = LoadImage(File); + uint32_t tick4 = GetMsTicks(); + #ifdef DEBUGIMAGELOADTIME + dsyslog(" load file from disk: %d ms", tick4 - tick3); + #endif + if( !success ) { File = cString::sprintf("%s%s/%s.%s", *Config.iconPath, "default", cIcon, *logoExtension); + #ifdef DEBUGIMAGELOADTIME + dsyslog("imageloader load icon %s", *File); + #endif + uint32_t tick5 = GetMsTicks(); img = imgCache.GetImage( *File, width, height ); + uint32_t tick6 = GetMsTicks(); + #ifdef DEBUGIMAGELOADTIME + dsyslog(" search in cache: %d ms", tick6 - tick5); + #endif if( img != NULL ) return img; + uint32_t tick7 = GetMsTicks(); success = LoadImage(File); + uint32_t tick8 = GetMsTicks(); + #ifdef DEBUGIMAGELOADTIME + dsyslog(" load file from disk: %d ms", tick8 - tick7); + #endif if( !success ) { dsyslog("imageloader LoadIcon: %s could not be loaded", *File); return NULL; } } + uint32_t tick9 = GetMsTicks(); img = CreateImage(width, height); + uint32_t tick10 = GetMsTicks(); + #ifdef DEBUGIMAGELOADTIME + dsyslog(" scale logo: %d ms", tick10 - tick9); + #endif if( img == NULL ) return NULL; - imgCache.InsertImage(img, cIcon, width, height); + imgCache.InsertImage(img, *File, width, height); return img; } @@ -177,6 +177,8 @@ void cFlatSetup::Store(void) { SetupStore("MenuRecordingView", Config.MenuRecordingView); SetupStore("ChannelSimpleAspectFormat", Config.ChannelSimpleAspectFormat); SetupStore("RecordingSimpleAspectFormat", Config.RecordingSimpleAspectFormat); + SetupStore("MenuItemRecordingClearPercent", Config.MenuItemRecordingClearPercent); + SetupStore("MenuItemRecordingShowFolderDate", Config.MenuItemRecordingShowFolderDate); Config.Init(); } |