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

Public Member Functions

 Validator (EffectUIClientInterface &effect, EffectSettingsAccess &access, const DtmfSettings &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 DoUpdateUI ()
 
void PopulateOrExchange (ShuttleGui &S, const EffectSettings &settings, double projectRate)
 
void OnSequence (wxCommandEvent &evt)
 
void OnDuration (wxCommandEvent &evt)
 
void OnDutyCycle (wxCommandEvent &evt)
 
- 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

DtmfSettings mSettings
 
wxTextCtrl * mDtmfSequenceT
 
wxSlider * mDtmfDutyCycleS
 
NumericTextCtrlmDtmfDurationT
 
wxStaticText * mDtmfToneT
 
wxStaticText * mDtmfSilenceT
 
wxStaticText * mDtmfDutyT
 

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 291 of file DtmfGen.cpp.

Constructor & Destructor Documentation

◆ Validator()

EffectDtmf::Validator::Validator ( EffectUIClientInterface effect,
EffectSettingsAccess access,
const DtmfSettings settings 
)
inline

Definition at line 294 of file DtmfGen.cpp.

296 : EffectUIValidator{effect, access}
297 // Copy settings
299 {}
static Settings & settings()
Definition: TrackInfo.cpp:87
Interface for transferring values from a panel of effect controls.
Definition: EffectPlugin.h:239
DtmfSettings mSettings
Definition: DtmfGen.cpp:315

◆ ~Validator()

virtual EffectDtmf::Validator::~Validator ( )
virtualdefault

Member Function Documentation

◆ DoUpdateUI()

void EffectDtmf::Validator::DoUpdateUI ( )

Definition at line 645 of file DtmfGen.cpp.

646{
647 // Update some texts in response to controls
648 auto &dtmfSettings = mSettings;
649
651 ->SetLabel(wxString::Format(wxT("%.1f %%"), dtmfSettings.dtmfDutyCycle));
652 mDtmfDutyT->SetName(mDtmfDutyT->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
653
655 ->SetLabel(wxString::Format(_("%.0f ms"), dtmfSettings.dtmfTone * 1000.0));
656 mDtmfSilenceT->SetName(mDtmfSilenceT->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
657
659 ->SetLabel(wxString::Format(_("%.0f ms"), dtmfSettings.dtmfSilence * 1000.0));
660 mDtmfToneT->SetName(mDtmfToneT->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
661}
wxT("CloseDown"))
#define _(s)
Definition: Internat.h:75
wxStaticText * mDtmfToneT
Definition: DtmfGen.cpp:320
wxStaticText * mDtmfSilenceT
Definition: DtmfGen.cpp:321
wxStaticText * mDtmfDutyT
Definition: DtmfGen.cpp:322

References _, and wxT().

Here is the call graph for this function:

◆ GetEffect()

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

Definition at line 302 of file DtmfGen.cpp.

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

References EffectUIValidator::mEffect.

◆ OnDuration()

void EffectDtmf::Validator::OnDuration ( wxCommandEvent &  evt)

Definition at line 674 of file DtmfGen.cpp.

675{
677 auto &dtmfSettings = mSettings;
678 auto &effect = GetEffect();
679 settings.extra.SetDuration(mDtmfDurationT->GetValue());
680 dtmfSettings.Recalculate(settings);
681 return nullptr;
682 });
683 DoUpdateUI();
684}
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
EffectSettingsAccess & mAccess
Definition: EffectPlugin.h:297
NumericTextCtrl * mDtmfDurationT
Definition: DtmfGen.cpp:319
Effect & GetEffect() const
Definition: DtmfGen.cpp:302
Externalized state of a plug-in.

References settings().

Referenced by PopulateOrExchange().

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

◆ OnDutyCycle()

void EffectDtmf::Validator::OnDutyCycle ( wxCommandEvent &  evt)

Definition at line 686 of file DtmfGen.cpp.

687{
689 auto &dtmfSettings = mSettings;
690 dtmfSettings.dtmfDutyCycle = (double) evt.GetInt() / DutyCycle.scale;
691 dtmfSettings.Recalculate(settings);
692 return nullptr;
693 });
694 DoUpdateUI();
695}
static constexpr EffectParameter DutyCycle
Definition: DtmfGen.h:84
double dtmfDutyCycle
Definition: DtmfGen.h:35
const Type scale
Scaling factor, for slider control.
Definition: Shuttle.h:32

