summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2014-10-18 10:05:32 +0200
committerlouis <louis.braun@gmx.de>2014-10-18 10:05:32 +0200
commit3d1a2f1090e5e2a1a2f69ec7fe518245078b6527 (patch)
tree6a8620bb61f2d883ad16c6ee7db262b266f9b199
parenta9f7a65578ea5ea1017d377d623c1171a33d67d3 (diff)
downloadvdr-plugin-skindesigner-3d1a2f1090e5e2a1a2f69ec7fe518245078b6527.tar.gz
vdr-plugin-skindesigner-3d1a2f1090e5e2a1a2f69ec7fe518245078b6527.tar.bz2
fixed bug that new skin was not properly loaded sometimes when skin was changed in OSD Setup menu
-rw-r--r--HISTORY1
-rw-r--r--config.c45
-rw-r--r--config.h7
-rw-r--r--designer.c144
-rw-r--r--designer.h10
5 files changed, 99 insertions, 108 deletions
diff --git a/HISTORY b/HISTORY
index 2a52538..8572342 100644
--- a/HISTORY
+++ b/HISTORY
@@ -24,3 +24,4 @@ Version 0.0.2
- implemented cSDDisplayMenu::GetTextAreaFont()
- introduced new viewelement audioinfo in displaychannel
- added setup option to choose Menu Item display method between "at one go" and "after one another"
+- fixed bug that new skin was not properly loaded sometimes when skin was changed in OSD Setup menu
diff --git a/config.c b/config.c
index 2f88ac5..45d8d3a 100644
--- a/config.c
+++ b/config.c
@@ -23,6 +23,10 @@ cDesignerConfig::cDesignerConfig() {
//menu display style, display menu items
//one after each other or in one step
blockFlush = 1;
+ //remember current skin and theme
+ SetSkin();
+ //remember osd size
+ SetOSDSize();
}
cDesignerConfig::~cDesignerConfig() {
@@ -101,6 +105,47 @@ void cDesignerConfig::CheckDecimalPoint(void) {
}
}
+void cDesignerConfig::SetSkin(void) {
+ osdSkin = Setup.OSDSkin;
+ osdTheme = Setup.OSDTheme;
+}
+
+bool cDesignerConfig::SkinChanged(void) {
+ bool changed = false;
+ if (osdSkin.compare(Setup.OSDSkin) != 0) {
+ dsyslog("skindesigner: skin changed from %s to %s", osdSkin.c_str(), Setup.OSDSkin);
+ changed = true;
+ }
+ if (osdTheme.compare(Setup.OSDTheme) != 0) {
+ dsyslog("skindesigner: theme changed from %s to %s", osdTheme.c_str(), Setup.OSDTheme);
+ changed = true;
+ }
+ if (changed)
+ SetSkin();
+ return changed;
+}
+
+void cDesignerConfig::SetOSDSize(void) {
+ osdSize.SetWidth(cOsd::OsdWidth());
+ osdSize.SetHeight(cOsd::OsdHeight());
+ osdSize.SetX(cOsd::OsdLeft());
+ osdSize.SetY(cOsd::OsdTop());
+}
+
+bool cDesignerConfig::OsdSizeChanged(void) {
+ if ((osdSize.Width() != cOsd::OsdWidth()) ||
+ (osdSize.Height() != cOsd::OsdHeight()) ||
+ (osdSize.X() != cOsd::OsdLeft()) ||
+ (osdSize.Y() != cOsd::OsdTop())) {
+ dsyslog("skindesigner: osd size changed");
+ dsyslog("skindesigner: old osd size: top %d left %d size %d * %d", osdSize.X(), osdSize.Y(), osdSize.Width(), osdSize.Height());
+ SetOSDSize();
+ dsyslog("skindesigner: new osd size: top %d left %d size %d * %d", osdSize.X(), osdSize.Y(), osdSize.Width(), osdSize.Height());
+ return true;
+ }
+ return false;
+}
+
cString cDesignerConfig::CheckSlashAtEnd(std::string path) {
try {
if (!(path.at(path.size()-1) == '/'))
diff --git a/config.h b/config.h
index afb6e17..4ff9aa9 100644
--- a/config.h
+++ b/config.h
@@ -16,6 +16,9 @@ private:
bool epgImagePathSet;
bool skinPathSet;
bool logoPathSet;
+ cRect osdSize;
+ string osdSkin;
+ string osdTheme;
public:
cDesignerConfig();
~cDesignerConfig();
@@ -29,6 +32,10 @@ public:
bool GetSkin(string &skin);
void SetChannelLogoSize(void);
void CheckDecimalPoint(void);
+ void SetSkin(void);
+ bool SkinChanged(void);
+ void SetOSDSize(void);
+ bool OsdSizeChanged(void);
cString logoExtension;
cString skinPath;
cString logoPath;
diff --git a/designer.c b/designer.c
index 0d4669d..6f07a00 100644
--- a/designer.c
+++ b/designer.c
@@ -7,7 +7,7 @@ cSkinDesigner::cSkinDesigner(string skin) : cSkin(skin.c_str(), &::Theme) {
backupSkin = NULL;
useBackupSkin = false;
-
+
globals = NULL;
channelTemplate = NULL;
menuTemplate = NULL;
@@ -15,6 +15,7 @@ cSkinDesigner::cSkinDesigner(string skin) : cSkin(skin.c_str(), &::Theme) {
replayTemplate = NULL;
volumeTemplate = NULL;
audiotracksTemplate = NULL;
+
dsyslog("skindesigner: skin %s started", skin.c_str());
}
@@ -30,43 +31,10 @@ const char *cSkinDesigner::Description(void) {
return skin.c_str();
}
-void cSkinDesigner::Init(void) {
- dsyslog("skindesigner: initializing skin %s", skin.c_str());
- SetOSDSize();
- osdSkin = Setup.OSDSkin;
- osdTheme = Setup.OSDTheme;
-
- config.SetChannelLogoSize();
- config.CheckDecimalPoint();
-
- if (fontManager)
- delete fontManager;
- fontManager = new cFontManager();
- if (imgCache)
- delete imgCache;
- imgCache = new cImageCache();
- imgCache->SetPathes();
-
- cStopWatch watch;
- bool ok = LoadTemplates();
- if (!ok) {
- esyslog("skindesigner: error during loading of templates - using LCARS as backup");
- backupSkin = new cSkinLCARS();
- useBackupSkin = true;
- } else {
- CacheTemplates();
- watch.Stop("templates loaded and cache created");
- }
- init = false;
-}
-
cSkinDisplayChannel *cSkinDesigner::DisplayChannel(bool WithInfo) {
- if (init) {
- Init();
- }
cSkinDisplayChannel *displayChannel = NULL;
if (!useBackupSkin) {
- ReloadCaches();
+ Init();
displayChannel = new cSDDisplayChannel(channelTemplate, WithInfo);
} else {
displayChannel = backupSkin->DisplayChannel(WithInfo);
@@ -75,12 +43,9 @@ cSkinDisplayChannel *cSkinDesigner::DisplayChannel(bool WithInfo) {
}
cSkinDisplayMenu *cSkinDesigner::DisplayMenu(void) {
- if (init) {
- Init();
- }
cSkinDisplayMenu *displayMenu = NULL;
if (!useBackupSkin) {
- ReloadCaches();
+ Init();
firstDisplay = false;
displayMenu = new cSDDisplayMenu(menuTemplate);
} else {
@@ -90,12 +55,9 @@ cSkinDisplayMenu *cSkinDesigner::DisplayMenu(void) {
}
cSkinDisplayReplay *cSkinDesigner::DisplayReplay(bool ModeOnly) {
- if (init) {
- Init();
- }
cSkinDisplayReplay *displayReplay = NULL;
if (!useBackupSkin) {
- ReloadCaches();
+ Init();
displayReplay = new cSDDisplayReplay(replayTemplate, ModeOnly);
} else {
displayReplay = backupSkin->DisplayReplay(ModeOnly);
@@ -104,12 +66,9 @@ cSkinDisplayReplay *cSkinDesigner::DisplayReplay(bool ModeOnly) {
}
cSkinDisplayVolume *cSkinDesigner::DisplayVolume(void) {
- if (init) {
- Init();
- }
cSkinDisplayVolume *displayVolume = NULL;
if (!useBackupSkin) {
- ReloadCaches();
+ Init();
displayVolume = new cSDDisplayVolume(volumeTemplate);
} else {
displayVolume = backupSkin->DisplayVolume();
@@ -118,12 +77,9 @@ cSkinDisplayVolume *cSkinDesigner::DisplayVolume(void) {
}
cSkinDisplayTracks *cSkinDesigner::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) {
- if (init) {
- Init();
- }
cSkinDisplayTracks *displayTracks = NULL;
if (!useBackupSkin) {
- ReloadCaches();
+ Init();
displayTracks = new cSDDisplayTracks(audiotracksTemplate, Title, NumTracks, Tracks);
} else {
displayTracks = backupSkin->DisplayTracks(Title, NumTracks, Tracks);
@@ -132,12 +88,9 @@ cSkinDisplayTracks *cSkinDesigner::DisplayTracks(const char *Title, int NumTrack
}
cSkinDisplayMessage *cSkinDesigner::DisplayMessage(void) {
- if (init) {
- Init();
- }
cSkinDisplayMessage *displayMessage = NULL;
if (!useBackupSkin) {
- ReloadCaches();
+ Init();
displayMessage = new cSDDisplayMessage(messageTemplate);
} else {
displayMessage = backupSkin->DisplayMessage();
@@ -204,6 +157,40 @@ void cSkinDesigner::ListCustomTokens(void) {
/*********************************************************************************
* PRIVATE FUNCTIONS
*********************************************************************************/
+void cSkinDesigner::Init(void) {
+ if (init || config.OsdSizeChanged() || config.SkinChanged()) {
+
+ if (init) {
+ config.SetSkin();
+ config.SetOSDSize();
+ }
+ dsyslog("skindesigner: initializing skin %s", skin.c_str());
+
+ config.SetChannelLogoSize();
+ config.CheckDecimalPoint();
+
+ if (fontManager)
+ delete fontManager;
+ fontManager = new cFontManager();
+ if (imgCache)
+ delete imgCache;
+ imgCache = new cImageCache();
+ imgCache->SetPathes();
+
+ cStopWatch watch;
+ bool ok = LoadTemplates();
+ if (!ok) {
+ esyslog("skindesigner: error during loading of templates - using LCARS as backup");
+ backupSkin = new cSkinLCARS();
+ useBackupSkin = true;
+ } else {
+ CacheTemplates();
+ watch.Stop("templates loaded and cache created");
+ }
+ init = false;
+ }
+}
+
void cSkinDesigner::DeleteTemplates(void) {
if (channelTemplate) {
delete channelTemplate;
@@ -232,7 +219,8 @@ void cSkinDesigner::DeleteTemplates(void) {
}
bool cSkinDesigner::LoadTemplates(void) {
-
+ if (globals)
+ delete globals;
globals = new cGlobals();
bool ok = globals->ReadFromXML();
if (!ok) {
@@ -333,47 +321,3 @@ void cSkinDesigner::CacheTemplates(void) {
imgCache->Debug(false);
}
-void cSkinDesigner::ReloadCaches(void) {
- if (OsdSizeChanged() || ThemeChanged()) {
- cStopWatch watch;
- bool ok = LoadTemplates();
- if (ok) {
- CacheTemplates();
- }
- watch.Stop("templates reloaded and cache recreated");
- }
-}
-
-void cSkinDesigner::SetOSDSize(void) {
- osdSize.SetWidth(cOsd::OsdWidth());
- osdSize.SetHeight(cOsd::OsdHeight());
- osdSize.SetX(cOsd::OsdLeft());
- osdSize.SetY(cOsd::OsdTop());
-}
-
-bool cSkinDesigner::OsdSizeChanged(void) {
- if ((osdSize.Width() != cOsd::OsdWidth()) ||
- (osdSize.Height() != cOsd::OsdHeight()) ||
- (osdSize.X() != cOsd::OsdLeft()) ||
- (osdSize.Y() != cOsd::OsdTop())) {
- dsyslog("skindesigner: osd size changed");
- dsyslog("skindesigner: old osd size: top %d left %d size %d * %d", osdSize.X(), osdSize.Y(), osdSize.Width(), osdSize.Height());
- SetOSDSize();
- dsyslog("skindesigner: new osd size: top %d left %d size %d * %d", osdSize.X(), osdSize.Y(), osdSize.Width(), osdSize.Height());
- return true;
- }
- return false;
-}
-
-bool cSkinDesigner::ThemeChanged(void) {
- bool changed = false;
- if (osdSkin.compare(Setup.OSDSkin) != 0) {
- osdSkin = Setup.OSDSkin;
- changed = true;
- }
- if (osdTheme.compare(Setup.OSDTheme) != 0) {
- osdTheme = Setup.OSDTheme;
- changed = true;
- }
- return changed;
-}
diff --git a/designer.h b/designer.h
index 3f0989e..2e2103b 100644
--- a/designer.h
+++ b/designer.h
@@ -18,9 +18,6 @@ private:
string skin;
cSkinLCARS *backupSkin;
bool useBackupSkin;
- cRect osdSize;
- std::string osdSkin;
- std::string osdTheme;
cGlobals *globals;
cTemplate *channelTemplate;
cTemplate *menuTemplate;
@@ -28,13 +25,11 @@ private:
cTemplate *replayTemplate;
cTemplate *volumeTemplate;
cTemplate *audiotracksTemplate;
- void DeleteTemplates(void);
+ void Init(void);
void ReloadCaches(void);
+ void DeleteTemplates(void);
bool LoadTemplates(void);
void CacheTemplates(void);
- void SetOSDSize(void);
- bool OsdSizeChanged(void);
- bool ThemeChanged(void);
public:
cSkinDesigner(string skin);
virtual ~cSkinDesigner(void);
@@ -45,7 +40,6 @@ public:
virtual cSkinDisplayVolume *DisplayVolume(void);
virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
virtual cSkinDisplayMessage *DisplayMessage(void);
- void Init(void);
void ActivateBackupSkin(void) { useBackupSkin = true; };
void Reload(void);
void ListAvailableFonts(void);