23#include <wx/checkbox.h>
26#include <wx/weakref.h>
31#include "../widgets/valnum.h"
86std::shared_ptr<EffectInstance>
89 return std::make_shared<BassTrebleBase::Instance>(*
this);
101 auto result = std::make_unique<Editor>(*
this, access, myEffSettings);
102 result->PopulateOrExchange(
S);
114 S.StartStatic(
XO(
"Tone controls"));
116 S.StartMultiColumn(3, wxEXPAND);
122 .Name(
XO(
"Bass (dB):"))
123 .Validator<FloatingPointValidator<double>>(
125 .AddTextBox(
XXO(
"Ba&ss (dB):"), L
"", 10);
130 .Style(wxSL_HORIZONTAL)
136 .Validator<FloatingPointValidator<double>>(
138 .AddTextBox(
XXO(
"&Treble (dB):"), L
"", 10);
143 .Style(wxSL_HORIZONTAL)
151 S.StartStatic(
XO(
"Output"));
153 S.StartMultiColumn(3, wxEXPAND);
159 .Validator<FloatingPointValidator<double>>(
161 .AddTextBox(
XXO(
"&Volume (dB):"), L
"", 10);
166 .Style(wxSL_HORIZONTAL)
172 S.StartMultiColumn(2, wxCENTER);
177 .AddCheckBox(
XXO(
"&Link Volume control to Tone controls"),
189 const auto&
settings = mAccess.Get();
193 if (! mUIParent->TransferDataToWindow())
198 mBassS-> SetValue((
int)(mSettings.mBass *
Bass.
scale));
199 mTrebleS-> SetValue((
int)(mSettings.mTreble *
Treble.
scale));
200 mGainS-> SetValue((
int)(mSettings.mGain *
Gain.
scale));
201 mLinkCheckBox->SetValue(mSettings.mLink);
208 auto& ms = mSettings;
210 double oldBass = ms.mBass;
212 if (!EnableApplyFromTransferDataFromWindow())
218 UpdateGain(oldBass,
kBass);
220 mBassS->SetValue((
int) (ms.mBass *
Bass.
scale));
228 auto& ms = mSettings;
230 double oldTreble = ms.mTreble;
232 if (!EnableApplyFromTransferDataFromWindow())
238 UpdateGain(oldTreble,
kTreble);
240 mTrebleS->SetValue((
int) (ms.mTreble *
Treble.
scale));
248 auto& ms = mSettings;
250 if (!EnableApplyFromTransferDataFromWindow())
255 mGainS->SetValue((
int) (ms.mGain *
Gain.
scale));
263 auto& ms = mSettings;
265 double oldBass = ms.mBass;
266 ms.mBass = (double) evt.GetInt() /
Bass.
scale;
267 mBassT->GetValidator()->TransferToWindow();
270 UpdateGain(oldBass,
kBass);
272 EnableApplyFromValidate();
280 auto& ms = mSettings;
282 double oldTreble = ms.mTreble;
284 mTrebleT->GetValidator()->TransferToWindow();
287 UpdateGain(oldTreble,
kTreble);
289 EnableApplyFromValidate();
297 auto& ms = mSettings;
299 ms.mGain = (double) evt.GetInt() /
Gain.
scale;
300 mGainT->GetValidator()->TransferToWindow();
302 EnableApplyFromValidate();
310 auto& ms = mSettings;
312 ms.mLink = mLinkCheckBox->GetValue();
320 auto& ms = mSettings;
323 oldVal = (oldVal > 0)? oldVal / 2.0 : oldVal / 4.0;
325 if (control ==
kBass)
326 newVal = (ms.mBass > 0)? ms.mBass / 2.0 : ms.mBass / 4.0;
328 newVal = (ms.mTreble > 0)? ms.mTreble / 2.0 : ms.mTreble / 4.0;
330 ms.mGain -= newVal - oldVal;
333 mGainS->SetValue(ms.mGain);
334 mGainT->GetValidator()->TransferToWindow();
341 if (! mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
347 mAccess.ModifySettings
XXO("&Cut/Copy/Paste Toolbar")
static Settings & settings()
bool ValidateUI(const EffectPlugin &context, EffectSettings &) const override
static constexpr EffectParameter Treble
static constexpr EffectParameter Bass
static constexpr EffectParameter Link
static constexpr EffectParameter Gain
std::unique_ptr< EffectEditor > MakeEditor(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
Called only from PopulateUI, to add controls to effect panel.
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Performs effect computation.
Hold values to send to effect output meters.
virtual const EffectSettings & Get()=0
static BassTrebleSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
BuiltinEffectsModule::Registration< EffectBassTreble > reg
void OnTrebleText(wxCommandEvent &evt)
void PopulateOrExchange(ShuttleGui &S)
void OnLinkCheckbox(wxCommandEvent &evt)
wxWeakRef< wxWindow > mUIParent
BassTrebleSettings mSettings
void OnGainText(wxCommandEvent &evt)
void OnBassSlider(wxCommandEvent &evt)
Editor(const EffectUIServices &services, EffectSettingsAccess &access, const BassTrebleSettings &settings)
wxCheckBox * mLinkCheckBox
bool EnableApplyFromTransferDataFromWindow()
void UpdateGain(double oldVal, int control)
void OnBassText(wxCommandEvent &evt)
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
void OnTrebleSlider(wxCommandEvent &evt)
bool UpdateUI() override
Update appearance of the panel for changes in settings.
void OnGainSlider(wxCommandEvent &evt)
void EnableApplyFromValidate()
virtual ~Editor()=default
const Type scale
Scaling factor, for slider control.
const Type def
Default value.
const Type min
Minimum value.
const Type max
Maximum value.
Message sent by EffectEditor when a setting is changed by the user.
Externalized state of a plug-in.