Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
VST3ParametersWindow Class Reference

"Plain" plugin UI, contains a list of parameter controls and values. More...

#include <VST3ParametersWindow.h>

Inheritance diagram for VST3ParametersWindow:
[legend]
Collaboration diagram for VST3ParametersWindow:
[legend]

Public Member Functions

 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)
 
void ReloadParameters ()
 
void UpdateParameter (Steinberg::Vst::ParamID paramId)
 

Static Public Member Functions

static VST3ParametersWindowSetup (wxWindow &parent, Steinberg::Vst::IEditController &editController, Steinberg::Vst::IComponentHandler &componentHandler)
 Creates VST3ParametersWindow inside parent. More...
 

Private Member Functions

void RegisterParameterControl (VST3ParameterControl *control)
 
void RegisterParameterLabel (VST3ParameterControl *label)
 
void OnParameterValueChanged (const wxCommandEvent &evt)
 

Private Attributes

const Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
 
const Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
 
std::unordered_map< Steinberg::Vst::ParamID, VST3ParameterControl * > mControls
 
std::unordered_map< Steinberg::Vst::ParamID, VST3ParameterControl * > mLabels
 

Detailed Description

"Plain" plugin UI, contains a list of parameter controls and values.

Definition at line 35 of file VST3ParametersWindow.h.

Constructor & Destructor Documentation

◆ VST3ParametersWindow()

VST3ParametersWindow::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 
)

Definition at line 230 of file VST3ParametersWindow.cpp.

238 : wxScrolledWindow(parent, id, pos, size, style, name)
239 , mEditController(&editController)
241{
242 using namespace Steinberg;
243
244 auto sizer = std::make_unique<wxGridSizer>(3, 5, 5);
245
246 for(int i = 0, count = editController.getParameterCount(); i < count; ++i)
247 {
248 Vst::ParameterInfo parameterInfo { };
249 if(editController.getParameterInfo(i, parameterInfo) != kResultOk)
250 continue;
251
252 if(parameterInfo.flags & (Vst::ParameterInfo::kIsHidden | Vst::ParameterInfo::kIsProgramChange))
253 continue;
254
255 if((parameterInfo.flags & (Vst::ParameterInfo::kCanAutomate | Vst::ParameterInfo::kIsBypass | Vst::ParameterInfo::kIsReadOnly)) == 0)
256 continue;
257
258 {
259 // Hide proxy parameters with name that starts with "MIDI CC "
260 // That prevents Plain UI from creating many useless controls
261 static_assert(sizeof(Steinberg::tchar) == sizeof(char16_t));
262 static const std::basic_string_view<tchar> MIDI_CC { reinterpret_cast<const tchar*>(u"MIDI CC ") };
263 if(std::basic_string_view<tchar>(parameterInfo.title).rfind(MIDI_CC, 0) == 0)
264 continue;
265 }
266
267 if (parameterInfo.stepCount != 1) // not a toggle
268 sizer->Add(safenew wxStaticText(
269 this,
270 wxID_ANY,
271 VST3Utils::ToWxString(parameterInfo.title),
272 wxDefaultPosition,
273 wxDefaultSize,
274 wxALIGN_RIGHT), 0, wxEXPAND
275 );
276
277 if(parameterInfo.flags & Vst::ParameterInfo::kIsReadOnly)
278 {
279 auto text = safenew VST3ValueText(
280 this,
281 wxID_ANY,
282 parameterInfo.id,
283 VST3Utils::ToWxString(parameterInfo.units)
284 );
285 sizer->Add(text);
286 sizer->AddStretchSpacer();
288 }
289 //toggle
290 else if(parameterInfo.stepCount == 1)
291 {
292 const auto toggle = safenew VST3ToggleParameter (this, wxID_ANY,
293 VST3Utils::ToWxString(parameterInfo.title), parameterInfo.id);
294 toggle->Bind(wxEVT_CHECKBOX, &VST3ParametersWindow::OnParameterValueChanged, this);
295 sizer->Add(toggle, 0, wxEXPAND);
296 sizer->AddStretchSpacer();
297 sizer->AddStretchSpacer();
299 }
300 //list
301 else if(parameterInfo.stepCount != 0 && (parameterInfo.flags & Vst::ParameterInfo::kIsList))
302 {
303 const auto list = safenew VST3ListParameter(this, wxID_ANY, parameterInfo.id);
304
305 for(auto j = 0; j <= parameterInfo.stepCount; ++j)
306 {
307 Vst::String128 displayValue = { 0 };
308 editController.getParamStringByValue(
309 parameterInfo.id,
310 editController.plainParamToNormalized(parameterInfo.id, j),
311 displayValue
312 );
313 list->AppendString(VST3Utils::ToWxString(displayValue));
314 }
315 list->Bind(wxEVT_CHOICE, &VST3ParametersWindow::OnParameterValueChanged, this);
316 sizer->Add(list, 0, wxEXPAND);
317 sizer->AddStretchSpacer();
319 }
320 else
321 {
322 //continuous
323 if(parameterInfo.stepCount == 0)
324 {
325 auto slider = safenew VST3ContinuousParameter(this, wxID_ANY, parameterInfo.id,
326 VST3Utils::ToWxString(parameterInfo.title), VST3Utils::ToWxString(parameterInfo.units));
327 sizer->Add(slider, 0, wxEXPAND);
328 slider->Bind(wxEVT_SLIDER, &VST3ParametersWindow::OnParameterValueChanged, this);
330 }
331 //discrete
332 else
333 {
334 auto slider = safenew VST3DiscreteParameter(this, wxID_ANY, parameterInfo.id, parameterInfo.stepCount,
335 VST3Utils::ToWxString(parameterInfo.title), VST3Utils::ToWxString(parameterInfo.units));
336 sizer->Add(slider, 0, wxEXPAND);
337 slider->Bind(wxEVT_SLIDER, &VST3ParametersWindow::OnParameterValueChanged, this);
339 }
340 const auto label = safenew VST3ValueText(this, wxID_ANY, parameterInfo.id, VST3Utils::ToWxString(parameterInfo.units));
341 sizer->Add(label);
343 }
344 }
345
346 SetSizer(sizer.release());
347}
const TranslatableString name
Definition: Distortion.cpp:74
#define safenew
Definition: MemoryX.h:10
TranslatableString label
Definition: TagsEditor.cpp:164
void OnParameterValueChanged(const wxCommandEvent &evt)
void RegisterParameterLabel(VST3ParameterControl *label)
const Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
void RegisterParameterControl(VST3ParameterControl *control)
const Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
static wxString ToWxString(const Steinberg::Vst::TChar *str)
Definition: VST3Utils.cpp:48

