1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

Theme.cpp has fewer dependencies...

It remains in a cycle with ImageManipulation, but the two are free from
other cycles
This commit is contained in:
Paul Licameli 2019-05-11 08:40:38 -04:00
parent 82f4948360
commit 4bdcf3152f
5 changed files with 26 additions and 27 deletions

View File

@ -72,13 +72,9 @@ can't be.
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/settings.h> #include <wx/settings.h>
#include "Project.h"
#include "toolbars/ToolManager.h"
#include "AllThemeResources.h" // can remove this later, only needed for 'XPMS_RETIRED'. #include "AllThemeResources.h" // can remove this later, only needed for 'XPMS_RETIRED'.
#include "FileNames.h" #include "FileNames.h"
#include "Prefs.h" #include "Prefs.h"
#include "AColor.h"
#include "AdornedRulerPanel.h"
#include "ImageManipulation.h" #include "ImageManipulation.h"
#include "widgets/ErrorDialog.h" #include "widgets/ErrorDialog.h"
@ -247,23 +243,6 @@ bool ThemeBase::LoadPreferredTheme()
return true; return true;
} }
void Theme::ApplyUpdatedImages()
{
AColor::ReInit();
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
AudacityProject *p = gAudacityProjects[i].get();
p->ApplyUpdatedTheme();
for( int ii = 0; ii < ToolBarCount; ++ii )
{
ToolBar *pToolBar = p->GetToolManager()->GetToolBar(ii);
if( pToolBar )
pToolBar->ReCreateButtons();
}
p->GetRulerPanel()->ReCreateButtons();
}
}
void Theme::RegisterImages() void Theme::RegisterImages()
{ {
if( mbInitialised ) if( mbInitialised )

View File

@ -102,7 +102,6 @@ public:
public: public:
virtual void EnsureInitialised()=0; virtual void EnsureInitialised()=0;
virtual void ApplyUpdatedImages()=0;
void LoadTheme( teThemeType Theme ); void LoadTheme( teThemeType Theme );
void RegisterImage( int &iIndex,char const** pXpm, const wxString & Name); void RegisterImage( int &iIndex,char const** pXpm, const wxString & Name);
void RegisterImage( int &iIndex, const wxImage &Image, const wxString & Name ); void RegisterImage( int &iIndex, const wxImage &Image, const wxString & Name );
@ -165,7 +164,6 @@ public:
~Theme(void); ~Theme(void);
public: public:
void EnsureInitialised() override; void EnsureInitialised() override;
void ApplyUpdatedImages() override;
void RegisterImages(); void RegisterImages();
void RegisterColours(); void RegisterColours();
bool mbInitialised; bool mbInitialised;

View File

@ -815,7 +815,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
// Reads preference /GUI/Theme // Reads preference /GUI/Theme
theTheme.LoadPreferredTheme(); theTheme.LoadPreferredTheme();
theTheme.ApplyUpdatedImages(); ThemePrefs::ApplyUpdatedImages();
SavePreferredPage(); SavePreferredPage();

View File

@ -170,7 +170,7 @@ void ThemePrefs::PopulateOrExchange(ShuttleGui & S)
void ThemePrefs::OnLoadThemeComponents(wxCommandEvent & WXUNUSED(event)) void ThemePrefs::OnLoadThemeComponents(wxCommandEvent & WXUNUSED(event))
{ {
theTheme.LoadComponents(); theTheme.LoadComponents();
theTheme.ApplyUpdatedImages(); ApplyUpdatedImages();
} }
/// Save Theme to multiple png files. /// Save Theme to multiple png files.
@ -183,7 +183,7 @@ void ThemePrefs::OnSaveThemeComponents(wxCommandEvent & WXUNUSED(event))
void ThemePrefs::OnLoadThemeCache(wxCommandEvent & WXUNUSED(event)) void ThemePrefs::OnLoadThemeCache(wxCommandEvent & WXUNUSED(event))
{ {
theTheme.ReadImageCache(); theTheme.ReadImageCache();
theTheme.ApplyUpdatedImages(); ApplyUpdatedImages();
} }
/// Save Theme to single png file. /// Save Theme to single png file.
@ -197,7 +197,7 @@ void ThemePrefs::OnSaveThemeCache(wxCommandEvent & WXUNUSED(event))
void ThemePrefs::OnReadThemeInternal(wxCommandEvent & WXUNUSED(event)) void ThemePrefs::OnReadThemeInternal(wxCommandEvent & WXUNUSED(event))
{ {
theTheme.ReadImageCache( theTheme.GetFallbackThemeType() ); theTheme.ReadImageCache( theTheme.GetFallbackThemeType() );
theTheme.ApplyUpdatedImages(); ApplyUpdatedImages();
} }
/// Save Theme as C source code. /// Save Theme as C source code.
@ -207,6 +207,26 @@ void ThemePrefs::OnSaveThemeAsCode(wxCommandEvent & WXUNUSED(event))
theTheme.WriteImageDefs();// bonus - give them the Defs too. theTheme.WriteImageDefs();// bonus - give them the Defs too.
} }
#include "../AdornedRulerPanel.h"
#include "../toolbars/ToolManager.h"
void ThemePrefs::ApplyUpdatedImages()
{
AColor::ReInit();
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
AudacityProject *p = gAudacityProjects[i].get();
p->ApplyUpdatedTheme();
for( int ii = 0; ii < ToolBarCount; ++ii )
{
ToolBar *pToolBar = p->GetToolManager()->GetToolBar(ii);
if( pToolBar )
pToolBar->ReCreateButtons();
}
p->GetRulerPanel()->ReCreateButtons();
}
}
/// Update the preferences stored on disk. /// Update the preferences stored on disk.
bool ThemePrefs::Commit() bool ThemePrefs::Commit()
{ {

View File

@ -33,6 +33,8 @@ class ThemePrefs final : public PrefsPanel
bool Commit() override; bool Commit() override;
wxString HelpPageName() override; wxString HelpPageName() override;
static void ApplyUpdatedImages();
private: private:
void Populate(); void Populate();
void PopulateOrExchange(ShuttleGui & S) override; void PopulateOrExchange(ShuttleGui & S) override;