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

#include <VST3UIValidator.h>

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

Public Member Functions

 VST3UIValidator (wxWindow *parent, VST3Wrapper &wrapper, EffectBase &effect, EffectSettingsAccess &access, bool useNativeUI)
 
 ~VST3UIValidator () override
 
bool IsGraphicalUI () override
 
bool UpdateUI () override
 Update appearance of the panel for changes in settings. More...
 
bool ValidateUI () override
 Get settings data from the panel; may make error dialogs and return false. More...
 
void OnClose () override
 
- Public Member Functions inherited from EffectUIValidator
 EffectUIValidator (EffectUIClientInterface &effect, EffectSettingsAccess &access)
 
virtual ~EffectUIValidator ()
 
virtual bool ValidateUI ()=0
 Get settings data from the panel; may make error dialogs and return false. More...
 
virtual bool UpdateUI ()
 Update appearance of the panel for changes in settings. More...
 
virtual bool IsGraphicalUI ()
 
virtual void Disconnect ()
 On the first call only, may disconnect from further event handling. More...
 
virtual void OnClose ()
 
- Public Member Functions inherited from Observer::Publisher< EffectSettingChanged >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Private Member Functions

void OnIdle (wxIdleEvent &)
 
bool TryLoadNativeUI (wxWindow *parent)
 

Private Attributes

VST3WrappermWrapper
 
Steinberg::IPtr< Steinberg::IPlugView > mPlugView
 
Steinberg::IPtr< Steinberg::IPlugFrame > mPlugFrame
 
wxWindow * mParent { nullptr }
 
NumericTextCtrlmDuration { nullptr }
 
VST3ParametersWindowmPlainUI { nullptr }
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< EffectSettingChanged >
using message_type = EffectSettingChanged
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const EffectSettingChanged &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Member Functions inherited from EffectUIValidator
static bool EnableApply (wxWindow *parent, bool enable=true)
 Enable or disable the Apply button of the dialog that contains parent. More...
 
static bool EnablePreview (wxWindow *parent, bool enable=true)
 
