Skip to content

Commit

Permalink
MetricParameter: add alternate constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Jan 8, 2025
1 parent 85bc9a7 commit bc90f9a
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,37 @@ class MetricParameter : public FloatParameter
float defaultValue,
const juce::String& unitSuffix = {},
int numDecimalPlaces = 2)
: FloatParameter (
: MetricParameter (
parameterID,
paramName,
paramRange,
defaultValue,
[numDecimalPlaces, unitSuffix] (float v)
{ return toString (v, numDecimalPlaces) + unitSuffix; },
[] (const juce::String& str)
{ return fromString (str); })
{ return toString (v, numDecimalPlaces) + unitSuffix; })
{
}

MetricParameter (const ParameterID& parameterID,
const juce::String& paramName,
const juce::NormalisableRange<float>& paramRange,
float defaultValue,
const std::function<juce::String (float)>& valueToTextFunction,
std::function<float (const juce::String&)>&& textToValueFunction = [] (const juce::String& str) { return fromString (str); })
: FloatParameter (
parameterID,
paramName,
paramRange,
defaultValue,
valueToTextFunction,
std::move (textToValueFunction))
{
}

private:
static juce::String toString (float value, int numDecimalPlaces);
static float fromString (const juce::String& str);

private:

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MetricParameter)
};
} // namespace chowdsp

0 comments on commit bc90f9a

Please sign in to comment.