From cb6c9ba9c25e4f265ea34a540e10e6735fbf6a99 Mon Sep 17 00:00:00 2001
From: kamel5 <vdr.kamel5 (at) gmx (dot) net>
Date: Wed, 3 Mar 2021 13:16:46 +0100
Subject: Simplify cGeometryManager

- Initiate osdLeft, osdTop, osdWidth and osdHeight with 0 in
cGeometryManager::cGeometryManager().

- cGeometryManager::GeometryChanged(void) is renamed
to cGeometryManager::SetOSDSize(void) and merged to set
osdLeft, osdTop, osdWidth and osdHeight to cOsd::*.

The cache is now created via cNopacity::SetOSDSize(void)
when the skin is started for the first time or when
the geometry is changed.

All SetDisplay*() were merged and moved to cGeometryManager::SetGeometry.
So we can delete then all unnecessary funktions.
---
 geometrymanager.c | 58 +++++++++++++++++++++----------------------------------
 geometrymanager.h |  9 +--------
 nopacity.c        |  2 +-
 3 files changed, 24 insertions(+), 45 deletions(-)

diff --git a/geometrymanager.c b/geometrymanager.c
index 9528061..08b1227 100644
--- a/geometrymanager.c
+++ b/geometrymanager.c
@@ -6,43 +6,34 @@
 cGeometryManager *geoManager;
 
 cGeometryManager::cGeometryManager() {
-    SetOSDSize();
+    osdLeft = 0;
+    osdTop = 0;
+    osdWidth = 0;
+    osdHeight = 0;
 }
 
 cGeometryManager::~cGeometryManager() {
 }
 
