Audacity 3.2.0
Public Member Functions | Private Member Functions | List of all members
ThemePrefs Class Referencefinal

A PrefsPanel that configures dynamic loading of Theme icons and colours. More...

#include <ThemePrefs.h>

Inheritance diagram for ThemePrefs:
[legend]
Collaboration diagram for ThemePrefs:
[legend]

Public Member Functions

 ThemePrefs (wxWindow *parent, wxWindowID winid)
 
 ~ThemePrefs (void)
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
bool Commit () override
 Update the preferences stored on disk. More...
 
void Cancel () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void Populate ()
 Creates the dialog and its contents. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 Create the dialog contents, or exchange data with it. More...
 
void OnLoadThemeComponents (wxCommandEvent &e)
 Load Theme from multiple png files. More...
 
void OnSaveThemeComponents (wxCommandEvent &e)
 Save Theme to multiple png files. More...
 
void OnLoadThemeCache (wxCommandEvent &e)
 Load Theme from single png file. More...
 
void OnSaveThemeCache (wxCommandEvent &e)
 Save Themes, each to a single png file. More...
 
void OnReadThemeInternal (wxCommandEvent &e)
 Read Theme from internal storage. More...
 
void OnSaveThemeAsCode (wxCommandEvent &e)
 Save Theme as C source code. More...
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Detailed Description

A PrefsPanel that configures dynamic loading of Theme icons and colours.

Provides:

See also
Themability of Audacity

Definition at line 25 of file ThemePrefs.h.

Constructor & Destructor Documentation

◆ ThemePrefs()

ThemePrefs::ThemePrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 75 of file ThemePrefs.cpp.

80: PrefsPanel(parent, winid, XO("Theme"))
81{
82 Populate();
83}
XO("Cut/Copy/Paste")
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:94
void Populate()
Creates the dialog and its contents.
Definition: ThemePrefs.cpp:105

References Populate().

Here is the call graph for this function:

◆ ~ThemePrefs()

ThemePrefs::~ThemePrefs ( void  )

Definition at line 85 of file ThemePrefs.cpp.

86{
87}

Member Function Documentation

◆ Cancel()

void ThemePrefs::Cancel ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 253 of file ThemePrefs.cpp.

254{
258}
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void ApplyUpdatedImages()
Definition: AColor.cpp:860
void DeleteUnusedThemes()
static bool LoadPreferredTheme()
Definition: Theme.cpp:162

References AColor::ApplyUpdatedImages(), ThemeBase::DeleteUnusedThemes(), ThemeBase::LoadPreferredTheme(), and theTheme.

Here is the call graph for this function:

◆ Commit()

bool ThemePrefs::Commit ( )
overridevirtual

Update the preferences stored on disk.

Implements PrefsPanel.

Definition at line 242 of file ThemePrefs.cpp.

243{
246
250 return true;
251}
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
void PopulateOrExchange(ShuttleGui &S) override
Create the dialog contents, or exchange data with it.
Definition: ThemePrefs.cpp:119

References AColor::ApplyUpdatedImages(), ThemeBase::DeleteUnusedThemes(), eIsSavingToPrefs, ThemeBase::LoadPreferredTheme(), PopulateOrExchange(), S, and theTheme.

Here is the call graph for this function:

◆ GetDescription()

TranslatableString ThemePrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 94 of file ThemePrefs.cpp.

95{
96 return XO("Preferences for Theme");
97}

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol ThemePrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 89 of file ThemePrefs.cpp.

90{
92}
#define THEME_PREFS_PLUGIN_SYMBOL
Definition: ThemePrefs.h:23

References THEME_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID ThemePrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 99 of file ThemePrefs.cpp.

100{
101 return "Theme_Preferences";
102}

◆ OnLoadThemeCache()

void ThemePrefs::OnLoadThemeCache ( wxCommandEvent &  e)
private

Load Theme from single png file.

Definition at line 206 of file ThemePrefs.cpp.

207{
208 wxBusyCursor busy;
211}
void SwitchTheme(teThemeType Theme)
Definition: Theme.cpp:217

References AColor::ApplyUpdatedImages(), ThemeBase::SwitchTheme(), and theTheme.

Here is the call graph for this function:

◆ OnLoadThemeComponents()

void ThemePrefs::OnLoadThemeComponents ( wxCommandEvent &  e)
private

Load Theme from multiple png files.

Definition at line 189 of file ThemePrefs.cpp.

190{
191 wxBusyCursor busy;
194}
void LoadThemeComponents(bool bOkIfNotFound=false)
Definition: Theme.cpp:1032

References AColor::ApplyUpdatedImages(), ThemeBase::LoadThemeComponents(), and theTheme.

Here is the call graph for this function:

◆ OnReadThemeInternal()

void ThemePrefs::OnReadThemeInternal ( wxCommandEvent &  e)
private

Read Theme from internal storage.

Definition at line 224 of file ThemePrefs.cpp.

225{
226 wxBusyCursor busy;
229}
teThemeType GetFallbackThemeType()
Definition: Theme.cpp:889

References AColor::ApplyUpdatedImages(), ThemeBase::GetFallbackThemeType(), ThemeBase::SwitchTheme(), and theTheme.

Here is the call graph for this function:

◆ OnSaveThemeAsCode()

void ThemePrefs::OnSaveThemeAsCode ( wxCommandEvent &  e)
private

Save Theme as C source code.

Definition at line 232 of file ThemePrefs.cpp.

233{
234 if (!ConfirmSave())
235 return;
236 wxBusyCursor busy;
238 theTheme.WriteImageDefs();// bonus - give them the Defs too.
239}
static bool ConfirmSave()
Definition: ThemePrefs.cpp:60
void SaveThemeAsCode()
void WriteImageDefs()
Writes a series of Macro definitions that can be used in the include file.
Definition: Theme.cpp:847

