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

#include <VST3Editor.h>

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

Public Member Functions

 VST3Editor (wxWindow *parent, VST3Wrapper &wrapper, const EffectUIServices &effect, EffectType type, EffectSettingsAccess &access, bool useNativeUI)
 
 ~VST3Editor () 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 EffectEditor
 EffectEditor (const EffectUIServices &services, EffectSettingsAccess &access)
 
virtual ~EffectEditor ()
 
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 EffectEditor
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 EffectEditor
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from EffectEditor
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 EffectEditor
const EffectUIServicesmUIServices
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 20 of file VST3Editor.h.

Constructor & Destructor Documentation

◆ VST3Editor()

VST3Editor::VST3Editor ( wxWindow *  parent,
VST3Wrapper wrapper,
const EffectUIServices effect,
EffectType  type,
EffectSettingsAccess access,
bool  useNativeUI 
)

Definition at line 16 of file VST3Editor.cpp.

20 : EffectEditor(effect, access), mWrapper(wrapper), mParent(parent)
21{
22 if (type == EffectTypeGenerate)
23 {
24 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
25 auto controlsRoot = safenew wxWindow(parent, wxID_ANY);
26 if(!useNativeUI || !TryLoadNativeUI(controlsRoot))
28 vSizer->Add(controlsRoot);
29
30 auto &extra = access.Get().extra;
33 parent, wxID_ANY,
35 extra.GetDurationFormat(),
36 extra.GetDuration(),
38 .AutoPos(true)
39 );
40 mDuration->SetName( XO("Duration") );
41
42 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
43 hSizer->Add(safenew wxStaticText(parent, wxID_ANY, _("Duration:")));
44 hSizer->AddSpacer(5);
45 hSizer->Add(mDuration);
46 vSizer->AddSpacer(10);
47 vSizer->Add(hSizer.release());
48
49 parent->SetMinSize(vSizer->CalcMin());
50 parent->SetSizer(vSizer.release());
51 }
52 else if(!useNativeUI || !TryLoadNativeUI(parent))
53 {
55 *parent,
58 );
59 }
60
62 [this](Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue value) {
63 Publish({ static_cast<size_t>(id), static_cast<float>(value) });
64 };
65
67
68 Bind(wxEVT_IDLE, &VST3Editor::OnIdle, this);
69
70 mParent->PushEventHandler(this);
71}
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:10
const NumericConverterType & NumericConverterType_TIME()
int id
EffectEditor(const EffectUIServices &services, EffectSettingsAccess &access)
EffectSettingsAccess & mAccess
Definition: EffectEditor.h:92
virtual const EffectSettings & Get()=0
static FormatterContext SampleRateContext(double sampleRate)
void SetName(const TranslatableString &name)
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207
bool TryLoadNativeUI(wxWindow *parent)
Definition: VST3Editor.cpp:95
VST3ParametersWindow * mPlainUI
Definition: VST3Editor.h:31
VST3Wrapper & mWrapper
Definition: VST3Editor.h:24
void OnIdle(wxIdleEvent &)
Definition: VST3Editor.cpp:78
NumericTextCtrl * mDuration
Definition: VST3Editor.h:29
wxWindow * mParent
Definition: VST3Editor.h:28
static VST3ParametersWindow * Setup(wxWindow &parent, Steinberg::Vst::IEditController &editController, Steinberg::Vst::IComponentHandler &componentHandler)
Creates VST3ParametersWindow inside parent.
void BeginParameterEdit(EffectSettingsAccess &access)
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
Definition: VST3Wrapper.h:70
Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
Definition: VST3Wrapper.h:73
std::function< void(Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler
Definition: VST3Wrapper.h:143
Steinberg::Vst::ProcessSetup mSetup
Definition: VST3Wrapper.h:68
EffectSettingsExtra extra
Options & AutoPos(bool enable)

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

Here is the call graph for this function:

◆ ~VST3Editor()

VST3Editor::~VST3Editor ( )
override

Definition at line 73 of file VST3Editor.cpp.

74{
76}

References mWrapper, and VST3Wrapper::ParamChangedHandler.

Member Function Documentation

◆ IsGraphicalUI()

bool VST3Editor::IsGraphicalUI ( )
overridevirtual

Default implementation returns false

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

Reimplemented from EffectEditor.

Definition at line 134 of file VST3Editor.cpp.

135{
136 return mPlugView != nullptr;
137}
Steinberg::IPtr< Steinberg::IPlugView > mPlugView
Definition: VST3Editor.h:26

References mPlugView.

◆ OnClose()

void VST3Editor::OnClose ( )
overridevirtual

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

Reimplemented from EffectEditor.

Definition at line 152 of file VST3Editor.cpp.

153{
154 using namespace Steinberg;
155
156 mParent->PopEventHandler();
157
158 mPlainUI = nullptr;
159 mParent = nullptr;
160 if(mPlugView)
161 {
162 mPlugView->setFrame(nullptr);
163 mPlugView->removed();
164 mPlugView = nullptr;
165 mPlugFrame = nullptr;
166 }
167
169
171 if (mDuration != nullptr)
172 settings.extra.SetDuration(mDuration->GetValue());
173 //Flush changes if there is no processing performed at the moment
176 return nullptr;
177 });
178 //Make sure that new state has been written to the caches...
179 mAccess.Flush();
180
182
184}
static Settings & settings()
Definition: TrackInfo.cpp:51
virtual void OnClose()
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.
Steinberg::IPtr< Steinberg::IPlugFrame > mPlugFrame
Definition: VST3Editor.h:27
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(), EffectEditor::mAccess, mDuration, EffectSettingsAccess::ModifySettings(), mParent, mPlainUI, mPlugFrame, mPlugView, mWrapper, EffectEditor::OnClose(), VST3Wrapper::ParamChangedHandler, settings(), and VST3Wrapper::StoreSettings().