-void cGeometryManager::SetOSDSize(void) {
-    osdWidth = cOsd::OsdWidth();
-    osdHeight = cOsd::OsdHeight();
-    osdLeft = cOsd::OsdLeft();
-    osdTop = cOsd::OsdTop();
-}
-
-void cGeometryManager::SetGeometry(void) {
-    SetDisplayMenuSizes();
-    SetDisplayChannelSizes();
-    SetDisplayReplaySizes();
-    SetDisplayMessageSizes();
-    SetDisplayTrackSizes();
-    SetDisplayVolumeSizes();
-}
-
-bool cGeometryManager::GeometryChanged(void) {
+bool cGeometryManager::SetOSDSize(void) {
     if ((osdWidth != cOsd::OsdWidth()) ||
         (osdHeight != cOsd::OsdHeight()) ||
         (osdLeft != cOsd::OsdLeft()) ||
         (osdTop != cOsd::OsdTop())) {
         dsyslog("nopacity: osd Size changed");
         dsyslog("nopacity: old osd size: top %d left %d size %d * %d", osdLeft, osdTop, osdWidth, osdHeight);
-        SetOSDSize();
+        osdWidth = cOsd::OsdWidth();
+        osdHeight = cOsd::OsdHeight();
+        osdLeft = cOsd::OsdLeft();
+        osdTop = cOsd::OsdTop();
         dsyslog("nopacity: new osd size: top %d left %d size %d * %d", osdLeft, osdTop, osdWidth, osdHeight);
         return true;
     }
     return false;
 }
 
-void cGeometryManager::SetDisplayMenuSizes() {
+void cGeometryManager::SetGeometry(void) {
+    // DisplayMenu Sizes
     menuSpace = config.GetValue("spaceMenu");
 
     menuWidthScrollbar = config.GetValue("widthScrollbar");
@@ -81,12 +72,12 @@ void cGeometryManager::SetDisplayMenuSizes() {
     menuItemHeightTracks = config.GetValue("tracksItemHeight");
 
     menuMainMenuIconSize = menuItemHeightMain - 2 * menuSpace;
-    cSize logoSize = ScaleToFit(1000,
+    cSize menuLogoSize = ScaleToFit(1000,
                                 menuItemHeightSchedule - 2,
                                 config.GetValue("logoWidthOriginal"),
                                 config.GetValue("logoHeightOriginal"));
-    menuLogoWidth = logoSize.Width();
-    menuLogoHeight = logoSize.Height();
+    menuLogoWidth = menuLogoSize.Width();
+    menuLogoHeight = menuLogoSize.Height();
     
     cSize logoSizeVDRHeader = ScaleToFit(1000,
                                 menuHeaderHeight - 4,
@@ -106,9 +97,8 @@ void cGeometryManager::SetDisplayMenuSizes() {
                                 config.GetValue("logoHeightOriginal"));
     menuTimersLogoWidth = timersLogoSize.Width();
     menuTimersLogoHeight = timersLogoSize.Height();
-}
 
-void cGeometryManager::SetDisplayChannelSizes(void) {
+    // DisplayChannel Sizes
     channelX = config.GetValue("channelBorderVertical");
     channelWidth = osdWidth - 2 * config.GetValue("channelBorderVertical");
     channelHeight = osdHeight * config.GetValue("channelHeight") / 100;
@@ -128,12 +118,12 @@ void cGeometryManager::SetDisplayChannelSizes(void) {
     } else {
         logoMaxHeight = channelHeight - 2;
     }
-    cSize logoSize = ScaleToFit(logoMaxWidth,
+    cSize channelLogoSize = ScaleToFit(logoMaxWidth,
                                 logoMaxHeight,
                                 config.GetValue("logoWidthOriginal"),
                                 config.GetValue("logoHeightOriginal"));
-    channelLogoWidth = logoSize.Width();
-    channelLogoHeight = logoSize.Height();
+    channelLogoWidth = channelLogoSize.Width();
+    channelLogoHeight = channelLogoSize.Height();
     channelLogoX = (channelLogoWidthTotal - channelLogoWidth) / 2;
 
     switch (config.GetValue("logoVerticalAlignment")) {
@@ -170,9 +160,8 @@ void cGeometryManager::SetDisplayChannelSizes(void) {
     channelEpgInfoHeight = channelContentHeight - channelProgressBarHeight;
     channelEpgInfoLineHeight = channelEpgInfoHeight / 4;
     channelFooterY = channelTop + channelHeaderHeight + channelContentHeight;
-}
 
-void cGeometryManager::SetDisplayReplaySizes(void) {
+    // DisplayReplay Sizes
     replayHeight = osdHeight * config.GetValue("replayHeight") / 100;
     replayWidth = osdWidth - 2 * config.GetValue("replayBorderVertical");
     replayHeaderHeight = replayHeight * 0.2;
@@ -204,18 +193,15 @@ void cGeometryManager::SetDisplayReplaySizes(void) {
     replayMessageY = replayHeight - replayFooterHeight;
     replayMessageWidth = replayWidth * 75 / 100;
     replayMessageHeight = replayFooterHeight;
-}
 
-void cGeometryManager::SetDisplayMessageSizes(void) {
+    // DisplayMessage Sizes
     messageWidth = osdWidth * config.GetValue("messageWidth") / 100;
     messageHeight = osdHeight * config.GetValue("messageHeight") / 100;
-}
 
-void cGeometryManager::SetDisplayTrackSizes(void) {
+    // DisplayTrack Sizes
     trackWidth = osdWidth * config.GetValue("tracksWidth") / 100;
-}
 
-void cGeometryManager::SetDisplayVolumeSizes(void) {
+    // DisplayVolume Sizes
     volumeWidth = osdWidth * config.GetValue("volumeWidth") / 100;
     volumeHeight = osdHeight * config.GetValue("volumeHeight") / 100;
     volumeLabelHeight = volumeHeight/3;
diff --git a/geometrymanager.h b/geometrymanager.h
index 7db9084..08fce75 100644
--- a/geometrymanager.h
+++ b/geometrymanager.h
@@ -7,18 +7,11 @@ enum eBackgroundStyle {bsTrans = 0, bsFull};
 
 class cGeometryManager {
     private:
-        void SetOSDSize(void);
-        void SetDisplayMenuSizes(void);
-        void SetDisplayChannelSizes(void);
-        void SetDisplayReplaySizes(void);
-        void SetDisplayMessageSizes(void);
-        void SetDisplayTrackSizes(void);
-        void SetDisplayVolumeSizes(void);
     public:
         cGeometryManager();
         ~cGeometryManager();
+        bool SetOSDSize(void);
         void SetGeometry(void);
-        bool GeometryChanged(void);
         int osdWidth;
         int osdHeight;
         int osdLeft;
diff --git a/nopacity.c b/nopacity.c
index 98c8a96..073eb9b 100644
--- a/nopacity.c
+++ b/nopacity.c
@@ -70,7 +70,7 @@ cSkinDisplayMessage *cNopacity::DisplayMessage(void) {
 }
 
 void cNopacity::ReloadCaches(void) {
-    if (geoManager->GeometryChanged() || imgCache->ThemeChanged()) {
+    if (geoManager->SetOSDSize() || imgCache->ThemeChanged()) {
         int start = cTimeMs::Now();
         config.LoadDefaults();
         config.SetThemeSpecificDefaults();
-- 
cgit v1.2.3