Skip to main content

EmbeddedEditor

Struct EmbeddedEditor 

Source
pub struct EmbeddedEditor { /* private fields */ }
Expand description

A plugin editor embedded into a host window. Drop it (or call Self::close) to detach the editor and remove the child view.

Not Sync: it caches the last negotiated size in a Cell, and every method belongs on the UI thread that owns the parent window anyway.

Implementations§

Source§

impl EmbeddedEditor

Source

pub fn embed( plugin: Arc<Mutex<Plugin>>, parent: RawWindowHandle, rect: EditorRect, ) -> Result<Self>

Embed plugin’s editor as a child of parent, at rect.

Must be called on the UI/main thread (where your event loop runs). parent is the host window’s handle (e.g. from eframe::Frame::window_handle()).

On Windows, continue forwarding later DPI/scale changes through Plugin::set_editor_scale_factor. An embedded child does not own the parent framework’s window procedure.

Sizing the editor to rect is best-effort: a fixed-size editor, or one behind process isolation (where resize requests are not marshalled), keeps its own size and the embed still succeeds. Read the size the child actually got back from Self::try_set_rect.

Source

pub fn set_rect(&self, rect: EditorRect)

Reposition/resize the embedded editor to track rect. Call each frame so the editor follows the host layout (scroll, window resize).

The position always follows rect. The size is whatever the plugin accepts: a fixed-size editor keeps its own dimensions, so the child view may be smaller or larger than the rectangle you asked for. Use Self::try_set_rect to learn which.

Implemented on macOS, Windows and Linux/X11 — the same platforms Self::embed supports. A no-op on any other platform, where embed cannot have succeeded in the first place.

Source

pub fn try_set_rect(&self, rect: EditorRect) -> Result<EditorRect>

Fallible variant of Self::set_rect that reports a rejected resize.

On success the returned rectangle carries the dimensions the plugin accepted after applying its checkSizeConstraint rules, which may be smaller or larger than the ones requested. On failure the child view has still been moved to rect’s position and kept at the last size the plugin accepted — a plugin that refuses to resize does not stop the editor from tracking the host layout.

Repeating the same size is cheap: the plugin is only asked when the requested dimensions differ from the last ones it answered.

Source

pub fn take_resize_request(&self) -> Option<(i32, i32)>

Poll for a resize the plugin asked for through VST 3’s IPlugFrame::resizeView, in pixels, consuming it.

An embedded editor cannot resize the host’s layout on its own. Call this each frame while the editor is open; when it answers, allocate that much space in your UI and feed the resulting rectangle back through Self::set_rect. Ignoring it leaves the plugin’s view drawing at a size its container does not match (clipped or letterboxed).

Returns None when nothing is pending, when the plugin mutex is momentarily held elsewhere (the request stays queued for the next poll), and always for a process-isolated plugin, whose editor is not bridged across the boundary.

Source

pub fn close(self)

Detach the editor and remove the child view (also done on drop).

Trait Implementations§

Source§

impl Drop for EmbeddedEditor

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.