Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Juce 8 font #574

Merged
merged 9 commits into from
Jan 9, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

namespace chowdsp
{
MetricParameter::MetricParameter (const ParameterID& parameterID,
const juce::String& paramName,
const juce::NormalisableRange<float>& 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<float>& paramRange,
float defaultValue,
const std::function<juce::String (float)>& valueToTextFunction,
std::function<float (const juce::String&)>&& 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,20 @@ class MetricParameter : public FloatParameter
const juce::NormalisableRange<float>& 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<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))
{
}
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 = 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