diff options
author | Martin Schirrmacher <vdr.skinflatplus@schirrmacher.eu> | 2014-08-04 18:50:13 +0200 |
---|---|---|
committer | Martin Schirrmacher <vdr.skinflatplus@schirrmacher.eu> | 2014-08-04 18:50:13 +0200 |
commit | 65c2d52d64f2667e9238413a6d3ffc8a8ab5c603 (patch) | |
tree | 84c9b13a4cb931b9160eaf1e7626c8cdac173612 | |
parent | ea7abbd4c040a5b5041a329db0e5a2beb1b8a7fb (diff) | |
download | skin-flatplus-65c2d52d64f2667e9238413a6d3ffc8a8ab5c603.tar.gz skin-flatplus-65c2d52d64f2667e9238413a6d3ffc8a8ab5c603.tar.bz2 |
new hidden config ChannelBitrateShowCalcInterval
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | baserender.c | 36 | ||||
-rw-r--r-- | baserender.h | 2 | ||||
-rw-r--r-- | config.c | 1 | ||||
-rw-r--r-- | config.h | 2 | ||||
-rw-r--r-- | displaychannel.c | 3 | ||||
-rw-r--r-- | displayreplay.c | 14 | ||||
-rw-r--r-- | setup.c | 1 |
9 files changed, 54 insertions, 8 deletions
@@ -17,6 +17,7 @@ VDR Plugin 'skinflatplus' Revision History - [add] new option "TopBar clock font scale" to scale the clock font - [add] new option "Draw small seconds" to draw the seconds small in recording view - [add] new option "Show video/audio bitrate" to show the bitrate of audio/video in display channel (lent code from femon, thanks!) + new hidden config "ChannelBitrateShowCalcInterval" to set the interval of the video/audio bitrate calculation - [add] image _cur version for recording_cutted, recording_new, timer_full, timer_partial, vps if it is the current/selected menu item the cur version of the image will be loaded - [add] Support for scrollbar type and size like border and progressbar @@ -66,7 +66,7 @@ SOFILE = libvdr-$(PLUGIN).so ### Includes and Defines and Dependencies (add further entries here): -INCLUDES += $(shell pkg-config --cflags Magick++) +INCLUDES += $(shell pkg-config --cflags Magick++ freetype2 fontconfig) DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DVDRLOGO=\"$(VDRLOGO)\" diff --git a/baserender.c b/baserender.c index 1f1de37a..5548f6e9 100644 --- a/baserender.c +++ b/baserender.c @@ -2,6 +2,8 @@ #include "flat.h" #include <vdr/menu.h> #include "services/epgsearch.h" +#include <ft2build.h> +#include FT_FREETYPE_H cFlatBaseRender::cFlatBaseRender(void) { font = cFont::CreateFont(Setup.FontOsd, Setup.FontOsdSize ); @@ -1391,3 +1393,37 @@ void cFlatBaseRender::DecorDrawGlowEllipseBR(cPixmap *pixmap, int Left, int Top, } } +int cFlatBaseRender::GetFontBaseHeight(const char *Name, int CharHeight, int CharWidth) { + FT_Library library; + FT_Face face; + cString fontFileName = cFont::GetFontFileName(Name); + int baseHeight = CharHeight; + int error = FT_Init_FreeType(&library); + if (!error) { + error = FT_New_Face(library, fontFileName, 0, &face); + if (!error) { + if (face->num_fixed_sizes && face->available_sizes) { // fixed font + // TODO what exactly does all this mean? + baseHeight = face->available_sizes->height; + } else { + error = FT_Set_Char_Size(face, CharWidth * 64, CharHeight * 64, 0, 0); + if (!error) { + //dsyslog("base: %d asc: %d desc: %d", baseHeight, face->size->metrics.ascender, face->size->metrics.descender + 63); + baseHeight = (face->size->metrics.ascender) / 64; + //dsyslog("base: %d", baseHeight); + } + else + esyslog("ERROR: FreeType: error %d during FT_Set_Char_Size (font = %s)\n", error, *fontFileName); + } + } + else + esyslog("ERROR: FreeType: load error %d (font = %s)", error, *fontFileName); + } + else + esyslog("ERROR: FreeType: initialization error %d (font = %s)", error, *fontFileName); + + FT_Done_Face(face); + FT_Done_FreeType(library); + + return baseHeight; +} diff --git a/baserender.h b/baserender.h index 799def9c..16e3c5d4 100644 --- a/baserender.h +++ b/baserender.h @@ -166,4 +166,6 @@ class cFlatBaseRender void DecorBorderClearAll(void); void DecorBorderRedrawAll(void); void DecorBorderClearByFrom(int From); + + int GetFontBaseHeight(const char *Name, int CharHeight, int CharWidth = 0); }; @@ -256,6 +256,7 @@ bool cFlatConfig::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "ChannelBitrateShow") == 0) ChannelBitrateShow = atoi(Value); else if (strcmp(Name, "TopBarFontClockScale") == 0) TopBarFontClockScale = atod(Value); else if (strcmp(Name, "RecordingSmallSecs") == 0) RecordingSmallSecs = atoi(Value); + else if (strcmp(Name, "ChannelBitrateShowCalcInterval") == 0) ChannelBitrateShowCalcInterval = atoi(Value); else return false; @@ -196,7 +196,7 @@ class cFlatConfig int ChannelFormatShow; int ChannelSimpleAspectFormat; int ChannelBitrateShow; - int ChannelBitrateShowCalcInterval; + int ChannelBitrateShowCalcInterval; // hidden config int RecordingResolutionAspectShow; int RecordingFormatShow; int RecordingSimpleAspectFormat; diff --git a/displaychannel.c b/displaychannel.c index c1a7593b..87c8abdc 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -554,7 +554,7 @@ void cFlatDisplayChannel::BitrateDraw(void) { else bitrateText = cString::sprintf("Video: %.2f Mbit/s | Dolby: %.2f kbit/s", bitrateVideo / 1000000.0, bitrateDolby / 1000.0 ); - chanInfoBottomPixmap->DrawText(cPoint(left, top), bitrateText, Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), BitrateFont); + chanInfoBottomPixmap->DrawText(cPoint(left, top), bitrateText, Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), BitrateFont, BitrateFont->Width(bitrateText) * 2); delete SignalFont; delete BitrateFont; @@ -625,7 +625,6 @@ void cFlatDisplayChannel::Flush(void) { } if( Config.ChannelBitrateShow ) { - bitrateVideo = m_Receiver->VideoBitrate(); bitrateAudio = m_Receiver->AudioBitrate(); bitrateDolby = m_Receiver->AC3Bitrate(); diff --git a/displayreplay.c b/displayreplay.c index 5d81ed9a..9fabead8 100644 --- a/displayreplay.c +++ b/displayreplay.c @@ -30,7 +30,7 @@ cFlatDisplayReplay::cFlatDisplayReplay(bool ModeOnly) { labelJump->Fill(clrTransparent); iconsPixmap->Fill(clrTransparent); - fontSecs = cFont::CreateFont(Setup.FontOsd, Setup.FontOsdSize * 0.6); + fontSecs = cFont::CreateFont(Setup.FontOsd, Setup.FontOsdSize * 0.5); } cFlatDisplayReplay::~cFlatDisplayReplay() { @@ -149,6 +149,10 @@ void cFlatDisplayReplay::UpdateInfo(void) { cString cutted; bool iscutted = false; + int fontBaseHeight = GetFontBaseHeight(Setup.FontOsd, fontHeight); + int fontSecsBaseHeight = GetFontBaseHeight(Setup.FontOsd, fontSecs->Height()); + int topSecs = fontBaseHeight - fontSecsBaseHeight - (fontSecs->Height() - fontSecsBaseHeight); + const char *foundDot = strchr(current, '.'); if( foundDot != NULL || !Config.RecordingSmallSecs ) labelPixmap->DrawText(cPoint(marginItem, 0), current, Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), font, font->Width(current), fontHeight); @@ -160,7 +164,7 @@ void cFlatDisplayReplay::UpdateInfo(void) { std::string secs = cur.substr(found, cur.length() - found); labelPixmap->DrawText(cPoint(marginItem, 0), hm.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), font, font->Width(hm.c_str()), fontHeight); - labelPixmap->DrawText(cPoint(marginItem + font->Width(hm.c_str()), fontHeight - fontSecs->Height() - marginItem), secs.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), fontSecs, fontSecs->Width(secs.c_str()), fontSecs->Height()); + labelPixmap->DrawText(cPoint(marginItem + font->Width(hm.c_str()), topSecs), secs.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), fontSecs, fontSecs->Width(secs.c_str()), fontSecs->Height()); } else { labelPixmap->DrawText(cPoint(marginItem, 0), current, Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), font, font->Width(current), fontHeight); } @@ -235,6 +239,7 @@ void cFlatDisplayReplay::UpdateInfo(void) { } delete index; } + if( iscutted ) { cImage *imgRecCut = imgLoader.LoadIcon("recording_cutted_extra", fontHeight, fontHeight); int imgWidth = 0; @@ -287,7 +292,7 @@ void cFlatDisplayReplay::UpdateInfo(void) { std::string secs = cutt.substr(found, cutt.length() - found); labelPixmap->DrawText(cPoint(right - marginItem, 0), hm.c_str(), Theme.Color(clrMenuItemExtraTextFont), Theme.Color(clrReplayBg), font, font->Width(hm.c_str()), fontHeight); - labelPixmap->DrawText(cPoint(right - marginItem + font->Width(hm.c_str()), fontHeight - fontSecs->Height() - marginItem), secs.c_str(), Theme.Color(clrMenuItemExtraTextFont), Theme.Color(clrReplayBg), fontSecs, fontSecs->Width(secs.c_str()), fontSecs->Height()); + labelPixmap->DrawText(cPoint(right - marginItem + font->Width(hm.c_str()), fontHeight - fontBaseHeight + fontSecs->Height()), secs.c_str(), Theme.Color(clrMenuItemExtraTextFont), Theme.Color(clrReplayBg), fontSecs, fontSecs->Width(secs.c_str()), fontSecs->Height()); } else { labelPixmap->DrawText(cPoint(right - marginItem, 0), cutted, Theme.Color(clrMenuItemExtraTextFont), Theme.Color(clrReplayBg), font, font->Width(cutted), fontHeight); } @@ -296,6 +301,7 @@ void cFlatDisplayReplay::UpdateInfo(void) { } } else { int right = osdWidth - Config.decorBorderReplaySize*2 - font->Width(total); + if( Config.RecordingSmallSecs ) { std::string tot = *total; size_t found = tot.find_last_of(':'); @@ -305,7 +311,7 @@ void cFlatDisplayReplay::UpdateInfo(void) { right = osdWidth - Config.decorBorderReplaySize*2 - font->Width(hm.c_str()) - fontSecs->Width(secs.c_str()); labelPixmap->DrawText(cPoint(right - marginItem, 0), hm.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), font, font->Width(hm.c_str()), fontHeight); - labelPixmap->DrawText(cPoint(right - marginItem + font->Width(hm.c_str()), fontHeight - fontSecs->Height() - marginItem), secs.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), fontSecs, fontSecs->Width(secs.c_str()), fontSecs->Height()); + labelPixmap->DrawText(cPoint(right - marginItem + font->Width(hm.c_str()), fontHeight - fontBaseHeight), secs.c_str(), Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), fontSecs, fontSecs->Width(secs.c_str()), fontSecs->Height()); } else { labelPixmap->DrawText(cPoint(right - marginItem, 0), total, Theme.Color(clrReplayFont), Theme.Color(clrReplayBg), font, font->Width(total), fontHeight); } @@ -256,6 +256,7 @@ void cFlatSetup::Store(void) { SetupStore("TopBarFontClockScale", dtoa(Config.TopBarFontClockScale)); SetupStore("RecordingSmallSecs", Config.RecordingSmallSecs); SetupStore("ChannelBitrateShow", Config.ChannelBitrateShow); + SetupStore("ChannelBitrateShowCalcInterval", Config.ChannelBitrateShowCalcInterval); Config.Init(); } |