- Static Public Attributes inherited from EffectUIValidator
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from EffectUIValidator
template<typename EventTag , typename Class , typename Event >
void BindTo (wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
 
- Protected Member Functions inherited from Observer::Publisher< EffectSettingChanged >
CallbackReturn Publish (const EffectSettingChanged &message)
 Send a message to connected callbacks. More...
 
- Protected Attributes inherited from EffectUIValidator
EffectUIClientInterfacemEffect
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 19 of file VST3UIValidator.h.

Constructor & Destructor Documentation

◆ VST3UIValidator()

VST3UIValidator::VST3UIValidator ( wxWindow *  parent,
VST3Wrapper wrapper,
EffectBase effect,
EffectSettingsAccess access,
bool  useNativeUI 
)

Definition at line 16 of file VST3UIValidator.cpp.

17 : EffectUIValidator(effect, access), mWrapper(wrapper), mParent(parent)
18{
19 if(effect.GetType() == EffectTypeGenerate)
20 {
21 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
22 auto controlsRoot = safenew wxWindow(parent, wxID_ANY);
23 if(!useNativeUI || !TryLoadNativeUI(controlsRoot))
25 vSizer->Add(controlsRoot);
26
27 auto &extra = access.Get().extra;
29 parent, wxID_ANY,
31 extra.GetDurationFormat(),
32 extra.GetDuration(),
33 mWrapper.mSetup.sampleRate,
35 .AutoPos(true)
36 );
37 mDuration->SetName( XO("Duration") );
38
39 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
40 hSizer->Add(safenew wxStaticText(parent, wxID_ANY, _("Duration:")));
41 hSizer->AddSpacer(5);
42 hSizer->Add(mDuration);
43 vSizer->AddSpacer(10);
44 vSizer->Add(hSizer.release());
45
46 parent->SetMinSize(vSizer->CalcMin());
47 parent->SetSizer(vSizer.release());
48 }
49 else if(!useNativeUI || !TryLoadNativeUI(parent))
50 {
52 *parent,
55 );
56 }
57
59 [this](Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue value) {
60 Publish({ static_cast<size_t>(id), static_cast<float>(value) });
61 };
62
64
65 Bind(wxEVT_IDLE, &VST3UIValidator::OnIdle, this);
66
67 mParent->PushEventHandler(this);
68}
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:75
#define safenew
Definition: MemoryX.h:10
int id
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual const EffectSettings & Get()=0
EffectSettingsAccess & mAccess
Definition: EffectPlugin.h:297
EffectUIValidator(EffectUIClientInterface &effect, EffectSettingsAccess &access)
void SetName(const TranslatableString &name)
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207
static VST3ParametersWindow * Setup(wxWindow &parent, Steinberg::Vst::IEditController &editController, Steinberg::Vst::IComponentHandler &componentHandler)
Creates VST3ParametersWindow inside parent.
VST3Wrapper & mWrapper
NumericTextCtrl * mDuration
wxWindow * mParent
VST3ParametersWindow * mPlainUI
void OnIdle(wxIdleEvent &)
bool TryLoadNativeUI(wxWindow *parent)
void BeginParameterEdit(EffectSettingsAccess &access)
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
Definition: VST3Wrapper.h:61
Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
Definition: VST3Wrapper.h:64
std::function< void(Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler
Definition: VST3Wrapper.h:126
Steinberg::Vst::ProcessSetup mSetup
Definition: VST3Wrapper.h:59
EffectSettingsExtra extra
Options & AutoPos(bool enable)

References _, NumericTextCtrl::Options::AutoPos(), VST3Wrapper::BeginParameterEdit(), EffectTypeGenerate, EffectSettings::extra, EffectSettingsAccess::Get(), EffectDefinitionInterface::GetType(), id, EffectUIValidator::mAccess, VST3Wrapper::mComponentHandler, mDuration, VST3Wrapper::mEditController, mParent, mPlainUI, VST3Wrapper::mSetup, mWrapper, OnIdle(), VST3Wrapper::ParamChangedHandler, Observer::Publisher< EffectSettingChanged >::Publish(), safenew, NumericTextCtrl::SetName(), VST3ParametersWindow::Setup(), NumericConverter::TIME, TryLoadNativeUI(), and XO().

Here is the call graph for this function:

◆ ~VST3UIValidator()

VST3UIValidator::~VST3UIValidator ( )
override

Definition at line 70 of file VST3UIValidator.cpp.

71{
73}

References mWrapper, and VST3Wrapper::ParamChangedHandler.

Member Function Documentation

◆ IsGraphicalUI()

bool VST3UIValidator::IsGraphicalUI ( )
overridevirtual

Default implementation returns false

Returns
true if using a native plug-in UI, not widgets

Reimplemented from EffectUIValidator.

Definition at line 131 of file VST3UIValidator.cpp.

132{
133 return mPlugView != nullptr;
134}
Steinberg::IPtr< Steinberg::IPlugView > mPlugView

References mPlugView.

◆ OnClose()

void VST3UIValidator::OnClose ( )
overridevirtual

Handle the UI OnClose event. Default implementation calls mEffect.CloseUI()

Reimplemented from EffectUIValidator.

Definition at line 149 of file VST3UIValidator.cpp.

150{
151 using namespace Steinberg;
152
153 mParent->PopEventHandler();
154
155 mPlainUI = nullptr;
156 mParent = nullptr;
157 if(mPlugView)
158 {
159 mPlugView->setFrame(nullptr);
160 mPlugView->removed();
161 mPlugView = nullptr;
162 mPlugFrame = nullptr;
163 }
164
166
168 if (mDuration != nullptr)
169 settings.extra.SetDuration(mDuration->GetValue());
170 //Flush changes if there is no processing performed at the moment
173 return nullptr;
174 });
175 //Make sure that new state has been written to the caches...
176 mAccess.Flush();
177
179
181}
static Settings & settings()
Definition: TrackInfo.cpp:87
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual void Flush()=0
Make the last Set changes "persistent" in underlying storage.
virtual void OnClose()
Steinberg::IPtr< Steinberg::IPlugFrame > mPlugFrame
void StoreSettings(EffectSettings &) const
Saves current state inside settings object, clears all runtime data.
void EndParameterEdit()
void FlushParameters(EffectSettings &settings, bool *hasChanges=nullptr)
Externalized state of a plug-in.

References VST3Wrapper::EndParameterEdit(), EffectSettingsAccess::Flush(), VST3Wrapper::FlushParameters(), NumericConverter::GetValue(), EffectUIValidator::mAccess, mDuration, EffectSettingsAccess::ModifySettings(), mParent, mPlainUI, mPlugFrame, mPlugView, mWrapper, EffectUIValidator::OnClose(), VST3Wrapper::ParamChangedHandler, settings(), and VST3Wrapper::StoreSettings().

Here is the call graph for this function:

◆ OnIdle()

void VST3UIValidator::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 75 of file VST3UIValidator.cpp.

76{
77 evt.Skip();
78 if(!mWrapper.IsActive())
79 {
81 {
82 bool hasChanges{false};
83 mWrapper.FlushParameters(settings, &hasChanges);
84 if(hasChanges)
86 return nullptr;
87 });
88 }
89}
bool IsActive() const noexcept

References VST3Wrapper::FlushParameters(), VST3Wrapper::IsActive(), EffectUIValidator::mAccess, EffectSettingsAccess::ModifySettings(), mWrapper, settings(), and VST3Wrapper::StoreSettings().

