1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 07:43:54 +02:00

ThemePrefs.cpp has fewer dependencies...

... Send an event via the app that projects listen to for theme update; don't
push it to projects directly.

This frees three files from dependency cycles.
This commit is contained in:
Paul Licameli
2019-05-13 03:39:08 -04:00
parent 519a988467
commit 7fc3adb54d
4 changed files with 27 additions and 15 deletions

View File

@@ -31,13 +31,15 @@ Provides:
#include "../Audacity.h"
#include "ThemePrefs.h"
#include <wx/app.h>
#include <wx/wxprec.h>
#include "../Prefs.h"
#include "../Theme.h"
#include "../Project.h"
#include "../ShuttleGui.h"
#include "../AColor.h"
wxDEFINE_EVENT(EVT_THEME_CHANGE, wxCommandEvent);
enum eThemePrefsIds {
idLoadThemeCache=7000,
idSaveThemeCache,
@@ -207,24 +209,12 @@ void ThemePrefs::OnSaveThemeAsCode(wxCommandEvent & WXUNUSED(event))
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();
}
wxCommandEvent e{ EVT_THEME_CHANGE };
wxTheApp->SafelyProcessEvent( e );
}
/// Update the preferences stored on disk.

View File

@@ -15,11 +15,16 @@
#define __AUDACITY_THEME_PREFS__
#include <wx/defs.h>
#include <wx/event.h> // to declare a custom event type
#include "PrefsPanel.h"
class ShuttleGui;
// An event sent to the application when the user changes choice of theme
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_THEME_CHANGE, wxCommandEvent);
#define THEME_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Theme") }
class ThemePrefs final : public PrefsPanel