Browse Source

Added an isBoolean flag to APVTS parameters

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
76ed748c79
2 changed files with 14 additions and 6 deletions
  1. +9
    -5
      modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp
  2. +5
    -1
      modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h

+ 9
- 5
modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp View File

@@ -38,14 +38,16 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete
bool meta,
bool automatable,
bool discrete,
AudioProcessorParameter::Category category)
AudioProcessorParameter::Category category,
bool boolean)
: AudioProcessorParameterWithID (parameterID, paramName, labelText, category),
owner (s), valueToTextFunction (valueToText), textToValueFunction (textToValue),
range (r), value (defaultVal), defaultValue (defaultVal),
listenersNeedCalling (true),
isMetaParam (meta),
isAutomatableParam (automatable),
isDiscreteParam (discrete)
isDiscreteParam (discrete),
isBooleanParam (boolean)
{
state.addListener (this);
needsUpdate.set (1);
@@ -152,6 +154,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete
bool isMetaParameter() const override { return isMetaParam; }
bool isAutomatable() const override { return isAutomatableParam; }
bool isDiscrete() const override { return isDiscreteParam; }
bool isBoolean() const override { return isBooleanParam; }
AudioProcessorValueTreeState& owner;
ValueTree state;
@@ -162,7 +165,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete
float value, defaultValue;
Atomic<int> needsUpdate;
bool listenersNeedCalling;
const bool isMetaParam, isAutomatableParam, isDiscreteParam;
const bool isMetaParam, isAutomatableParam, isDiscreteParam, isBooleanParam;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Parameter)
};
@@ -184,7 +187,8 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet
bool isMetaParameter,
bool isAutomatableParameter,
bool isDiscreteParameter,
AudioProcessorParameter::Category category)
AudioProcessorParameter::Category category,
bool isBooleanParameter)
{
// All parameters must be created before giving this manager a ValueTree state!
jassert (! state.isValid());
@@ -192,7 +196,7 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet
Parameter* p = new Parameter (*this, paramID, paramName, labelText, r,
defaultVal, valueToTextFunction, textToValueFunction,
isMetaParameter, isAutomatableParameter,
isDiscreteParameter, category);
isDiscreteParameter, category, isBooleanParameter);
processor.addParameter (p);
return p;
}


+ 5
- 1
modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h View File

@@ -84,6 +84,9 @@ public:
@see AudioProcessorParameter::isDiscrete
@param category Which category the parameter should use.
@see AudioProcessorParameter::Category
@param isBoolean Set this value to true to make this parameter appear as a boolean toggle in
a hosts view of your plug-ins parameters
@see AudioProcessorParameter::isBoolean
@returns the parameter object that was created
*/
@@ -98,7 +101,8 @@ public:
bool isAutomatableParameter = true,
bool isDiscrete = false,
AudioProcessorParameter::Category category
= AudioProcessorParameter::genericParameter);
= AudioProcessorParameter::genericParameter,
bool isBoolean = false);
/** Returns a parameter by its ID string. */
AudioProcessorParameterWithID* getParameter (StringRef parameterID) const noexcept;


Loading…
Cancel
Save