pub trait Editor: Send {
// Required methods
fn spawn(
&self,
parent: ParentWindowHandle,
context: Arc<dyn GuiContext>
) -> Box<dyn Any + Send>;
fn size(&self) -> (u32, u32);
fn set_scale_factor(&self, factor: f32) -> bool;
fn param_value_changed(&self, id: &str, normalized_value: f32);
fn param_modulation_changed(&self, id: &str, modulation_offset: f32);
fn param_values_changed(&self);
}
Expand description
An editor for a Plugin
.
Required Methods§
sourcefn spawn(
&self,
parent: ParentWindowHandle,
context: Arc<dyn GuiContext>
) -> Box<dyn Any + Send>
fn spawn( &self, parent: ParentWindowHandle, context: Arc<dyn GuiContext> ) -> Box<dyn Any + Send>
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 set_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.
sourcefn size(&self) -> (u32, u32)
fn size(&self) -> (u32, u32)
Returns the (current) size of the editor in pixels as a (width, height)
pair. This size
must be reported in logical pixels, i.e. the size before being multiplied by the DPI
scaling factor to get the actual physical screen pixels.
sourcefn set_scale_factor(&self, factor: f32) -> bool
fn set_scale_factor(&self, factor: f32) -> bool
Set the DPI scaling factor, if supported. The plugin APIs don’t make any guarantees on when this is called, but for now just assume it will be the first function that gets called before creating the editor. If this is set, then any windows created by this editor should have their sizes multiplied by this scaling factor on Windows and Linux.
Right now this is never called on macOS since DPI scaling is built into the operating system there.
sourcefn param_value_changed(&self, id: &str, normalized_value: f32)
fn param_value_changed(&self, id: &str, normalized_value: f32)
Called whenever a specific parameter’s value has changed while the editor is open. You don’t need to do anything with this, but this can be used to force a redraw when the host sends a new value for a parameter or when a parameter change sent to the host gets processed.
sourcefn param_modulation_changed(&self, id: &str, modulation_offset: f32)
fn param_modulation_changed(&self, id: &str, modulation_offset: f32)
Called whenever a specific parameter’s monophonic modulation value has changed while the editor is open.
sourcefn param_values_changed(&self)
fn param_values_changed(&self)
Called whenever one or more parameter values or modulations have changed while the editor is
open. This may be called in place of param_value_changed()
when multiple parameter values hcange at the same time. For example, when a preset is
loaded.