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

Constructor & Destructor Documentation

◆ Editor()

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

Definition at line 36 of file DtmfGen.cpp.

38 : EffectEditor{effect, access}
39 // Copy settings
41 {}
static Settings & settings()
Definition: TrackInfo.cpp:51
DtmfSettings mSettings
Definition: DtmfGen.cpp:55

◆ ~Editor()

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

Member Function Documentation

◆ DoUpdateUI()

void EffectDtmf::Editor::DoUpdateUI ( )

Definition at line 204 of file DtmfGen.cpp.

205{
206 // Update some texts in response to controls
207 auto &dtmfSettings = mSettings;
208
210 ->SetLabel(wxString::Format(wxT("%.1f %%"), dtmfSettings.dtmfDutyCycle));
211 mDtmfDutyT->SetName(mDtmfDutyT->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
212
214 ->SetLabel(wxString::Format(_("%.0f ms"), dtmfSettings.dtmfTone * 1000.0));
215 mDtmfSilenceT->SetName(mDtmfSilenceT->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
216
218 ->SetLabel(wxString::Format(_("%.0f ms"), dtmfSettings.dtmfSilence * 1000.0));
219 mDtmfToneT->SetName(mDtmfToneT->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
220}
wxT("CloseDown"))
#define _(s)
Definition: Internat.h:73
wxStaticText * mDtmfDutyT
Definition: DtmfGen.cpp:62
wxStaticText * mDtmfSilenceT
Definition: DtmfGen.cpp:61
wxStaticText * mDtmfToneT
Definition: DtmfGen.cpp:60

References _, and wxT().

Here is the call graph for this function:

◆ OnDuration()

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

Definition at line 233 of file DtmfGen.cpp.

234{
236 auto &dtmfSettings = mSettings;
237 settings.extra.SetDuration(mDtmfDurationT->GetValue());
238 dtmfSettings.Recalculate(settings);
239 return nullptr;
240 });
241 DoUpdateUI();
242}
EffectSettingsAccess & mAccess
Definition: EffectEditor.h:92
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
NumericTextCtrl * mDtmfDurationT
Definition: DtmfGen.cpp:59
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 244 of file DtmfGen.cpp.

245{
247 auto &dtmfSettings = mSettings;
248 dtmfSettings.dtmfDutyCycle = (double) evt.GetInt() / DutyCycle.scale;
249 dtmfSettings.Recalculate(settings);
250 return nullptr;
251 });
252 DoUpdateUI();
253}
static constexpr EffectParameter DutyCycle
Definition: DtmfBase.h:111
double dtmfDutyCycle
Definition: DtmfBase.h:18
const Type scale
Scaling factor, for slider control.

References DtmfBase::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 222 of file DtmfGen.cpp.

223{
225 auto &dtmfSettings = mSettings;
226 dtmfSettings.dtmfSequence = mDtmfSequenceT->GetValue();
227 dtmfSettings.Recalculate(settings);
228 return nullptr;
229 });
230 DoUpdateUI();
231}
wxString dtmfSequence
Definition: DtmfBase.h:13
wxTextCtrl * mDtmfSequenceT
Definition: DtmfGen.cpp:57

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

67{
68 // Reference to our copy of this effect's special settings
69 auto &dtmfSettings = mSettings;
70
71 // Do NOT hold a reference to EffectSettings, just use it to find initial
72 // duration values. (It came from EffectSettingsAccess so its stable address
73 // can't be relied on.)
74
75 // dialog will be passed values from effect
76 // Effect retrieves values from saved config
77 // Dialog will take care of using them to initialize controls
78 // If there is a selection, use that duration, otherwise use
79 // value from saved config: this is useful is user wants to
80 // replace selection with dtmf sequence
81
82 S.AddSpace(0, 5);
83 S.StartMultiColumn(2, wxCENTER);
84 {
86 S
87 .Validator([&dtmfSettings]{
88 wxTextValidator vldDtmf(
89 wxFILTER_INCLUDE_CHAR_LIST, &dtmfSettings.dtmfSequence);
90 wxArrayString symbols;
91 symbols.Alloc(DtmfBase::kSymbols.size());
92 for (auto c : DtmfBase::kSymbols)
93 symbols.Add(wxString::Format(wxT("%c"), c));
94 vldDtmf.SetIncludes(symbols);
95 return vldDtmf;
96 })
97 .AddTextBox(XXO("DTMF &sequence:"), wxT(""), 10);
99
100 // A control with no event handler but the validator causes updates
101 // when TransferData functions are called
102 S
103 .Validator<FloatingPointValidator<double>>(
104 3, &dtmfSettings.dtmfAmplitude, NumValidatorStyle::NO_TRAILING_ZEROES,
106 .AddTextBox(XXO("&Amplitude (0-1):"), wxT(""), 10);
107
108 S.AddPrompt(XXO("&Duration:"));
109 auto &extra = settings.extra;
112 S.GetParent(), wxID_ANY,
114 extra.GetDurationFormat(),
115 extra.GetDuration(),
117 .AutoPos(true));
118 S.Name(XO("Duration"))
119 .AddWindow(mDtmfDurationT);
121
122 S.AddFixedText(XO("&Tone/silence ratio:"), false);
124 S
125 .Style(wxSL_HORIZONTAL | wxEXPAND)
126 .MinSize( { -1, -1 } )
127 .AddSlider( {},
128 dtmfSettings.dtmfDutyCycle * DutyCycle.scale,
132 }
133 S.EndMultiColumn();
134
135 S.StartMultiColumn(2, wxCENTER);
136 {
137 S.AddFixedText(XO("Duty cycle:"), false);
138 mDtmfDutyT =
139 S.AddVariableText(XO("%.1f %%")
140 .Format( dtmfSettings.dtmfDutyCycle ), false);
141
142 S.AddFixedText(XO("Tone duration:"), false);
144 /* i18n-hint milliseconds */
145 S.AddVariableText(XO("%.0f ms")
146 .Format( dtmfSettings.dtmfTone * 1000.0 ), false);
147
148 S.AddFixedText(XO("Silence duration:"), false);
149 mDtmfToneT =
150 /* i18n-hint milliseconds */
151 S.AddVariableText(XO("%0.f ms")
152 .Format( dtmfSettings.dtmfSilence * 1000.0 ), false);
153 }
154 S.EndMultiColumn();
155}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
const NumericConverterType & NumericConverterType_TIME()
#define S(N)
Definition: ToChars.cpp:64
static constexpr EffectParameter Amplitude
Definition: DtmfBase.h:117
static constexpr std::array< char, 6 *7 > kSymbols
Definition: DtmfBase.h:34
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:58
void OnDuration(wxCommandEvent &evt)
Definition: DtmfGen.cpp:233
void OnDutyCycle(wxCommandEvent &evt)
Definition: DtmfGen.cpp:244
void OnSequence(wxCommandEvent &evt)
Definition: DtmfGen.cpp:222
const Type min
Minimum value.
const Type max
Maximum value.
Options & AutoPos(bool enable)

References DtmfBase::Amplitude, NumericTextCtrl::Options::AutoPos(), EffectEditor::BindTo(), DtmfBase::DutyCycle, DtmfBase::kSymbols, EffectParameter< Structure, Member, Type, Value >::max, mDtmfDurationT, mDtmfDutyCycleS, mDtmfDutyT, mDtmfSequenceT, mDtmfSilenceT, mDtmfToneT, EffectParameter< Structure, Member, Type, Value >::min, mSettings, NumericConverterType_TIME(), OnDuration(), OnDutyCycle(), OnSequence(), S, safenew, FormatterContext::SampleRateContext(), EffectParameter< Structure, Member, Type, Value >::scale, settings(), size, 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 170 of file DtmfGen.cpp.

171{
172 const auto &settings = mAccess.Get();
173 auto &dtmfSettings = mSettings;
174
175 // Copy into our settings
177
178 mDtmfDutyCycleS->SetValue(dtmfSettings.dtmfDutyCycle * DutyCycle.scale);
179
180 mDtmfDurationT->SetValue(settings.extra.GetDuration());
181
182 DoUpdateUI();
183
184 return true;
185}
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 DtmfBase::DutyCycle, EffectWithSettings< DtmfSettings, PerTrackEffect >::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 187 of file DtmfGen.cpp.

188{
190 auto &dtmfSettings = mSettings;
191 dtmfSettings.dtmfDutyCycle =
192 (double) mDtmfDutyCycleS->GetValue() / DutyCycle.scale;
193 settings.extra.SetDuration(mDtmfDurationT->GetValue());
194
195 // recalculate to make sure all values are up-to-date. This is especially
196 // important if the user did not change any values in the dialog
197 dtmfSettings.Recalculate(settings);
198 return nullptr;
199 });
200
201 return true;
202}

References DtmfBase::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 59 of file DtmfGen.cpp.

Referenced by PopulateOrExchange().

◆ mDtmfDutyCycleS

wxSlider* EffectDtmf::Editor::mDtmfDutyCycleS

Definition at line 58 of file DtmfGen.cpp.

Referenced by PopulateOrExchange().

◆ mDtmfDutyT

wxStaticText* EffectDtmf::Editor::mDtmfDutyT

Definition at line 62 of file DtmfGen.cpp.

Referenced by PopulateOrExchange().

◆ mDtmfSequenceT

wxTextCtrl* EffectDtmf::Editor::mDtmfSequenceT

Definition at line 57 of file DtmfGen.cpp.

Referenced by PopulateOrExchange().

◆ mDtmfSilenceT

wxStaticText* EffectDtmf::Editor::mDtmfSilenceT

Definition at line 61 of file DtmfGen.cpp.

Referenced by PopulateOrExchange().

◆ mDtmfToneT

wxStaticText* EffectDtmf::Editor::mDtmfToneT

Definition at line 60 of file DtmfGen.cpp.

Referenced by PopulateOrExchange().

◆ mSettings

DtmfSettings EffectDtmf::Editor::mSettings

Definition at line 55 of file DtmfGen.cpp.

Referenced by PopulateOrExchange().


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