mirror of
https://github.com/robbert-vdh/nih-plug.git
synced 2026-07-01 02:36:54 +00:00
Rework Params trait API with Arc instead of Pin
This is a breaking change requiring a small change to plugin implementations. The reason why `Pin<&dyn Params>` was used was more as a hint to indicate that the object must last for the plugin's lifetime, but `Pin` doesn't enforce that. It also makes the APIs a lot more awkward. Requiring the use of `Arc` fixes the following problems: - When storing the params object in the wrapper, the `ParamPtr`s are guaranteed to be stable. - This makes it possible to access the `Params` object without acquiring a lock on the plugin, this is very important for implementing plugin-side preset management. - It enforces immutability on the `Params` object. - And of course the API is much nicer without a bunch of unsafe code to work around Pin's limitations.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//! A simple generic UI widget that renders all parameters in a [`Params`] object as a scrollable
|
||||
//! list of sliders and labels.
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
|
||||
use egui::{TextStyle, Ui, Vec2};
|
||||
use nih_plug::prelude::{Param, ParamFlags, ParamPtr, ParamSetter, Params};
|
||||
@@ -35,7 +35,7 @@ pub struct GenericSlider;
|
||||
/// space.
|
||||
pub fn create(
|
||||
ui: &mut Ui,
|
||||
params: Pin<&dyn Params>,
|
||||
params: Arc<impl Params>,
|
||||
setter: &ParamSetter,
|
||||
widget: impl ParamWidget,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user