summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-03-03 12:55:25 +0100
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-03-10 17:17:47 +0100
commitb386b8cab6beb65bfc8e5999273516762d0ee301 (patch)
tree23b1913c2029814e0a21e10c00b3890f866499c6
parent03337e57fdd83344d9b24ffcad394e76d5f92007 (diff)
downloadskin-nopacity-b386b8cab6beb65bfc8e5999273516762d0ee301.tar.gz
skin-nopacity-b386b8cab6beb65bfc8e5999273516762d0ee301.tar.bz2
Simplify cFontManager
Almost everything is done in the constructor and destructor of cFontManager. So we can delete most of the funktions in this class. This allows a new instance of fontmanager to be created after configuration changes.
-rw-r--r--fontmanager.c101
-rw-r--r--fontmanager.h16
-rw-r--r--nopacity.c7
-rw-r--r--setup.c4
4 files changed, 35 insertions, 93 deletions
diff --git a/fontmanager.c b/fontmanager.c
index 6715865..8666380 100644
--- a/fontmanager.c
+++ b/fontmanager.c
@@ -5,35 +5,7 @@
cFontManager *fontManager;
cFontManager::cFontManager() {
-}
-
-cFontManager::~cFontManager() {
- DeleteFonts();
-}
-
-void cFontManager::SetFonts() {
- SetFontsMenu();
- SetFontsChannel();
- SetFontsReplay();
- SetFontsMessage();
- SetFontsTrack();
- SetFontsVolume();
-}
-
-void cFontManager::DeleteFonts() {
- DeleteFontsMenu();
- DeleteFontsChannel();
- DeleteFontsReplay();
- DeleteFontsMessage();
- DeleteFontsTrack();
- DeleteFontsVolume();
-}
-
-cFont *cFontManager::CreateFont(int size) {
- return cFont::CreateFont(config.fontName, size);
-}
-
-void cFontManager::SetFontsMenu(void) {
+ // Menu fonts
menuHeader = CreateFont(geoManager->menuHeaderHeight / 2 + config.GetValue("fontHeader"));
menuDate = CreateFont(geoManager->menuHeaderHeight / 2 + config.GetValue("fontDate"));
menuItemLarge = CreateFont(geoManager->menuItemHeightMain/3 + 4 + config.GetValue("fontMenuitemLarge"));
@@ -54,9 +26,28 @@ void cFontManager::SetFontsMenu(void) {
menuMessage = CreateFont(geoManager->messageHeight / 3 + config.GetValue("fontMessageMenu"));
menuEPGInfoWindow = CreateFont(geoManager->menuContentHeight / 30 + config.GetValue("fontEPGInfoWindow"));
menuEPGInfoWindowLarge = CreateFont(geoManager->menuContentHeight / 20 + config.GetValue("fontEPGInfoWindowLarge"));
+ // Channel fonts
+ channelHeader = CreateFont(geoManager->channelHeaderHeight - 8 + config.GetValue("fontChannelHeaderSize"));
+ channelDate = CreateFont(geoManager->channelHeaderHeight/2 + config.GetValue("fontChannelDateSize"));
+ channelEPG = CreateFont(geoManager->channelEpgInfoLineHeight + config.GetValue("fontEPGSize"));
+ channelEPGSmall = CreateFont(geoManager->channelEpgInfoLineHeight - 6 + config.GetValue("fontEPGSmallSize"));
+ channelSourceInfo = CreateFont(geoManager->channelFooterHeight/2 + config.GetValue("fontChannelSourceInfoSize"));;
+ channelChannelGroup = CreateFont(geoManager->channelEpgInfoHeight/3 + config.GetValue("fontChannelGroupSize"));
+ channelChannelGroupSmall = CreateFont(geoManager->channelEpgInfoHeight/3 - 5 + config.GetValue("fontChannelGroupSmallSize"));
+ // Replay fonts
+ replayHeader = CreateFont(geoManager->replayHeaderHeight - 8 + config.GetValue("fontReplayHeader"));
+ replayText = CreateFont(geoManager->replayCurrentHeight);
+ //Message fonts
+ messageText = CreateFont(geoManager->messageHeight / 4 + 15 + config.GetValue("fontMessage"));
+ // Track fonts
+ trackText = CreateFont(geoManager->menuItemHeightTracks/3 + config.GetValue("fontTracks"));
+ trackHeader = CreateFont(geoManager->menuItemHeightTracks/2 + config.GetValue("fontTracksHeader"));
+ // Volume fonts
+ volumeText = CreateFont(geoManager->volumeLabelHeight - 6 + config.GetValue("fontVolume"));
}
-void cFontManager::DeleteFontsMenu(void) {
+cFontManager::~cFontManager() {
+ // Menu fonts
delete menuHeader;
delete menuDate;
delete menuItemLarge;
@@ -77,19 +68,7 @@ void cFontManager::DeleteFontsMenu(void) {
delete menuMessage;
delete menuEPGInfoWindow;
delete menuEPGInfoWindowLarge;
-}
-
-void cFontManager::SetFontsChannel(void) {
- channelHeader = CreateFont(geoManager->channelHeaderHeight - 8 + config.GetValue("fontChannelHeaderSize"));
- channelDate = CreateFont(geoManager->channelHeaderHeight/2 + config.GetValue("fontChannelDateSize"));
- channelEPG = CreateFont(geoManager->channelEpgInfoLineHeight + config.GetValue("fontEPGSize"));
- channelEPGSmall = CreateFont(geoManager->channelEpgInfoLineHeight - 6 + config.GetValue("fontEPGSmallSize"));
- channelSourceInfo = CreateFont(geoManager->channelFooterHeight/2 + config.GetValue("fontChannelSourceInfoSize"));;
- channelChannelGroup = CreateFont(geoManager->channelEpgInfoHeight/3 + config.GetValue("fontChannelGroupSize"));
- channelChannelGroupSmall = CreateFont(geoManager->channelEpgInfoHeight/3 - 5 + config.GetValue("fontChannelGroupSmallSize"));
-}
-
-void cFontManager::DeleteFontsChannel(void) {
+ // Channel fonts
delete channelHeader;
delete channelDate;
delete channelEPG;
@@ -97,40 +76,18 @@ void cFontManager::DeleteFontsChannel(void) {
delete channelSourceInfo;
delete channelChannelGroup;
delete channelChannelGroupSmall;
-}
-
-void cFontManager::SetFontsReplay(void) {
- replayHeader = CreateFont(geoManager->replayHeaderHeight - 8 + config.GetValue("fontReplayHeader"));
- replayText = CreateFont(geoManager->replayCurrentHeight);
-}
-
-void cFontManager::DeleteFontsReplay(void) {
+ // Replay fonts
delete replayHeader;
delete replayText;
-}
-
-void cFontManager::SetFontsMessage(void) {
- messageText = CreateFont(geoManager->messageHeight / 4 + 15 + config.GetValue("fontMessage"));
-}
-
-void cFontManager::DeleteFontsMessage(void) {
+ //Message fonts
delete messageText;
-}
-
-void cFontManager::SetFontsTrack(void) {
- trackText = CreateFont(geoManager->menuItemHeightTracks/3 + config.GetValue("fontTracks"));
- trackHeader = CreateFont(geoManager->menuItemHeightTracks/2 + config.GetValue("fontTracksHeader"));
-}
-
-void cFontManager::DeleteFontsTrack(void) {
+ // Track fonts
delete trackText;
delete trackHeader;
+ // Volume fonts
+ delete volumeText;
}
-void cFontManager::SetFontsVolume(void) {
- volumeText = CreateFont(geoManager->volumeLabelHeight - 6 + config.GetValue("fontVolume"));
-}
-
-void cFontManager::DeleteFontsVolume(void) {
- delete volumeText;
+cFont *cFontManager::CreateFont(int size) {
+ return cFont::CreateFont(config.fontName, size);
}
diff --git a/fontmanager.h b/fontmanager.h
index 7d3ef51..b285bcd 100644
--- a/fontmanager.h
+++ b/fontmanager.h
@@ -5,24 +5,10 @@
class cFontManager {
private:
- void SetFontsMenu(void);
- void DeleteFontsMenu(void);
- void SetFontsChannel(void);
- void DeleteFontsChannel(void);
- void SetFontsReplay(void);
- void DeleteFontsReplay(void);
- void SetFontsMessage(void);
- void DeleteFontsMessage(void);
- void SetFontsTrack(void);
- void DeleteFontsTrack(void);
- void SetFontsVolume(void);
- void DeleteFontsVolume(void);
+ cFont *CreateFont(int size);
public:
cFontManager();
~cFontManager();
- cFont *CreateFont(int size);
- void SetFonts(void);
- void DeleteFonts(void);
//Fonts DisplayMenu
cFont *menuHeader;
cFont *menuDate;
diff --git a/nopacity.c b/nopacity.c
index a4fcfb9..98c8a96 100644
--- a/nopacity.c
+++ b/nopacity.c
@@ -20,8 +20,7 @@ cNopacity::cNopacity(void) : cSkin("nOpacity", &::Theme) {
config.SetFontName();
geoManager = new cGeometryManager();
geoManager->SetGeometry();
- fontManager = new cFontManager();
- fontManager->SetFonts();
+ fontManager = NULL;
imgCache = new cImageCache();
imgCache->CreateCache();
}
@@ -78,8 +77,8 @@ void cNopacity::ReloadCaches(void) {
config.SetThemeSetup();
config.SetFontName();
geoManager->SetGeometry();
- fontManager->DeleteFonts();
- fontManager->SetFonts();
+ delete fontManager;
+ fontManager = new cFontManager();
imgCache->Reload();
dsyslog("nopacity: Cache reloaded in %d ms", int(cTimeMs::Now()-start));
}
diff --git a/setup.c b/setup.c
index 5258051..01eb97f 100644
--- a/setup.c
+++ b/setup.c
@@ -11,8 +11,8 @@ cNopacitySetup::~cNopacitySetup() {
config.SetFontName();
int start = cTimeMs::Now();
geoManager->SetGeometry();
- fontManager->DeleteFonts();
- fontManager->SetFonts();
+ delete fontManager;
+ fontManager = new cFontManager();
imgCache->Reload();
dsyslog("nopacity: Cache reloaded in %d ms", int(cTimeMs::Now()-start));
}