Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
EffectBassTreble::Editor Struct Reference
Inheritance diagram for EffectBassTreble::Editor:
[legend]
Collaboration diagram for EffectBassTreble::Editor:
[legend]

Public Member Functions

 Editor (const EffectUIServices &services, EffectSettingsAccess &access, const BassTrebleSettings &settings)
 
virtual ~Editor ()=default
 
bool ValidateUI () override
 Get settings data from the panel; may make error dialogs and return false. More...
 
bool UpdateUI () override
 Update appearance of the panel for changes in settings. More...
 
void PopulateOrExchange (ShuttleGui &S)
 
void OnBassText (wxCommandEvent &evt)
 
void OnTrebleText (wxCommandEvent &evt)
 
void OnGainText (wxCommandEvent &evt)
 
void OnBassSlider (wxCommandEvent &evt)
 
void OnTrebleSlider (wxCommandEvent &evt)
 
void OnGainSlider (wxCommandEvent &evt)
 
void OnLinkCheckbox (wxCommandEvent &evt)
 
void UpdateGain (double oldVal, int control)
 
void EnableApplyFromValidate ()
 
bool EnableApplyFromTransferDataFromWindow ()
 
- Public Member Functions inherited from EffectEditor
 EffectEditor (const EffectUIServices &services, EffectSettingsAccess &access)
 
virtual ~EffectEditor ()
 
virtual bool ValidateUI ()=0
 Get settings data from the panel; may make error dialogs and return false. More...
 
virtual bool UpdateUI ()
 Update appearance of the panel for changes in settings. More...
 
virtual bool IsGraphicalUI ()
 
virtual void Disconnect ()
 On the first call only, may disconnect from further event handling. More...
 
virtual void OnClose ()
 
- Public Member Functions inherited from Observer::Publisher< EffectSettingChanged >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Public Attributes

wxWeakRef< wxWindow > mUIParent {}
 
BassTrebleSettings mSettings
 
wxSlider * mBassS
 
wxSlider * mTrebleS
 
wxSlider * mGainS
 
wxTextCtrl * mBassT
 
wxTextCtrl * mTrebleT
 
wxTextCtrl * mGainT
 
wxCheckBox * mLinkCheckBox
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< EffectSettingChanged >
using message_type = EffectSettingChanged
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const EffectSettingChanged &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Member Functions inherited from EffectEditor
static bool EnableApply (wxWindow *parent, bool enable=true)
 Enable or disable the Apply button of the dialog that contains parent. More...
 
static bool EnablePreview (wxWindow *parent, bool enable=true)
 
