From 8ddad4e89350b4fc0b39693513b2b2612e37f3f2 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 16 Feb 2022 20:41:00 +0100 Subject: [PATCH] Store the IPlugFrame instance --- src/wrapper/vst3/view.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/wrapper/vst3/view.rs b/src/wrapper/vst3/view.rs index 2abb9518..27d3c19f 100644 --- a/src/wrapper/vst3/view.rs +++ b/src/wrapper/vst3/view.rs @@ -4,11 +4,13 @@ use std::any::Any; use std::ffi::{c_void, CStr}; use std::mem; use std::sync::Arc; +use vst3_com::utils::SharedVstPtr; use vst3_sys::base::{kInvalidArgument, kResultFalse, kResultOk, tresult, TBool}; -use vst3_sys::gui::IPlugView; +use vst3_sys::gui::{IPlugFrame, IPlugView}; use vst3_sys::VST3; use super::inner::WrapperInner; +use super::util::VstPtr; use crate::plugin::{Editor, Plugin}; use crate::ParentWindowHandle; @@ -34,11 +36,14 @@ pub(crate) struct WrapperView { inner: Arc>, editor: Arc, editor_handle: RwLock>>, + + /// The `IPlugFrame` instance passed by the host during `IPlugView::set_frame`. + pub plug_frame: RwLock>>, } impl WrapperView

{ pub fn new(inner: Arc>, editor: Arc) -> Box { - Self::allocate(inner, editor, RwLock::new(None)) + Self::allocate(inner, editor, RwLock::new(None), RwLock::new(None)) } } @@ -176,9 +181,14 @@ impl IPlugView for WrapperView

{ kResultOk } - unsafe fn set_frame(&self, _frame: *mut c_void) -> tresult { - // TODO: Implement resizing. We don't implement that right now, so we also don't need the - // plug frame. + unsafe fn set_frame(&self, frame: *mut c_void) -> tresult { + // The correct argument type is missing from the bindings + let frame: SharedVstPtr = mem::transmute(frame); + match frame.upgrade() { + Some(frame) => *self.plug_frame.write() = Some(frame.into()), + None => *self.plug_frame.write() = None, + } + kResultOk }