pub struct BuiltinEditor<P: Params> { /* private fields */ }Expand description
Built-in editor that renders parameter widgets to a pixel buffer.
Uses the CPU backend (tiny-skia) for software rasterization. When
open() is called, creates a baseview window and blits pixels via wgpu.
Implementations§
Source§impl<P: Params + 'static> BuiltinEditor<P>
impl<P: Params + 'static> BuiltinEditor<P>
Sourcepub fn request_repaint(&self)
pub fn request_repaint(&self)
Request a repaint on the next idle tick. Call this if plugin
code mutates display state outside the normal param or
state_changed pathways (uncommon). User interaction and
host automation already flag themselves dirty automatically.
pub fn new(params: Arc<P>, layout: PluginLayout) -> Self
pub fn new_with_layout(params: Arc<P>, layout: Layout) -> Self
pub fn new_grid(params: Arc<P>, layout: GridLayout) -> Self
pub fn with_theme(self, theme: Theme) -> Self
Sourcepub fn render(&mut self)
pub fn render(&mut self)
Render the full UI to the internal CPU pixel buffer.
Only available when the cpu feature is on. In gpu-only
mode, render through Self::render_to with a
truce_gpu::WgpuBackend instead.
§Panics
Panics if the lazy CpuBackend::new allocation fails (out of
memory or zero dimensions). The backend is allocated on first
render - subsequent calls reuse it.
Sourcepub fn dispatch_events(&mut self, events: &[InputEvent])
pub fn dispatch_events(&mut self, events: &[InputEvent])
Feed a batch of input events through interaction::dispatch and
apply the resulting param edits. Flags a repaint when hover,
dropdown-open state, or any param moved.
Typically callers build the events by running each baseview
event through interaction::BaseviewTranslator and batching
the non-None results.
Sourcepub fn pixel_data(&self) -> Option<&[u8]>
pub fn pixel_data(&self) -> Option<&[u8]>
Get the raw pixel data after rendering (RGBA premultiplied).
Only available when the cpu feature is on.
Sourcepub fn has_context(&self) -> bool
pub fn has_context(&self) -> bool
Whether the editor has an active context.
Sourcepub fn take_context(&mut self) -> Option<PluginContext>
pub fn take_context(&mut self) -> Option<PluginContext>
Take the editor context, leaving None in its place.
Used by hot-reload to preserve the context when swapping editors.
Sourcepub fn set_context(&mut self, context: PluginContext)
pub fn set_context(&mut self, context: PluginContext)
Set the editor context (host callbacks) without opening the CPU view.
Sourcepub fn size(&self) -> (u32, u32)
pub fn size(&self) -> (u32, u32)
Editor logical size (width, height in points). Inherent
method so it stays callable when the Editor trait impl is
cfg’d out in gpu-only builds.
Sourcepub fn can_resize(&self) -> bool
pub fn can_resize(&self) -> bool
Whether the editor supports host/user-driven resize. Inherent
for the same reason as Self::size: the GPU editor wraps this
type and delegates to it in gpu-only builds where the Editor
trait impl is cfg’d out.
Sourcepub fn min_size(&self) -> (u32, u32)
pub fn min_size(&self) -> (u32, u32)
Minimum logical size in points. Inherent (see Self::size).
Sourcepub fn max_size(&self) -> (u32, u32)
pub fn max_size(&self) -> (u32, u32)
Maximum logical size in points. Inherent (see Self::size).
Sourcepub fn size_increment(&self) -> Option<(u32, u32)>
pub fn size_increment(&self) -> Option<(u32, u32)>
Cell-step resize increment, or None when not resizable.
Inherent (see Self::size).
Sourcepub fn can_maximize(&self) -> bool
pub fn can_maximize(&self) -> bool
Whether the standalone host may maximize the window. Inherent
(see Self::size) so the gpu-only GpuEditor wrapper can
reach it when this Editor impl is cfg’d out. Sourced from the
grid’s .maximizable() (default false); Rows layouts are
fixed-size and never maximizable, and the value is moot there
anyway since can_resize is false.
Sourcepub fn set_size(&mut self, width: u32, height: u32) -> bool
pub fn set_size(&mut self, width: u32, height: u32) -> bool
Snap a requested logical size to whole cells, reflow the grid,
and post the result for the next frame. Returns true when
accepted. Inherent (see Self::size).
Sourcepub fn state_changed(&mut self)
pub fn state_changed(&mut self)
Notify the widget tree that plugin state was restored
(preset recall, undo, session load). Inherent for the same
reason as Self::size above.
Sourcepub fn render_to(&mut self, backend: &mut dyn RenderBackend)
pub fn render_to(&mut self, backend: &mut dyn RenderBackend)
Render all widgets to an external RenderBackend.
Used by truce-gpu to draw through the GPU backend instead of
the internal CPU backend.
Trait Implementations§
Source§impl<P: Params + 'static> Drop for BuiltinEditor<P>
Available on crate feature cpu only.
impl<P: Params + 'static> Drop for BuiltinEditor<P>
cpu only.Source§impl<P: Params + 'static> Editor for BuiltinEditor<P>
Available on crate feature cpu only.
impl<P: Params + 'static> Editor for BuiltinEditor<P>
cpu only.Source§fn state_changed(&mut self)
fn state_changed(&mut self)
Source§fn can_resize(&self) -> bool
fn can_resize(&self) -> bool
Source§fn can_maximize(&self) -> bool
fn can_maximize(&self) -> bool
Source§fn min_size(&self) -> (u32, u32)
fn min_size(&self) -> (u32, u32)
(1, 1). Wrappers consult this for CLAP’s
gui_get_resize_hints and VST3’s checkSizeConstraint.
Ignored when can_resize() returns false.Source§fn max_size(&self) -> (u32, u32)
fn max_size(&self) -> (u32, u32)
(u32::MAX, u32::MAX). Same wrapper consumers
as min_size.Source§fn size_increment(&self) -> Option<(u32, u32)>
fn size_increment(&self) -> Option<(u32, u32)>
None
for free (pixel-precise) resizing. The standalone X11 host
maps this onto WM resize increments (PResizeInc) so the
window manager snaps edge-drags to whole cells - the same
mechanism terminal emulators use to snap to character cells.
The snap counts from Self::min_size, which is already
cell-aligned, so every allowed size lands on a boundary.
Ignored when can_resize() returns false.Source§fn set_size(&mut self, width: u32, height: u32) -> bool
fn set_size(&mut self, width: u32, height: u32) -> bool
Source§fn open(&mut self, parent: RawWindowHandle, context: PluginContext)
fn open(&mut self, parent: RawWindowHandle, context: PluginContext)
Source§fn set_scale_factor(&mut self, factor: f64)
fn set_scale_factor(&mut self, factor: f64)
Source§fn set_uses_system_scale(&mut self, yes: bool)
fn set_uses_system_scale(&mut self, yes: bool)
Source§fn screenshot(
&mut self,
_params: Arc<dyn Params>,
) -> Option<(Vec<u8>, u32, u32)>
fn screenshot( &mut self, _params: Arc<dyn Params>, ) -> Option<(Vec<u8>, u32, u32)>
Source§fn aspect_ratio(&self) -> Option<(u32, u32)>
fn aspect_ratio(&self) -> Option<(u32, u32)>
(numerator, denominator), or
None for free resizing. CLAP, VST3, AU v3, standalone, and
LV2 honour this; VST2 / AAX silently ignore. Integer pair
(not f64) avoids the Cubase-9 aspect-rounding quirk JUCE
special-cases.Source§fn prefers_pow2(&self) -> bool
fn prefers_pow2(&self) -> bool
clap_gui_resize_hints.preserve_aspect_ratio /
aspect_ratio_width siblings; ignored on formats without
an equivalent.impl<P: Params> Send for BuiltinEditor<P>
Auto Trait Implementations§
impl<P> !RefUnwindSafe for BuiltinEditor<P>
impl<P> !Sync for BuiltinEditor<P>
impl<P> !UnwindSafe for BuiltinEditor<P>
impl<P> Freeze for BuiltinEditor<P>
impl<P> Unpin for BuiltinEditor<P>
impl<P> UnsafeUnpin for BuiltinEditor<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<E> IntoEditor for Ewhere
E: Editor + 'static,
impl<E> IntoEditor for Ewhere
E: Editor + 'static,
Source§fn into_editor(self) -> Box<dyn Editor>
fn into_editor(self) -> Box<dyn Editor>
Box<dyn Editor>.