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 EffectBassTrebleSettings &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 {}
 
EffectBassTrebleSettings 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 55 of file BassTreble.cpp.

Constructor & Destructor Documentation

◆ Editor()

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

Definition at line 58 of file BassTreble.cpp.

60 : EffectEditor{ services, access }
62 {}
static Settings & settings()
Definition: TrackInfo.cpp:69
EffectBassTrebleSettings mSettings
Definition: BassTreble.cpp:71

◆ ~Editor()

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

Member Function Documentation

◆ EnableApplyFromTransferDataFromWindow()

bool EffectBassTreble::Editor::EnableApplyFromTransferDataFromWindow ( )
inline

Definition at line 99 of file BassTreble.cpp.

100 {
101 return EnableApply(
102 mUIParent, mUIParent->TransferDataFromWindow());
103 }
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:70

References EffectEditor::EnableApply(), and mUIParent.

Here is the call graph for this function:

◆ EnableApplyFromValidate()

void EffectBassTreble::Editor::EnableApplyFromValidate ( )
inline

Definition at line 94 of file BassTreble.cpp.

95 {
96 EnableApply(mUIParent, mUIParent->Validate());
97 }

References EffectEditor::EnableApply(), and mUIParent.

Here is the call graph for this function:

◆ OnBassSlider()

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

Definition at line 568 of file BassTreble.cpp.

569{
570 auto& ms = mSettings;
571
572 double oldBass = ms.mBass;
573 ms.mBass = (double) evt.GetInt() / Bass.scale;
574 mBassT->GetValidator()->TransferToWindow();
575
576 if (ms.mLink)
577 UpdateGain(oldBass, kBass);
578
580
581 ValidateUI();
583}
@ kBass
Definition: BassTreble.cpp:44
static constexpr EffectParameter Bass
Definition: BassTreble.h:92
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:625
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Definition: BassTreble.cpp:648
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 EffectBassTreble::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 513 of file BassTreble.cpp.

514{
515 auto& ms = mSettings;
516
517 double oldBass = ms.mBass;
518
520 {
521 return;
522 }
523
524 if (ms.mLink)
525 UpdateGain(oldBass, kBass);
526
527 mBassS->SetValue((int) (ms.mBass * Bass.scale));
528
529 ValidateUI();
531}
bool EnableApplyFromTransferDataFromWindow()
Definition: BassTreble.cpp:99

References EffectBassTreble::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 602 of file BassTreble.cpp.

603{
604 auto& ms = mSettings;
605
606 ms.mGain = (double) evt.GetInt() / Gain.scale;
607 mGainT->GetValidator()->TransferToWindow();
608
610
611 ValidateUI();
613}
static constexpr EffectParameter Gain
Definition: BassTreble.h:98

References EffectBassTreble::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 553 of file BassTreble.cpp.

554{
555 auto& ms = mSettings;
556
558 {
559 return;
560 }
561
562 mGainS->SetValue((int) (ms.mGain * Gain.scale));
563
564 ValidateUI();
566}

References EffectBassTreble::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 615 of file BassTreble.cpp.

616{
617 auto& ms = mSettings;
618
619 ms.mLink = mLinkCheckBox->GetValue();
620
621 ValidateUI();
623}
wxCheckBox * mLinkCheckBox
Definition: BassTreble.cpp:81

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 585 of file BassTreble.cpp.

586{
587 auto& ms = mSettings;
588
589 double oldTreble = ms.mTreble;
590 ms.mTreble = (double) evt.GetInt() / Treble.scale;
591 mTrebleT->GetValidator()->TransferToWindow();
592
593 if (ms.mLink)
594 UpdateGain(oldTreble, kTreble);
595
597
598 ValidateUI();
600}
@ kTreble
Definition: BassTreble.cpp:45
static constexpr EffectParameter Treble
Definition: BassTreble.h:95

References kTreble, EffectParameter< Structure, Member, Type, Value >::scale, EffectBassTreble::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 533 of file BassTreble.cpp.

534{
535 auto& ms = mSettings;
536
537 double oldTreble = ms.mTreble;
538
540 {
541 return;
542 }
543
544 if (ms.mLink)
545 UpdateGain(oldTreble, kTreble);
546
547 mTrebleS->SetValue((int) (ms.mTreble * Treble.scale));
548
549 ValidateUI();
551}

