Audacity  2.2.2
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 #include "../Audacity.h"
32 
33 #include <wx/wxprec.h>
34 #include "../Prefs.h"
35 #include "../Theme.h"
36 #include "../Project.h"
37 #include "../ShuttleGui.h"
38 #include "ThemePrefs.h"
39 #include "../AColor.h"
40 
48 };
49 
50 BEGIN_EVENT_TABLE(ThemePrefs, PrefsPanel)
51  EVT_BUTTON(idLoadThemeCache, ThemePrefs::OnLoadThemeCache)
52  EVT_BUTTON(idSaveThemeCache, ThemePrefs::OnSaveThemeCache)
53  EVT_BUTTON(idLoadThemeComponents, ThemePrefs::OnLoadThemeComponents)
54  EVT_BUTTON(idSaveThemeComponents, ThemePrefs::OnSaveThemeComponents)
55  EVT_BUTTON(idReadThemeInternal, ThemePrefs::OnReadThemeInternal)
56  EVT_BUTTON(idSaveThemeAsCode, ThemePrefs::OnSaveThemeAsCode)
58 
59 ThemePrefs::ThemePrefs(wxWindow * parent, wxWindowID winid)
60 /* i18n-hint: A theme is a consistent visual style across an application's
61  graphical user interface, including choices of colors, and similarity of images
62  such as those on button controls. Audacity can load and save alternative
63  themes. */
64 : PrefsPanel(parent, winid, _("Theme"))
65 {
66  Populate();
67 }
68 
70 {
71 }
72 
75 {
76  // First any pre-processing for constructing the GUI.
77 
78  //------------------------- Main section --------------------
79  // Now construct the GUI itself.
80  // Use 'eIsCreatingFromPrefs' so that the GUI is
81  // initialised with values from gPrefs.
84  // ----------------------- End of main section --------------
85 }
86 
89 {
90  S.SetBorder(2);
91  S.StartScroller();
92 
93  S.StartStatic(_("Info"));
94  {
95  S.AddFixedText(
96  _("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.\n\n(Only the Transport Toolbar and the colors on the wavetrack are currently affected, even\nthough the image file shows other icons too.)")
97  );
98 
99 #ifdef __WXDEBUG__
100  S.AddFixedText(
101  _("This is a debug version of Audacity, with an extra button, 'Output Sourcery'. This will save a\nC version of the image cache that can be compiled in as a default.")
102  );
103 #endif
104 
105  S.AddFixedText(
106  _("Saving and loading individual theme files uses a separate file for each image, but is\notherwise the same idea.")
107  );
108  }
109  S.EndStatic();
110 
111  /* i18n-hint: && in here is an escape character to get a single & on screen,
112  * so keep it as is */
113  S.StartStatic( _("Theme Cache - Images && Color"));
114  {
115  S.StartHorizontalLay(wxALIGN_LEFT);
116  {
117  S.Id(idSaveThemeCache).AddButton(_("Save Theme Cache"));
118  S.Id(idLoadThemeCache).AddButton(_("Load Theme Cache"));
119 
120  // This next button is only provided in Debug mode.
121  // It is for developers who are compiling Audacity themselves
122  // and who who wish to generate a NEW ThemeAsCeeCode.h and compile it in.
123 #ifdef __WXDEBUG__
124  S.Id(idSaveThemeAsCode).AddButton(wxT("Output Sourcery"));
125 #endif
126 
127  S.Id(idReadThemeInternal).AddButton(_("&Defaults"));
128  }
129  S.EndHorizontalLay();
130  }
131  S.EndStatic();
132 
133  // JKC: 'Ergonomic' details:
134  // Theme components are used much less frequently than
135  // the ImageCache. Yet it's easy to click them 'by mistake'.
136  //
137  // To reduce that risk, we use a separate box to separate them off.
138  // And choose text on the buttons that is shorter, making the
139  // buttons smaller and less tempting to click.
140  S.StartStatic( _("Individual Theme Files"),1);
141  {
142  S.StartHorizontalLay(wxALIGN_LEFT);
143  {
144  S.Id(idSaveThemeComponents).AddButton( _("Save Files"));
145  S.Id(idLoadThemeComponents).AddButton( _("Load Files"));
146  }
147  S.EndHorizontalLay();
148  }
149  S.EndStatic();
150  S.EndScroller();
151 
152 }
153 
155 void ThemePrefs::OnLoadThemeComponents(wxCommandEvent & WXUNUSED(event))
156 {
159 }
160 
162 void ThemePrefs::OnSaveThemeComponents(wxCommandEvent & WXUNUSED(event))
163 {
165 }
166 
168 void ThemePrefs::OnLoadThemeCache(wxCommandEvent & WXUNUSED(event))
169 {
172 }
173 
175 void ThemePrefs::OnSaveThemeCache(wxCommandEvent & WXUNUSED(event))
176 {
178  theTheme.WriteImageMap();// bonus - give them the html version.
179 }
180 
182 void ThemePrefs::OnReadThemeInternal(wxCommandEvent & WXUNUSED(event))
183 {
186 }
187 
189 void ThemePrefs::OnSaveThemeAsCode(wxCommandEvent & WXUNUSED(event))
190 {
192  theTheme.WriteImageDefs();// bonus - give them the Defs too.
193 }
194 
197 {
198  ShuttleGui S(this, eIsSavingToPrefs);
200 
201  return true;
202 }
203 
204 PrefsPanel *ThemePrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
205 {
206  wxASSERT(parent); // to justify safenew
207  return safenew ThemePrefs(parent, winid);
208 }
void SaveComponents()
Definition: Theme.cpp:1118
eThemePrefsIds
Definition: ThemePrefs.cpp:41
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
Based on ThemeBase, Theme manages image and icon resources.
Definition: Theme.h:157
void CreateImageCache(bool bBinarySave=true)
Definition: Theme.cpp:660
void ApplyUpdatedImages() override
Definition: Theme.cpp:250
void Populate()
Creates the dialog and its contents.
Definition: ThemePrefs.cpp:74
void OnSaveThemeAsCode(wxCommandEvent &e)
Save Theme as C source code.
Definition: ThemePrefs.cpp:189
void OnSaveThemeCache(wxCommandEvent &e)
Save Theme to single png file.
Definition: ThemePrefs.cpp:175
bool Commit() override
Update the preferences stored on disk.
Definition: ThemePrefs.cpp:196
void EndScroller()
Definition: ShuttleGui.cpp:770
void OnLoadThemeCache(wxCommandEvent &e)
Load Theme from single png file.
Definition: ThemePrefs.cpp:168
#define safenew
Definition: Audacity.h:223
void EndHorizontalLay()
Definition: ShuttleGui.cpp:975
PrefsPanel * operator()(wxWindow *parent, wxWindowID winid) override
Definition: ThemePrefs.cpp:204
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:733
void OnReadThemeInternal(wxCommandEvent &e)
Read Theme from internal storage.
Definition: ThemePrefs.cpp:182
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:966
void LoadComponents(bool bOkIfNotFound=false)
Definition: Theme.cpp:1068
ShuttleGui & Id(int id)
teThemeType GetFallbackThemeType()
Definition: Theme.cpp:910
void AddFixedText(const wxString &Str, bool bCenter=false)
Definition: ShuttleGui.cpp:356
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:43
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
~ThemePrefs(void)
Definition: ThemePrefs.cpp:69
bool ReadImageCache(teThemeType type=themeFromFile, bool bOkIfNotFound=false)
Definition: Theme.cpp:941
A PrefsPanel that configures dynamic loading of Theme icons and colours.
Definition: ThemePrefs.h:24
void OnSaveThemeComponents(wxCommandEvent &e)
Save Theme to multiple png files.
Definition: ThemePrefs.cpp:162
void WriteImageMap()
Definition: Theme.cpp:817
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:701
void PopulateOrExchange(ShuttleGui &S)
Create the dialog contents, or exchange data with it.
Definition: ThemePrefs.cpp:88
void SaveThemeAsCode()
Definition: Theme.cpp:1195
END_EVENT_TABLE()
void WriteImageDefs()
Writes a series of Macro definitions that can be used in the include file.
Definition: Theme.cpp:870
void SetBorder(int Border)
Definition: ShuttleGui.h:251
void OnLoadThemeComponents(wxCommandEvent &e)
Load Theme from multiple png files.
Definition: ThemePrefs.cpp:155
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:301