diff --git a/src/wrapper/vst3.rs b/src/wrapper/vst3.rs index 0e5999a3..bfb3eebb 100644 --- a/src/wrapper/vst3.rs +++ b/src/wrapper/vst3.rs @@ -32,6 +32,7 @@ use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use std::sync::Arc; use vst3_sys::base::{kInvalidArgument, kNoInterface, kResultFalse, kResultOk, tresult, TBool}; use vst3_sys::base::{IBStream, IPluginBase, IPluginFactory, IPluginFactory2, IPluginFactory3}; +use vst3_sys::gui::IPlugView; use vst3_sys::utils::SharedVstPtr; use vst3_sys::vst::{ IAudioProcessor, IComponent, IComponentHandler, IEditController, IEventList, IParamValueQueue, @@ -90,7 +91,6 @@ macro_rules! check_null_ptr_msg { struct WrapperInner { /// The wrapped plugin instance. plugin: Box>, - editor: RwLock>>, /// The host's `IComponentHandler` instance, if passed through /// `IEditController::set_component_handler`. @@ -154,6 +154,14 @@ pub(crate) struct Wrapper { inner: Arc>, } +/// The plugin's [IPlugView] instance created in [IEditController::create_view] if `P` has an +/// editor. This is managed separately so the lifetime bounds match up. +#[VST3(implements(IPlugView))] +struct WrapperView { + inner: Arc>, + editor: RwLock>>, +} + /// A [ProcessContext] implementation for the wrapper. This is a separate object so it can hold on /// to lock guards for event queues. Otherwise reading these events would require constant /// unnecessary atomic operations to lock the uncontested RwLocks. @@ -266,7 +274,6 @@ impl WrapperInner

{ pub fn new() -> Arc { let mut wrapper = Self { plugin: Box::new(RwLock::default()), - editor: RwLock::new(None), component_handler: RwLock::new(None), @@ -391,6 +398,12 @@ impl Wrapper

{ } } +impl WrapperView

{ + pub fn new(inner: Arc>) -> Box { + Self::allocate(inner, RwLock::new(None)) + } +} + impl MainThreadExecutor for WrapperInner

{ unsafe fn execute(&self, task: Task) { // This function is always called from the main thread @@ -1254,6 +1267,66 @@ impl IAudioProcessor for Wrapper

{ } } +impl IPlugView for WrapperView

{ + unsafe fn is_platform_type_supported(&self, type_: vst3_com::base::FIDString) -> tresult { + todo!() + } + + unsafe fn attached(&self, parent: *mut c_void, type_: vst3_com::base::FIDString) -> tresult { + todo!() + } + + unsafe fn removed(&self) -> tresult { + todo!() + } + + unsafe fn on_wheel(&self, distance: f32) -> tresult { + todo!() + } + + unsafe fn on_key_down( + &self, + key: vst3_com::base::char16, + key_code: i16, + modifiers: i16, + ) -> tresult { + todo!() + } + + unsafe fn on_key_up( + &self, + key: vst3_com::base::char16, + key_code: i16, + modifiers: i16, + ) -> tresult { + todo!() + } + + unsafe fn get_size(&self, size: *mut vst3_com::gui::ViewRect) -> tresult { + todo!() + } + + unsafe fn on_size(&self, new_size: *mut vst3_com::gui::ViewRect) -> tresult { + todo!() + } + + unsafe fn on_focus(&self, state: TBool) -> tresult { + todo!() + } + + unsafe fn set_frame(&self, frame: *mut c_void) -> tresult { + todo!() + } + + unsafe fn can_resize(&self) -> tresult { + todo!() + } + + unsafe fn check_size_constraint(&self, rect: *mut vst3_com::gui::ViewRect) -> tresult { + todo!() + } +} + #[doc(hidden)] #[VST3(implements(IPluginFactory, IPluginFactory2, IPluginFactory3))] pub struct Factory {