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

Public Member Functions

 Validator (EffectUIClientInterface &effect, EffectSettingsAccess &access, const EffectBassTrebleSettings &settings)
 
virtual ~Validator ()=default
 
EffectGetEffect () const
 
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 EffectUIValidator
 EffectUIValidator (EffectUIClientInterface &effect, EffectSettingsAccess &access)
 
virtual ~EffectUIValidator ()
 
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 EffectUIValidator
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 EffectUIValidator
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from EffectUIValidator
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 EffectUIValidator
EffectUIClientInterfacemEffect
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 55 of file BassTreble.cpp.

Constructor & Destructor Documentation

◆ Validator()

EffectBassTreble::Validator::Validator ( EffectUIClientInterface effect,
EffectSettingsAccess access,
const EffectBassTrebleSettings settings 
)
inline

Definition at line 58 of file BassTreble.cpp.

60 : EffectUIValidator{ effect, access }
62 {}
static Settings & settings()
Definition: TrackInfo.cpp:87
Interface for transferring values from a panel of effect controls.
Definition: EffectPlugin.h:239
EffectBassTrebleSettings mSettings
Definition: BassTreble.cpp:73

◆ ~Validator()

virtual EffectBassTreble::Validator::~Validator ( )
virtualdefault

Member Function Documentation

◆ EnableApplyFromTransferDataFromWindow()

bool EffectBassTreble::Validator::EnableApplyFromTransferDataFromWindow ( )
inline

Definition at line 101 of file BassTreble.cpp.

102 {
103 return EnableApply(
104 mUIParent, mUIParent->TransferDataFromWindow());
105 }
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:72

References EffectUIValidator::EnableApply(), and mUIParent.

Here is the call graph for this function:

◆ EnableApplyFromValidate()

void EffectBassTreble::Validator::EnableApplyFromValidate ( )
inline

Definition at line 96 of file BassTreble.cpp.

97 {
98 EnableApply(mUIParent, mUIParent->Validate());
99 }

References EffectUIValidator::EnableApply(), and mUIParent.

Here is the call graph for this function:

◆ GetEffect()

Effect & EffectBassTreble::Validator::GetEffect ( ) const
inline

Definition at line 65 of file BassTreble.cpp.

65{ return static_cast<Effect&>(mEffect); }
Base class for many of the effects in Audacity.
Definition: Effect.h:62
EffectUIClientInterface & mEffect
Definition: EffectPlugin.h:296

References EffectUIValidator::mEffect.

◆ OnBassSlider()

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

Definition at line 572 of file BassTreble.cpp.

573{
574 auto& ms = mSettings;
575
576 double oldBass = ms.mBass;
577 ms.mBass = (double) evt.GetInt() / Bass.scale;
578 mBassT->GetValidator()->TransferToWindow();
579
580 if (ms.mLink)
581 UpdateGain(oldBass, kBass);
582
584
585 ValidateUI();
587}
@ kBass
Definition: BassTreble.cpp:44
static constexpr EffectParameter Bass
Definition: BassTreble.h:89
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Definition: BassTreble.cpp:652
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:629
const Type scale
Scaling factor, for slider control.
Definition: Shuttle.h:32
Message sent by validator when a setting is changed by a user.
Definition: EffectPlugin.h:225

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

Referenced by PopulateOrExchange().

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

◆ OnBassText()

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

Definition at line 517 of file BassTreble.cpp.

518{
519 auto& ms = mSettings;
520
521 double oldBass = ms.mBass;
522
524 {
525 return;
526 }
527
528 if (ms.mLink)
529 UpdateGain(oldBass, kBass);
530
531 mBassS->SetValue((int) (ms.mBass * Bass.scale));
532
533 ValidateUI();
535}
bool EnableApplyFromTransferDataFromWindow()
Definition: BassTreble.cpp:101

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

Referenced by PopulateOrExchange().

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

◆ OnGainSlider()

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

Definition at line 606 of file BassTreble.cpp.

