diff --git a/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.cpp b/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.cpp index 8759244a..ead2df41 100644 --- a/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.cpp +++ b/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.cpp @@ -2,6 +2,42 @@ namespace chowdsp { +MetricParameter::MetricParameter (const ParameterID& parameterID, + const juce::String& paramName, + const juce::NormalisableRange& paramRange, + float defaultValue, + const juce::String& unitSuffix, + int numDecimalPlaces) + : MetricParameter ( + parameterID, + paramName, + paramRange, + defaultValue, + [numDecimalPlaces, unitSuffix] (float v) + { return toString (v, numDecimalPlaces) + unitSuffix; }) +{ +} + +MetricParameter::MetricParameter ( + const ParameterID& parameterID, + const juce::String& paramName, + const juce::NormalisableRange& paramRange, + float defaultValue, + const std::function& valueToTextFunction, + std::function&& textToValueFunction) + : FloatParameter ( + parameterID, + paramName, + paramRange, + defaultValue, + valueToTextFunction, + textToValueFunction != nullptr + ? std::move (textToValueFunction) + : [] (const juce::String& str) + { return fromString (str); }) +{ +} + juce::String MetricParameter::toString (float value, int numDecimalPlaces) { if (value < 1.0e-9f) // pico diff --git a/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.h b/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.h index 682734e1..4503acf6 100644 --- a/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.h +++ b/modules/plugin/chowdsp_parameters/ParamUtils/chowdsp_MetricParameter.h @@ -13,38 +13,20 @@ class MetricParameter : public FloatParameter const juce::NormalisableRange& paramRange, float defaultValue, const juce::String& unitSuffix = {}, - int numDecimalPlaces = 2) - : MetricParameter ( - parameterID, - paramName, - paramRange, - defaultValue, - [numDecimalPlaces, unitSuffix] (float v) - { return toString (v, numDecimalPlaces) + unitSuffix; }) - { - } + int numDecimalPlaces = 2); - MetricParameter (const ParameterID& parameterID, - const juce::String& paramName, - const juce::NormalisableRange& paramRange, - float defaultValue, - const std::function& valueToTextFunction, - std::function&& textToValueFunction = [] (const juce::String& str) { return fromString (str); }) - : FloatParameter ( - parameterID, - paramName, - paramRange, - defaultValue, - valueToTextFunction, - std::move (textToValueFunction)) - { - } + MetricParameter ( + const ParameterID& parameterID, + const juce::String& paramName, + const juce::NormalisableRange& paramRange, + float defaultValue, + const std::function& valueToTextFunction, + std::function&& textToValueFunction = nullptr); 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