References kTreble, EffectParameter< Structure, Member, Type, Value >::scale, EffectBassTreble::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 280 of file BassTreble.cpp.

281{
282 mUIParent = S.GetParent();
283 auto& ms = mSettings;
284
285 S.SetBorder(5);
286 S.AddSpace(0, 5);
287
288 S.StartStatic(XO("Tone controls"));
289 {
290 S.StartMultiColumn(3, wxEXPAND);
291 {
292 S.SetStretchyCol(2);
293
294 // Bass control
295 mBassT = S
296 .Name(XO("Bass (dB):"))
297 .Validator<FloatingPointValidator<double>>(
298 1, &ms.mBass, NumValidatorStyle::DEFAULT, Bass.min, Bass.max)
299 .AddTextBox(XXO("Ba&ss (dB):"), L"", 10);
300 BindTo(*mBassT, wxEVT_TEXT, &Editor::OnBassText);
301
302 mBassS = S
303 .Name(XO("Bass"))
304 .Style(wxSL_HORIZONTAL)
305 .AddSlider( {}, 0, Bass.max * Bass.scale, Bass.min * Bass.scale);
306 BindTo(*mBassS, wxEVT_SLIDER, &Editor::OnBassSlider);
307
308 // Treble control
309 mTrebleT = S
310 .Validator<FloatingPointValidator<double>>(
311 1, &ms.mTreble, NumValidatorStyle::DEFAULT, Treble.min, Treble.max)
312 .AddTextBox(XXO("&Treble (dB):"), L"", 10);
313 BindTo(*mTrebleT, wxEVT_TEXT, &Editor::OnTrebleText);
314
315 mTrebleS = S
316 .Name(XO("Treble"))
317 .Style(wxSL_HORIZONTAL)
318 .AddSlider( {}, 0, Treble.max * Treble.scale, Treble.min * Treble.scale);
319 BindTo(*mTrebleS, wxEVT_SLIDER, &Editor::OnTrebleSlider);
320 }
321 S.EndMultiColumn();
322 }
323 S.EndStatic();
324
325 S.StartStatic(XO("Output"));
326 {
327 S.StartMultiColumn(3, wxEXPAND);
328 {
329 S.SetStretchyCol(2);
330
331 // Gain control
332 mGainT = S
333 .Validator<FloatingPointValidator<double>>(
334 1, &ms.mGain, NumValidatorStyle::DEFAULT, Gain.min, Gain.max)
335 .AddTextBox(XXO("&Volume (dB):"), L"", 10);
336 BindTo(*mGainT, wxEVT_TEXT, &Editor::OnGainText);
337
338 mGainS = S
339 .Name(XO("Level"))
340 .Style(wxSL_HORIZONTAL)
341 .AddSlider( {}, 0, Gain.max * Gain.scale, Gain.min * Gain.scale);
342 BindTo(*mGainS, wxEVT_SLIDER, &Editor::OnGainSlider);
343 }
344 S.EndMultiColumn();
345
346 S.StartMultiColumn(2, wxCENTER);
347 {
348 // Link checkbox
350 S
351 .AddCheckBox(XXO("&Link Volume control to Tone controls"),
352 Link.def);
353 BindTo(*mLinkCheckBox, wxEVT_CHECKBOX, &Editor::OnLinkCheckbox);
354 }
355 S.EndMultiColumn();
356 }
357 S.EndStatic();
358}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64
static constexpr EffectParameter Link
Definition: BassTreble.h:101
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectEditor.h:85
void OnTrebleText(wxCommandEvent &evt)
Definition: BassTreble.cpp:533
void OnLinkCheckbox(wxCommandEvent &evt)
Definition: BassTreble.cpp:615
void OnGainText(wxCommandEvent &evt)
Definition: BassTreble.cpp:553
void OnBassSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:568
void OnBassText(wxCommandEvent &evt)
Definition: BassTreble.cpp:513
void OnTrebleSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:585
void OnGainSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:602
const Type def
Default value.
const Type min
Minimum value.
const Type max
Maximum value.

