From 3135ab96104b9c723578b247a0ae2b9f32c965af Mon Sep 17 00:00:00 2001 From: Micah Johnston Date: Wed, 28 Aug 2024 11:04:05 -0500 Subject: [PATCH] rename Parent to ParentWindow and pass it by reference to Plugin::editor --- examples/gain/src/lib.rs | 4 ++-- src/editor.rs | 8 ++++---- src/format/clap/gui.rs | 4 ++-- src/format/clap/tests.rs | 4 ++-- src/format/vst3/tests.rs | 4 ++-- src/format/vst3/view.rs | 4 ++-- src/plugin.rs | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/gain/src/lib.rs b/examples/gain/src/lib.rs index 1a9a9e8..df27ffa 100644 --- a/examples/gain/src/lib.rs +++ b/examples/gain/src/lib.rs @@ -86,7 +86,7 @@ impl Plugin for Gain { } } - fn editor(&mut self, parent: Parent) -> Self::Editor { + fn editor(&mut self, parent: &ParentWindow) -> Self::Editor { GainEditor::open(parent).unwrap() } } @@ -138,7 +138,7 @@ pub struct GainEditor { } impl GainEditor { - fn open(parent: Parent) -> reflector_platform::Result { + fn open(parent: &ParentWindow) -> reflector_platform::Result { let app = AppOptions::new().mode(AppMode::Guest).build()?; let mut options = WindowOptions::new(); diff --git a/src/editor.rs b/src/editor.rs index 4ed1010..1e0bee0 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -9,13 +9,13 @@ pub enum RawParent { X11(c_ulong), } -pub struct Parent { +pub struct ParentWindow { parent: RawParent, } -impl Parent { - pub unsafe fn from_raw(parent: RawParent) -> Parent { - Parent { parent } +impl ParentWindow { + pub unsafe fn from_raw(parent: RawParent) -> ParentWindow { + ParentWindow { parent } } pub fn as_raw(&self) -> RawParent { diff --git a/src/format/clap/gui.rs b/src/format/clap/gui.rs index 77eb1fa..2fb69f1 100644 --- a/src/format/clap/gui.rs +++ b/src/format/clap/gui.rs @@ -4,7 +4,7 @@ use clap_sys::ext::gui::*; use clap_sys::plugin::*; use super::instance::Instance; -use crate::editor::{Editor, Parent, RawParent}; +use crate::editor::{Editor, ParentWindow, RawParent}; use crate::plugin::Plugin; impl Instance

{ @@ -151,7 +151,7 @@ impl Instance

{ let instance = &*(plugin as *const Self); let main_thread_state = &mut *instance.main_thread_state.get(); - let editor = main_thread_state.plugin.editor(Parent::from_raw(raw_parent)); + let editor = main_thread_state.plugin.editor(&ParentWindow::from_raw(raw_parent)); main_thread_state.editor = Some(editor); true diff --git a/src/format/clap/tests.rs b/src/format/clap/tests.rs index 9515f6b..5b970bc 100644 --- a/src/format/clap/tests.rs +++ b/src/format/clap/tests.rs @@ -2,7 +2,7 @@ use std::ffi::{c_char, CStr}; use std::io::{self, Read, Write}; use crate::buffers::Buffers; -use crate::editor::{Editor, Parent, Size}; +use crate::editor::{Editor, ParentWindow, Size}; use crate::events::Events; use clap_sys::plugin_factory::{clap_plugin_factory, CLAP_PLUGIN_FACTORY_ID}; @@ -57,7 +57,7 @@ impl Plugin for TestPlugin { fn processor(&mut self, _config: Config) -> Self::Processor { TestProcessor } - fn editor(&mut self, _parent: Parent) -> Self::Editor { + fn editor(&mut self, _parent: &ParentWindow) -> Self::Editor { TestEditor } diff --git a/src/format/vst3/tests.rs b/src/format/vst3/tests.rs index c934a93..29e7c13 100644 --- a/src/format/vst3/tests.rs +++ b/src/format/vst3/tests.rs @@ -4,7 +4,7 @@ use std::io::{self, Read, Write}; use std::{ptr, slice}; use crate::buffers::Buffers; -use crate::editor::{Editor, Parent, Size}; +use crate::editor::{Editor, ParentWindow, Size}; use crate::events::Events; use crate::host::Host; use crate::params::{ParamId, ParamValue}; @@ -64,7 +64,7 @@ impl Plugin for TestPlugin { fn processor(&mut self, _config: Config) -> Self::Processor { TestProcessor } - fn editor(&mut self, _parent: Parent) -> Self::Editor { + fn editor(&mut self, _parent: &ParentWindow) -> Self::Editor { TestEditor } diff --git a/src/format/vst3/view.rs b/src/format/vst3/view.rs index 49abd1f..3380dc5 100644 --- a/src/format/vst3/view.rs +++ b/src/format/vst3/view.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use vst3::{Class, Steinberg::*}; use super::component::MainThreadState; -use crate::editor::{Editor, Parent, RawParent}; +use crate::editor::{Editor, ParentWindow, RawParent}; use crate::plugin::Plugin; pub struct View { @@ -60,7 +60,7 @@ impl IPlugViewTrait for View

{ let main_thread_state = &mut *self.main_thread_state.get(); - let editor = main_thread_state.plugin.editor(Parent::from_raw(raw_parent)); + let editor = main_thread_state.plugin.editor(&ParentWindow::from_raw(raw_parent)); main_thread_state.editor = Some(editor); kResultOk diff --git a/src/plugin.rs b/src/plugin.rs index d924e9f..030bfff 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -1,7 +1,7 @@ use std::io::{self, Read, Write}; use crate::bus::{BusInfo, Layout}; -use crate::editor::{Editor, Parent}; +use crate::editor::{Editor, ParentWindow}; use crate::host::Host; use crate::params::{ParamId, ParamInfo, ParamValue}; use crate::process::{Config, Processor}; @@ -46,7 +46,7 @@ pub trait Plugin: Send + Sized + 'static { fn save(&self, output: &mut impl Write) -> io::Result<()>; fn load(&mut self, input: &mut impl Read) -> io::Result<()>; fn processor(&mut self, config: Config) -> Self::Processor; - fn editor(&mut self, parent: Parent) -> Self::Editor; + fn editor(&mut self, parent: &ParentWindow) -> Self::Editor; #[allow(unused_variables)] fn latency(&self, config: &Config) -> u64 {