16#include <pluginterfaces/vst/ivsteditcontroller.h>
19#include <wx/stattext.h>
20#include <wx/checkbox.h>
26#if wxUSE_ACCESSIBILITY
40 virtual void SetNormalizedValue(Steinberg::Vst::IEditController&, Steinberg::Vst::ParamValue value) = 0;
42 virtual Steinberg::Vst::ParamValue
GetNormalizedValue(Steinberg::Vst::IEditController& editController)
const = 0;
44 virtual void UpdateAccessible(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value) {}
57 Steinberg::Vst::ParamID paramId,
58 const wxString& units,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize&
size = wxDefaultSize,
62 const wxString&
name = wxStaticTextNameStr)
67 void SetNormalizedValue(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value)
override
69 Steinberg::Vst::String128
str { };
70 editController.getParamStringByValue(GetParameterId(), value,
str);
77 Steinberg::Vst::ParamValue
GetNormalizedValue(Steinberg::Vst::IEditController& editController)
const override
79 return editController.getParamNormalized(GetParameterId());
88 Steinberg::Vst::ParamID paramId,
89 const wxPoint& pos = wxDefaultPosition,
90 const wxSize&
size = wxDefaultSize,
92 const wxValidator& validator = wxDefaultValidator,
93 const wxString&
name = wxChoiceNameStr)
97 void SetNormalizedValue(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value)
override
99 SetSelection(
static_cast<int>(editController.normalizedParamToPlain(GetParameterId(), value)));
102 Steinberg::Vst::ParamValue
GetNormalizedValue(Steinberg::Vst::IEditController& editController)
const override
104 return editController.plainParamToNormalized(GetParameterId(), GetSelection());
114 static constexpr auto Step = 0.01;
118 Steinberg::Vst::ParamID paramId,
119 const wxString&
title,
120 const wxString& units,
121 const wxPoint& pos = wxDefaultPosition,
122 const wxSize&
size = wxDefaultSize,
123 long style = wxSL_HORIZONTAL,
124 const wxValidator& validator = wxDefaultValidator,
125 const wxString&
name = wxSliderNameStr)
126 : wxSlider(parent,
id, 0, 0, static_cast<int>(1.0 / Step), pos,
size,
style, validator,
name)
131#if wxUSE_ACCESSIBILITY
136 void SetNormalizedValue(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value)
override
138 SetValue(
static_cast<int>(value / Step));
139 UpdateAccessible(editController, value);
142 void UpdateAccessible(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value)
override
144 Steinberg::Vst::String128
str{};
145 editController.getParamStringByValue(GetParameterId(), value,
str);
146 SetName(wxString::Format(
"%s %s %s",
152 return GetValue() * Step;
160 const int mStepCount{};
161 bool mUsePluginConversions{
true };
166 Steinberg::Vst::ParamID paramId,
168 const wxString&
title,
169 const wxString& units,
170 Steinberg::Vst::IEditController& editController,
171 const wxPoint& pos = wxDefaultPosition,
172 const wxSize&
size = wxDefaultSize,
173 long style = wxSL_HORIZONTAL,
174 const wxValidator& validator = wxDefaultValidator,
175 const wxString&
name = wxSliderNameStr)
176 : wxSlider(parent,
id, 0, 0, maxValue, pos,
size,
style, validator,
name)
180 , mStepCount(maxValue)
182#if wxUSE_ACCESSIBILITY
192 mUsePluginConversions = mStepCount != editController.plainParamToNormalized(paramId, mStepCount);
195 void SetNormalizedValue(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value)
override
197 int plainValue = mUsePluginConversions ?
198 static_cast<int>(editController.normalizedParamToPlain(GetParameterId(), value)) :
199 static_cast<int>(
std::min(
static_cast<double>(mStepCount), value * (mStepCount + 1)));
200 SetValue(plainValue);
201 UpdateAccessible(editController, value);
204 void UpdateAccessible(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value)
override
206 Steinberg::Vst::String128
str{ };
207 editController.getParamStringByValue(GetParameterId(), value,
str);
211 Steinberg::Vst::ParamValue
GetNormalizedValue(Steinberg::Vst::IEditController& editController)
const override
213 return mUsePluginConversions ?
214 editController.plainParamToNormalized(GetParameterId(), GetValue()) :
215 GetValue() /
static_cast<double>(mStepCount);
225 const wxString&
label,
226 Steinberg::Vst::ParamID paramId,
227 const wxPoint& pos = wxDefaultPosition,
228 const wxSize&
size = wxDefaultSize,
229 long style = wxALIGN_RIGHT,
230 const wxValidator& validator = wxDefaultValidator,
231 const wxString&
name = wxCheckBoxNameStr)
235 void SetNormalizedValue(Steinberg::Vst::IEditController& editController, Steinberg::Vst::ParamValue value)
override
237 SetValue(value != .0);
242 return GetValue() ? 1. : .0;
248 Steinberg::Vst::IEditController& editController,
249 Steinberg::Vst::IComponentHandler&
handler,
254 const wxString&
name)
256 , mEditController(&editController)
261 auto sizer = std::make_unique<wxGridSizer>(3, 5, 5);
263 for(
int i = 0, count = editController.getParameterCount(); i < count; ++i)
265 Vst::ParameterInfo parameterInfo { };
266 if(editController.getParameterInfo(i, parameterInfo) != kResultOk)
269 if(parameterInfo.flags & (Vst::ParameterInfo::kIsHidden | Vst::ParameterInfo::kIsProgramChange))
272 if((parameterInfo.flags & (Vst::ParameterInfo::kCanAutomate | Vst::ParameterInfo::kIsBypass | Vst::ParameterInfo::kIsReadOnly)) == 0)
278 static_assert(
sizeof(Steinberg::tchar) ==
sizeof(
char16_t));
279 static const std::basic_string_view<tchar> MIDI_CC {
reinterpret_cast<const tchar*
>(u
"MIDI CC ") };
280 if(std::basic_string_view<tchar>(parameterInfo.title).rfind(MIDI_CC, 0) == 0)
284 if (parameterInfo.stepCount != 1)
285 sizer->Add(
safenew wxStaticText(
291 wxALIGN_RIGHT), 0, wxEXPAND
294 if(parameterInfo.flags & Vst::ParameterInfo::kIsReadOnly)
296 auto text =
safenew VST3ValueText(
303 sizer->AddStretchSpacer();
307 else if(parameterInfo.stepCount == 1)
309 const auto toggle =
safenew VST3ToggleParameter (
this, wxID_ANY,
312 sizer->Add(toggle, 0, wxEXPAND);
313 sizer->AddStretchSpacer();
314 sizer->AddStretchSpacer();
318 else if(parameterInfo.stepCount != 0 && (parameterInfo.flags & Vst::ParameterInfo::kIsList))
320 const auto list =
safenew VST3ListParameter(
this, wxID_ANY, parameterInfo.id);
322 for(
auto j = 0; j <= parameterInfo.stepCount; ++j)
324 Vst::String128 displayValue = { 0 };
325 editController.getParamStringByValue(
327 editController.plainParamToNormalized(parameterInfo.id, j),
333 sizer->Add(list, 0, wxEXPAND);
334 sizer->AddStretchSpacer();
340 if(parameterInfo.stepCount == 0)
342 auto slider =
safenew VST3ContinuousParameter(
this, wxID_ANY, parameterInfo.id,
344 sizer->Add(slider, 0, wxEXPAND);
351 auto slider =
safenew VST3DiscreteParameter(
this, wxID_ANY, parameterInfo.id, parameterInfo.stepCount,
354 sizer->Add(slider, 0, wxEXPAND);
364 SetSizer(sizer.release());
383 auto it =
mLabels.find(paramId);
405 const auto paramId = control->GetParameterId();
406 const auto normalizedValue = control->GetNormalizedValue(*
mEditController);
414 auto it =
mLabels.find(paramId);
423 Steinberg::Vst::IComponentHandler& componentHandler)
425 constexpr int WindowBorder { 5 };
426 constexpr int WindowMaxHeight { 450 };
434 wxVSCROLL | wxTAB_TRAVERSAL);
436 parametersWindow->SetName(
wxT(
"\a"));
437 parametersWindow->SetLabel(
wxT(
"\a"));
439 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
441 mainSizer->Add(parametersWindow, 1, wxEXPAND | wxALL, WindowBorder);
443 auto minSize = parametersWindow->GetSizer()->CalcMin();
444 if(minSize.GetHeight() > (WindowMaxHeight - WindowBorder * 2))
446 minSize.SetHeight(WindowMaxHeight);
447 parametersWindow->SetScrollRate(0, 20);
450 minSize.y += WindowBorder * 2;
452 parent.SetMinSize(minSize);
453 parent.SetSizer(mainSizer.release());
455 return parametersWindow;
virtual void UpdateAccessible(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value)
Steinberg::Vst::ParamID GetParameterId() const noexcept
VST3ParameterControl(Steinberg::Vst::ParamID id)
const Steinberg::Vst::ParamID mParameterId
virtual Steinberg::Vst::ParamValue GetNormalizedValue(Steinberg::Vst::IEditController &editController) const =0
virtual ~VST3ParameterControl()
virtual void SetNormalizedValue(Steinberg::Vst::IEditController &, Steinberg::Vst::ParamValue value)=0
"Plain" plugin UI, contains a list of parameter controls and values.
void OnParameterValueChanged(const wxCommandEvent &evt)
void RegisterParameterLabel(VST3ParameterControl *label)
std::unordered_map< Steinberg::Vst::ParamID, VST3ParameterControl * > mControls
void UpdateParameter(Steinberg::Vst::ParamID paramId)
const Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
VST3ParametersWindow(wxWindow *parent, Steinberg::Vst::IEditController &editController, Steinberg::Vst::IComponentHandler &handler, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxScrolledWindowStyle, const wxString &name=wxPanelNameStr)
static VST3ParametersWindow * Setup(wxWindow &parent, Steinberg::Vst::IEditController &editController, Steinberg::Vst::IComponentHandler &componentHandler)
Creates VST3ParametersWindow inside parent.
std::unordered_map< Steinberg::Vst::ParamID, VST3ParameterControl * > mLabels
void RegisterParameterControl(VST3ParameterControl *control)
const Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
static wxString ToWxString(const Steinberg::Vst::TChar *str)
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
Steinberg::Vst::ParamValue GetNormalizedValue(Steinberg::Vst::IEditController &) const override
VST3ContinuousParameter(wxWindow *parent, wxWindowID id, Steinberg::Vst::ParamID paramId, const wxString &title, const wxString &units, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSL_HORIZONTAL, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxSliderNameStr)
void UpdateAccessible(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value) override
void SetNormalizedValue(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value) override
Steinberg::Vst::ParamValue GetNormalizedValue(Steinberg::Vst::IEditController &editController) const override
void SetNormalizedValue(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value) override
void UpdateAccessible(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value) override
VST3DiscreteParameter(wxWindow *parent, wxWindowID id, Steinberg::Vst::ParamID paramId, int maxValue, const wxString &title, const wxString &units, Steinberg::Vst::IEditController &editController, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSL_HORIZONTAL, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxSliderNameStr)
Steinberg::Vst::ParamValue GetNormalizedValue(Steinberg::Vst::IEditController &editController) const override
void SetNormalizedValue(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value) override
VST3ListParameter(wxWindow *parent, wxWindowID id, Steinberg::Vst::ParamID paramId, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxChoiceNameStr)
void SetNormalizedValue(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value) override
VST3ToggleParameter(wxWindow *parent, wxWindowID id, const wxString &label, Steinberg::Vst::ParamID paramId, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxALIGN_RIGHT, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxCheckBoxNameStr)
Steinberg::Vst::ParamValue GetNormalizedValue(Steinberg::Vst::IEditController &) const override
Steinberg::Vst::ParamValue GetNormalizedValue(Steinberg::Vst::IEditController &editController) const override
VST3ValueText(wxWindow *parent, wxWindowID id, Steinberg::Vst::ParamID paramId, const wxString &units, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxStaticTextNameStr)
void SetNormalizedValue(Steinberg::Vst::IEditController &editController, Steinberg::Vst::ParamValue value) override
AuthorizationHandler handler