Here is the call graph for this function:

◆ OnIdle()

void VST3Editor::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 78 of file VST3Editor.cpp.

79{
80 evt.Skip();
81 if(!mWrapper.IsActive())
82 {
84 {
85 bool hasChanges{false};
86 mWrapper.FlushParameters(settings, &hasChanges);
87 if(hasChanges)
89 return nullptr;
90 });
91 }
92}
bool IsActive() const noexcept

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

Referenced by VST3Editor().

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

◆ TryLoadNativeUI()

bool VST3Editor::TryLoadNativeUI ( wxWindow *  parent)
private

Definition at line 95 of file VST3Editor.cpp.

96{
97 using namespace Steinberg;
98
99 if(const auto view = owned (mWrapper.mEditController->createView (Vst::ViewType::kEditor)))
100 {
101 //Workaround: override default min size set by EffectUIHost::Initialize()
102 parent->SetMinSize(wxDefaultSize);
103 //IPlugFrame::resizeView is supposed to call IPlugView::setSize
104 //in the same call stack, assign before frame is attached
105 mPlugView = view;
106
107#if __WXGTK__
108 safenew internal::x11::SocketWindow(parent, wxID_ANY, view);
109#else
110
111 static const auto platformType =
112# if __WXMAC__
113 kPlatformTypeNSView;
114# elif __WXMSW__
115 kPlatformTypeHWND;
116# else
117# error "Platform not supported"
118# endif
119 auto plugFrame = owned(safenew internal::PlugFrame { parent });
120 view->setFrame(plugFrame);
121 if(view->attached(parent->GetHandle(), platformType) != kResultOk)
122 return false;
123 mPlugFrame = plugFrame;
124
125 ViewRect initialSize;
126 if(view->getSize(&initialSize) == kResultOk)
127 plugFrame->init(view.get(), &initialSize);
128#endif
129 return true;
130 }
131 return false;
132}
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 VST3Editor().

Here is the caller graph for this function:

◆ UpdateUI()

bool VST3Editor::UpdateUI ( )
overridevirtual

Update appearance of the panel for changes in settings.

Default implementation does nothing, returns true

Returns
true if successful

Reimplemented from EffectEditor.

Definition at line 186 of file VST3Editor.cpp.

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

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

Here is the call graph for this function:

◆ ValidateUI()

bool VST3Editor::ValidateUI ( )
overridevirtual

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

Returns
true only if panel settings are acceptable

Implements EffectEditor.

Definition at line 139 of file VST3Editor.cpp.

140{
142 if (mDuration != nullptr)
143 settings.extra.SetDuration(mDuration->GetValue());
146 return nullptr;
147 });
148
149 return true;
150}

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

Here is the call graph for this function:

Member Data Documentation

◆ mDuration

NumericTextCtrl* VST3Editor::mDuration { nullptr }
private

Definition at line 29 of file VST3Editor.h.

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

◆ mParent

wxWindow* VST3Editor::mParent { nullptr }
private

Definition at line 28 of file VST3Editor.h.

Referenced by OnClose(), and VST3Editor().

◆ mPlainUI

VST3ParametersWindow* VST3Editor::mPlainUI { nullptr }
private

Definition at line 31 of file VST3Editor.h.

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

◆ mPlugFrame

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

Definition at line 27 of file VST3Editor.h.

Referenced by OnClose(), and TryLoadNativeUI().

◆ mPlugView

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

Definition at line 26 of file VST3Editor.h.

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

◆ mWrapper

VST3Wrapper& VST3Editor::mWrapper
private

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