Referenced by VST3UIValidator().

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

◆ TryLoadNativeUI()

bool VST3UIValidator::TryLoadNativeUI ( wxWindow *  parent)
private

Definition at line 92 of file VST3UIValidator.cpp.

93{
94 using namespace Steinberg;
95
96 if(const auto view = owned (mWrapper.mEditController->createView (Vst::ViewType::kEditor)))
97 {
98 //Workaround: override default min size set by EffectUIHost::Initialize()
99 parent->SetMinSize(wxDefaultSize);
100 //IPlugFrame::resizeView is supposed to call IPlugView::setSize
101 //in the same call stack, assign before frame is attached
102 mPlugView = view;
103
104#if __WXGTK__
105 safenew internal::x11::SocketWindow(parent, wxID_ANY, view);
106#else
107
108 static const auto platformType =
109# if __WXMAC__
110 kPlatformTypeNSView;
111# elif __WXMSW__
112 kPlatformTypeHWND;
113# else
114# error "Platform not supported"
115# endif
116 auto plugFrame = owned(safenew internal::PlugFrame { parent });
117 view->setFrame(plugFrame);
118 if(view->attached(parent->GetHandle(), platformType) != kResultOk)
119 return false;
120 mPlugFrame = plugFrame;
121
122 ViewRect initialSize;
123 if(view->getSize(&initialSize) == kResultOk)
124 plugFrame->init(view.get(), &initialSize);
125#endif
126 return true;
127 }
128 return false;
129}
Dispatches window resize events from VST PlugView to the wxWindow.
Definition: PlugFrame.h:23
Wrapper for GtkSocket object, which provides X window mapping via XEmbed protocol.
Definition: SocketWindow.h:34

References VST3Wrapper::mEditController, mPlugFrame, mPlugView, mWrapper, and safenew.

Referenced by VST3UIValidator().

Here is the caller graph for this function:

◆ UpdateUI()

bool VST3UIValidator::UpdateUI ( )
overridevirtual

Update appearance of the panel for changes in settings.

Default implementation does nothing, returns true

Returns
true if successful

Reimplemented from EffectUIValidator.

Definition at line 183 of file VST3UIValidator.cpp.

184{
187 return nullptr;
188 });
189
190 if (mPlainUI != nullptr)
192
193 //Write to main...
194 mAccess.Flush();
195
196 return true;
197}
void FetchSettings(EffectSettings &)
Fetch state from settings object, may change internal runtime data.

References VST3Wrapper::FetchSettings(), EffectSettingsAccess::Flush(), EffectUIValidator::mAccess, EffectSettingsAccess::ModifySettings(), mPlainUI, mWrapper, VST3ParametersWindow::ReloadParameters(), and settings().

Here is the call graph for this function:

◆ ValidateUI()

bool VST3UIValidator::ValidateUI ( )
overridevirtual

Get settings data from the panel; may make error dialogs and return false.

Returns
true only if panel settings are acceptable

Implements EffectUIValidator.

Definition at line 136 of file VST3UIValidator.cpp.

137{
139 if (mDuration != nullptr)
140 settings.extra.SetDuration(mDuration->GetValue());
143 return nullptr;
144 });
145
146 return true;
147}

References VST3Wrapper::FlushParameters(), NumericConverter::GetValue(), EffectUIValidator::mAccess, mDuration, EffectSettingsAccess::ModifySettings(), mWrapper, settings(), and VST3Wrapper::StoreSettings().

Here is the call graph for this function:

Member Data Documentation

◆ mDuration

NumericTextCtrl* VST3UIValidator::mDuration { nullptr }
private

Definition at line 28 of file VST3UIValidator.h.

Referenced by OnClose(), ValidateUI(), and VST3UIValidator().

◆ mParent

wxWindow* VST3UIValidator::mParent { nullptr }
private

Definition at line 27 of file VST3UIValidator.h.

Referenced by OnClose(), and VST3UIValidator().

◆ mPlainUI

VST3ParametersWindow* VST3UIValidator::mPlainUI { nullptr }
private

Definition at line 30 of file VST3UIValidator.h.

Referenced by OnClose(), UpdateUI(), and VST3UIValidator().

◆ mPlugFrame

Steinberg::IPtr<Steinberg::IPlugFrame> VST3UIValidator::mPlugFrame
private

Definition at line 26 of file VST3UIValidator.h.

Referenced by OnClose(), and TryLoadNativeUI().

◆ mPlugView

Steinberg::IPtr<Steinberg::IPlugView> VST3UIValidator::mPlugView
private

Definition at line 25 of file VST3UIValidator.h.

Referenced by IsGraphicalUI(), OnClose(), and TryLoadNativeUI().

◆ mWrapper

VST3Wrapper& VST3UIValidator::mWrapper
private

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