mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
fixed bug that new skin was not properly loaded sometimes when skin was changed in OSD Setup menu
This commit is contained in:
parent
a9f7a65578
commit
3d1a2f1090
1
HISTORY
1
HISTORY
@ -24,3 +24,4 @@ Version 0.0.2
|
|||||||
- implemented cSDDisplayMenu::GetTextAreaFont()
|
- implemented cSDDisplayMenu::GetTextAreaFont()
|
||||||
- introduced new viewelement audioinfo in displaychannel
|
- introduced new viewelement audioinfo in displaychannel
|
||||||
- added setup option to choose Menu Item display method between "at one go" and "after one another"
|
- 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
|
||||||
|
45
config.c
45
config.c
@ -23,6 +23,10 @@ cDesignerConfig::cDesignerConfig() {
|
|||||||
//menu display style, display menu items
|
//menu display style, display menu items
|
||||||
//one after each other or in one step
|
//one after each other or in one step
|
||||||
blockFlush = 1;
|
blockFlush = 1;
|
||||||
|
//remember current skin and theme
|
||||||
|
SetSkin();
|
||||||
|
//remember osd size
|
||||||
|
SetOSDSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
cDesignerConfig::~cDesignerConfig() {
|
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) {
|
cString cDesignerConfig::CheckSlashAtEnd(std::string path) {
|
||||||
try {
|
try {
|
||||||
if (!(path.at(path.size()-1) == '/'))
|
if (!(path.at(path.size()-1) == '/'))
|
||||||
|
7
config.h
7
config.h
@ -16,6 +16,9 @@ private:
|
|||||||
bool epgImagePathSet;
|
bool epgImagePathSet;
|
||||||
bool skinPathSet;
|
bool skinPathSet;
|
||||||
bool logoPathSet;
|
bool logoPathSet;
|
||||||
|
cRect osdSize;
|
||||||
|
string osdSkin;
|
||||||
|
string osdTheme;
|
||||||
public:
|
public:
|
||||||
cDesignerConfig();
|
cDesignerConfig();
|
||||||
~cDesignerConfig();
|
~cDesignerConfig();
|
||||||
@ -29,6 +32,10 @@ public:
|
|||||||
bool GetSkin(string &skin);
|
bool GetSkin(string &skin);
|
||||||
void SetChannelLogoSize(void);
|
void SetChannelLogoSize(void);
|
||||||
void CheckDecimalPoint(void);
|
void CheckDecimalPoint(void);
|
||||||
|
void SetSkin(void);
|
||||||
|
bool SkinChanged(void);
|
||||||
|
void SetOSDSize(void);
|
||||||
|
bool OsdSizeChanged(void);
|
||||||
cString logoExtension;
|
cString logoExtension;
|
||||||
cString skinPath;
|
cString skinPath;
|
||||||
cString logoPath;
|
cString logoPath;
|
||||||
|
144
designer.c
144
designer.c
@ -7,7 +7,7 @@ cSkinDesigner::cSkinDesigner(string skin) : cSkin(skin.c_str(), &::Theme) {
|
|||||||
|
|
||||||
backupSkin = NULL;
|
backupSkin = NULL;
|
||||||
useBackupSkin = false;
|
useBackupSkin = false;
|
||||||
|
|
||||||
globals = NULL;
|
globals = NULL;
|
||||||
channelTemplate = NULL;
|
channelTemplate = NULL;
|
||||||
menuTemplate = NULL;
|
menuTemplate = NULL;
|
||||||
@ -15,6 +15,7 @@ cSkinDesigner::cSkinDesigner(string skin) : cSkin(skin.c_str(), &::Theme) {
|
|||||||
replayTemplate = NULL;
|
replayTemplate = NULL;
|
||||||
volumeTemplate = NULL;
|
volumeTemplate = NULL;
|
||||||
audiotracksTemplate = NULL;
|
audiotracksTemplate = NULL;
|
||||||
|
|
||||||
dsyslog("skindesigner: skin %s started", skin.c_str());
|
dsyslog("skindesigner: skin %s started", skin.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,43 +31,10 @@ const char *cSkinDesigner::Description(void) {
|
|||||||
return skin.c_str();
|
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) {
|
cSkinDisplayChannel *cSkinDesigner::DisplayChannel(bool WithInfo) {
|
||||||
if (init) {
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
cSkinDisplayChannel *displayChannel = NULL;
|
cSkinDisplayChannel *displayChannel = NULL;
|
||||||
if (!useBackupSkin) {
|
if (!useBackupSkin) {
|
||||||
ReloadCaches();
|
Init();
|
||||||
displayChannel = new cSDDisplayChannel(channelTemplate, WithInfo);
|
displayChannel = new cSDDisplayChannel(channelTemplate, WithInfo);
|
||||||
} else {
|
} else {
|
||||||
displayChannel = backupSkin->DisplayChannel(WithInfo);
|
displayChannel = backupSkin->DisplayChannel(WithInfo);
|
||||||
@ -75,12 +43,9 @@ cSkinDisplayChannel *cSkinDesigner::DisplayChannel(bool WithInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cSkinDisplayMenu *cSkinDesigner::DisplayMenu(void) {
|
cSkinDisplayMenu *cSkinDesigner::DisplayMenu(void) {
|
||||||
if (init) {
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
cSkinDisplayMenu *displayMenu = NULL;
|
cSkinDisplayMenu *displayMenu = NULL;
|
||||||
if (!useBackupSkin) {
|
if (!useBackupSkin) {
|
||||||
ReloadCaches();
|
Init();
|
||||||
firstDisplay = false;
|
firstDisplay = false;
|
||||||
displayMenu = new cSDDisplayMenu(menuTemplate);
|
displayMenu = new cSDDisplayMenu(menuTemplate);
|
||||||
} else {
|
} else {
|
||||||
@ -90,12 +55,9 @@ cSkinDisplayMenu *cSkinDesigner::DisplayMenu(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cSkinDisplayReplay *cSkinDesigner::DisplayReplay(bool ModeOnly) {
|
cSkinDisplayReplay *cSkinDesigner::DisplayReplay(bool ModeOnly) {
|
||||||
if (init) {
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
cSkinDisplayReplay *displayReplay = NULL;
|
cSkinDisplayReplay *displayReplay = NULL;
|
||||||
if (!useBackupSkin) {
|
if (!useBackupSkin) {
|
||||||
ReloadCaches();
|
Init();
|
||||||
displayReplay = new cSDDisplayReplay(replayTemplate, ModeOnly);
|
displayReplay = new cSDDisplayReplay(replayTemplate, ModeOnly);
|
||||||
} else {
|
} else {
|
||||||
displayReplay = backupSkin->DisplayReplay(ModeOnly);
|
displayReplay = backupSkin->DisplayReplay(ModeOnly);
|
||||||
@ -104,12 +66,9 @@ cSkinDisplayReplay *cSkinDesigner::DisplayReplay(bool ModeOnly) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cSkinDisplayVolume *cSkinDesigner::DisplayVolume(void) {
|
cSkinDisplayVolume *cSkinDesigner::DisplayVolume(void) {
|
||||||
if (init) {
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
cSkinDisplayVolume *displayVolume = NULL;
|
cSkinDisplayVolume *displayVolume = NULL;
|
||||||
if (!useBackupSkin) {
|
if (!useBackupSkin) {
|
||||||
ReloadCaches();
|
Init();
|
||||||
displayVolume = new cSDDisplayVolume(volumeTemplate);
|
displayVolume = new cSDDisplayVolume(volumeTemplate);
|
||||||
} else {
|
} else {
|
||||||
displayVolume = backupSkin->DisplayVolume();
|
displayVolume = backupSkin->DisplayVolume();
|
||||||
@ -118,12 +77,9 @@ cSkinDisplayVolume *cSkinDesigner::DisplayVolume(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cSkinDisplayTracks *cSkinDesigner::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) {
|
cSkinDisplayTracks *cSkinDesigner::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) {
|
||||||
if (init) {
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
cSkinDisplayTracks *displayTracks = NULL;
|
cSkinDisplayTracks *displayTracks = NULL;
|
||||||
if (!useBackupSkin) {
|
if (!useBackupSkin) {
|
||||||
ReloadCaches();
|
Init();
|
||||||
displayTracks = new cSDDisplayTracks(audiotracksTemplate, Title, NumTracks, Tracks);
|
displayTracks = new cSDDisplayTracks(audiotracksTemplate, Title, NumTracks, Tracks);
|
||||||
} else {
|
} else {
|
||||||
displayTracks = backupSkin->DisplayTracks(Title, NumTracks, Tracks);
|
displayTracks = backupSkin->DisplayTracks(Title, NumTracks, Tracks);
|
||||||
@ -132,12 +88,9 @@ cSkinDisplayTracks *cSkinDesigner::DisplayTracks(const char *Title, int NumTrack
|
|||||||
}
|
}
|
||||||
|
|
||||||
cSkinDisplayMessage *cSkinDesigner::DisplayMessage(void) {
|
cSkinDisplayMessage *cSkinDesigner::DisplayMessage(void) {
|
||||||
if (init) {
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
cSkinDisplayMessage *displayMessage = NULL;
|
cSkinDisplayMessage *displayMessage = NULL;
|
||||||
if (!useBackupSkin) {
|
if (!useBackupSkin) {
|
||||||
ReloadCaches();
|
Init();
|
||||||
displayMessage = new cSDDisplayMessage(messageTemplate);
|
displayMessage = new cSDDisplayMessage(messageTemplate);
|
||||||
} else {
|
} else {
|
||||||
displayMessage = backupSkin->DisplayMessage();
|
displayMessage = backupSkin->DisplayMessage();
|
||||||
@ -204,6 +157,40 @@ void cSkinDesigner::ListCustomTokens(void) {
|
|||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
* PRIVATE FUNCTIONS
|
* 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) {
|
void cSkinDesigner::DeleteTemplates(void) {
|
||||||
if (channelTemplate) {
|
if (channelTemplate) {
|
||||||
delete channelTemplate;
|
delete channelTemplate;
|
||||||
@ -232,7 +219,8 @@ void cSkinDesigner::DeleteTemplates(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool cSkinDesigner::LoadTemplates(void) {
|
bool cSkinDesigner::LoadTemplates(void) {
|
||||||
|
if (globals)
|
||||||
|
delete globals;
|
||||||
globals = new cGlobals();
|
globals = new cGlobals();
|
||||||
bool ok = globals->ReadFromXML();
|
bool ok = globals->ReadFromXML();
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@ -333,47 +321,3 @@ void cSkinDesigner::CacheTemplates(void) {
|
|||||||
imgCache->Debug(false);
|
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;
|
|
||||||
}
|
|
||||||
|
10
designer.h
10
designer.h
@ -18,9 +18,6 @@ private:
|
|||||||
string skin;
|
string skin;
|
||||||
cSkinLCARS *backupSkin;
|
cSkinLCARS *backupSkin;
|
||||||
bool useBackupSkin;
|
bool useBackupSkin;
|
||||||
cRect osdSize;
|
|
||||||
std::string osdSkin;
|
|
||||||
std::string osdTheme;
|
|
||||||
cGlobals *globals;
|
cGlobals *globals;
|
||||||
cTemplate *channelTemplate;
|
cTemplate *channelTemplate;
|
||||||
cTemplate *menuTemplate;
|
cTemplate *menuTemplate;
|
||||||
@ -28,13 +25,11 @@ private:
|
|||||||
cTemplate *replayTemplate;
|
cTemplate *replayTemplate;
|
||||||
cTemplate *volumeTemplate;
|
cTemplate *volumeTemplate;
|
||||||
cTemplate *audiotracksTemplate;
|
cTemplate *audiotracksTemplate;
|
||||||
void DeleteTemplates(void);
|
void Init(void);
|
||||||
void ReloadCaches(void);
|
void ReloadCaches(void);
|
||||||
|
void DeleteTemplates(void);
|
||||||
bool LoadTemplates(void);
|
bool LoadTemplates(void);
|
||||||
void CacheTemplates(void);
|
void CacheTemplates(void);
|
||||||
void SetOSDSize(void);
|
|
||||||
bool OsdSizeChanged(void);
|
|
||||||
bool ThemeChanged(void);
|
|
||||||
public:
|
public:
|
||||||
cSkinDesigner(string skin);
|
cSkinDesigner(string skin);
|
||||||
virtual ~cSkinDesigner(void);
|
virtual ~cSkinDesigner(void);
|
||||||
@ -45,7 +40,6 @@ public:
|
|||||||
virtual cSkinDisplayVolume *DisplayVolume(void);
|
virtual cSkinDisplayVolume *DisplayVolume(void);
|
||||||
virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
|
virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
|
||||||
virtual cSkinDisplayMessage *DisplayMessage(void);
|
virtual cSkinDisplayMessage *DisplayMessage(void);
|
||||||
void Init(void);
|
|
||||||
void ActivateBackupSkin(void) { useBackupSkin = true; };
|
void ActivateBackupSkin(void) { useBackupSkin = true; };
|
||||||
void Reload(void);
|
void Reload(void);
|
||||||
void ListAvailableFonts(void);
|
void ListAvailableFonts(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user