Audacity 3.2.0
GUIPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 GUIPrefs.cpp
6
7 Brian Gunlogson
8 Joshua Haberman
9 Dominic Mazzoni
10 James Crook
11
12
13*******************************************************************//*******************************************************************/
19
20
21#include "GUIPrefs.h"
22
23#include <wx/defs.h>
24#include <mutex> // once_flag
25
26#include "FileNames.h"
27#include "Languages.h"
28#include "Theme.h"
29#include "Prefs.h"
30#include "ShuttleGui.h"
31
32#include "Decibels.h"
33#include "Beats.h"
34
35#include "ThemePrefs.h"
36#include "AColor.h"
37#include "GUISettings.h"
38
39GUIPrefs::GUIPrefs(wxWindow * parent, wxWindowID winid)
40/* i18n-hint: refers to Audacity's user interface settings */
41: PrefsPanel(parent, winid, XC("Interface", "GUI"))
42{
43 Populate();
44}
45
47{
48}
49
51{
53}
54
56{
57 return XO("Preferences for GUI");
58}
59
61{
62 return "Interface_Preferences";
63}
64
66 TranslatableStrings *pChoices,
67 wxArrayStringEx *pCodes,
68 int *pDefaultRangeIndex
69)
70{
71 static const auto sCodes = {
72 wxT("36") ,
73 wxT("48") ,
74 wxT("60") ,
75 wxT("72") ,
76 wxT("84") ,
77 wxT("96") ,
78 wxT("120") ,
79 wxT("145") ,
80 };
81 if (pCodes)
82 *pCodes = sCodes;
83
84 static const std::initializer_list<TranslatableString> sChoices = {
85 XO("-36 dB (shallow range for high-amplitude editing)") ,
86 XO("-48 dB (PCM range of 8 bit samples)") ,
87 XO("-60 dB (PCM range of 10 bit samples)") ,
88 XO("-72 dB (PCM range of 12 bit samples)") ,
89 XO("-84 dB (PCM range of 14 bit samples)") ,
90 XO("-96 dB (PCM range of 16 bit samples)") ,
91 XO("-120 dB (approximate limit of human hearing)") ,
92 XO("-145 dB (PCM range of 24 bit samples)") ,
93 };
94
95 if (pChoices)
96 *pChoices = sChoices;
97
98 if (pDefaultRangeIndex)
99 *pDefaultRangeIndex = 2; // 60 == ENV_DB_RANGE
100}
101
103 TranslatableStrings* pChoices,
104 wxArrayStringEx* pCodes,
105 int* pDefaultIndex
106)
107{
108 static wxArrayStringEx sCodes;
109 static TranslatableStrings sChoices;
110
111 static std::once_flag flag;
112 std::call_once(flag, [&]{
113 sCodes.Clear();
114 sChoices.clear();
115
116 for (int i = 1; i <= 64; i *= 2) {
117 auto lts = wxString::Format(wxT("%d"), i);
118 sCodes.Add(lts);
119 sChoices.push_back(Verbatim(lts));
120 }
121 });
122
123 if (pCodes)
124 *pCodes = sCodes;
125
126 if (pChoices)
127 *pChoices = sChoices;
128
129 if (pDefaultIndex)
130 *pDefaultIndex = 2; // 4 == LowerTimeSig
131}
132
134{
135 // First any pre-processing for constructing the GUI.
138
140
142
143#if 0
145 // only for testing...
146 "kg" ,
147 "ep" ,
148 } );
149
150 mLangNames.insert( mLangNames.end(), {
151 "Klingon" ,
152 "Esperanto" ,
153 } );
154#endif
155
156 //------------------------- Main section --------------------
157 // Now construct the GUI itself.
158 // Use 'eIsCreatingFromPrefs' so that the GUI is
159 // initialised with values from gPrefs.
162 // ----------------------- End of main section --------------
163}
164
166{
167 ChoiceSetting LanguageSetting{ wxT("/Locale/Language"),
169 };
173 };
174
175 ChoiceSetting LowerTimeSigSettings{ LowerTimeSignature,
178 };
179
180 S.SetBorder(2);
181 S.StartScroller();
182
183 S.StartStatic(XO("Display"));
184 {
185 S.StartMultiColumn(2);
186 {
187 S.TieChoice( XXO("&Language:"), LanguageSetting);
188 // S.TieChoice( XXO("Location of &Manual:"), GUIManualLocation);
189 S.TieChoice( XXO("Th&eme:"), GUITheme());
190 S.TieChoice( XXO("Meter dB &range:"), DBSetting);
191 }
192 S.EndMultiColumn();
193
194 S.StartMultiColumn(2);
195 {
196 S.TieNumericTextBox(XXO("Beats per &minute:"), BeatsPerMinute, 10);
197 S.TieIntegerTextBox(XXO("Upper time &signature:"), UpperTimeSignature, 6);
198 S.TieChoice(XXO("Lower time &signature:"), LowerTimeSigSettings);
199 }
200 S.EndMultiColumn();
201
202 }
203 S.EndStatic();
204
205 S.StartStatic(XO("Options"));
206 {
207 // Start wording of options with a verb, if possible.
208 S.TieCheckBox(XXO("Show 'How to Get &Help' at launch"),
209 {wxT("/GUI/ShowSplashScreen"),
210 true});
211 S.TieCheckBox(XXO("Show e&xtra menus"),
212 {wxT("/GUI/ShowExtraMenus"),
213 false});
214#ifdef EXPERIMENTAL_THEME_PREFS
215 // We do not want to make this option mainstream. It's a
216 // convenience for developers.
217 S.TieCheckBox(XXO("Show alternative &styling (Mac vs PC)"),
218 {wxT("/GUI/ShowMac"),
219 false});
220#endif
221 S.TieCheckBox(XXO("&Beep on completion of longer activities"),
222 {wxT("/GUI/BeepOnCompletion"),
223 false});
224 S.TieCheckBox(XXO("Re&tain labels if selection snaps to a label"),
225 {wxT("/GUI/RetainLabels"),
226 false});
227 S.TieCheckBox(XXO("B&lend system and Audacity theme"),
229#ifndef __WXMAC__
230 /* i18n-hint: RTL stands for 'Right to Left' */
231 S.TieCheckBox(XXO("Use mostly Left-to-Right layouts in RTL languages"),
232 {"/GUI/RtlWorkaround",
233 true});
234#endif
235#ifdef EXPERIMENTAL_CEE_NUMBERS_OPTION
236 S.TieCheckBox(XXO("Never use comma as decimal point"),
237 {wxT("/Locale/CeeNumberFormat"),
238 false});
239#endif
240 }
241 S.EndStatic();
242
243 S.StartStatic(XO("Timeline"));
244 {
245 S.TieCheckBox(XXO("Show Timeline Tooltips"),
246 {wxT("/QuickPlay/ToolTips"),
247 true});
248 S.TieCheckBox(XXO("Show Scrub Ruler"),
249 {wxT("/QuickPlay/ScrubbingEnabled"),
250 false});
251 }
252 S.EndStatic();
253
254 S.EndScroller();
255}
256
258{
261
262 // If language has changed, we want to change it now, not on the next reboot.
263 wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
264 wxString usedLang = GUISettings::SetLang(lang);
265 // Bug 1523: Previously didn't check no-language (=System Language)
266 if (!(lang.empty() || lang == L"System") && (lang != usedLang)) {
267 // lang was not usable and is not system language. We got overridden.
268 gPrefs->Write(wxT("/Locale/Language"), usedLang);
269 gPrefs->Flush();
270 }
271
272 // Reads preference GUITheme
273 {
274 wxBusyCursor busy;
277 }
279
285
286 return true;
287}
288
290{
291 static int value = wxNewId();
292 return value;
293}
294
296{
297 static int value = wxNewId();
298 return value;
299}
300
301namespace{
303 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
304 {
305 wxASSERT(parent); // to justify safenew
306 return safenew GUIPrefs(parent, winid);
307 }
308};
309}
wxT("CloseDown"))
IntSetting UpperTimeSignature
The upper time signature of the Beats & Measures ruler.
Definition: Beats.cpp:14
IntSetting LowerTimeSignature
The lower time signature of the Beats & Measures ruler.
Definition: Beats.cpp:15
DoubleSetting BeatsPerMinute
The tempo used for drawing the Beats & Measures ruler.
Definition: Beats.cpp:13
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
int ShowTrackNameInWaveformPrefsID()
Definition: GUIPrefs.cpp:295
int ShowClippingPrefsID()
Definition: GUIPrefs.cpp:289
#define GUI_PREFS_PLUGIN_SYMBOL
Definition: GUIPrefs.h:23
#define XC(s, c)
Definition: Internat.h:37
#define safenew
Definition: MemoryX.h:10
FileConfig * gPrefs
Definition: Prefs.cpp:70
ByColumns_t ByColumns
Definition: Prefs.cpp:474
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
THEME_API Theme theTheme
Definition: Theme.cpp:82
THEME_API BoolSetting GUIBlendThemes
THEME_API ChoiceSetting & GUITheme()
#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.
std::vector< TranslatableString > TranslatableStrings
static std::once_flag flag
static void ApplyUpdatedImages()
Definition: AColor.cpp:872
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,...
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
A PrefsPanel for general GUI preferences.
Definition: GUIPrefs.h:26
int mDefaultRangeIndex
Definition: GUIPrefs.h:57
GUIPrefs(wxWindow *parent, wxWindowID winid)
Definition: GUIPrefs.cpp:39
wxArrayStringEx mRangeCodes
Definition: GUIPrefs.h:55
int mDefaultLTSIndex
Definition: GUIPrefs.h:64
TranslatableString GetDescription() const override
Definition: GUIPrefs.cpp:55
wxArrayStringEx mLangCodes
Definition: GUIPrefs.h:52
void PopulateOrExchange(ShuttleGui &S) override
Definition: GUIPrefs.cpp:165
~GUIPrefs()
Definition: GUIPrefs.cpp:46
TranslatableStrings mLTSChoices
Definition: GUIPrefs.h:63
ComponentInterfaceSymbol GetSymbol() const override
Definition: GUIPrefs.cpp:50
static void GetLTSChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultIndex=nullptr)
Definition: GUIPrefs.cpp:102
bool Commit() override
Definition: GUIPrefs.cpp:257
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:65
TranslatableStrings mLangNames
Definition: GUIPrefs.h:53
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
Definition: GUIPrefs.cpp:60
void Populate()
Definition: GUIPrefs.cpp:133
wxArrayStringEx mLTSCodes
Definition: GUIPrefs.h:62
TranslatableStrings mRangeChoices
Definition: GUIPrefs.h:56
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
void Invalidate() override
Definition: Prefs.h:282
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
void DeleteUnusedThemes()
static bool LoadPreferredTheme()
Definition: Theme.cpp:162
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
iterator insert(const_iterator pos, std::initializer_list< T > items)
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...
AUDACITY_DLL_API wxString SetLang(const wxString &lang)
Definition: GUISettings.cpp:19
void GetLanguages(FilePaths pathList, wxArrayString &langCodes, TranslatableStrings &langNames)
Definition: Languages.cpp:140
PrefsPanel::Registration sAttachment
Definition: GUIPrefs.cpp:302