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 247 of file VST3ParametersWindow.cpp.

255 : wxScrolledWindow(parent, id, pos, size, style, name)
256 , mEditController(&editController)
258{
259 using namespace Steinberg;
260
261 auto sizer = std::make_unique<wxGridSizer>(3, 5, 5);
262
263 for(int i = 0, count = editController.getParameterCount(); i < count; ++i)
264 {
265 Vst::ParameterInfo parameterInfo { };
266 if(editController.getParameterInfo(i, parameterInfo) != kResultOk)
267 continue;
268
269 if(parameterInfo.flags & (Vst::ParameterInfo::kIsHidden | Vst::ParameterInfo::kIsProgramChange))
270 continue;
271
272 if((parameterInfo.flags & (Vst::ParameterInfo::kCanAutomate | Vst::ParameterInfo::kIsBypass | Vst::ParameterInfo::kIsReadOnly)) == 0)
273 continue;
274
275 {
276 // Hide proxy parameters with name that starts with "MIDI CC "
277 // That prevents Plain UI from creating many useless controls
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)
281 continue;
282 }
283
284 if (parameterInfo.stepCount != 1) // not a toggle
285 sizer->Add(safenew wxStaticText(
286 this,
287 wxID_ANY,
288 VST3Utils::ToWxString(parameterInfo.title),
289 wxDefaultPosition,
290 wxDefaultSize,
291 wxALIGN_RIGHT), 0, wxEXPAND
292 );
293
294 if(parameterInfo.flags & Vst::ParameterInfo::kIsReadOnly)
295 {
296 auto text = safenew VST3ValueText(
297 this,
298 wxID_ANY,
299 parameterInfo.id,
300 VST3Utils::ToWxString(parameterInfo.units)
301 );
302 sizer->Add(text);
303 sizer->AddStretchSpacer();
305 }
306 //toggle
307 else if(parameterInfo.stepCount == 1)
308 {
309 const auto toggle = safenew VST3ToggleParameter (this, wxID_ANY,
310 VST3Utils::ToWxString(parameterInfo.title), parameterInfo.id);
311 toggle->Bind(wxEVT_CHECKBOX, &VST3ParametersWindow::OnParameterValueChanged, this);
312 sizer->Add(toggle, 0, wxEXPAND);
313 sizer->AddStretchSpacer();
314 sizer->AddStretchSpacer();
316 }
317 //list
318 else if(parameterInfo.stepCount != 0 && (parameterInfo.flags & Vst::ParameterInfo::kIsList))
319 {
320 const auto list = safenew VST3ListParameter(this, wxID_ANY, parameterInfo.id);
321
322 for(auto j = 0; j <= parameterInfo.stepCount; ++j)
323 {
324 Vst::String128 displayValue = { 0 };
325 editController.getParamStringByValue(
326 parameterInfo.id,
327 editController.plainParamToNormalized(parameterInfo.id, j),
328 displayValue
329 );
330 list->AppendString(VST3Utils::ToWxString(displayValue));
331 }
332 list->Bind(wxEVT_CHOICE, &VST3ParametersWindow::OnParameterValueChanged, this);
333 sizer->Add(list, 0, wxEXPAND);
334 sizer->AddStretchSpacer();
336 }
337 else
338 {
339 //continuous
340 if(parameterInfo.stepCount == 0)
341 {
342 auto slider = safenew VST3ContinuousParameter(this, wxID_ANY, parameterInfo.id,
343 VST3Utils::ToWxString(parameterInfo.title), VST3Utils::ToWxString(parameterInfo.units));
344 sizer->Add(slider, 0, wxEXPAND);
345 slider->Bind(wxEVT_SLIDER, &VST3ParametersWindow::OnParameterValueChanged, this);
347 }
348 //discrete
349 else
350 {
351 auto slider = safenew VST3DiscreteParameter(this, wxID_ANY, parameterInfo.id, parameterInfo.stepCount,
352 VST3Utils::ToWxString(parameterInfo.title), VST3Utils::ToWxString(parameterInfo.units),
353 editController);
354 sizer->Add(slider, 0, wxEXPAND);
355 slider->Bind(wxEVT_SLIDER, &VST3ParametersWindow::OnParameterValueChanged, this);
357 }
358 const auto label = safenew VST3ValueText(this, wxID_ANY, parameterInfo.id, VST3Utils::ToWxString(parameterInfo.units));
359 sizer->Add(label);
361 }
362 }
363
364 SetSizer(sizer.release());
365}
#define safenew
Definition: MemoryX.h:10
wxString name
Definition: TagsEditor.cpp:166
TranslatableString label
Definition: TagsEditor.cpp:165
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:93

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 401 of file VST3ParametersWindow.cpp.

