Skip to content

Commit

Permalink
Added an isBoolean flag to APVTS parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoole committed Apr 6, 2018
1 parent f44ead2 commit 76ed748
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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)
};
Expand All @@ -184,15 +187,16 @@ 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());

Parameter* p = new Parameter (*this, paramID, paramName, labelText, r,
defaultVal, valueToTextFunction, textToValueFunction,
isMetaParameter, isAutomatableParameter,
isDiscreteParameter, category);
isDiscreteParameter, category, isBooleanParameter);
processor.addParameter (p);
return p;
}
Expand Down
Expand Up @@ -84,6 +84,9 @@ class JUCE_API AudioProcessorValueTreeState : private Timer,
@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
*/
Expand All @@ -98,7 +101,8 @@ class JUCE_API AudioProcessorValueTreeState : private Timer,
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;
Expand Down

0 comments on commit 76ed748

Please sign in to comment.