Audacity 3.2.0
ThemePrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ThemePrefs.cpp
6
7 James Crook
8
9 Audacity is free software.
10 This file is licensed under the wxWidgets license, see License.txt
11
12********************************************************************//********************************************************************/
30
31
32#include "ThemePrefs.h"
33
34#include <wx/app.h>
35#include <wx/wxprec.h>
36#include "Prefs.h"
37#include "Theme.h"
38#include "ShuttleGui.h"
39#include "AColor.h"
40#include "BasicUI.h"
41
49};
50
51BEGIN_EVENT_TABLE(ThemePrefs, PrefsPanel)
59
60ThemePrefs::ThemePrefs(wxWindow * parent, wxWindowID winid)
61/* i18n-hint: A theme is a consistent visual style across an application's
62 graphical user interface, including choices of colors, and similarity of images
63 such as those on button controls. Audacity can load and save alternative
64 themes. */
65: PrefsPanel(parent, winid, XO("Theme"))
66{
67 Populate();
68}
69
71{
72}
73
75{
77}
78
80{
81 return XO("Preferences for Theme");
82}
83
85{
86 return "Theme_Preferences";
87}
88
91{
92 // First any pre-processing for constructing the GUI.
93
94 //------------------------- Main section --------------------
95 // Now construct the GUI itself.
96 // Use 'eIsCreatingFromPrefs' so that the GUI is
97 // initialised with values from gPrefs.
100 // ----------------------- End of main section --------------
101}
102
105{
106 S.SetBorder(2);
107 S.StartScroller();
108
109 S.StartStatic(XO("Info"));
110 {
111 S.AddFixedText(
112 XO(
113"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.")
114 );
115
116#ifdef _DEBUG
117 S.AddFixedText(
118 Verbatim(
119"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.")
120 );
121#endif
122
123 S.AddFixedText(
124 XO(
125"Saving and loading individual theme files uses a separate file for each image, but is\notherwise the same idea.")
126 );
127 }
128 S.EndStatic();
129
130 /* i18n-hint: && in here is an escape character to get a single & on screen,
131 * so keep it as is */
132 S.StartStatic( XO("Theme Cache - Images && Color"));
133 {
134 S.StartHorizontalLay(wxALIGN_LEFT);
135 {
136 S.Id(idSaveThemeCache).AddButton(XXO("Save Theme Cache"));
137 S.Id(idLoadThemeCache).AddButton(XXO("Load Theme Cache"));
138
139 // This next button is only provided in Debug mode.
140 // It is for developers who are compiling Audacity themselves
141 // and who wish to generate NEW *ThemeAsCeeCode.h and compile them in.
142#ifdef _DEBUG
143 S.Id(idSaveThemeAsCode).AddButton(Verbatim("Output Sourcery"));
144#endif
145
146 S.Id(idReadThemeInternal).AddButton(XXO("&Defaults"));
147 }
148 S.EndHorizontalLay();
149 }
150 S.EndStatic();
151
152 // JKC: 'Ergonomic' details:
153 // Theme components are used much less frequently than
154 // the ImageCache. Yet it's easy to click them 'by mistake'.
155 //
156 // To reduce that risk, we use a separate box to separate them off.
157 // And choose text on the buttons that is shorter, making the
158 // buttons smaller and less tempting to click.
159 S.StartStatic( XO("Individual Theme Files"),1);
160 {
161 S.StartHorizontalLay(wxALIGN_LEFT);
162 {
163 S.Id(idSaveThemeComponents).AddButton( XXO("Save Files"));
164 S.Id(idLoadThemeComponents).AddButton( XXO("Load Files"));
165 }
166 S.EndHorizontalLay();
167 }
168 S.EndStatic();
169 S.EndScroller();
170
171}
172
174void ThemePrefs::OnLoadThemeComponents(wxCommandEvent & WXUNUSED(event))
175{
176 wxBusyCursor busy;
179}
180
182void ThemePrefs::OnSaveThemeComponents(wxCommandEvent & WXUNUSED(event))
183{
184 wxBusyCursor busy;
186}
187
189void ThemePrefs::OnLoadThemeCache(wxCommandEvent & WXUNUSED(event))
190{
191 wxBusyCursor busy;
194}
195
197void ThemePrefs::OnSaveThemeCache(wxCommandEvent & WXUNUSED(event))
198{
199 wxBusyCursor busy;
201 theTheme.WriteImageMap();// bonus - give them the html version.
202}
203
205void ThemePrefs::OnReadThemeInternal(wxCommandEvent & WXUNUSED(event))
206{
207 wxBusyCursor busy;
210}
211
213void ThemePrefs::OnSaveThemeAsCode(wxCommandEvent & WXUNUSED(event))
214{
215 wxBusyCursor busy;
217 theTheme.WriteImageDefs();// bonus - give them the Defs too.
218}
219
222{
225
229 return true;
230}
231
233{
237}
238
239#ifdef EXPERIMENTAL_THEME_PREFS
240namespace{
242 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
243 {
244 wxASSERT(parent); // to justify safenew
245 return safenew ThemePrefs(parent, winid);
246 },
247 false,
248 // Register with an explicit ordering hint because this one is
249 // only conditionally compiled
250 { "", { Registry::OrderingHint::After, "Effects" } }
251};
252}
253#endif
Toolkit-neutral facade for basic user interface services.
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:9
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
THEME_API Theme theTheme
Definition: Theme.cpp:82
eThemePrefsIds
Definition: ThemePrefs.cpp:42
@ 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
#define THEME_PREFS_PLUGIN_SYMBOL
Definition: ThemePrefs.h:23
#define S(N)
Definition: ToChars.cpp:64
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
static void ApplyUpdatedImages()
Definition: AColor.cpp:860
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
void SwitchTheme(teThemeType Theme)
Definition: Theme.cpp:217
void DeleteUnusedThemes()
void SaveThemeAsCode()
teThemeType GetFallbackThemeType()
Definition: Theme.cpp:831
void WriteImageMap()
Definition: Theme.cpp:728
void CreateImageCache()
Definition: Theme.cpp:556
static bool LoadPreferredTheme()
Definition: Theme.cpp:162
void WriteImageDefs()
Writes a series of Macro definitions that can be used in the include file.
Definition: Theme.cpp:789
void SaveThemeComponents()
void LoadThemeComponents(bool bOkIfNotFound=false)
Definition: Theme.cpp:972
Based on ThemeBase, Theme manages image and icon resources.
Definition: Theme.h:209
A PrefsPanel that configures dynamic loading of Theme icons and colours.
Definition: ThemePrefs.h:26
void OnReadThemeInternal(wxCommandEvent &e)
Read Theme from internal storage.
Definition: ThemePrefs.cpp:205
void PopulateOrExchange(ShuttleGui &S) override
Create the dialog contents, or exchange data with it.
Definition: ThemePrefs.cpp:104
bool Commit() override
Update the preferences stored on disk.
Definition: ThemePrefs.cpp:221
ComponentInterfaceSymbol GetSymbol() const override
Definition: ThemePrefs.cpp:74
void OnSaveThemeComponents(wxCommandEvent &e)
Save Theme to multiple png files.
Definition: ThemePrefs.cpp:182
void OnSaveThemeAsCode(wxCommandEvent &e)
Save Theme as C source code.
Definition: ThemePrefs.cpp:213
void OnLoadThemeComponents(wxCommandEvent &e)
Load Theme from multiple png files.
Definition: ThemePrefs.cpp:174
~ThemePrefs(void)
Definition: ThemePrefs.cpp:70
void OnLoadThemeCache(wxCommandEvent &e)
Load Theme from single png file.
Definition: ThemePrefs.cpp:189
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
Definition: ThemePrefs.cpp:84
void OnSaveThemeCache(wxCommandEvent &e)
Save Themes, each to a single png file.
Definition: ThemePrefs.cpp:197
void Cancel() override
Definition: ThemePrefs.cpp:232
TranslatableString GetDescription() const override
Definition: ThemePrefs.cpp:79
void Populate()
Creates the dialog and its contents.
Definition: ThemePrefs.cpp:90
Holds a msgid for the translation catalog; may also bind format arguments.