15#include <wx/checkbox.h>
16#include <wx/dcclient.h>
18#include <wx/stattext.h>
19#include <wx/textctrl.h>
20#include <wx/scrolwin.h>
22#include "../../widgets/NumericTextCtrl.h"
23#include "../../widgets/valnum.h"
25#if wxUSE_ACCESSIBILITY
62 void OnErase(wxEraseEvent & evt);
63 void OnPaint(wxPaintEvent & evt);
64 void OnIdle(wxIdleEvent & evt);
65 void OnSize(wxSizeEvent & evt);
85: wxWindow{ parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
92 SetBackgroundColour(*wxWHITE);
93 SetMinSize({ 20, 20 });
122 wxRect r = GetClientRect();
123 wxCoord x = r.GetLeft();
124 wxCoord y = r.GetTop();
125 wxCoord w = r.GetWidth();
126 wxCoord h = r.GetHeight();
137 dc.SetPen(*wxTRANSPARENT_PEN);
138 dc.SetBrush(wxColour(100, 100, 220));
140 dc.DrawRectangle(x, y, (w * (val / fabs(
mMax -
mMin))), h);
159 auto parent =
S.GetParent();
168 mMeters.resize( data.PortCount );
175 wxVSCROLL | wxTAB_TRAVERSAL);
178 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
179 w->SetScrollRate(0, 20);
182 w->SetName(
wxT(
"\a"));
183 w->SetLabel(
wxT(
"\a"));
185 mainSizer->Add(w, 1, wxEXPAND);
186 mParent->SetSizer(mainSizer.release());
189 wxSizer *marginSizer;
191 auto uMarginSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
192 marginSizer = uMarginSizer.get();
196 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, w,
_(
"Effect Settings"));
198 auto gridSizer = std::make_unique<wxFlexGridSizer>(5, 0, 0);
199 gridSizer->AddGrowableCol(3);
205 item =
safenew wxStaticText(w, 0,
_(
"Duration:"));
206 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
212 extra.GetDurationFormat(),
217 gridSizer->Add(
mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
218 gridSizer->Add(1, 1, 0);
219 gridSizer->Add(1, 1, 0);
220 gridSizer->Add(1, 1, 0);
223 for (
unsigned long p = 0; p < data.PortCount; ++p) {
230 wxString labelText =
LAT1CTOWX(data.PortNames[p]);
231 item =
safenew wxStaticText(w, 0, wxString::Format(
_(
"%s:"), labelText));
232 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
240 mToggles[p]->SetValue(controls[p] > 0);
243 gridSizer->Add(
mToggles[p], 0, wxALL, 5);
245 gridSizer->Add(1, 1, 0);
246 gridSizer->Add(1, 1, 0);
247 gridSizer->Add(1, 1, 0);
252 float lower = -FLT_MAX;
253 float upper = FLT_MAX;
256 bool forceint =
false;
275 lower = ceilf(lower * 1000000.0) / 1000000.0;
276 upper = floorf(upper * 1000000.0) / 1000000.0;
277 controls[p] = roundf(controls[p] * 1000000.0) / 1000000.0;
279 if (haslo && controls[p] < lower)
282 if (hashi && controls[p] > upper)
289 mFields[p]->SetName(labelText);
292 gridSizer->Add(
mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
298 str.Printf(
wxT(
"%d"), (
int)(lower + 0.5));
305 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
308 gridSizer->Add(1, 1, 0);
314#if wxUSE_ACCESSIBILITY
321 gridSizer->Add(
mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
325 str.Printf(
wxT(
"%d"), (
int)(upper + 0.5));
329 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
332 gridSizer->Add(1, 1, 0);
335 fieldText.Printf(
wxT(
"%d"), (
int)(controls[p] + 0.5));
337 IntegerValidator<float> vld(&controls[p]);
338 vld.SetRange(haslo ? lower : INT_MIN,
339 hashi ? upper : INT_MAX);
346 FloatingPointValidator<float> vld(6, &controls[p]);
347 vld.SetRange(lower, upper);
350 if (upper - lower < 10.0)
351 vld.SetStyle(NumValidatorStyle::THREE_TRAILING_ZEROES);
352 else if (upper - lower < 100.0)
353 vld.SetStyle(NumValidatorStyle::TWO_TRAILING_ZEROES);
355 vld.SetStyle(NumValidatorStyle::ONE_TRAILING_ZERO);
362 mFields[p]->SetValue(fieldText);
365 paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5);
366 marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5);
371 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, w,
_(
"Effect Output"));
373 auto gridSizer = std::make_unique<wxFlexGridSizer>(2, 0, 0);
374 gridSizer->AddGrowableCol(1);
378 for (
unsigned long p = 0; p < data.PortCount; ++p) {
383 wxString labelText =
LAT1CTOWX(data.PortNames[p]);
385 w, 0, wxString::Format(
_(
"%s:"), labelText));
387 item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
396 lower = ceilf(lower * 1000000.0) / 1000000.0;
397 upper = floorf(upper * 1000000.0) / 1000000.0;
405 w, *pOutput, lower, upper);
406 mMeters[p]->SetLabel(labelText);
407 gridSizer->Add(
mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
410 paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5);
411 marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5);
414 w->SetSizer(uMarginSizer.release());
420 wxSize sz1 = marginSizer->GetMinSize();
421 wxSize sz2 =
mParent->GetMinSize();
425 mParent->SetMinSize({ -1, -1 });
430 unsigned numInputControls,
unsigned numOutputControls,
434 , mInstance{ instance }
435 , mNumInputControls{ numInputControls }
436 , mNumOutputControls{ numOutputControls }
441 , mpOutputs{ pOutputs }
477 float lower = float(0.0);
478 float upper = float(10.0);
480 bool forceint =
false;
493 range = upper - lower;
494 val = (
mSliders[p]->GetValue() / 1000.0) * range + lower;
497 str.Printf(
wxT(
"%d"), (int)(val + 0.5));
512 float lower = float(0.0);
513 float upper = float(10.0);
527 range = upper - lower;
533 mSliders[p]->SetValue((
int)(((val-lower)/range) * 1000.0 + 0.5));
550 for (
unsigned long p = 0; p < data.PortCount; ++p) {
558 bool forceint =
false;
566 mToggles[p]->SetValue(controls[p] > 0);
571 fieldText.Printf(
wxT(
"%d"), (
int)(controls[p] + 0.5));
577 mFields[p]->SetValue(fieldText);
585 assert(index <
static_cast<int>(controls.size()));
587 if (std::abs(controls[index] - value) < epsilon)
590 controls[index] = value;
591 Publish({ size_t(index), value });
598 for (
size_t portIndex = 0, portsCount = src.
controls.size();
599 portIndex < portsCount;
constexpr float ControlValueTolerance
const NumericConverterType & NumericConverterType_TIME()
wxEVT_COMMAND_TEXT_UPDATED
static Settings & settings()
void reinit(Integral count, bool initialize=false)
EffectSettingsAccess & mAccess
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
static FormatterContext SampleRateContext(double sampleRate)
static wxString ToDisplayString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, uses the user's locale's decimal separator.
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
void OnErase(wxEraseEvent &evt)
void OnSize(wxSizeEvent &evt)
LadspaEffectMeter(wxWindow *parent, const float &val, float min, float max)
void OnIdle(wxIdleEvent &evt)
virtual ~LadspaEffectMeter()
void OnPaint(wxPaintEvent &evt)
void SetName(const TranslatableString &name)
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
#define LADSPA_IS_HINT_BOUNDED_BELOW(x)
#define LADSPA_IS_HINT_BOUNDED_ABOVE(x)
#define LADSPA_IS_HINT_INTEGER(x)
#define LADSPA_IS_HINT_TOGGLED(x)
int LADSPA_PortDescriptor
#define LADSPA_IS_PORT_INPUT(x)
#define LADSPA_IS_PORT_AUDIO(x)
#define LADSPA_IS_PORT_CONTROL(x)
#define LADSPA_IS_PORT_OUTPUT(x)
#define LADSPA_IS_HINT_SAMPLE_RATE(x)
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
constexpr auto sampleRate
DynamicRangeProcessorSettings GetSettings(EffectSettingsAccess &access)
const LADSPA_PortDescriptor * PortDescriptors
const LADSPA_PortRangeHint * PortRangeHints
_LADSPA_PortRangeHint is a structure that gives parameter validation information for a LADSPA (Linux ...
LADSPA_PortRangeHintDescriptor HintDescriptor
Externalized state of a plug-in.
EffectSettingsExtra extra
const unsigned mNumInputControls
void PopulateUI(ShuttleGui &S)
ArrayOf< wxSlider * > mSliders
void Disconnect() override
On the first call only, may disconnect from further event handling.
ArrayOf< wxCheckBox * > mToggles
static LadspaEffectSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
LadspaEffectSettings mSettings
NumericTextCtrl * mDuration
ArrayOf< wxStaticText * > mLabels
ArrayOf< wxTextCtrl * > mFields
LadspaEditor(const EffectUIServices &effect, const LadspaInstance &instance, unsigned numInputControls, unsigned numOutputControls, EffectSettingsAccess &access, double sampleRate, EffectType type, const LadspaEffectOutputs *pOutputs)
const LadspaEffectOutputs *const mpOutputs
void UpdateControls(const LadspaEffectSettings &src)
void OnCheckBox(wxCommandEvent &evt)
void OnSlider(wxCommandEvent &evt)
void UpdateControl(int index, float value, float epsilon)
void OnTextCtrl(wxCommandEvent &evt)
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
std::vector< LadspaEffectMeter * > mMeters
const unsigned mNumOutputControls
const LadspaInstance & mInstance
bool UpdateUI() override
Update appearance of the panel for changes in settings.
Carry output control port information back to main thread.
std::vector< float > controls
std::vector< float > controls
const LADSPA_Descriptor *const mData
Options & AutoPos(bool enable)