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
impl EmbeddedEditor
Sourcepub fn embed(
plugin: Arc<Mutex<Plugin>>,
parent: RawWindowHandle,
rect: EditorRect,
) -> Result<Self>
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.
Sourcepub fn set_rect(&self, rect: EditorRect)
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.
Sourcepub fn try_set_rect(&self, rect: EditorRect) -> Result<EditorRect>
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.
Sourcepub fn take_resize_request(&self) -> Option<(i32, i32)>
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.