References EffectDtmf::DutyCycle, EffectParameter< Structure, Member, Type, Value >::scale, and settings().

Referenced by PopulateOrExchange().

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

◆ OnSequence()

void EffectDtmf::Validator::OnSequence ( wxCommandEvent &  evt)

Definition at line 663 of file DtmfGen.cpp.

664{
666 auto &dtmfSettings = mSettings;
667 dtmfSettings.dtmfSequence = mDtmfSequenceT->GetValue();
668 dtmfSettings.Recalculate(settings);
669 return nullptr;
670 });
671 DoUpdateUI();
672}
wxString dtmfSequence
Definition: DtmfGen.h:31
wxTextCtrl * mDtmfSequenceT
Definition: DtmfGen.cpp:317

References settings().

Referenced by PopulateOrExchange().

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

◆ PopulateOrExchange()

void EffectDtmf::Validator::PopulateOrExchange ( ShuttleGui S,
const EffectSettings settings,
double  projectRate 
)

Definition at line 325 of file DtmfGen.cpp.

327{
328 // Reference to our copy of this effect's special settings
329 auto &dtmfSettings = mSettings;
330
331 // Do NOT hold a reference to EffectSettings, just use it to find initial
332 // duration values. (It came from EffectSettingsAccess so its stable address
333 // can't be relied on.)
334
335 // dialog will be passed values from effect
336 // Effect retrieves values from saved config
337 // Dialog will take care of using them to initialize controls
338 // If there is a selection, use that duration, otherwise use
339 // value from saved config: this is useful is user wants to
340 // replace selection with dtmf sequence
341
342 S.AddSpace(0, 5);
343 S.StartMultiColumn(2, wxCENTER);
344 {
346 S
347 .Validator([&dtmfSettings]{
348 wxTextValidator vldDtmf(
349 wxFILTER_INCLUDE_CHAR_LIST, &dtmfSettings.dtmfSequence);
350 vldDtmf.SetIncludes(wxArrayString(WXSIZEOF(kSymbols), kSymbols));
351 return vldDtmf;
352 })
353 .AddTextBox(XXO("DTMF &sequence:"), wxT(""), 10);
355
356 // A control with no event handler but the validator causes updates
357 // when TransferData functions are called
358 S
359 .Validator<FloatingPointValidator<double>>(
360 3, &dtmfSettings.dtmfAmplitude, NumValidatorStyle::NO_TRAILING_ZEROES,
362 .AddTextBox(XXO("&Amplitude (0-1):"), wxT(""), 10);
363
364 S.AddPrompt(XXO("&Duration:"));
365 auto &extra = settings.extra;
367 NumericTextCtrl(S.GetParent(), wxID_ANY,
369 extra.GetDurationFormat(),
370 extra.GetDuration(),
371 projectRate,
373 .AutoPos(true));
374 S.Name(XO("Duration"))
375 .AddWindow(mDtmfDurationT);
377
378 S.AddFixedText(XO("&Tone/silence ratio:"), false);
380 S
381 .Style(wxSL_HORIZONTAL | wxEXPAND)
382 .MinSize( { -1, -1 } )
383 .AddSlider( {},
384 dtmfSettings.dtmfDutyCycle * DutyCycle.scale,
388 }
389 S.EndMultiColumn();
390
391 S.StartMultiColumn(2, wxCENTER);
392 {
393 S.AddFixedText(XO("Duty cycle:"), false);
394 mDtmfDutyT =
395 S.AddVariableText(XO("%.1f %%")
396 .Format( dtmfSettings.dtmfDutyCycle ), false);
397
398 S.AddFixedText(XO("Tone duration:"), false);
400 /* i18n-hint milliseconds */
401 S.AddVariableText(XO("%.0f ms")
402 .Format( dtmfSettings.dtmfTone * 1000.0 ), false);
403
404 S.AddFixedText(XO("Silence duration:"), false);
405 mDtmfToneT =
406 /* i18n-hint milliseconds */
407 S.AddVariableText(XO("%0.f ms")
408 .Format( dtmfSettings.dtmfSilence * 1000.0 ), false);
409 }
410 S.EndMultiColumn();
411}
static const wxChar * kSymbols[]
Definition: DtmfGen.cpp:55
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
#define S(N)
Definition: ToChars.cpp:64
static constexpr EffectParameter Amplitude
Definition: DtmfGen.h:86
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectPlugin.h:290
Abstract base class used in importing a file.
void OnSequence(wxCommandEvent &evt)
Definition: DtmfGen.cpp:663
wxSlider * mDtmfDutyCycleS
Definition: DtmfGen.cpp:318
void OnDuration(wxCommandEvent &evt)
Definition: DtmfGen.cpp:674
void OnDutyCycle(wxCommandEvent &evt)
Definition: DtmfGen.cpp:686
const Type min
Minimum value.
Definition: Shuttle.h:30
const Type max
Maximum value.
Definition: Shuttle.h:31
Options & AutoPos(bool enable)

References EffectDtmf::Amplitude, NumericTextCtrl::Options::AutoPos(), EffectDtmf::DutyCycle, kSymbols, EffectParameter< Structure, Member, Type, Value >::max, EffectParameter< Structure, Member, Type, Value >::min, OnDuration(), OnDutyCycle(), OnSequence(), S, safenew, EffectParameter< Structure, Member, Type, Value >::scale, settings(), NumericConverter::TIME, wxT(), XO(), and XXO().

Here is the call graph for this function:

◆ UpdateUI()

bool EffectDtmf::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 433 of file DtmfGen.cpp.

434{
435 const auto &settings = mAccess.Get();
436 auto &dtmfSettings = mSettings;
437
438 // Copy into our settings
440
441 mDtmfDutyCycleS->SetValue(dtmfSettings.dtmfDutyCycle * DutyCycle.scale);
442
443 mDtmfDurationT->SetValue(settings.extra.GetDuration());
444
445 DoUpdateUI();
446
447 return true;
448}
virtual const EffectSettings & Get()=0
static DtmfSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:326
void SetValue(double newValue)

References EffectDtmf::DutyCycle, EffectWithSettings< DtmfSettings, PerTrackEffect >::GetSettings(), EffectParameter< Structure, Member, Type, Value >::scale, and settings().

Here is the call graph for this function:

◆ ValidateUI()

bool EffectDtmf::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 450 of file DtmfGen.cpp.

451{
453 auto &dtmfSettings = mSettings;
454 dtmfSettings.dtmfDutyCycle =
455 (double) mDtmfDutyCycleS->GetValue() / DutyCycle.scale;
456 settings.extra.SetDuration(mDtmfDurationT->GetValue());
457
458 // recalculate to make sure all values are up-to-date. This is especially
459 // important if the user did not change any values in the dialog
460 dtmfSettings.Recalculate(settings);
461 return nullptr;
462 });
463
464 return true;
465}

References EffectDtmf::DutyCycle, EffectParameter< Structure, Member, Type, Value >::scale, and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mDtmfDurationT

NumericTextCtrl* EffectDtmf::Validator::mDtmfDurationT

Definition at line 319 of file DtmfGen.cpp.

◆ mDtmfDutyCycleS

wxSlider* EffectDtmf::Validator::mDtmfDutyCycleS

Definition at line 318 of file DtmfGen.cpp.

◆ mDtmfDutyT

wxStaticText* EffectDtmf::Validator::mDtmfDutyT

Definition at line 322 of file DtmfGen.cpp.

◆ mDtmfSequenceT

wxTextCtrl* EffectDtmf::Validator::mDtmfSequenceT

Definition at line 317 of file DtmfGen.cpp.

◆ mDtmfSilenceT

wxStaticText* EffectDtmf::Validator::mDtmfSilenceT

Definition at line 321 of file DtmfGen.cpp.

◆ mDtmfToneT

wxStaticText* EffectDtmf::Validator::mDtmfToneT

Definition at line 320 of file DtmfGen.cpp.

◆ mSettings

DtmfSettings EffectDtmf::Validator::mSettings

Definition at line 315 of file DtmfGen.cpp.


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