Audacity  3.0.3
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 () override
 
TranslatableString GetDescription () 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 PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
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 }

◆ ~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 }

References TrackList::Channels(), WaveformSettings::ConvertToActualDBRange(), WaveformSettings::ConvertToEnumeratedDBRange(), WaveformSettings::defaults(), eIsGettingFromDialog, WaveformSettings::Globals::Get(), TrackPanel::Get(), WaveTrackView::Get(), WaveformSettings::LoadPrefs(), mDefaulted, mProject, mTempSettings, mWt, PopulateOrExchange(), 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
246  (mScaleChoice->GetSelection() == WaveformSettings::stLogarithmic);
247 }

References mRangeChoice, mScaleChoice, and WaveformSettings::stLogarithmic.

Referenced by OnScale(), and PopulateOrExchange().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString WaveformPrefs::GetDescription ( )
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 ( )
overridevirtual

Implements ComponentInterface.

Definition at line 59 of file WaveformPrefs.cpp.

60 {
62 }

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 
218  if (mDefaultsCheckbox && !mPopulating) {
219  mDefaulted = false;
220  mDefaultsCheckbox->SetValue(false);
221  }
222 }

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 }

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

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 }

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 }

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

Here is the call 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  {
102  mDefaultsCheckbox = 0;
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  {
112  mScaleChoice =
113  S.Id(ID_SCALE).TieChoice(XXO("S&cale:"),
116 
117  mRangeChoice =
118  S.Id(ID_RANGE).TieChoice(XXO("Waveform dB &range:"),
120  mRangeChoices);
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 }

References WaveformSettings::dBRange, EnableDisableRange(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndTwoColumn(), WaveformSettings::GetScaleNames(), ShuttleGui::Id(), ID_DEFAULTS, ID_RANGE, ID_SCALE, mDefaulted, mDefaultsCheckbox, mPopulating, mRangeChoice, mRangeChoices, mScaleChoice, Msgids(), mTempSettings, mWt, WaveformSettings::scaleType, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartTwoColumn(), ShuttleGuiBase::TieCheckBox(), ShuttleGuiBase::TieChoice(), 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 }

References WaveformSettings::ConvertToActualDBRange(), WaveformSettings::ConvertToEnumeratedDBRange(), eIsGettingFromDialog, mTempSettings, PopulateOrExchange(), 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(), and PopulateOrExchange().

◆ 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(), and Validate().

◆ mWt

WaveTrack* const WaveformPrefs::mWt
private

Definition at line 52 of file WaveformPrefs.h.

Referenced by Commit(), and PopulateOrExchange().


The documentation for this class was generated from the following files:
WaveformSettings::scaleType
ScaleType scaleType
Definition: WaveformSettings.h:67
WaveformPrefs::mDefaulted
bool mDefaulted
Definition: WaveformPrefs.h:53
WaveformPrefs::mWt
WaveTrack *const mWt
Definition: WaveformPrefs.h:52
WaveformPrefs::mScaleChoice
wxChoice * mScaleChoice
Definition: WaveformPrefs.h:56
eIsGettingFromDialog
@ eIsGettingFromDialog
Definition: ShuttleGui.h:39
WaveformSettings::Validate
bool Validate(bool quiet)
Definition: WaveformSettings.cpp:75
WaveformSettings::Globals::Get
static Globals & Get()
Definition: WaveformSettings.cpp:43
WaveformPrefs::mDefaultsCheckbox
wxCheckBox * mDefaultsCheckbox
Definition: WaveformPrefs.h:55
WAVEFORM_PREFS_PLUGIN_SYMBOL
#define WAVEFORM_PREFS_PLUGIN_SYMBOL
Definition: WaveformPrefs.h:23
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
WaveformPrefs::mTempSettings
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:62
ID_RANGE
@ ID_RANGE
Definition: WaveformPrefs.cpp:78
WaveformPrefs::Populate
void Populate()
Definition: WaveformPrefs.cpp:81
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
XO
#define XO(s)
Definition: Internat.h:31
ID_DEFAULTS
@ ID_DEFAULTS
Definition: WaveformPrefs.cpp:75
WaveformPrefs::mProject
AudacityProject * mProject
Definition: WaveformPrefs.h:50
eIsSettingToDialog
@ eIsSettingToDialog
Definition: ShuttleGui.h:40
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
WaveformSettings::stLogarithmic
@ stLogarithmic
Definition: WaveformSettings.h:60
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
ID_SCALE
@ ID_SCALE
Definition: WaveformPrefs.cpp:77
WaveformSettings::LoadPrefs
void LoadPrefs()
Definition: WaveformSettings.cpp:87
WaveformPrefs::OnControl
void OnControl(wxCommandEvent &)
Definition: WaveformPrefs.cpp:211
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
WaveformSettings::GetScaleNames
static const EnumValueSymbols & GetScaleNames()
Definition: WaveformSettings.cpp:162
WaveformSettings::ConvertToActualDBRange
void ConvertToActualDBRange()
Definition: WaveformSettings.cpp:137
WaveformPrefs::mRangeChoices
TranslatableStrings mRangeChoices
Definition: WaveformPrefs.h:60
GUIPrefs::GetRangeChoices
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:64
WaveformSettings::Globals::SavePrefs
void SavePrefs()
Definition: WaveformSettings.cpp:34
ShuttleGuiBase::StartTwoColumn
void StartTwoColumn()
Definition: ShuttleGui.h:366
WaveTrack::GetWaveformSettings
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:810
WaveformPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: WaveformPrefs.cpp:93
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2522
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
WaveformSettings::defaults
static WaveformSettings & defaults()
Definition: WaveformSettings.cpp:69
WaveformPrefs::mPopulating
bool mPopulating
Definition: WaveformPrefs.h:64
WaveformSettings::ConvertToEnumeratedDBRange
void ConvertToEnumeratedDBRange()
Definition: WaveformSettings.cpp:122
WaveTrackView::Get
static WaveTrackView & Get(WaveTrack &track)
Definition: WaveTrackView.cpp:880
WaveformSettings::dBRange
int dBRange
Definition: WaveformSettings.h:68
WaveformSettings
Waveform settings, either for one track or as defaults.
Definition: WaveformSettings.h:19
WaveformPrefs::mRangeCodes
wxArrayStringEx mRangeCodes
Definition: WaveformPrefs.h:59
WaveformSettings::SavePrefs
void SavePrefs()
Definition: WaveformSettings.cpp:99
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
ShuttleGuiBase::EndTwoColumn
void EndTwoColumn()
Definition: ShuttleGui.h:367
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
WaveTrackView::SetDisplay
void SetDisplay(Display display, bool exclusive=true)
Definition: WaveTrackView.cpp:992
WaveformPrefs::EnableDisableRange
void EnableDisableRange()
Definition: WaveformPrefs.cpp:243
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1727
WaveformPrefs::mRangeChoice
wxChoice * mRangeChoice
Definition: WaveformPrefs.h:57
WaveTrackViewConstants::Waveform
@ Waveform
Definition: WaveTrackViewConstants.h:24
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90