References label, OnParameterValueChanged(), RegisterParameterControl(), RegisterParameterLabel(), safenew, and VST3Utils::ToWxString().

Referenced by Setup().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ OnParameterValueChanged()

void VST3ParametersWindow::OnParameterValueChanged ( const wxCommandEvent &  evt)
private

Definition at line 383 of file VST3ParametersWindow.cpp.

384{
385 if(auto control = dynamic_cast<VST3ParameterControl*>(evt.GetEventObject()))
386 {
387 const auto paramId = control->GetParameterId();
388 const auto normalizedValue = control->GetNormalizedValue(*mEditController);
389
390 mEditController->setParamNormalized(paramId, normalizedValue);
391 if(mComponentHandler->beginEdit(paramId) == Steinberg::kResultOk)
392 {
393 auto cleanup = finally([=] { mComponentHandler->endEdit(paramId); });
394 mComponentHandler->performEdit(paramId, normalizedValue);
395 }
396 auto it = mLabels.find(paramId);
397 if (it != mLabels.end()) {
398 it->second->SetNormalizedValue(*mEditController, normalizedValue);
399 control->UpdateAccessible(*mEditController, normalizedValue);
400 }
401 }
402}
std::unordered_map< Steinberg::Vst::ParamID, VST3ParameterControl * > mLabels

References mComponentHandler, mEditController, and mLabels.

Referenced by VST3ParametersWindow().

Here is the caller graph for this function:

◆ RegisterParameterControl()

void VST3ParametersWindow::RegisterParameterControl ( VST3ParameterControl control)
private

Definition at line 371 of file VST3ParametersWindow.cpp.

372{
373 mControls[control->GetParameterId()] = control;
374 control->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(control->GetParameterId()));
375}
Steinberg::Vst::ParamID GetParameterId() const noexcept
virtual void SetNormalizedValue(Steinberg::Vst::IEditController &, Steinberg::Vst::ParamValue value)=0
std::unordered_map< Steinberg::Vst::ParamID, VST3ParameterControl * > mControls

