1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Some minor cleanups

This commit is contained in:
jules 2019-06-17 13:58:07 +01:00
parent fdcebfe6a2
commit 9a06be6d61
10 changed files with 106 additions and 124 deletions

View file

@ -112,6 +112,11 @@ public:
{
}
/** A function object which can remap a value in some way based on the start and end of a range. */
using ValueRemapFunction = std::function<ValueType(ValueType rangeStart,
ValueType rangeEnd,
ValueType valueToRemap)>;
/** Creates a NormalisableRange with a given range and an injective mapping function.
@param rangeStart The minimum value in the range.
@ -125,14 +130,14 @@ public:
*/
NormalisableRange (ValueType rangeStart,
ValueType rangeEnd,
std::function<ValueType(ValueType currentRangeStart, ValueType currentRangeEnd, ValueType normalisedValue)> convertFrom0To1Func,
std::function<ValueType(ValueType currentRangeStart, ValueType currentRangeEnd, ValueType mappedValue)> convertTo0To1Func,
std::function<ValueType(ValueType currentRangeStart, ValueType currentRangeEnd, ValueType valueToSnap)> snapToLegalValueFunc = nullptr) noexcept
ValueRemapFunction convertFrom0To1Func,
ValueRemapFunction convertTo0To1Func,
ValueRemapFunction snapToLegalValueFunc = {}) noexcept
: start (rangeStart),
end (rangeEnd),
convertFrom0To1Function (convertFrom0To1Func),
convertTo0To1Function (convertTo0To1Func),
snapToLegalValueFunction (snapToLegalValueFunc)
convertFrom0To1Function (std::move (convertFrom0To1Func)),
convertTo0To1Function (std::move (convertTo0To1Func)),
snapToLegalValueFunction (std::move (snapToLegalValueFunc))
{
checkInvariants();
}
@ -274,11 +279,7 @@ private:
return clampedValue;
}
using ConversionFunction = std::function<ValueType(ValueType, ValueType, ValueType)>;
ConversionFunction convertFrom0To1Function = {},
convertTo0To1Function = {},
snapToLegalValueFunction = {};
ValueRemapFunction convertFrom0To1Function, convertTo0To1Function, snapToLegalValueFunction;
};
} // namespace juce