References EffectBassTreble::Bass, EffectParameter< Structure, Member, Type, Value >::def, EffectBassTreble::Gain, EffectBassTreble::Link, EffectParameter< Structure, Member, Type, Value >::max, EffectParameter< Structure, Member, Type, Value >::min, OnBassSlider(), OnBassText(), OnGainSlider(), OnGainText(), OnLinkCheckbox(), OnTrebleSlider(), OnTrebleText(), S, EffectParameter< Structure, Member, Type, Value >::scale, EffectBassTreble::Treble, XO(), and XXO().

Here is the call graph for this function:

◆ UpdateGain()

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

Definition at line 625 of file BassTreble.cpp.

626{
627 auto& ms = mSettings;
628
629 double newVal;
630 oldVal = (oldVal > 0)? oldVal / 2.0 : oldVal / 4.0;
631
632 if (control == kBass)
633 newVal = (ms.mBass > 0)? ms.mBass / 2.0 : ms.mBass / 4.0;
634 else
635 newVal = (ms.mTreble > 0)? ms.mTreble / 2.0 : ms.mTreble / 4.0;
636
637 ms.mGain -= newVal - oldVal;
638 ms.mGain = std::min(Gain.max, std::max(Gain.min, ms.mGain));
639
640 mGainS->SetValue(ms.mGain);
641 mGainT->GetValidator()->TransferToWindow();
642
643}
int min(int a, int b)

References EffectBassTreble::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 360 of file BassTreble.cpp.

361{
362 // get the settings from the MessageBuffer and write them to our local copy
363 const auto& settings = mAccess.Get();
364
366
367 if (! mUIParent->TransferDataToWindow())
368 {
369 return false;
370 }
371
372 mBassS-> SetValue((int)(mSettings.mBass * Bass.scale));
373 mTrebleS-> SetValue((int)(mSettings.mTreble *Treble.scale));
374 mGainS-> SetValue((int)(mSettings.mGain * Gain.scale));
375 mLinkCheckBox->SetValue(mSettings.mLink);
376
377 return true;
378}
EffectSettingsAccess & mAccess
Definition: EffectEditor.h:92
virtual const EffectSettings & Get()=0
static EffectBassTrebleSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166

References EffectBassTreble::Bass, EffectBassTreble::Gain, EffectWithSettings< EffectBassTrebleSettings, StatelessPerTrackEffect >::GetSettings(), EffectParameter< Structure, Member, Type, Value >::scale, settings(), and EffectBassTreble::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 648 of file BassTreble.cpp.

649{
650 // This bit was copied from the original override of the effect's TransferDataFromWindow
651 if (! mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
652 {
653 return false;
654 }
655
656
658 (
659 [this](EffectSettings& settings)
660 {
661 // pass back the modified settings to the MessageBuffer
662 //
664
665 return nullptr;
666 }
667 );
668
669 return true;
670}
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
Externalized state of a plug-in.

References EffectWithSettings< EffectBassTrebleSettings, StatelessPerTrackEffect >::GetSettings(), and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mBassS

wxSlider* EffectBassTreble::Editor::mBassS

Definition at line 73 of file BassTreble.cpp.

◆ mBassT

wxTextCtrl* EffectBassTreble::Editor::mBassT

Definition at line 77 of file BassTreble.cpp.

◆ mGainS

wxSlider* EffectBassTreble::Editor::mGainS

Definition at line 75 of file BassTreble.cpp.

◆ mGainT

wxTextCtrl* EffectBassTreble::Editor::mGainT

Definition at line 79 of file BassTreble.cpp.

◆ mLinkCheckBox

wxCheckBox* EffectBassTreble::Editor::mLinkCheckBox

Definition at line 81 of file BassTreble.cpp.

◆ mSettings

EffectBassTrebleSettings EffectBassTreble::Editor::mSettings

Definition at line 71 of file BassTreble.cpp.

◆ mTrebleS

wxSlider* EffectBassTreble::Editor::mTrebleS

Definition at line 74 of file BassTreble.cpp.

◆ mTrebleT

wxTextCtrl* EffectBassTreble::Editor::mTrebleT

Definition at line 78 of file BassTreble.cpp.

◆ mUIParent

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

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