Skip to main content

Editor

Trait Editor 

Source
pub trait Editor: Send {
    type Handle: EditorHandle;

    // Required methods
    fn spawn(
        &self,
        parent: Option<ParentWindowHandle>,
        wait_for_parent: bool,
        fallback_scale_factor: Option<f64>,
        gui_context: GuiContext,
        host: Option<HostMethods>,
    ) -> Result<SpawnedEditor<Self::Handle>, Box<dyn Error>>;
    fn size(&self) -> PhysicalSize<u32>;

    // Provided method
    fn resize_hint(&self) -> ResizeHint { ... }
}
Expand description

An editor for a Plugin.

Required Associated Types§

Required Methods§

Source

fn spawn( &self, parent: Option<ParentWindowHandle>, wait_for_parent: bool, fallback_scale_factor: Option<f64>, gui_context: GuiContext, host: Option<HostMethods>, ) -> Result<SpawnedEditor<Self::Handle>, Box<dyn Error>>

Create an instance of the plugin’s editor and embed it in the parent window. As explained in Plugin::editor(), you can then read the parameter values directly from your Params object, and modifying the values can be done using the functions on the ParamSetter. When you change a parameter value that way it will be broadcasted to the host and also updated in your Params struct.

This function should return a handle to the editor, which will be dropped when the editor gets closed. Implement the Drop trait on the returned handle if you need to explicitly handle the editor’s closing behavior.

If an error is returned, then the editor will not open.

If EditorHandle::set_fallback_scale_factor() has been called, then any created windows should have their sizes multiplied by that factor.

The wrapper guarantees that a previous handle has been dropped before this function is called again.

Source

fn size(&self) -> PhysicalSize<u32>

Returns the (current) size of the editor in physical pixels.

Provided Methods§

Source

fn resize_hint(&self) -> ResizeHint

Describes whether and how the host may resize this editor. The wrapper reads this to answer the host’s resize-capability queries (CLAP’s gui.can_resize / gui.get_resize_hints, VST3’s canResize).

The default is ResizeHint::default(), which is not resizable, so editors keep their fixed-size behavior unless they opt in. An editor that supports host resizing should return a hint with can_resize: true (and usually also implement EditorHandle::set_size() to apply the new size). See ResizeHint for the per-axis and aspect-ratio options.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Editor for ()

Source§

type Handle = ()

Source§

fn spawn( &self, _parent: Option<ParentWindowHandle>, _wait_for_parent: bool, _fallback_scale_factor: Option<f64>, _gui_context: GuiContext, _host: Option<HostMethods>, ) -> Result<SpawnedEditor<Self::Handle>, Box<dyn Error>>

Source§

fn size(&self) -> PhysicalSize<u32>

Implementors§