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

A PrefsPanel for spectrum settings. More...

#include <WaveformPrefs.h>

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

Public Member Functions

 WaveformPrefs (wxWindow *parent, wxWindowID winid, AudacityProject *pProject, WaveTrack *wt)
 
virtual ~WaveformPrefs ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
bool Commit () override
 
bool ShowsPreviewButton () override
 
bool Validate () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
- 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 ()
 
void OnControl (wxCommandEvent &)
 
void OnScale (wxCommandEvent &)
 
void OnDefaults (wxCommandEvent &)
 
void EnableDisableRange ()
 

Private Attributes

AudacityProjectmProject {}
 
WaveTrack *const mWt
 
bool mDefaulted
 
wxCheckBox * mDefaultsCheckbox
 
wxChoice * mScaleChoice
 
wxChoice * mRangeChoice
 
wxArrayStringEx mRangeCodes
 
TranslatableStrings mRangeChoices
 
WaveformSettings mTempSettings
 
bool mPopulating
 

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 for spectrum settings.

Definition at line 25 of file WaveformPrefs.h.

Constructor & Destructor Documentation

◆ WaveformPrefs()

WaveformPrefs::WaveformPrefs ( wxWindow *  parent,
wxWindowID  winid,
AudacityProject pProject,
WaveTrack wt 
)

Definition at line 33 of file WaveformPrefs.cpp.

36: PrefsPanel(parent, winid, XO("Waveforms"))
37, mProject{ pProject }
38, mWt(wt)
39, mPopulating(false)
40{
41 if (mWt) {
45 }
46 else {
48 mDefaulted = false;
49 }
50
52 Populate();
53}
#define XO(s)
Definition: Internat.h:31
static Settings & settings()
Definition: TrackInfo.cpp:87
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:847
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:62
AudacityProject * mProject
Definition: WaveformPrefs.h:50
WaveTrack *const mWt
Definition: WaveformPrefs.h:52
Waveform settings, either for one track or as defaults.
static WaveformSettings & defaults()

References WaveformSettings::ConvertToEnumeratedDBRange(), WaveformSettings::defaults(), WaveTrack::GetWaveformSettings(), mDefaulted, mTempSettings, mWt, Populate(), and settings().

Here is the call graph for this function:

◆ ~WaveformPrefs()

WaveformPrefs::~WaveformPrefs ( )
virtual

Definition at line 55 of file WaveformPrefs.cpp.

56{
57}

Member Function Documentation

◆ Commit()

bool WaveformPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 158 of file WaveformPrefs.cpp.

159{
160 const bool isOpenPage = this->IsShown();
161
164
167
168 if (mWt) {
169 for (auto channel : TrackList::Channels(mWt)) {
170 if (mDefaulted)
171 channel->SetWaveformSettings({});
172 else {
174 channel->GetWaveformSettings();
176 }
177 }
178 }
179
180 WaveformSettings *const pSettings = &WaveformSettings::defaults();
181 if (!mWt || mDefaulted) {
182 *pSettings = mTempSettings;
183 pSettings->SavePrefs();
184 }
185 pSettings->LoadPrefs(); // always; in case Globals changed
186
188
189 if (mWt && isOpenPage) {
190 for (auto channel : TrackList::Channels(mWt))
191 WaveTrackView::Get( *channel )
193 }
194
195 if (isOpenPage) {
196 if ( mProject ) {
197 auto &tp = TrackPanel::Get( *mProject );
198 tp.UpdateVRulers();
199 tp.Refresh(false);
200 }
201 }
202
203 return true;
204}
@ eIsGettingFromDialog
Definition: ShuttleGui.h:40
#define S(N)
Definition: ToChars.cpp:64
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1539
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:230
void SetDisplay(Display display, bool exclusive=true)
static WaveTrackView & Get(WaveTrack &track)
void PopulateOrExchange(ShuttleGui &S) override

References TrackList::Channels(), WaveformSettings::ConvertToActualDBRange(), WaveformSettings::ConvertToEnumeratedDBRange(), WaveformSettings::defaults(), eIsGettingFromDialog, WaveformSettings::Globals::Get(), TrackPanel::Get(), WaveTrackView::Get(), WaveformSettings::LoadPrefs(), mDefaulted, mProject, mTempSettings, mWt, PopulateOrExchange(), S, WaveformSettings::Globals::SavePrefs(), WaveformSettings::SavePrefs(), WaveTrackView::SetDisplay(), settings(), and WaveTrackViewConstants::Waveform.

Here is the call graph for this function:

◆ EnableDisableRange()

void WaveformPrefs::EnableDisableRange ( )
private

Definition at line 243 of file WaveformPrefs.cpp.

244{
245 mRangeChoice->Enable
247}
wxChoice * mRangeChoice
Definition: WaveformPrefs.h:57
wxChoice * mScaleChoice
Definition: WaveformPrefs.h:56

References mRangeChoice, mScaleChoice, and WaveformSettings::stLogarithmic.

Referenced by OnScale(), and PopulateOrExchange().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString WaveformPrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 64 of file WaveformPrefs.cpp.

65{
66 return XO("Preferences for Waveforms");
67}

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol WaveformPrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 59 of file WaveformPrefs.cpp.

60{
62}
#define WAVEFORM_PREFS_PLUGIN_SYMBOL
Definition: WaveformPrefs.h:23

References WAVEFORM_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID WaveformPrefs::HelpPageName ( )
overridevirtual

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

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 69 of file WaveformPrefs.cpp.

70{
71 return "Waveform_Preferences";
72}

◆ OnControl()

void WaveformPrefs::OnControl ( wxCommandEvent &  )
private

Definition at line 211 of file WaveformPrefs.cpp.

