From 1a9db3ab8e51e8594b79cf0874247b5287128d59 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 20 Mar 2022 01:23:44 +0100 Subject: [PATCH] Temporarily add more widgets to vizia Gain GUI --- nih_plug_vizia/src/widgets/param_slider.rs | 3 +++ plugins/examples/gain-gui-vizia/src/editor.rs | 16 +++++++++++++--- plugins/examples/gain-gui-vizia/src/lib.rs | 9 +++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/nih_plug_vizia/src/widgets/param_slider.rs b/nih_plug_vizia/src/widgets/param_slider.rs index 239fb45d..8cbb443a 100644 --- a/nih_plug_vizia/src/widgets/param_slider.rs +++ b/nih_plug_vizia/src/widgets/param_slider.rs @@ -307,7 +307,10 @@ impl View for ParamSlider { match window_event { WindowEvent::MouseDown(MouseButton::Left) => { if cx.modifiers.alt() { + // ALt+Click brings up a text entry dialog cx.emit(ParamSliderInternalEvent::SetTextInputActive(true)); + cx.current.set_active(cx, true); + // TODO: Once vizia implements it: (and probably do this from // `SetTextInputActive`) // - Focus the text box diff --git a/plugins/examples/gain-gui-vizia/src/editor.rs b/plugins/examples/gain-gui-vizia/src/editor.rs index 695cf854..68346ef8 100644 --- a/plugins/examples/gain-gui-vizia/src/editor.rs +++ b/plugins/examples/gain-gui-vizia/src/editor.rs @@ -24,7 +24,7 @@ impl Model for Data {} // Makes sense to also define this here, makes it a bit easier to keep track of pub(crate) fn default_state() -> Arc { - ViziaState::from_size(200, 150) + ViziaState::from_size(200, 250) } pub(crate) fn create( @@ -41,7 +41,7 @@ pub(crate) fn create( } .build(cx); - VStack::new(cx, move |cx| { + VStack::new(cx, |cx| { Label::new(cx, "Gain GUI") .font(assets::NOTO_SANS_THIN) .font_size(40.0 * POINT_SCALE) @@ -52,7 +52,17 @@ pub(crate) fn create( // compensate for that Label::new(cx, "Gain").bottom(Pixels(-1.0)); - ParamSlider::new(cx, Data::params, setter, |params| ¶ms.gain); + VStack::new(cx, |cx| { + ParamSlider::new(cx, Data::params, setter, |params| ¶ms.gain); + ParamSlider::new(cx, Data::params, setter, |params| ¶ms.gain) + .set_style(ParamSliderStyle::FromLeft); + ParamSlider::new(cx, Data::params, setter, |params| ¶ms.foo); + ParamSlider::new(cx, Data::params, setter, |params| ¶ms.foo) + .set_style(ParamSliderStyle::CurrentStep); + ParamSlider::new(cx, Data::params, setter, |params| ¶ms.foo) + .set_style(ParamSliderStyle::CurrentStepLabeled); + }) + .row_between(Pixels(5.0)); // TODO: Add a peak meter }) diff --git a/plugins/examples/gain-gui-vizia/src/lib.rs b/plugins/examples/gain-gui-vizia/src/lib.rs index a68f63bd..644d62e0 100644 --- a/plugins/examples/gain-gui-vizia/src/lib.rs +++ b/plugins/examples/gain-gui-vizia/src/lib.rs @@ -26,6 +26,14 @@ struct Gain { pub struct GainParams { #[id = "gain"] pub gain: FloatParam, + #[id = "foo"] + pub foo: EnumParam, +} + +#[derive(Debug, PartialEq, Eq, Enum)] +pub enum Foo { + Foo, + Bar, } impl Default for Gain { @@ -54,6 +62,7 @@ impl Default for GainParams { .with_smoother(SmoothingStyle::Linear(50.0)) .with_step_size(0.01) .with_unit(" dB"), + foo: EnumParam::new("Foo", Foo::Bar), } } }