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

Public Member Functions

 Editor (const EffectUIServices &effect, EffectSettingsAccess &access, const DtmfSettings &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 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 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

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

Constructor & Destructor Documentation

◆ Editor()

EffectDtmf::Editor::Editor ( const EffectUIServices effect,
EffectSettingsAccess access,
const DtmfSettings settings 
)
inline

Definition at line 295 of file DtmfGen.cpp.

297 : EffectEditor{effect, access}
298 // Copy settings
300 {}
static Settings & settings()
Definition: TrackInfo.cpp:69
DtmfSettings mSettings
Definition: DtmfGen.cpp:314

◆ ~Editor()

virtual EffectDtmf::Editor::~Editor ( )
virtualdefault

Member Function Documentation

◆ DoUpdateUI()

void EffectDtmf::Editor::DoUpdateUI ( )

Definition at line 644 of file DtmfGen.cpp.

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

References _, and wxT().

Here is the call graph for this function:

◆ OnDuration()

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

Definition at line 673 of file DtmfGen.cpp.

674{
676 auto &dtmfSettings = mSettings;
677 settings.extra.SetDuration(mDtmfDurationT->GetValue());
678 dtmfSettings.Recalculate(settings);
679 return nullptr;
680 });
681 DoUpdateUI();
682}
EffectSettingsAccess & mAccess
Definition: EffectEditor.h:92
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
NumericTextCtrl * mDtmfDurationT
Definition: DtmfGen.cpp:318
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::Editor::OnDutyCycle ( wxCommandEvent &  evt)

Definition at line 684 of file DtmfGen.cpp.

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

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::Editor::OnSequence ( wxCommandEvent &  evt)

Definition at line 662 of file DtmfGen.cpp.

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

References settings().

Referenced by PopulateOrExchange().

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

◆ PopulateOrExchange()

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

Definition at line 324 of file DtmfGen.cpp.

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

Here is the call graph for this function:

◆ UpdateUI()

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

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

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

Here is the call graph for this function:

◆ ValidateUI()

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

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

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::Editor::mDtmfDurationT

Definition at line 318 of file DtmfGen.cpp.

◆ mDtmfDutyCycleS

wxSlider* EffectDtmf::Editor::mDtmfDutyCycleS

Definition at line 317 of file DtmfGen.cpp.

◆ mDtmfDutyT

wxStaticText* EffectDtmf::Editor::mDtmfDutyT

Definition at line 321 of file DtmfGen.cpp.

◆ mDtmfSequenceT

wxTextCtrl* EffectDtmf::Editor::mDtmfSequenceT

Definition at line 316 of file DtmfGen.cpp.

◆ mDtmfSilenceT

wxStaticText* EffectDtmf::Editor::mDtmfSilenceT

Definition at line 320 of file DtmfGen.cpp.

◆ mDtmfToneT

wxStaticText* EffectDtmf::Editor::mDtmfToneT

Definition at line 319 of file DtmfGen.cpp.

◆ mSettings

DtmfSettings EffectDtmf::Editor::mSettings

Definition at line 314 of file DtmfGen.cpp.


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