212{
213 // Common routine for most controls
214 // If any per-track setting is changed, break the association with defaults
215 // Skip this, and View Settings... will be able to change defaults instead
216 // when the checkbox is on, as in the original design.
217
219 mDefaulted = false;
220 mDefaultsCheckbox->SetValue(false);
221 }
222}
wxCheckBox * mDefaultsCheckbox
Definition: WaveformPrefs.h:55

References mDefaulted, mDefaultsCheckbox, and mPopulating.

Referenced by OnScale().

Here is the caller graph for this function:

◆ OnDefaults()

void WaveformPrefs::OnDefaults ( wxCommandEvent &  )
private

Definition at line 232 of file WaveformPrefs.cpp.

233{
234 if (mDefaultsCheckbox->IsChecked()) {
237 mDefaulted = true;
240 }
241}
@ eIsSettingToDialog
Definition: ShuttleGui.h:41

References WaveformSettings::ConvertToEnumeratedDBRange(), WaveformSettings::defaults(), eIsSettingToDialog, mDefaulted, mDefaultsCheckbox, mTempSettings, PopulateOrExchange(), and S.

Here is the call graph for this function:

◆ OnScale()

void WaveformPrefs::OnScale ( wxCommandEvent &  e)
private

Definition at line 224 of file WaveformPrefs.cpp.

225{
227
228 // do the common part
229 OnControl(e);
230}
void OnControl(wxCommandEvent &)
void EnableDisableRange()

References EnableDisableRange(), and OnControl().

Here is the call graph for this function:

◆ Populate()

void WaveformPrefs::Populate ( )
private

Definition at line 81 of file WaveformPrefs.cpp.

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}
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:48
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:63
TranslatableStrings mRangeChoices
Definition: WaveformPrefs.h:60
wxArrayStringEx mRangeCodes
Definition: WaveformPrefs.h:59

References eIsCreatingFromPrefs, GUIPrefs::GetRangeChoices(), mRangeChoices, mRangeCodes, PopulateOrExchange(), and S.

Referenced by WaveformPrefs().

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

◆ PopulateOrExchange()

void WaveformPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 93 of file WaveformPrefs.cpp.

94{
95 mPopulating = true;
96
97 S.SetBorder(2);
98 S.StartScroller();
99
100 // S.StartStatic(XO("Track Settings"));
101 {
103 if (mWt) {
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}
#define XXO(s)
Definition: Internat.h:44
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
@ ID_SCALE
@ ID_DEFAULTS
@ ID_RANGE
static const EnumValueSymbols & GetScaleNames()

References WaveformSettings::dBRange, EnableDisableRange(), WaveformSettings::GetScaleNames(), ID_DEFAULTS, ID_RANGE, ID_SCALE, mDefaulted, mDefaultsCheckbox, mPopulating, mRangeChoice, mRangeChoices, mScaleChoice, Msgids(), mTempSettings, mWt, S, WaveformSettings::scaleType, XO, and XXO.

Referenced by Commit(), OnDefaults(), Populate(), and Validate().

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

◆ ShowsPreviewButton()

bool WaveformPrefs::ShowsPreviewButton ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 206 of file WaveformPrefs.cpp.

207{
208 return true;
209}

◆ Validate()

bool WaveformPrefs::Validate ( )
override

Definition at line 142 of file WaveformPrefs.cpp.

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}
bool Validate(bool quiet)

References WaveformSettings::ConvertToActualDBRange(), WaveformSettings::ConvertToEnumeratedDBRange(), eIsGettingFromDialog, mTempSettings, PopulateOrExchange(), S, and WaveformSettings::Validate().

Here is the call graph for this function:

Member Data Documentation

◆ mDefaulted

bool WaveformPrefs::mDefaulted
private

Definition at line 53 of file WaveformPrefs.h.

Referenced by Commit(), OnControl(), OnDefaults(), PopulateOrExchange(), and WaveformPrefs().

◆ mDefaultsCheckbox

wxCheckBox* WaveformPrefs::mDefaultsCheckbox
private

Definition at line 55 of file WaveformPrefs.h.

Referenced by OnControl(), OnDefaults(), and PopulateOrExchange().

◆ mPopulating

bool WaveformPrefs::mPopulating
private

Definition at line 64 of file WaveformPrefs.h.

Referenced by OnControl(), and PopulateOrExchange().

◆ mProject

AudacityProject* WaveformPrefs::mProject {}
private

Definition at line 50 of file WaveformPrefs.h.

Referenced by Commit().

◆ mRangeChoice

wxChoice* WaveformPrefs::mRangeChoice
private

Definition at line 57 of file WaveformPrefs.h.

Referenced by EnableDisableRange(), and PopulateOrExchange().

◆ mRangeChoices

TranslatableStrings WaveformPrefs::mRangeChoices
private

Definition at line 60 of file WaveformPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

◆ mRangeCodes

wxArrayStringEx WaveformPrefs::mRangeCodes
private

Definition at line 59 of file WaveformPrefs.h.

Referenced by Populate().

◆ mScaleChoice

wxChoice* WaveformPrefs::mScaleChoice
private

Definition at line 56 of file WaveformPrefs.h.

Referenced by EnableDisableRange(), and PopulateOrExchange().

◆ mTempSettings

WaveformSettings WaveformPrefs::mTempSettings
private

Definition at line 62 of file WaveformPrefs.h.

Referenced by Commit(), OnDefaults(), PopulateOrExchange(), Validate(), and WaveformPrefs().

◆ mWt

WaveTrack* const WaveformPrefs::mWt
private

Definition at line 52 of file WaveformPrefs.h.

Referenced by Commit(), PopulateOrExchange(), and WaveformPrefs().


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