pub trait GuiContext: Send + Sync + 'static {
    // Required methods
    fn plugin_api(&self) -> PluginApi;
    fn request_resize(&self) -> bool;
    unsafe fn raw_begin_set_parameter(&self, param: ParamPtr);
    unsafe fn raw_set_parameter_normalized(
        &self,
        param: ParamPtr,
        normalized: f32
    );
    unsafe fn raw_end_set_parameter(&self, param: ParamPtr);
    fn get_state(&self) -> PluginState;
    fn set_state(&self, state: PluginState);
}
Expand description

Callbacks the plugin can make when the user interacts with its GUI such as updating parameter values. This is passed to the plugin during Editor::spawn(). All of these functions assume they’re being called from the main GUI thread.

Required Methods§

source

fn plugin_api(&self) -> PluginApi

Get the current plugin API. This may be useful to display in the plugin’s GUI as part of an about screen.

source

fn request_resize(&self) -> bool

Ask the host to resize the editor window to the size specified by Editor::size(). This will return false if the host somehow didn’t like this and rejected the resize, in which case the window should revert to its old size. You should only actually resize your embedded window once this returns true.

TODO: Host->Plugin resizing has not been implemented yet

source

unsafe fn raw_begin_set_parameter(&self, param: ParamPtr)

Inform the host a parameter will be automated. Create a ParamSetter and use ParamSetter::begin_set_parameter() instead for a safe, user friendly API.

Safety

The implementing function still needs to check if param actually exists. This function is mostly marked as unsafe for API reasons.

source

unsafe fn raw_set_parameter_normalized(&self, param: ParamPtr, normalized: f32)

Inform the host a parameter is being automated with an already normalized value. Create a ParamSetter and use ParamSetter::set_parameter() instead for a safe, user friendly API.

Safety

The implementing function still needs to check if param actually exists. This function is mostly marked as unsafe for API reasons.

source

unsafe fn raw_end_set_parameter(&self, param: ParamPtr)

Inform the host a parameter has been automated. Create a ParamSetter and use ParamSetter::end_set_parameter() instead for a safe, user friendly API.

Safety

The implementing function still needs to check if param actually exists. This function is mostly marked as unsafe for API reasons.

source

fn get_state(&self) -> PluginState

Serialize the plugin’s current state to a serde-serializable object. Useful for implementing preset handling within a plugin’s GUI.

source

fn set_state(&self, state: PluginState)

Restore the state from a previously serialized state object. This will block the GUI thread until the state has been restored and a parameter value rescan has been requested from the host. If the plugin is currently processing audio, then the parameter values will be restored at the end of the current processing cycle.

Implementors§