References VST3ParameterControl::GetParameterId(), mControls, mEditController, and VST3ParameterControl::SetNormalizedValue().

Referenced by VST3ParametersWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterParameterLabel()

void VST3ParametersWindow::RegisterParameterLabel ( VST3ParameterControl label)
private

Definition at line 377 of file VST3ParametersWindow.cpp.

378{
379 mLabels[label->GetParameterId()] = label;
380 label->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(label->GetParameterId()));
381}

References label, mEditController, and mLabels.

Referenced by VST3ParametersWindow().

Here is the caller graph for this function:

◆ ReloadParameters()

void VST3ParametersWindow::ReloadParameters ( )

Definition at line 349 of file VST3ParametersWindow.cpp.

350{
351 for(auto& p : mControls)
352 p.second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(p.second->GetParameterId()));
353 for(auto& p : mLabels)
354 p.second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(p.second->GetParameterId()));
355}

References mControls, mEditController, and mLabels.

Referenced by VST3UIValidator::UpdateUI().

Here is the caller graph for this function:

◆ Setup()

VST3ParametersWindow * VST3ParametersWindow::Setup ( wxWindow &  parent,
Steinberg::Vst::IEditController &  editController,
Steinberg::Vst::IComponentHandler &  componentHandler 
)
static

Creates VST3ParametersWindow inside parent.

Parameters
parentWhere all parameter controls will be placed
editControllerUsed to read current values
handlerUsed to report parameter changes

Definition at line 404 of file VST3ParametersWindow.cpp.

406{
407 constexpr int WindowBorder { 5 };
408 constexpr int WindowMaxHeight { 450 };
409
410 auto parametersWindow = safenew VST3ParametersWindow(&parent,
411 editController,
412 componentHandler,
413 wxID_ANY,
414 wxDefaultPosition,
415 wxDefaultSize,
416 wxVSCROLL | wxTAB_TRAVERSAL);
417 // This fools NVDA into not saying "Panel" when the dialog gets focus
418 parametersWindow->SetName(wxT("\a"));
419 parametersWindow->SetLabel(wxT("\a"));
420
421 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
422
423 mainSizer->Add(parametersWindow, 1, wxEXPAND | wxALL, WindowBorder);
424
425 auto minSize = parametersWindow->GetSizer()->CalcMin();
426 if(minSize.GetHeight() > (WindowMaxHeight - WindowBorder * 2))
427 {
428 minSize.SetHeight(WindowMaxHeight);
429 parametersWindow->SetScrollRate(0, 20);
430 }
431 else
432 minSize.y += WindowBorder * 2;
433
434 parent.SetMinSize(minSize);
435 parent.SetSizer(mainSizer.release());
436
437 return parametersWindow;
438}
wxT("CloseDown"))
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)

References safenew, VST3ParametersWindow(), and wxT().

Referenced by VST3UIValidator::VST3UIValidator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateParameter()

void VST3ParametersWindow::UpdateParameter ( Steinberg::Vst::ParamID  paramId)

Definition at line 357 of file VST3ParametersWindow.cpp.

358{
359 {
360 auto it = mControls.find(paramId);
361 if(it != mControls.end())
362 it->second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(it->second->GetParameterId()));
363 }
364 {
365 auto it = mLabels.find(paramId);
366 if(it != mLabels.end())
367 it->second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(it->second->GetParameterId()));
368 }
369}

References mControls, mEditController, and mLabels.

Member Data Documentation

◆ mComponentHandler

const Steinberg::IPtr<Steinberg::Vst::IComponentHandler> VST3ParametersWindow::mComponentHandler
private

Definition at line 38 of file VST3ParametersWindow.h.

Referenced by OnParameterValueChanged().

◆ mControls

std::unordered_map<Steinberg::Vst::ParamID, VST3ParameterControl*> VST3ParametersWindow::mControls
private

◆ mEditController

const Steinberg::IPtr<Steinberg::Vst::IEditController> VST3ParametersWindow::mEditController
private

◆ mLabels

std::unordered_map<Steinberg::Vst::ParamID, VST3ParameterControl*> VST3ParametersWindow::mLabels
private

The documentation for this class was generated from the following files: