diff --git a/nih_plug_egui/src/widgets/generic_ui.rs b/nih_plug_egui/src/widgets/generic_ui.rs index 005d751b..fc71975f 100644 --- a/nih_plug_egui/src/widgets/generic_ui.rs +++ b/nih_plug_egui/src/widgets/generic_ui.rs @@ -4,8 +4,7 @@ use std::pin::Pin; use egui::{TextStyle, Ui, Vec2}; -use nih_plug::context::ParamSetter; -use nih_plug::prelude::{Param, ParamPtr, Params}; +use nih_plug::prelude::{Param, ParamFlags, ParamPtr, ParamSetter, Params}; use super::ParamSlider; @@ -45,14 +44,22 @@ pub fn create( // Take up all remaining space, use a wrapper container to adjust how much space that is .auto_shrink([false, false]) .show(ui, |ui| { - for (widget_idx, (_, param_ptr, _)) in params.param_map().into_iter().enumerate() { + let mut first_widget = true; + for (_, param_ptr, _) in params.param_map().into_iter() { + let flags = unsafe { param_ptr.flags() }; + if flags.contains(ParamFlags::HIDE_IN_GENERIC_UI) { + continue; + } + // This list looks weird without a little padding - if widget_idx > 0 { + if !first_widget { ui.allocate_space(padding); } ui.label(unsafe { param_ptr.name() }); unsafe { widget.add_widget_raw(ui, ¶m_ptr, setter) }; + + first_widget = false; } }); } diff --git a/nih_plug_iced/src/widgets/generic_ui.rs b/nih_plug_iced/src/widgets/generic_ui.rs index ba74fc03..36ca057b 100644 --- a/nih_plug_iced/src/widgets/generic_ui.rs +++ b/nih_plug_iced/src/widgets/generic_ui.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use std::marker::PhantomData; use std::pin::Pin; -use nih_plug::prelude::{Param, ParamPtr, Params}; +use nih_plug::prelude::{Param, ParamFlags, ParamPtr, Params}; use super::{ParamMessage, ParamSlider}; use crate::backend::Renderer; @@ -160,12 +160,22 @@ where // Make sure we already have widget state for each widget let param_map = self.params.param_map(); for (_, param_ptr, _) in ¶m_map { + let flags = unsafe { param_ptr.flags() }; + if flags.contains(ParamFlags::HIDE_IN_GENERIC_UI) { + continue; + } + if !widget_state.contains_key(param_ptr) { widget_state.insert(*param_ptr, Default::default()); } } for (_, param_ptr, _) in param_map { + let flags = unsafe { param_ptr.flags() }; + if flags.contains(ParamFlags::HIDE_IN_GENERIC_UI) { + continue; + } + // SAFETY: We only borrow each item once, and the plugin framework statically asserted // that parameter indices are unique and this widget state cannot outlive this // function diff --git a/nih_plug_vizia/src/widgets/generic_ui.rs b/nih_plug_vizia/src/widgets/generic_ui.rs index 0b3c0d16..6b2c8f7a 100644 --- a/nih_plug_vizia/src/widgets/generic_ui.rs +++ b/nih_plug_vizia/src/widgets/generic_ui.rs @@ -2,7 +2,7 @@ use std::{ops::Deref, pin::Pin}; -use nih_plug::prelude::{ParamPtr, Params}; +use nih_plug::prelude::{ParamFlags, ParamPtr, Params}; use vizia::*; use super::{ParamSlider, ParamSliderExt, ParamSliderStyle}; @@ -86,6 +86,11 @@ impl GenericUi { // map `params` to some `impl Param` and everything would have been a lot neater let param_map = &*params.map(|params| params.as_ref().param_map()).get(cx); for (_, param_ptr, _) in param_map { + let flags = unsafe { param_ptr.flags() }; + if flags.contains(ParamFlags::HIDE_IN_GENERIC_UI) { + continue; + } + make_widget(cx, *param_ptr); } })