23#include <wx/recguard.h>
25#include <wx/scrolwin.h>
26#include <wx/stattext.h>
29#include "../../widgets/NumericTextCtrl.h"
31#if wxUSE_ACCESSIBILITY
39#elif defined(__WXMSW__)
41#elif defined(__WXGTK__)
116 if (guard.IsInside())
158 [index, value, &
settings,
this](
const auto&
pi)
166 constexpr float epsilon = 1.0e-5f;
169 it ==
settings.mParamsMap.end() || !it->second.has_value() ||
170 std::abs(*it->second - value) > epsilon)
188 const auto &string = mParamNames[index];
189 auto &mySettings = VSTWrapper::GetSettings(settings);
190 mySettings.mParamsMap[string] = value;
203 if (
GetInstance().OnePresetWasLoadedWhilePlaying() )
215 wxCommandEvent sw(EVT_SIZEWINDOW);
218 mParent->GetEventHandler()->AddPendingEvent(sw);
233 wxWindow *w = (wxWindow *) evt.GetEventObject();
234 wxSize sz = w->GetMinSize();
236 if (sz != wxDefaultSize)
244 auto& vstEffInstance =
dynamic_cast<VSTInstance&
>(instance);
255 if (!control->Create(
mParent, &vstEffInstance))
261 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
263 mainSizer->Add((
mControl = control.release()), 0, wxALIGN_CENTER);
265 mParent->SetMinSize(wxDefaultSize);
266 mParent->SetSizer(mainSizer.release());
277#ifdef __WX_EVTLOOP_BUSY_WAITING__
278 wxEventLoop::SetBusyWaiting(
true);
288 wxScrolledWindow *
const scroller =
safenew wxScrolledWindow(
mParent,
292 wxVSCROLL | wxTAB_TRAVERSAL);
295 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
298 scroller->SetMinSize(wxSize(wxMax(600,
mParent->GetSize().GetWidth() * 2 / 3),
299 mParent->GetSize().GetHeight() / 2));
300 scroller->SetScrollRate(0, 20);
303 scroller->SetName(
wxT(
"\a"));
304 scroller->SetLabel(
wxT(
"\a"));
306 mainSizer->Add(scroller, 1, wxEXPAND | wxALL, 5);
307 mParent->SetSizer(mainSizer.release());
316 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, scroller,
_(
"Effect Settings"));
319 auto gridSizer = std::make_unique<wxFlexGridSizer>(4, 0, 0);
320 gridSizer->AddGrowableCol(1);
325 wxControl *item =
safenew wxStaticText(scroller, 0,
_(
"Duration:"));
326 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
332 extra.GetDurationFormat(),
337 gridSizer->Add(
mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
338 gridSizer->Add(1, 1, 0);
339 gridSizer->Add(1, 1, 0);
350 if (text.Right(1) !=
wxT(
':'))
355 scroller->GetTextExtent(text, &w, &h);
362 scroller->GetTextExtent(
wxT(
"HHHHHHHH"), &w, &h);
371 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
372 gridSizer->Add(
mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
381 gridSizer->Add(
mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
382#if wxUSE_ACCESSIBILITY
395 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
396 gridSizer->Add(
mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
403 wxALIGN_LEFT | wxST_NO_AUTORESIZE);
404 gridSizer->Add(
mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
407 paramSizer->Add(gridSizer.release(), 1, wxEXPAND | wxALL, 5);
409 scroller->SetSizer(paramSizer.release());
428 text = text.Trim(
true).Trim(
false);
430 wxString
name = text;
432 if (text.Right(1) !=
wxT(
':'))
436 mNames[i]->SetLabel(text);
453 mDisplays[i]->SetLabel(wxString::Format(
wxT(
"%8s"), text));
460 mLabels[i]->SetLabel(wxString::Format(
wxT(
"%8s"), text));
475 mControl->SetMinSize(wxSize(evt.GetInt(), (
int) evt.GetExtraLong()));
476 mControl->SetSize(wxSize(evt.GetInt(), (
int) evt.GetExtraLong()));
482 mDialog->SetMinSize(wxDefaultSize);
483 mDialog->SetMaxSize(wxDefaultSize);
492 wxSlider *s = (wxSlider *) evt.GetEventObject();
494 float value = s->GetValue() / 1000.0;
530 mDialog( static_cast<wxDialog*>(wxGetTopLevelParent(pParent)) ),
531 mNumParams(numParams)
548 mTimer = std::make_unique<VSTTimer>(
this);
596#ifdef __WX_EVTLOOP_BUSY_WAITING__
597 wxEventLoop::SetBusyWaiting(
false);
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
const NumericConverterType & NumericConverterType_TIME()
static Settings & settings()
DEFINE_LOCAL_EVENT_TYPE(EVT_UPDATEDISPLAY)
wxDEFINE_EVENT(EVT_SIZEWINDOW, wxCommandEvent)
static void OnSize(wxSizeEvent &evt)
const int effGetParamDisplay
const int effGetParamLabel
const int effGetParamName
void reinit(Integral count, bool initialize=false)
EffectSettingsAccess & mAccess
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Performs effect computation.
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
virtual void Set(EffectSettings &&settings, std::unique_ptr< Message > pMessage=nullptr)=0
virtual void Flush()=0
Make the last Set changes "persistent" in underlying storage.
static FormatterContext SampleRateContext(double sampleRate)
void SetName(const TranslatableString &name)
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
void BuildPlain(EffectSettingsAccess &access, EffectType effectType, double projectRate)
ArrayOf< wxStaticText * > mLabels
bool IsGraphicalUI() override
bool FetchSettingsFromInstance(EffectSettings &settings)
void BuildFancy(EffectInstance &instance)
void NotifyParameterChanged(int index, float value)
void OnSizeWindow(wxCommandEvent &evt)
std::unique_ptr< VSTTimer > mTimer
std::vector< wxString > mParamNames
bool StoreSettingsToInstance(const EffectSettings &settings)
void Automate(int index, float value) override
void OnSlider(wxCommandEvent &evt)
void NeedEditIdle(bool state)
ArrayOf< wxStaticText * > mDisplays
wxWeakRef< wxDialog > mDialog
void SizeWindow(int w, int h) override
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
ArrayOf< wxStaticText * > mNames
void RefreshParameters(int skip=-1) const
int ShowDialog(bool nonModal)
void OnIdle(wxIdleEvent &evt)
std::vector< std::pair< int, double > > mLastMovements
VSTInstance & GetInstance() const
NumericTextCtrl * mDuration
bool UpdateUI() override
Update appearance of the panel for changes in settings.
VSTEditor(VSTInstance &instance, EffectType type, bool gui, const EffectUIServices &services, EffectSettingsAccess &access, wxWindow *pParent, int numParams)
ArrayOf< wxSlider * > mSliders
void DeferChunkApplication()
std::unique_ptr< Message > MakeMessage() const override
Called on the main thread, in which the result may be cloned.
void SetOwningValidator(VSTUIWrapper *vi)
VSTTimer(VSTEditor *pEditor)
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
Message sent by EffectEditor when a setting is changed by the user.
Externalized state of a plug-in.
EffectSettingsExtra extra
Options & AutoPos(bool enable)
int GetString(wxString &outstr, int opcode, int index=0) const
bool FetchSettings(VSTSettings &vst3Settings, bool doFetch=true) const
static VSTSettings & GetSettings(EffectSettings &settings)
bool StoreSettings(const VSTSettings &vst3settings) const
void ForEachParameter(ParameterVisitor visitor) const
intptr_t callDispatcher(int opcode, int index, intptr_t value, void *ptr, float opt) override
std::unique_ptr< EffectInstance::Message > MakeMessageFS(const VSTSettings &settings) const