Skip to content

Commit

Permalink
Juce 8 font (#574)
Browse files Browse the repository at this point in the history
* Make use of juce::Font compatible with JUCE-8

* Silencing logging warning

* Apply clang-format

* Trying to fix MetricParameter constructor

* Apply clang-format

* CI tweaks

* Revert CI tweaks [ci skip]

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jatinchowdhury18 and github-actions[bot] authored Jan 9, 2025
1 parent bc90f9a commit f59b466
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
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

0 comments on commit f59b466

Please sign in to comment.