References ConfirmSave(), ThemeBase::SaveThemeAsCode(), theTheme, and ThemeBase::WriteImageDefs().

Here is the call graph for this function:

◆ OnSaveThemeCache()

void ThemePrefs::OnSaveThemeCache ( wxCommandEvent &  e)
private

Save Themes, each to a single png file.

Definition at line 214 of file ThemePrefs.cpp.

215{
216 if (!ConfirmSave())
217 return;
218 wxBusyCursor busy;
220 theTheme.WriteImageMap();// bonus - give them the html version.
221}
void WriteImageMap()
Definition: Theme.cpp:786
void CreateImageCache()
Definition: Theme.cpp:614

References ConfirmSave(), ThemeBase::CreateImageCache(), theTheme, and ThemeBase::WriteImageMap().

Here is the call graph for this function:

◆ OnSaveThemeComponents()

void ThemePrefs::OnSaveThemeComponents ( wxCommandEvent &  e)
private

Save Theme to multiple png files.

Definition at line 197 of file ThemePrefs.cpp.

198{
199 if (!ConfirmSave())
200 return;
201 wxBusyCursor busy;
203}
void SaveThemeComponents()

References ConfirmSave(), ThemeBase::SaveThemeComponents(), and theTheme.

Here is the call graph for this function:

◆ Populate()

void ThemePrefs::Populate ( )
private

Creates the dialog and its contents.

Definition at line 105 of file ThemePrefs.cpp.

106{
107 // First any pre-processing for constructing the GUI.
108
109 //------------------------- Main section --------------------
110 // Now construct the GUI itself.
111 // Use 'eIsCreatingFromPrefs' so that the GUI is
112 // initialised with values from gPrefs.
115 // ----------------------- End of main section --------------
116}
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46

References eIsCreatingFromPrefs, PopulateOrExchange(), and S.

Referenced by ThemePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

void ThemePrefs::PopulateOrExchange ( ShuttleGui S)
overrideprivate

Create the dialog contents, or exchange data with it.

Definition at line 119 of file ThemePrefs.cpp.

120{
121 S.SetBorder(2);
122 S.StartScroller();
123
124 S.StartStatic(XO("Info"));
125 {
126 S.AddFixedText(
127 XO(
128"Themability is an experimental feature.\n\nTo try it out, click \"Save Theme Cache\" then find and modify the images and colors in\nImageCacheVxx.png using an image editor such as the Gimp.\n\nClick \"Load Theme Cache\" to load the changed images and colors back into Audacity.")
129 );
130
131#ifdef _DEBUG
132 S.AddFixedText(
133 Verbatim(
134"This is a debug version of Audacity, with an extra button, 'Output Sourcery'. This will save\nC versions of the image caches that can be compiled in as defaults.")
135 );
136#endif
137
138 S.AddFixedText(
139 XO(
140"Saving and loading individual theme files uses a separate file for each image, but is\notherwise the same idea.")
141 );
142 }
143 S.EndStatic();
144
145 /* i18n-hint: && in here is an escape character to get a single & on screen,
146 * so keep it as is */
147 S.StartStatic( XO("Theme Cache - Images && Color"));
148 {
149 S.StartHorizontalLay(wxALIGN_LEFT);
150 {
151 S.Id(idSaveThemeCache).AddButton(XXO("Save Theme Cache"));
152 S.Id(idLoadThemeCache).AddButton(XXO("Load Theme Cache"));
153
154 // This next button is only provided in Debug mode.
155 // It is for developers who are compiling Audacity themselves
156 // and who wish to generate NEW *ThemeAsCeeCode.h and compile them in.
157#ifdef _DEBUG
158 S.Id(idSaveThemeAsCode).AddButton(Verbatim("Output Sourcery"));
159#endif
160
161 S.Id(idReadThemeInternal).AddButton(XXO("&Defaults"));
162 }
163 S.EndHorizontalLay();
164 }
165 S.EndStatic();
166
167 // JKC: 'Ergonomic' details:
168 // Theme components are used much less frequently than
169 // the ImageCache. Yet it's easy to click them 'by mistake'.
170 //
171 // To reduce that risk, we use a separate box to separate them off.
172 // And choose text on the buttons that is shorter, making the
173 // buttons smaller and less tempting to click.
174 S.StartStatic( XO("Individual Theme Files"),1);
175 {
176 S.StartHorizontalLay(wxALIGN_LEFT);
177 {
178 S.Id(idSaveThemeComponents).AddButton( XXO("Save Files"));
179 S.Id(idLoadThemeComponents).AddButton( XXO("Load Files"));
180 }
181 S.EndHorizontalLay();
182 }
183 S.EndStatic();
184 S.EndScroller();
185
186}
XXO("&Cut/Copy/Paste Toolbar")
@ idLoadThemeComponents
Definition: ThemePrefs.cpp:45
@ idSaveThemeAsCode
Definition: ThemePrefs.cpp:48
@ idSaveThemeCache
Definition: ThemePrefs.cpp:44
@ idReadThemeInternal
Definition: ThemePrefs.cpp:47
@ idSaveThemeComponents
Definition: ThemePrefs.cpp:46
@ idLoadThemeCache
Definition: ThemePrefs.cpp:43
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.

References idLoadThemeCache, idLoadThemeComponents, idReadThemeInternal, idSaveThemeAsCode, idSaveThemeCache, idSaveThemeComponents, S, Verbatim(), XO(), and XXO().

Referenced by Commit(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: