Audacity  2.2.2
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:
PrefsPanel wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 WaveformPrefs (wxWindow *parent, wxWindowID winid, WaveTrack *wt)
 
virtual ~WaveformPrefs ()
 
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 wxString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual wxString HelpPageName ()
 
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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- 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

WaveTrack *const mWt
 
bool mDefaulted
 
wxCheckBox * mDefaultsCheckbox
 
wxChoice * mScaleChoice
 
wxChoice * mRangeChoice
 
wxArrayString mScaleChoices
 
wxArrayString mRangeCodes
 
wxArrayString mRangeChoices
 
WaveformSettings mTempSettings
 
bool mPopulating
 

Detailed Description

A PrefsPanel for spectrum settings.

Definition at line 23 of file WaveformPrefs.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file WaveformPrefs.cpp.

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

31 : PrefsPanel(parent, winid, _("Waveforms"))
32 , mWt(wt)
33 , mPopulating(false)
34 {
35  if (mWt) {
36  WaveformSettings &settings = wt->GetWaveformSettings();
37  mDefaulted = (&WaveformSettings::defaults() == &settings);
38  mTempSettings = settings;
39  }
40  else {
42  mDefaulted = false;
43  }
44 
46  Populate();
47 }
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:738
static WaveformSettings & defaults()
WaveTrack *const mWt
Definition: WaveformPrefs.h:43
PrefsPanel(wxWindow *parent, wxWindowID winid, const wxString &title)
Definition: PrefsPanel.h:48
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:54
Waveform settings, either for one track or as defaults.
WaveformPrefs::~WaveformPrefs ( )
virtual

Definition at line 49 of file WaveformPrefs.cpp.

50 {
51 }

Member Function Documentation

bool WaveformPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 139 of file WaveformPrefs.cpp.

References WaveformSettings::ConvertToActualDBRange(), WaveformSettings::ConvertToEnumeratedDBRange(), WaveformSettings::defaults(), eIsGettingFromDialog, WaveformSettings::Globals::Get(), GetActiveProject(), WaveTrack::GetIndependentWaveformSettings(), Track::GetLink(), AudacityProject::GetTrackPanel(), mDefaulted, mTempSettings, mWt, PopulateOrExchange(), TrackPanel::Refresh(), WaveformSettings::Globals::SavePrefs(), WaveformSettings::SavePrefs(), WaveTrack::SetDisplay(), WaveTrack::SetWaveformSettings(), TrackPanel::UpdateVRulers(), and WaveTrack::Waveform.

140 {
141  const bool isOpenPage = this->IsShown();
142 
143  const auto partner =
144  mWt ?
145  // Assume linked track is wave or null
146  static_cast<WaveTrack*>(mWt->GetLink())
147  : nullptr;
148 
151 
154 
155  if (mWt) {
156  if (mDefaulted) {
158  if (partner)
159  partner->SetWaveformSettings({});
160  }
161  else {
162  WaveformSettings *pSettings =
164  *pSettings = mTempSettings;
165  if (partner) {
166  pSettings = &partner->GetIndependentWaveformSettings();
167  *pSettings = mTempSettings;
168  }
169  }
170  }
171 
172  if (!mWt || mDefaulted) {
173  WaveformSettings *const pSettings =
175  *pSettings = mTempSettings;
176  pSettings->SavePrefs();
177  }
178 
180 
181  if (mWt && isOpenPage) {
183  if (partner)
184  partner->SetDisplay(WaveTrack::Waveform);
185  }
186 
187  if (isOpenPage) {
189  tp->UpdateVRulers();
190  tp->Refresh(false);
191  }
192 
193  return true;
194 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
WaveformSettings & GetIndependentWaveformSettings()
Definition: WaveTrack.cpp:754
void PopulateOrExchange(ShuttleGui &S) override
static WaveformSettings & defaults()
WaveTrack *const mWt
Definition: WaveformPrefs.h:43
void SetDisplay(WaveTrackDisplay display)
Definition: WaveTrack.h:594
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:245
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
TrackPanel * GetTrackPanel()
Definition: Project.h:307
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:54
void UpdateVRulers()
void SetWaveformSettings(std::unique_ptr< WaveformSettings > &&pSettings)
Definition: WaveTrack.cpp:761
Waveform settings, either for one track or as defaults.
void WaveformPrefs::EnableDisableRange ( )
private

Definition at line 233 of file WaveformPrefs.cpp.

References mRangeChoice, mScaleChoice, and WaveformSettings::stLogarithmic.

Referenced by OnScale(), and PopulateOrExchange().

234 {
235  mRangeChoice->Enable
236  (mScaleChoice->GetSelection() == WaveformSettings::stLogarithmic);
237 }
wxChoice * mRangeChoice
Definition: WaveformPrefs.h:48
wxChoice * mScaleChoice
Definition: WaveformPrefs.h:47
void WaveformPrefs::OnControl ( wxCommandEvent &  )
private

Definition at line 201 of file WaveformPrefs.cpp.

References mDefaulted, mDefaultsCheckbox, and mPopulating.

Referenced by OnScale().

202 {
203  // Common routine for most controls
204  // If any per-track setting is changed, break the association with defaults
205  // Skip this, and View Settings... will be able to change defaults instead
206  // when the checkbox is on, as in the original design.
207 
208  if (mDefaultsCheckbox && !mPopulating) {
209  mDefaulted = false;
210  mDefaultsCheckbox->SetValue(false);
211  }
212 }
wxCheckBox * mDefaultsCheckbox
Definition: WaveformPrefs.h:46
void WaveformPrefs::OnDefaults ( wxCommandEvent &  )
private

Definition at line 222 of file WaveformPrefs.cpp.

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

223 {
224  if (mDefaultsCheckbox->IsChecked()) {
227  mDefaulted = true;
230  }
231 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void PopulateOrExchange(ShuttleGui &S) override
static WaveformSettings & defaults()
wxCheckBox * mDefaultsCheckbox
Definition: WaveformPrefs.h:46
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:54
void WaveformPrefs::OnScale ( wxCommandEvent &  e)
private

Definition at line 214 of file WaveformPrefs.cpp.

References EnableDisableRange(), and OnControl().

215 {
217 
218  // do the common part
219  OnControl(e);
220 }
void EnableDisableRange()
void OnControl(wxCommandEvent &)
void WaveformPrefs::Populate ( )
private

Definition at line 60 of file WaveformPrefs.cpp.

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

Referenced by WaveformPrefs().

61 {
63 
64  // Reuse the same choices and codes as for Interface prefs
66 
67  //------------------------- Main section --------------------
68  // Now construct the GUI itself.
71  // ----------------------- End of main section --------------
72 }
wxArrayString mRangeChoices
Definition: WaveformPrefs.h:52
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
static void GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes)
Definition: GUIPrefs.cpp:50
void PopulateOrExchange(ShuttleGui &S) override
static const wxArrayString & GetScaleNames()
wxArrayString mRangeCodes
Definition: WaveformPrefs.h:51
wxArrayString mScaleChoices
Definition: WaveformPrefs.h:50
void WaveformPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 74 of file WaveformPrefs.cpp.

References _(), WaveformSettings::dBRange, EnableDisableRange(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndTwoColumn(), ShuttleGui::Id(), ID_DEFAULTS, ID_RANGE, ID_SCALE, mDefaulted, mDefaultsCheckbox, mPopulating, mRangeChoice, mRangeChoices, mScaleChoice, mScaleChoices, mTempSettings, mWt, WaveformSettings::scaleType, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartTwoColumn(), ShuttleGuiBase::TieCheckBox(), and ShuttleGuiBase::TieChoice().

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

75 {
76  mPopulating = true;
77 
78  S.SetBorder(2);
79  S.StartScroller();
80 
81  // S.StartStatic(_("Track Settings"));
82  {
84  if (mWt) {
85  /* i18n-hint: use is a verb */
86  mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(_("&Use Preferences"), mDefaulted);
87  }
88 
89  S.StartStatic(_("Display"));
90  {
91  S.StartTwoColumn();
92  {
93  mScaleChoice =
94  S.Id(ID_SCALE).TieChoice(_("S&cale") + wxString(wxT(":")),
96  &mScaleChoices);
97 
98  mRangeChoice =
99  S.Id(ID_RANGE).TieChoice(_("Waveform dB &range") + wxString(wxT(":")),
101  &mRangeChoices);
102  }
103  S.EndTwoColumn();
104  }
105  S.EndStatic();
106  }
107  // S.EndStatic();
108 
109  /*
110  S.StartStatic(_("Global settings"));
111  {
112  }
113  S.EndStatic();
114  */
115 
116  S.EndScroller();
117 
119 
120  mPopulating = false;
121 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
wxArrayString mRangeChoices
Definition: WaveformPrefs.h:52
void EndScroller()
Definition: ShuttleGui.cpp:828
WaveTrack *const mWt
Definition: WaveformPrefs.h:43
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:795
void StartTwoColumn()
Definition: ShuttleGui.h:136
ShuttleGui & Id(int id)
void EnableDisableRange()
wxChoice * mRangeChoice
Definition: WaveformPrefs.h:48
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
wxCheckBox * mDefaultsCheckbox
Definition: WaveformPrefs.h:46
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
wxChoice * mScaleChoice
Definition: WaveformPrefs.h:47
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:54
void SetBorder(int Border)
Definition: ShuttleGui.h:286
void EndTwoColumn()
Definition: ShuttleGui.h:137
wxArrayString mScaleChoices
Definition: WaveformPrefs.h:50
bool WaveformPrefs::ShowsPreviewButton ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 196 of file WaveformPrefs.cpp.

197 {
198  return true;
199 }
bool WaveformPrefs::Validate ( )
override

Definition at line 123 of file WaveformPrefs.cpp.

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

124 {
125  // Do checking for whole numbers
126 
127  // ToDo: use wxIntegerValidator<unsigned> when available
128 
131 
132  // Delegate range checking to WaveformSettings class
134  const bool result = mTempSettings.Validate(false);
136  return result;
137 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
bool Validate(bool quiet)
void PopulateOrExchange(ShuttleGui &S) override
WaveformSettings mTempSettings
Definition: WaveformPrefs.h:54

Member Data Documentation

bool WaveformPrefs::mDefaulted
private

Definition at line 44 of file WaveformPrefs.h.

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

wxCheckBox* WaveformPrefs::mDefaultsCheckbox
private

Definition at line 46 of file WaveformPrefs.h.

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

bool WaveformPrefs::mPopulating
private

Definition at line 56 of file WaveformPrefs.h.

Referenced by OnControl(), and PopulateOrExchange().

wxChoice* WaveformPrefs::mRangeChoice
private

Definition at line 48 of file WaveformPrefs.h.

Referenced by EnableDisableRange(), and PopulateOrExchange().

wxArrayString WaveformPrefs::mRangeChoices
private

Definition at line 52 of file WaveformPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

wxArrayString WaveformPrefs::mRangeCodes
private

Definition at line 51 of file WaveformPrefs.h.

Referenced by Populate().

wxChoice* WaveformPrefs::mScaleChoice
private

Definition at line 47 of file WaveformPrefs.h.

Referenced by EnableDisableRange(), and PopulateOrExchange().

wxArrayString WaveformPrefs::mScaleChoices
private

Definition at line 50 of file WaveformPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

WaveformSettings WaveformPrefs::mTempSettings
private

Definition at line 54 of file WaveformPrefs.h.

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

WaveTrack* const WaveformPrefs::mWt
private

Definition at line 43 of file WaveformPrefs.h.

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


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