From e1d4be2a03df40fc7c74b4c7c820c173ea25016a Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 22 May 2022 12:37:30 +0200 Subject: [PATCH] Change NON_AUTOMATABLE semantics and add HIDDEN This now lets you have parameters that cannot be automated but that are still changeable through the generic UI. --- BREAKING_CHANGES.md | 19 +++++++++++++++++++ src/param.rs | 12 ++++++++---- src/param/boolean.rs | 14 +++++++++++--- src/param/enums.rs | 14 +++++++++++--- src/param/float.rs | 14 +++++++++++--- src/param/integer.rs | 14 +++++++++++--- src/wrapper/clap/wrapper.rs | 13 ++++++++----- src/wrapper/vst3/wrapper.rs | 13 ++++++++----- 8 files changed, 87 insertions(+), 26 deletions(-) create mode 100644 BREAKING_CHANGES.md diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md new file mode 100644 index 00000000..292d33c3 --- /dev/null +++ b/BREAKING_CHANGES.md @@ -0,0 +1,19 @@ +# Breaking changes + +Since there is no stable release yet, there is also no proper changelog yet. But +since not everyone might want to dive through commit messages to find out what's +new and what's changed, this document lists all breaking changes in reverse +chronological order. If a new feature did not require any changes to existing +code then it will not be listed here. + +## [2022-05-22] + +- Previously calling `param.non_automatable()` when constructing a parameter + also made the parameter hidden. Hiding a parameter is now done through + `param.hide()`, while `param.non_automatable()` simply makes it so that the + parameter can only be changed manually and not through automation or + modulation. + +## ... + +Who knows what happened at this point! diff --git a/src/param.rs b/src/param.rs index 3e04c909..ca1d6f93 100644 --- a/src/param.rs +++ b/src/param.rs @@ -31,13 +31,17 @@ bitflags::bitflags! { /// you don't have a bypass parameter, then NIH-plug will add one for you. You will need to /// implement this yourself if your plugin introduces latency. const BYPASS = 1 << 0; - /// The parameter cannot be automated from the host. Setting this flag also prevents it from - /// showing up in the host's own generic UI for this plugin. The parameter can still be - /// changed from the plugin's editor GUI. + /// The parameter cannot be changed from an automation lane. The parameter can however still + /// be manually changed by the user from either the plugin's own GUI or from the host's + /// generic UI. const NON_AUTOMATABLE = 1 << 1; + /// Hides the parameter in the host's generic UI for this plugin. This also implies + /// `NON_AUTOMATABLE`. Setting this does not prevent you from changing the parameter in the + /// plugin's editor GUI. + const HIDDEN = 1 << 2; /// Don't show this parameter when generating a generic UI for the plugin using one of /// NIH-plug's generic UI widgets. - const HIDE_IN_GENERIC_UI = 1 << 2; + const HIDE_IN_GENERIC_UI = 1 << 3; } } diff --git a/src/param/boolean.rs b/src/param/boolean.rs index e6b3dcab..b111b4ce 100644 --- a/src/param/boolean.rs +++ b/src/param/boolean.rs @@ -246,14 +246,22 @@ impl BoolParam { self } - /// Mark the paramter as non-automatable. This means that the parameter cannot be automated from - /// the host. Setting this flag also prevents it from showing up in the host's own generic UI - /// for this plugin. The parameter can still be changed from the plugin's editor GUI. + /// Mark the paramter as non-automatable. This means that the parameter cannot be changed from + /// an automation lane. The parameter can however still be manually changed by the user from + /// either the plugin's own GUI or from the host's generic UI. pub fn non_automatable(mut self) -> Self { self.flags.insert(ParamFlags::NON_AUTOMATABLE); self } + /// Hide the parameter in the host's generic UI for this plugin. This also implies + /// `NON_AUTOMATABLE`. Setting this does not prevent you from changing the parameter in the + /// plugin's editor GUI. + pub fn hide(mut self) -> Self { + self.flags.insert(ParamFlags::HIDDEN); + self + } + /// Don't show this parameter when generating a generic UI for the plugin using one of /// NIH-plug's generic UI widgets. pub fn hide_in_generic_ui(mut self) -> Self { diff --git a/src/param/enums.rs b/src/param/enums.rs index 9d446665..3205835c 100644 --- a/src/param/enums.rs +++ b/src/param/enums.rs @@ -306,14 +306,22 @@ impl EnumParam { self } - /// Mark the paramter as non-automatable. This means that the parameter cannot be automated from - /// the host. Setting this flag also prevents it from showing up in the host's own generic UI - /// for this plugin. The parameter can still be changed from the plugin's editor GUI. + /// Mark the paramter as non-automatable. This means that the parameter cannot be changed from + /// an automation lane. The parameter can however still be manually changed by the user from + /// either the plugin's own GUI or from the host's generic UI. pub fn non_automatable(mut self) -> Self { self.inner.inner = self.inner.inner.non_automatable(); self } + /// Hide the parameter in the host's generic UI for this plugin. This also implies + /// `NON_AUTOMATABLE`. Setting this does not prevent you from changing the parameter in the + /// plugin's editor GUI. + pub fn hide(mut self) -> Self { + self.inner.inner = self.inner.inner.hide(); + self + } + /// Don't show this parameter when generating a generic UI for the plugin using one of /// NIH-plug's generic UI widgets. pub fn hide_in_generic_ui(mut self) -> Self { diff --git a/src/param/float.rs b/src/param/float.rs index a1cea599..9ca38598 100644 --- a/src/param/float.rs +++ b/src/param/float.rs @@ -349,14 +349,22 @@ impl FloatParam { self } - /// Mark the paramter as non-automatable. This means that the parameter cannot be automated from - /// the host. Setting this flag also prevents it from showing up in the host's own generic UI - /// for this plugin. The parameter can still be changed from the plugin's editor GUI. + /// Mark the paramter as non-automatable. This means that the parameter cannot be changed from + /// an automation lane. The parameter can however still be manually changed by the user from + /// either the plugin's own GUI or from the host's generic UI. pub fn non_automatable(mut self) -> Self { self.flags.insert(ParamFlags::NON_AUTOMATABLE); self } + /// Hide the parameter in the host's generic UI for this plugin. This also implies + /// `NON_AUTOMATABLE`. Setting this does not prevent you from changing the parameter in the + /// plugin's editor GUI. + pub fn hide(mut self) -> Self { + self.flags.insert(ParamFlags::HIDDEN); + self + } + /// Don't show this parameter when generating a generic UI for the plugin using one of /// NIH-plug's generic UI widgets. pub fn hide_in_generic_ui(mut self) -> Self { diff --git a/src/param/integer.rs b/src/param/integer.rs index 3b763a1a..efd71134 100644 --- a/src/param/integer.rs +++ b/src/param/integer.rs @@ -303,14 +303,22 @@ impl IntParam { self } - /// Mark the paramter as non-automatable. This means that the parameter cannot be automated from - /// the host. Setting this flag also prevents it from showing up in the host's own generic UI - /// for this plugin. The parameter can still be changed from the plugin's editor GUI. + /// Mark the paramter as non-automatable. This means that the parameter cannot be changed from + /// an automation lane. The parameter can however still be manually changed by the user from + /// either the plugin's own GUI or from the host's generic UI. pub fn non_automatable(mut self) -> Self { self.flags.insert(ParamFlags::NON_AUTOMATABLE); self } + /// Hide the parameter in the host's generic UI for this plugin. This also implies + /// `NON_AUTOMATABLE`. Setting this does not prevent you from changing the parameter in the + /// plugin's editor GUI. + pub fn hide(mut self) -> Self { + self.flags.insert(ParamFlags::HIDDEN); + self + } + /// Don't show this parameter when generating a generic UI for the plugin using one of /// NIH-plug's generic UI widgets. pub fn hide_in_generic_ui(mut self) -> Self { diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 2152fabc..6fb4ecb2 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -2504,6 +2504,7 @@ impl Wrapper