607{
608 auto& ms = mSettings;
609
610 ms.mGain = (double) evt.GetInt() / Gain.scale;
611 mGainT->GetValidator()->TransferToWindow();
612
614
615 ValidateUI();
617}
static constexpr EffectParameter Gain
Definition: BassTreble.h:95

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

Referenced by PopulateOrExchange().

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

◆ OnGainText()

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

Definition at line 557 of file BassTreble.cpp.

558{
559 auto& ms = mSettings;
560
562 {
563 return;
564 }
565
566 mGainS->SetValue((int) (ms.mGain * Gain.scale));
567
568 ValidateUI();
570}

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

Referenced by PopulateOrExchange().

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

◆ OnLinkCheckbox()

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

Definition at line 619 of file BassTreble.cpp.

620{
621 auto& ms = mSettings;
622
623 ms.mLink = mLinkCheckBox->GetValue();
624
625 ValidateUI();
627}

References Effect::ValidateUI().

Referenced by PopulateOrExchange().

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

◆ OnTrebleSlider()

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

Definition at line 589 of file BassTreble.cpp.

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

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

Referenced by PopulateOrExchange().

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

◆ OnTrebleText()

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

Definition at line 537 of file BassTreble.cpp.

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

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

Referenced by PopulateOrExchange().

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

◆ PopulateOrExchange()

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

Definition at line 282 of file BassTreble.cpp.

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

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, Effect::mUIParent, 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::Validator::UpdateGain ( double  oldVal,
int  control 
)

Definition at line 629 of file BassTreble.cpp.

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

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

Here is the call graph for this function:

◆ UpdateUI()

bool EffectBassTreble::Validator::UpdateUI ( )
overridevirtual

Update appearance of the panel for changes in settings.

Default implementation does nothing, returns true

Returns
true if successful

Reimplemented from EffectUIValidator.

Definition at line 362 of file BassTreble.cpp.

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

References EffectBassTreble::Bass, EffectBassTreble::Gain, EffectWithSettings< EffectBassTrebleSettings, PerTrackEffect >::GetSettings(), Effect::mUIParent, EffectParameter< Structure, Member, Type, Value >::scale, settings(), and EffectBassTreble::Treble.

Here is the call graph for this function:

◆ ValidateUI()

bool EffectBassTreble::Validator::ValidateUI ( )
overridevirtual

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

Returns
true only if panel settings are acceptable

Implements EffectUIValidator.

Definition at line 652 of file BassTreble.cpp.

653{
654 // This bit was copied from the original override of the effect's TransferDataFromWindow
655 Effect& actualEffect = static_cast<Effect&>(mEffect);
656 if (! mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
657 {
658 return false;
659 }
660
661
663 (
664 [this](EffectSettings& settings)
665 {
666 // pass back the modified settings to the MessageBuffer
667 //
669
670 return nullptr;
671 }
672 );
673
674 return true;
675}
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
Externalized state of a plug-in.

References EffectWithSettings< EffectBassTrebleSettings, PerTrackEffect >::GetSettings(), Effect::mUIParent, and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mBassS

wxSlider* EffectBassTreble::Validator::mBassS

Definition at line 75 of file BassTreble.cpp.

◆ mBassT

wxTextCtrl* EffectBassTreble::Validator::mBassT

Definition at line 79 of file BassTreble.cpp.

◆ mGainS

wxSlider* EffectBassTreble::Validator::mGainS

Definition at line 77 of file BassTreble.cpp.

◆ mGainT

wxTextCtrl* EffectBassTreble::Validator::mGainT

Definition at line 81 of file BassTreble.cpp.

◆ mLinkCheckBox

wxCheckBox* EffectBassTreble::Validator::mLinkCheckBox

Definition at line 83 of file BassTreble.cpp.

◆ mSettings

EffectBassTrebleSettings EffectBassTreble::Validator::mSettings

Definition at line 73 of file BassTreble.cpp.

◆ mTrebleS

wxSlider* EffectBassTreble::Validator::mTrebleS

Definition at line 76 of file BassTreble.cpp.

◆ mTrebleT

wxTextCtrl* EffectBassTreble::Validator::mTrebleT

Definition at line 80 of file BassTreble.cpp.

◆ mUIParent

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

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