1
0
Fork 0

Add an individual Editor::param_value_changed

This commit is contained in:
Robbert van der Helm 2023-01-11 14:16:19 +01:00
parent bdc8537f3f
commit 922d2de603
4 changed files with 30 additions and 14 deletions

View file

@ -101,11 +101,15 @@ where
true
}
fn param_values_changed(&self) {
fn param_value_changed(&self, _id: &str, _normalized_value: f32) {
// As mentioned above, for now we'll always force a redraw to allow meter widgets to work
// correctly. In the future we can use an `Arc<AtomicBool>` and only force a redraw when
// that boolean is set.
}
fn param_values_changed(&self) {
// Same
}
}
/// The window handle used for [`EguiEditor`].

View file

@ -101,12 +101,16 @@ impl<E: IcedEditor> Editor for IcedEditorWrapper<E> {
true
}
fn param_values_changed(&self) {
if self.iced_state.is_open() {
fn param_value_changed(&self, _id: &str, _normalized_value: f32) {
// If there's already a paramter change notification in the channel then we don't need
// to do anything else. This avoids queueing up redundant GUI redraws.
// NOTE: We could add an event containing the parameter's ID and the normalized value, but
// these events aren't really necessary for Vizia.
let _ = self.parameter_updates_sender.try_send(ParameterUpdate);
}
fn param_values_changed(&self) {
let _ = self.parameter_updates_sender.try_send(ParameterUpdate);
}
}

View file

@ -123,8 +123,15 @@ impl Editor for ViziaEditor {
true
}
fn param_values_changed(&self) {
fn param_value_changed(&self, _id: &str, _normalized_value: f32) {
// This will cause a future idle callback to send a parameters changed event.
// NOTE: We could add an event containing the parameter's ID and the normalized value, but
// these events aren't really necessary for Vizia.
self.emit_parameters_changed_event
.store(true, Ordering::Relaxed);
}
fn param_values_changed(&self) {
self.emit_parameters_changed_event
.store(true, Ordering::Relaxed);
}

View file

@ -53,13 +53,14 @@ pub trait Editor: Send {
/// there.
fn set_scale_factor(&self, factor: f32) -> bool;
/// A callback that will be called whenever the parameter values 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.
///
/// This function will be called from the **audio thread**. It must thus be lock-free and may
/// not allocate.
/// 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.
fn param_value_changed(&self, id: &str, normalized_value: f32);
/// Called whenever one or more parameter values changed while the editor is open. This may be
/// called in place of [`param_value_changed()`][Self::param_value_changed()] when multiple
/// parameter values hcange at the same time. For example, when a preset is loaded.
fn param_values_changed(&self);
// TODO: Reconsider adding a tick function here for the Linux `IRunLoop`. To keep this platform