- Static Public Attributes inherited from EffectEditor
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from EffectEditor
template<typename EventTag , typename Class , typename Event >
void BindTo (wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
 
- Protected Member Functions inherited from Observer::Publisher< EffectSettingChanged >
CallbackReturn Publish (const EffectSettingChanged &message)
 Send a message to connected callbacks. More...
 
- Protected Attributes inherited from EffectEditor
const EffectUIServicesmUIServices
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 35 of file BassTreble.cpp.

Constructor & Destructor Documentation

◆ Editor()

EffectBassTreble::Editor::Editor ( const EffectUIServices services,
EffectSettingsAccess access,
const BassTrebleSettings settings 
)
inline

Definition at line 38 of file BassTreble.cpp.

40 : EffectEditor{ services, access }
42 {}
static Settings & settings()
Definition: TrackInfo.cpp:51
BassTrebleSettings mSettings
Definition: BassTreble.cpp:51

◆ ~Editor()

virtual EffectBassTreble::Editor::~Editor ( )
virtualdefault

Member Function Documentation

◆ EnableApplyFromTransferDataFromWindow()

bool EffectBassTreble::Editor::EnableApplyFromTransferDataFromWindow ( )
inline

Definition at line 79 of file BassTreble.cpp.

80 {
81 return EnableApply(
82 mUIParent, mUIParent->TransferDataFromWindow());
83 }
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
wxWeakRef< wxWindow > mUIParent
Definition: BassTreble.cpp:50

References EffectEditor::EnableApply(), and mUIParent.

Here is the call graph for this function:

◆ EnableApplyFromValidate()

void EffectBassTreble::Editor::EnableApplyFromValidate ( )
inline

Definition at line 74 of file BassTreble.cpp.

75 {
76 EnableApply(mUIParent, mUIParent->Validate());
77 }

References EffectEditor::EnableApply(), and mUIParent.

Here is the call graph for this function:

◆ OnBassSlider()

void EffectBassTreble::Editor::OnBassSlider ( wxCommandEvent &  evt)

Definition at line 261 of file BassTreble.cpp.

262{
263 auto& ms = mSettings;
264
265 double oldBass = ms.mBass;
266 ms.mBass = (double) evt.GetInt() / Bass.scale;
267 mBassT->GetValidator()->TransferToWindow();
268
269 if (ms.mLink)
270 UpdateGain(oldBass, kBass);
271
273
274 ValidateUI();
276}
@ kBass
static constexpr EffectParameter Bass
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:318
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Definition: BassTreble.cpp:338
const Type scale
Scaling factor, for slider control.
Message sent by EffectEditor when a setting is changed by the user.
Definition: EffectEditor.h:26

References BassTrebleBase::Bass, kBass, EffectParameter< Structure, Member, Type, Value >::scale, and BasicEffectUIServices::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ OnBassText()

void EffectBassTreble::Editor::OnBassText ( wxCommandEvent &  evt)

Definition at line 206 of file BassTreble.cpp.

207{
208 auto& ms = mSettings;
209
210 double oldBass = ms.mBass;
211
213 {
214 return;
215 }
216
217 if (ms.mLink)
218 UpdateGain(oldBass, kBass);
219
220 mBassS->SetValue((int) (ms.mBass * Bass.scale));
221
222 ValidateUI();
224}
bool EnableApplyFromTransferDataFromWindow()
Definition: BassTreble.cpp:79

References BassTrebleBase::Bass, kBass, EffectParameter< Structure, Member, Type, Value >::scale, and BasicEffectUIServices::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ OnGainSlider()

void EffectBassTreble::Editor::OnGainSlider ( wxCommandEvent &  evt)

Definition at line 295 of file BassTreble.cpp.

296{
297 auto& ms = mSettings;
298
299 ms.mGain = (double) evt.GetInt() / Gain.scale;
300 mGainT->GetValidator()->TransferToWindow();
301
303
304 ValidateUI();
306}
static constexpr EffectParameter Gain

References BassTrebleBase::Gain, EffectParameter< Structure, Member, Type, Value >::scale, and BasicEffectUIServices::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ OnGainText()

void EffectBassTreble::Editor::OnGainText ( wxCommandEvent &  evt)

Definition at line 246 of file BassTreble.cpp.

247{
248 auto& ms = mSettings;
249
251 {
252 return;
253 }
254
255 mGainS->SetValue((int) (ms.mGain * Gain.scale));
256
257 ValidateUI();
259}

References BassTrebleBase::Gain, EffectParameter< Structure, Member, Type, Value >::scale, and BasicEffectUIServices::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ OnLinkCheckbox()

void EffectBassTreble::Editor::OnLinkCheckbox ( wxCommandEvent &  evt)

Definition at line 308 of file BassTreble.cpp.

309{
310 auto& ms = mSettings;
311
312 ms.mLink = mLinkCheckBox->GetValue();
313
314 ValidateUI();
316}
wxCheckBox * mLinkCheckBox
Definition: BassTreble.cpp:61

References BasicEffectUIServices::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ OnTrebleSlider()

void EffectBassTreble::Editor::OnTrebleSlider ( wxCommandEvent &  evt)

Definition at line 278 of file BassTreble.cpp.

279{
280 auto& ms = mSettings;
281
282 double oldTreble = ms.mTreble;
283 ms.mTreble = (double) evt.GetInt() / Treble.scale;
284 mTrebleT->GetValidator()->TransferToWindow();
285
286 if (ms.mLink)
287 UpdateGain(oldTreble, kTreble);
288
290
291 ValidateUI();
293}
@ kTreble
static constexpr EffectParameter Treble

References kTreble, EffectParameter< Structure, Member, Type, Value >::scale, BassTrebleBase::Treble, and BasicEffectUIServices::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ OnTrebleText()

void EffectBassTreble::Editor::OnTrebleText ( wxCommandEvent &  evt)

Definition at line 226 of file BassTreble.cpp.

227{
228 auto& ms = mSettings;
229
230 double oldTreble = ms.mTreble;
231
233 {
234 return;
235 }
236
237 if (ms.mLink)
238 UpdateGain(oldTreble, kTreble);
239
240 mTrebleS->SetValue((int) (ms.mTreble * Treble.scale));
241
242 ValidateUI();
244}

References kTreble, EffectParameter< Structure, Member, Type, Value >::scale, BassTrebleBase::Treble, and BasicEffectUIServices::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ PopulateOrExchange()

void EffectBassTreble::Editor::PopulateOrExchange ( ShuttleGui S)

Definition at line 106 of file BassTreble.cpp.

107{
108 mUIParent = S.GetParent();
109 auto& ms = mSettings;
110
111 S.SetBorder(5);
112 S.AddSpace(0, 5);
113
114 S.StartStatic(XO("Tone controls"));
115 {
116 S.StartMultiColumn(3, wxEXPAND);
117 {
118 S.SetStretchyCol(2);
119
120 // Bass control
121 mBassT = S
122 .Name(XO("Bass (dB):"))
123 .Validator<FloatingPointValidator<double>>(
124 1, &ms.mBass, NumValidatorStyle::DEFAULT, Bass.min, Bass.max)
125 .AddTextBox(XXO("Ba&ss (dB):"), L"", 10);
126 BindTo(*mBassT, wxEVT_TEXT, &Editor::OnBassText);
127
128 mBassS = S
129 .Name(XO("Bass"))
130 .Style(wxSL_HORIZONTAL)
131 .AddSlider( {}, 0, Bass.max * Bass.scale, Bass.min * Bass.scale);
132 BindTo(*mBassS, wxEVT_SLIDER, &Editor::OnBassSlider);
133
134 // Treble control
135 mTrebleT = S
136 .Validator<FloatingPointValidator<double>>(
137 1, &ms.mTreble, NumValidatorStyle::DEFAULT, Treble.min, Treble.max)
138 .AddTextBox(XXO("&Treble (dB):"), L"", 10);
139 BindTo(*mTrebleT, wxEVT_TEXT, &Editor::OnTrebleText);
140
141 mTrebleS = S
142 .Name(XO("Treble"))
143 .Style(wxSL_HORIZONTAL)
144 .AddSlider( {}, 0, Treble.max * Treble.scale, Treble.min * Treble.scale);
145 BindTo(*mTrebleS, wxEVT_SLIDER, &Editor::OnTrebleSlider);
146 }
147 S.EndMultiColumn();
148 }
149 S.EndStatic();
150
151 S.StartStatic(XO("Output"));
152 {
153 S.StartMultiColumn(3, wxEXPAND);
154 {
155 S.SetStretchyCol(2);
156
157 // Gain control
158 mGainT = S
159 .Validator<FloatingPointValidator<double>>(
160 1, &ms.mGain, NumValidatorStyle::DEFAULT, Gain.min, Gain.max)
161 .AddTextBox(XXO("&Volume (dB):"), L"", 10);
162 BindTo(*mGainT, wxEVT_TEXT, &Editor::OnGainText);
163
164 mGainS = S
165 .Name(XO("Level"))
166 .Style(wxSL_HORIZONTAL)
167 .AddSlider( {}, 0, Gain.max * Gain.scale, Gain.min * Gain.scale);
168 BindTo(*mGainS, wxEVT_SLIDER, &Editor::OnGainSlider);
169 }
170 S.EndMultiColumn();
171
172 S.StartMultiColumn(2, wxCENTER);
173 {
174 // Link checkbox
176 S
177 .AddCheckBox(XXO("&Link Volume control to Tone controls"),
178 Link.def);
179 BindTo(*mLinkCheckBox, wxEVT_CHECKBOX, &Editor::OnLinkCheckbox);
180 }
181 S.EndMultiColumn();
182 }
183 S.EndStatic();
184}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64
static constexpr EffectParameter Link
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectEditor.h:85
void OnTrebleText(wxCommandEvent &evt)
Definition: BassTreble.cpp:226
void OnLinkCheckbox(wxCommandEvent &evt)
Definition: BassTreble.cpp:308
void OnGainText(wxCommandEvent &evt)
Definition: BassTreble.cpp:246
void OnBassSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:261
void OnBassText(wxCommandEvent &evt)
Definition: BassTreble.cpp:206
void OnTrebleSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:278
void OnGainSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:295
const Type def
Default value.
const Type min
Minimum value.
const Type max
Maximum value.

References BassTrebleBase::Bass, EffectEditor::BindTo(), EffectParameter< Structure, Member, Type, Value >::def, BassTrebleBase::Gain, BassTrebleBase::Link, EffectParameter< Structure, Member, Type, Value >::max, mBassS, mBassT, mGainS, mGainT, EffectParameter< Structure, Member, Type, Value >::min, mLinkCheckBox, mSettings, mTrebleS, mTrebleT, mUIParent, OnBassSlider(), OnBassText(), OnGainSlider(), OnGainText(), OnLinkCheckbox(), OnTrebleSlider(), OnTrebleText(), S, EffectParameter< Structure, Member, Type, Value >::scale, BassTrebleBase::Treble, XO(), and XXO().

Here is the call graph for this function:

◆ UpdateGain()

void EffectBassTreble::Editor::UpdateGain ( double  oldVal,
int  control 
)

Definition at line 318 of file BassTreble.cpp.

319{
320 auto& ms = mSettings;
321
322 double newVal;
323 oldVal = (oldVal > 0)? oldVal / 2.0 : oldVal / 4.0;
324
325 if (control == kBass)
326 newVal = (ms.mBass > 0)? ms.mBass / 2.0 : ms.mBass / 4.0;
327 else
328 newVal = (ms.mTreble > 0)? ms.mTreble / 2.0 : ms.mTreble / 4.0;
329
330 ms.mGain -= newVal - oldVal;
331 ms.mGain = std::min(Gain.max, std::max(Gain.min, ms.mGain));
332
333 mGainS->SetValue(ms.mGain);
334 mGainT->GetValidator()->TransferToWindow();
335
336}
int min(int a, int b)

References BassTrebleBase::Gain, kBass, EffectParameter< Structure, Member, Type, Value >::max, EffectParameter< Structure, Member, Type, Value >::min, and min().

Here is the call graph for this function:

◆ UpdateUI()

bool EffectBassTreble::Editor::UpdateUI ( )
overridevirtual

Update appearance of the panel for changes in settings.

Default implementation does nothing, returns true

Returns
true if successful

Reimplemented from EffectEditor.

Definition at line 186 of file BassTreble.cpp.

187{
188 // get the settings from the MessageBuffer and write them to our local copy
189 const auto& settings = mAccess.Get();
190
192
193 if (! mUIParent->TransferDataToWindow())
194 {
195 return false;
196 }
197
198 mBassS-> SetValue((int)(mSettings.mBass * Bass.scale));
199 mTrebleS-> SetValue((int)(mSettings.mTreble *Treble.scale));
200 mGainS-> SetValue((int)(mSettings.mGain * Gain.scale));
201 mLinkCheckBox->SetValue(mSettings.mLink);
202
203 return true;
204}
EffectSettingsAccess & mAccess
Definition: EffectEditor.h:92
virtual const EffectSettings & Get()=0
static BassTrebleSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166

References BassTrebleBase::Bass, BassTrebleBase::Gain, EffectWithSettings< BassTrebleSettings, PerTrackEffect >::GetSettings(), EffectParameter< Structure, Member, Type, Value >::scale, settings(), and BassTrebleBase::Treble.

Here is the call graph for this function:

◆ ValidateUI()

bool EffectBassTreble::Editor::ValidateUI ( )
overridevirtual

Get settings data from the panel; may make error dialogs and return false.

Returns
true only if panel settings are acceptable

Implements EffectEditor.

Definition at line 338 of file BassTreble.cpp.

339{
340 // This bit was copied from the original override of the effect's TransferDataFromWindow
341 if (! mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
342 {
343 return false;
344 }
345
346
348 (
349 [this](EffectSettings& settings)
350 {
351 // pass back the modified settings to the MessageBuffer
352 //
354
355 return nullptr;
356 }
357 );
358
359 return true;
360}
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
Externalized state of a plug-in.

References EffectWithSettings< BassTrebleSettings, PerTrackEffect >::GetSettings(), and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mBassS

wxSlider* EffectBassTreble::Editor::mBassS

Definition at line 53 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mBassT

wxTextCtrl* EffectBassTreble::Editor::mBassT

Definition at line 57 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mGainS

wxSlider* EffectBassTreble::Editor::mGainS

Definition at line 55 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mGainT

wxTextCtrl* EffectBassTreble::Editor::mGainT

Definition at line 59 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mLinkCheckBox

wxCheckBox* EffectBassTreble::Editor::mLinkCheckBox

Definition at line 61 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mSettings

BassTrebleSettings EffectBassTreble::Editor::mSettings

Definition at line 51 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mTrebleS

wxSlider* EffectBassTreble::Editor::mTrebleS

Definition at line 54 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mTrebleT

wxTextCtrl* EffectBassTreble::Editor::mTrebleT

Definition at line 58 of file BassTreble.cpp.

Referenced by PopulateOrExchange().

◆ mUIParent

wxWeakRef<wxWindow> EffectBassTreble::Editor::mUIParent {}

The documentation for this struct was generated from the following file: