Audacity 3.2.0
WaveformPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveformPrefs.cpp
6
7Paul Licameli
8
9*******************************************************************//*******************************************************************/
15
16
17#include "WaveformPrefs.h"
18
19#include "GUIPrefs.h"
20#include "Decibels.h"
21
22#include <wx/checkbox.h>
23#include <wx/choice.h>
24
25#include "Project.h"
26
27#include "../TrackPanel.h"
28#include "ShuttleGui.h"
29#include "WaveTrack.h"
30#include "../tracks/playabletrack/wavetrack/ui/WaveChannelView.h"
31#include "../tracks/playabletrack/wavetrack/ui/WaveChannelViewConstants.h"
32
33WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid,
34 AudacityProject *pProject, WaveChannel *wc)
35/* i18n-hint: A waveform is a visual representation of vibration */
36: PrefsPanel(parent, winid, XO("Waveforms"))
37, mProject{ pProject }
38, mWc(wc)
39, mPopulating(false)
40{
41 if (mWc) {
45 }
46 else {
48 mDefaulted = false;
49 }
50
52 Populate();
53}
54
56{
57}
58
60{
62}
63
65{
66 return XO("Preferences for Waveforms");
67}
68
70{
71 return "Waveform_Preferences";
72}
73
74enum {
75 ID_DEFAULTS = 10001,
76
79};
80
82{
83 // Reuse the same choices and codes as for Interface prefs
85
86 //------------------------- Main section --------------------
87 // Now construct the GUI itself.
90 // ----------------------- End of main section --------------
91}
92
94{
95 mPopulating = true;
96
97 S.SetBorder(2);
98 S.StartScroller();
99
100 // S.StartStatic(XO("Track Settings"));
101 {
103 if (mWc) {
104 /* i18n-hint: use is a verb */
105 mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(XXO("&Use Preferences"), mDefaulted);
106 }
107
108 S.StartStatic(XO("Display"));
109 {
110 S.StartTwoColumn();
111 {
113 S.Id(ID_SCALE).TieChoice(XXO("S&cale:"),
116
118 S.Id(ID_RANGE).TieChoice(XXO("Waveform dB &range:"),
121 }
122 S.EndTwoColumn();
123 }
124 S.EndStatic();
125 }
126 // S.EndStatic();
127
128 /*
129 S.StartStatic(XO("Global settings"));
130 {
131 }
132 S.EndStatic();
133 */
134
135 S.EndScroller();
136
138
139 mPopulating = false;
140}
141
143{
144 // Do checking for whole numbers
145
146 // ToDo: use wxIntegerValidator<unsigned> when available
147
150
151 // Delegate range checking to WaveformSettings class
153 const bool result = mTempSettings.Validate(false);
155 return result;
156}
157
159{
160 const bool isOpenPage = this->IsShown();
161
164
167
168 if (mWc) {
169 if (mDefaulted)
171 else {
174 }
175 }
176
177 WaveformSettings *const pSettings = &WaveformSettings::defaults();
178 if (!mWc || mDefaulted) {
179 *pSettings = mTempSettings;
180 pSettings->SavePrefs();
181 }
182 pSettings->LoadPrefs(); // always; in case Globals changed
183
185
186 if (mWc && isOpenPage) {
188 }
189
190 if (isOpenPage) {
191 if ( mProject ) {
192 auto &tp = TrackPanel::Get( *mProject );
193 tp.UpdateVRulers();
194 tp.Refresh(false);
195 }
196 }
197
198 return true;
199}
200
202{
203 return true;
204}
205
206void WaveformPrefs::OnControl(wxCommandEvent&)
207{
208 // Common routine for most controls
209 // If any per-track setting is changed, break the association with defaults
210 // Skip this, and View Settings... will be able to change defaults instead
211 // when the checkbox is on, as in the original design.
212
214 mDefaulted = false;
215 mDefaultsCheckbox->SetValue(false);
216 }
217}
218
219void WaveformPrefs::OnScale(wxCommandEvent &e)
220{
222
223 // do the common part
224 OnControl(e);
225}
226
227void WaveformPrefs::OnDefaults(wxCommandEvent &)
228{
229 if (mDefaultsCheckbox->IsChecked()) {
232 mDefaulted = true;
235 }
236}
237
239{
240 mRangeChoice->Enable(
242}
243
244BEGIN_EVENT_TABLE(WaveformPrefs, PrefsPanel)
245
248
251
252PrefsPanel::Factory
254{
255 return [=](wxWindow *parent, wxWindowID winid, AudacityProject *pProject)
256 {
257 wxASSERT(parent); // to justify safenew
258 return safenew WaveformPrefs(parent, winid, pProject, wc);
259 };
260}
261#if 0
262namespace{
264 WaveformPrefsFactory( nullptr ),
265 false,
266 // Register with an explicit ordering hint because this one is
267 // only conditionally compiled; and place it at a lower tree level
268 { "Tracks", { Registry::OrderingHint::Before, "Spectrum" } }
269};
270}
271#endif
END_EVENT_TABLE()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
@ eIsSettingToDialog
Definition: ShuttleGui.h:39
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsGettingFromDialog
Definition: ShuttleGui.h:38
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:47
PrefsPanel::Factory WaveformPrefsFactory(WaveChannel *wc)
@ ID_SCALE
@ ID_DEFAULTS
@ ID_RANGE
#define WAVEFORM_PREFS_PLUGIN_SYMBOL
Definition: WaveformPrefs.h:23
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,...
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:65
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
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
Holds a msgid for the translation catalog; may also bind format arguments.
void SetDisplay(Display display, bool exclusive=true)
static WaveChannelView & Get(WaveChannel &channel)
A PrefsPanel for spectrum settings.
Definition: WaveformPrefs.h:26
virtual ~WaveformPrefs()
WaveChannel *const mWc
Definition: WaveformPrefs.h:52
WaveformPrefs(wxWindow *parent, wxWindowID winid, AudacityProject *pProject, WaveChannel *wc)
bool ShowsPreviewButton() override
TranslatableStrings mRangeChoices
Definition: WaveformPrefs.h:60
void OnControl(wxCommandEvent &)
TranslatableString GetDescription() const override
void OnDefaults(wxCommandEvent &)
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:62
ComponentInterfaceSymbol GetSymbol() const override
void EnableDisableRange()
AudacityProject * mProject
Definition: WaveformPrefs.h:50
void OnScale(wxCommandEvent &)
wxChoice * mRangeChoice
Definition: WaveformPrefs.h:57
bool Commit() override
wxChoice * mScaleChoice
Definition: WaveformPrefs.h:56
wxCheckBox * mDefaultsCheckbox
Definition: WaveformPrefs.h:55
void PopulateOrExchange(ShuttleGui &S) override
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
bool Validate() override
wxArrayStringEx mRangeCodes
Definition: WaveformPrefs.h:59
Waveform settings, either for one track or as defaults.
static void Set(WaveChannel &channel, std::unique_ptr< WaveformSettings > pSettings)
Guarantee independence of settings, then assign.
static const EnumValueSymbols & GetScaleNames()
bool Validate(bool quiet)
static WaveformSettings & defaults()
static WaveformSettings & Get(const WaveTrack &track)