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 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 // 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 // correctly. In the future we can use an `Arc<AtomicBool>` and only force a redraw when
// that boolean is set. // that boolean is set.
} }
fn param_values_changed(&self) {
// Same
}
} }
/// The window handle used for [`EguiEditor`]. /// The window handle used for [`EguiEditor`].

View file

@ -101,12 +101,16 @@ impl<E: IcedEditor> Editor for IcedEditorWrapper<E> {
true true
} }
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) { fn param_values_changed(&self) {
if self.iced_state.is_open() { let _ = self.parameter_updates_sender.try_send(ParameterUpdate);
// 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.
let _ = self.parameter_updates_sender.try_send(ParameterUpdate);
}
} }
} }

View file

@ -123,8 +123,15 @@ impl Editor for ViziaEditor {
true 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. // 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 self.emit_parameters_changed_event
.store(true, Ordering::Relaxed); .store(true, Ordering::Relaxed);
} }

View file

@ -53,13 +53,14 @@ pub trait Editor: Send {
/// there. /// there.
fn set_scale_factor(&self, factor: f32) -> bool; fn set_scale_factor(&self, factor: f32) -> bool;
/// A callback that will be called whenever the parameter values changed while the editor is /// Called whenever a specific parameter's value has changed while the editor is open. You don't
/// open. You don't need to do anything with this, but this can be used to force a redraw when /// need to do anything with this, but this can be used to force a redraw when the host sends a
/// the host sends a new value for a parameter or when a parameter change sent to the host gets /// new value for a parameter or when a parameter change sent to the host gets processed.
/// processed. fn param_value_changed(&self, id: &str, normalized_value: f32);
///
/// This function will be called from the **audio thread**. It must thus be lock-free and may /// Called whenever one or more parameter values changed while the editor is open. This may be
/// not allocate. /// 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); fn param_values_changed(&self);
// TODO: Reconsider adding a tick function here for the Linux `IRunLoop`. To keep this platform // TODO: Reconsider adding a tick function here for the Linux `IRunLoop`. To keep this platform