From 2d5e027d9c7614fa55a670b569d48340e6084515 Mon Sep 17 00:00:00 2001
From: Martin Schirrmacher <vdr.skinflatplus@schirrmacher.eu>
Date: Sun, 27 Aug 2017 14:49:01 +0200
Subject: - [update] use std::min & std:max

---
 HISTORY          |  3 ++-
 baserender.c     | 16 ++++++++--------
 displaychannel.c | 14 +++++++-------
 displaymenu.c    |  2 +-
 displaytracks.c  |  6 +++---
 5 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/HISTORY b/HISTORY
index 438fc07f..a4574847 100644
--- a/HISTORY
+++ b/HISTORY
@@ -2,7 +2,8 @@ VDR Plugin 'skinflatplus' Revision History
 ---------------------------------------
 
 201X-XX-XX: Version XXX
-- [fix] '%' sign not shown in menĂ¼ weather widget at certian font
+- [fix] '%' sign not shown in menu weather widget at certian font
+- [update] use std::min & std:max
 - [add] support for change color key mapping
 - [add] displaychannel show event start time on the left before event title
 
diff --git a/baserender.c b/baserender.c
index 8a38c8cb..17e2acec 100644
--- a/baserender.c
+++ b/baserender.c
@@ -385,9 +385,9 @@ void cFlatBaseRender::TopBarUpdate(void) {
         cString date = ShortDateString(t);
         int dateWidth = topBarFontSml->Width(*date);
 
-        Right = TopBarWidth - timeWidth - max(weekdayWidth, dateWidth) - marginItem;
-        topBarPixmap->DrawText(cPoint(Right, fontSmlTop), weekday, Theme.Color(clrTopBarDateFont), Theme.Color(clrTopBarBg), topBarFontSml, max(weekdayWidth, dateWidth), 0, taRight);
-        topBarPixmap->DrawText(cPoint(Right, fontSmlTop + topBarFontSmlHeight), date, Theme.Color(clrTopBarDateFont), Theme.Color(clrTopBarBg), topBarFontSml, max(weekdayWidth, dateWidth), 0, taRight);
+        Right = TopBarWidth - timeWidth - std::max(weekdayWidth, dateWidth) - marginItem;
+        topBarPixmap->DrawText(cPoint(Right, fontSmlTop), weekday, Theme.Color(clrTopBarDateFont), Theme.Color(clrTopBarBg), topBarFontSml, std::max(weekdayWidth, dateWidth), 0, taRight);
+        topBarPixmap->DrawText(cPoint(Right, fontSmlTop + topBarFontSmlHeight), date, Theme.Color(clrTopBarDateFont), Theme.Color(clrTopBarBg), topBarFontSml, std::max(weekdayWidth, dateWidth), 0, taRight);
 
         int middleWidth = 0;
         int numConflicts = 0;
@@ -462,7 +462,7 @@ void cFlatBaseRender::TopBarUpdate(void) {
 
         int extra1Width = topBarFontSml->Width(tobBarTitleExtra1);
         int extra2Width = topBarFontSml->Width(tobBarTitleExtra2);
-        int extraMaxWidth = max(extra1Width, extra2Width);
+        int extraMaxWidth = std::max(extra1Width, extra2Width);
         middleWidth += extraMaxWidth;
         Right -= extraMaxWidth + marginItem;
 
@@ -1106,8 +1106,8 @@ void cFlatBaseRender::ScrollbarDraw(cPixmap *Pixmap, int Left, int Top, int Heig
     if( !Pixmap )
         return;
 
-    int scrollHeight = max(int((Height) * double(Shown) / Total + 0.5), 5);
-    int scrollTop = min(int(Top + (Height) * double(Offset) / Total + 0.5), Top + Height - scrollHeight);
+    int scrollHeight = std::max(int((Height) * double(Shown) / Total + 0.5), 5);
+    int scrollTop = std::min(int(Top + (Height) * double(Offset) / Total + 0.5), Top + Height - scrollHeight);
 
     /* Types
      * 0 = left line + rect bar
@@ -1697,8 +1697,8 @@ void cFlatBaseRender::DrawWidgetWeather(void) {
 
     int left = marginItem;
 
-    int widthTempToday = max(weatherFontSml->Width(tempMaxToday.c_str()), weatherFontSml->Width(tempMinToday.c_str()) );
-    int widthTempTomorrow = max(weatherFontSml->Width(tempMaxTomorrow.c_str()), weatherFontSml->Width(tempMinTomorrow.c_str()) );
+    int widthTempToday = std::max(weatherFontSml->Width(tempMaxToday.c_str()), weatherFontSml->Width(tempMinToday.c_str()) );
+    int widthTempTomorrow = std::max(weatherFontSml->Width(tempMaxTomorrow.c_str()), weatherFontSml->Width(tempMinTomorrow.c_str()) );
 
     int wTop = topBarHeight + Config.decorBorderTopBarSize*2 + 20 + Config.decorBorderChannelEPGSize;
     int wWidth = marginItem + weatherFont->Width(tempToday.c_str()) + weatherFontSign->Width(tempTodaySign.c_str()) + marginItem*2 + weatherFont->Height() + marginItem \
diff --git a/displaychannel.c b/displaychannel.c
index ef9048db..d6fd6945 100644
--- a/displaychannel.c
+++ b/displaychannel.c
@@ -41,7 +41,7 @@ cFlatDisplayChannel::cFlatDisplayChannel(bool WithInfo) {
     heightBottom = (fontHeight*2) + (fontSmlHeight*2) + marginItem; // Top, Buttom, Between
     heightImageLogo = heightBottom;
     if( Config.SignalQualityShow )
-        heightBottom += max(fontSmlHeight, (Config.decorProgressSignalSize*2) + marginItem) + marginItem;
+        heightBottom += std::max(fontSmlHeight, (Config.decorProgressSignalSize*2) + marginItem) + marginItem;
     else if( Config.ChannelIconsShow )
         heightBottom += fontSmlHeight + marginItem;
 
@@ -367,7 +367,7 @@ void cFlatDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Followi
 
         epg = Present->Title();
         epgShort = Present->ShortText();
-        int maxWidth = max(timeStringWidth, seenWidth);
+        int maxWidth = std::max(timeStringWidth, seenWidth);
 
         chanInfoBottomPixmap->DrawText(cPoint(channelWidth - timeStringWidth - marginItem * 2, 0), *timeString,
             Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml, timeStringWidth, 0, taRight);
@@ -415,7 +415,7 @@ void cFlatDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Followi
         cString dur = cString::sprintf("%d min", Following->Duration() / 60);
         int durWidth = fontSml->Width(*dur) + fontSml->Width("  ");
 
-        int maxWidth = max(timeStringWidth, durWidth);
+        int maxWidth = std::max(timeStringWidth, durWidth);
 
         epg = Following->Title();
         epgShort = Following->ShortText();
@@ -514,10 +514,10 @@ void cFlatDisplayChannel::SignalQualityDraw(void) {
     cFont *SignalFont = cFont::CreateFont(Setup.FontOsd, Config.decorProgressSignalSize);
 
     int top = fontHeight*2 + fontSmlHeight*2 + marginItem;
-    top += max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem;
+    top += std::max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem;
     int left = marginItem * 2;
     int progressTop = fontHeight*2 + fontSmlHeight*2 + marginItem;
-    progressTop += max(fontSmlHeight, Config.decorProgressSignalSize) / 2 - Config.decorProgressSignalSize / 2;
+    progressTop += std::max(fontSmlHeight, Config.decorProgressSignalSize) / 2 - Config.decorProgressSignalSize / 2;
 
     progressTop = top;
 
@@ -585,7 +585,7 @@ void cFlatDisplayChannel::DvbapiInfoDraw(void) {
         return;
 
     int top = fontHeight*2 + fontSmlHeight*2 + marginItem;
-    top += max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem*2;
+    top += std::max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem*2;
     int left = BitrateRight + marginItem * 2;
     if (BitrateRight == 0 )
         left = SignalStrengthRight + marginItem * 2;
@@ -675,7 +675,7 @@ void cFlatDisplayChannel::PreLoadImages(void) {
             index++;
     }
 
-    height = max(fontSmlHeight, Config.decorProgressSignalSize);
+    height = std::max(fontSmlHeight, Config.decorProgressSignalSize);
     imgLoader.LoadIcon("crypted", 999, height);
     imgLoader.LoadIcon("uncrypted", 999, height);
     imgLoader.LoadIcon("unknown_asp", 999, height);
diff --git a/displaymenu.c b/displaymenu.c
index 56db135c..8a52adbc 100644
--- a/displaymenu.c
+++ b/displaymenu.c
@@ -2022,7 +2022,7 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index,
                 Left += fontHeight + marginItem;
             }
 
-            //int Minutes = max(0, (Recording->LengthInSeconds() + 30) / 60);
+            //int Minutes = std::max(0, (Recording->LengthInSeconds() + 30) / 60);
             int Minutes = (Recording->LengthInSeconds() + 30) / 60;
             cString Length = cString::sprintf("%02d:%02d", Minutes / 60, Minutes % 60);
             buffer = cString::sprintf("%s  %s  %s ", *ShortDateString(Recording->Start()), *TimeString(Recording->Start()), *Length);
diff --git a/displaytracks.c b/displaytracks.c
index 5db0bc31..7e9527e1 100644
--- a/displaytracks.c
+++ b/displaytracks.c
@@ -15,15 +15,15 @@ cFlatDisplayTracks::cFlatDisplayTracks(const char *Title, int NumTracks, const c
     if( img_stereo )
         stereoWidth = img_stereo->Width();
 
-    int imgWidthMax = max(ac3Width, stereoWidth);
+    int imgWidthMax = std::max(ac3Width, stereoWidth);
     itemHeight = fontHeight + Config.MenuItemPadding + Config.decorBorderTrackSize*2;
     currentIndex = -1;
     maxItemWidth = font->Width(Title) + marginItem*4;
     for (int i = 0; i < NumTracks; i++)
-        maxItemWidth = max(maxItemWidth, font->Width(Tracks[i]) + marginItem*2);
+        maxItemWidth = std::max(maxItemWidth, font->Width(Tracks[i]) + marginItem*2);
 
     int headerWidth = font->Width(Title) + font->Width(" ") + imgWidthMax;
-    maxItemWidth = max(maxItemWidth, headerWidth);
+    maxItemWidth = std::max(maxItemWidth, headerWidth);
 
     itemsHeight = (NumTracks+1) * itemHeight;
     int left = osdWidth - maxItemWidth;
-- 
cgit v1.2.3