{ let step_count = param_ptr.step_count(); let flags = param_ptr.flags(); let automatable = !flags.contains(ParamFlags::NON_AUTOMATABLE); + let hidden = flags.contains(ParamFlags::HIDDEN); let is_bypass = flags.contains(ParamFlags::BYPASS); *param_info = std::mem::zeroed(); @@ -2513,11 +2514,13 @@ impl Wrapper

{ let param_info = &mut *param_info; param_info.id = *param_hash; // TODO: Somehow expose per note/channel/port modulation - param_info.flags = if automatable { - CLAP_PARAM_IS_AUTOMATABLE | CLAP_PARAM_IS_MODULATABLE - } else { - CLAP_PARAM_IS_HIDDEN | CLAP_PARAM_IS_READONLY - }; + param_info.flags = 0; + if automatable && !hidden { + param_info.flags |= CLAP_PARAM_IS_AUTOMATABLE | CLAP_PARAM_IS_MODULATABLE; + } + if hidden { + param_info.flags |= CLAP_PARAM_IS_HIDDEN | CLAP_PARAM_IS_READONLY; + } if is_bypass { param_info.flags |= CLAP_PARAM_IS_BYPASS } diff --git a/src/wrapper/vst3/wrapper.rs b/src/wrapper/vst3/wrapper.rs index 8afc8dd6..400bddbd 100644 --- a/src/wrapper/vst3/wrapper.rs +++ b/src/wrapper/vst3/wrapper.rs @@ -451,6 +451,7 @@ impl IEditController for Wrapper

{ let default_value = param_ptr.default_normalized_value(); let flags = param_ptr.flags(); let automatable = !flags.contains(ParamFlags::NON_AUTOMATABLE); + let hidden = flags.contains(ParamFlags::HIDDEN); let is_bypass = flags.contains(ParamFlags::BYPASS); info.id = *param_hash; @@ -460,11 +461,13 @@ impl IEditController for Wrapper

{ info.step_count = param_ptr.step_count().unwrap_or(0) as i32; info.default_normalized_value = default_value as f64; info.unit_id = *param_unit; - info.flags = if automatable { - ParameterFlags::kCanAutomate as i32 - } else { - ParameterFlags::kIsReadOnly as i32 | (1 << 4) // kIsHidden - }; + info.flags = 0; + if automatable && !hidden { + info.flags |= ParameterFlags::kCanAutomate as i32; + } + if hidden { + info.flags |= ParameterFlags::kIsReadOnly as i32 | (1 << 4); // kIsHidden + } if is_bypass { info.flags |= ParameterFlags::kIsBypass as i32; }