Skip to content

Commit

Permalink
rename Parent to ParentWindow and pass it by reference to Plugin::editor
Browse files Browse the repository at this point in the history
  • Loading branch information
micahrj committed Aug 28, 2024
1 parent 4518b92 commit 3135ab9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions examples/gain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ pub struct GainEditor {
}

impl GainEditor {
fn open(parent: Parent) -> reflector_platform::Result<GainEditor> {
fn open(parent: &ParentWindow) -> reflector_platform::Result<GainEditor> {
let app = AppOptions::new().mode(AppMode::Guest).build()?;

let mut options = WindowOptions::new();
Expand Down
8 changes: 4 additions & 4 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/format/clap/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: Plugin> Instance<P> {
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<P: Plugin> Instance<P> {
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
Expand Down
4 changes: 2 additions & 2 deletions src/format/clap/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/format/vst3/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/format/vst3/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: Plugin> {
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<P: Plugin> IPlugViewTrait for View<P> {

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
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3135ab9

Please sign in to comment.