402{
403 if(auto control = dynamic_cast<VST3ParameterControl*>(evt.GetEventObject()))
404 {
405 const auto paramId = control->GetParameterId();
406 const auto normalizedValue = control->GetNormalizedValue(*mEditController);
407
408 mEditController->setParamNormalized(paramId, normalizedValue);
409 if(mComponentHandler->beginEdit(paramId) == Steinberg::kResultOk)
410 {
411 auto cleanup = finally([=] { mComponentHandler->endEdit(paramId); });
412 mComponentHandler->performEdit(paramId, normalizedValue);
413 }
414 auto it = mLabels.find(paramId);
415 if (it != mLabels.end()) {
416 it->second->SetNormalizedValue(*mEditController, normalizedValue);
417 control->UpdateAccessible(*mEditController, normalizedValue);
418 }
419 }
420}
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 389 of file VST3ParametersWindow.cpp.

390{
391 mControls[control->GetParameterId()] = control;
392 control->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(control->GetParameterId()));
393}
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 395 of file VST3ParametersWindow.cpp.

396{
397 mLabels[label->GetParameterId()] = label;
398 label->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(label->GetParameterId()));
399}

References label, mEditController, and mLabels.

Referenced by VST3ParametersWindow().

Here is the caller graph for this function:

◆ ReloadParameters()

void VST3ParametersWindow::ReloadParameters ( )

Definition at line 367 of file VST3ParametersWindow.cpp.

368{
369 for(auto& p : mControls)
370 p.second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(p.second->GetParameterId()));
371 for(auto& p : mLabels)
372 p.second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(p.second->GetParameterId()));
373}

References mControls, mEditController, and mLabels.

Referenced by VST3Editor::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 422 of file VST3ParametersWindow.cpp.

424{
425 constexpr int WindowBorder { 5 };
426 constexpr int WindowMaxHeight { 450 };
427
428 auto parametersWindow = safenew VST3ParametersWindow(&parent,
429 editController,
430 componentHandler,
431 wxID_ANY,
432 wxDefaultPosition,
433 wxDefaultSize,
434 wxVSCROLL | wxTAB_TRAVERSAL);
435 // This fools NVDA into not saying "Panel" when the dialog gets focus
436 parametersWindow->SetName(wxT("\a"));
437 parametersWindow->SetLabel(wxT("\a"));
438
439 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
440
441 mainSizer->Add(parametersWindow, 1, wxEXPAND | wxALL, WindowBorder);
442
443 auto minSize = parametersWindow->GetSizer()->CalcMin();
444 if(minSize.GetHeight() > (WindowMaxHeight - WindowBorder * 2))
445 {
446 minSize.SetHeight(WindowMaxHeight);
447 parametersWindow->SetScrollRate(0, 20);
448 }
449 else
450 minSize.y += WindowBorder * 2;
451
452 parent.SetMinSize(minSize);
453 parent.SetSizer(mainSizer.release());
454
455 return parametersWindow;
456}
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 VST3Editor::VST3Editor().

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 375 of file VST3ParametersWindow.cpp.

376{
377 {
378 auto it = mControls.find(paramId);
379 if(it != mControls.end())
380 it->second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(it->second->GetParameterId()));
381 }
382 {
383 auto it = mLabels.find(paramId);
384 if(it != mLabels.end())
385 it->second->SetNormalizedValue(*mEditController, mEditController->getParamNormalized(it->second->GetParameterId()));
386 }
387}

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: