38template <
typename ValueType>
64 ValueType rangeEnd) noexcept
112 :
start (rangeStart),
126 if (convertTo0To1Function !=
nullptr)
127 return clampTo0To1 (convertTo0To1Function (
start,
end, v));
141 :
static_cast<ValueType
> (1)))
142 /
static_cast<ValueType
> (2);
152 if (convertFrom0To1Function !=
nullptr)
168 :
static_cast<ValueType
> (1));
178 if (snapToLegalValueFunction !=
nullptr)
179 return snapToLegalValueFunction (
start,
end, v);
240 void checkInvariants()
const
247 static ValueType clampTo0To1 (ValueType value)
249 auto clampedValue =
jlimit (
static_cast<ValueType
> (0),
static_cast<ValueType
> (1), value);
258 ValueRemapFunction convertFrom0To1Function, convertTo0To1Function, snapToLegalValueFunction;
Represents a mapping between an arbitrary range of values and a normalised 0->1 range.
ValueType skew
An optional skew factor that alters the way values are distribute across the range.
ValueType end
The maximum value of the non-normalised range.
bool symmetricSkew
If true, the skew factor applies from the middle of the slider to each of its ends.
ValueType snapToLegalValue(ValueType v) const noexcept
Takes a non-normalised value and snaps it based on either the interval property of this NormalisableR...
std::function< ValueType(ValueType rangeStart, ValueType rangeEnd, ValueType valueToRemap)> ValueRemapFunction
A function object which can remap a value in some way based on the start and end of a range.
NormalisableRange()=default
Creates a continuous range that performs a dummy mapping.
ValueType start
The minimum value of the non-normalised range.
ValueType convertFrom0to1(ValueType proportion) const noexcept
Uses the properties of this mapping to convert a normalised 0->1 value to its full-range representati...
NormalisableRange(ValueType rangeStart, ValueType rangeEnd) noexcept
Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor.
void setSkewForCentre(ValueType centrePointValue) noexcept
Given a value which is between the start and end points, this sets the skew such that convertFrom0to1...
NormalisableRange(ValueType rangeStart, ValueType rangeEnd, ValueRemapFunction convertFrom0To1Func, ValueRemapFunction convertTo0To1Func, ValueRemapFunction snapToLegalValueFunc={}) noexcept
Creates a NormalisableRange with a given range and an injective mapping function.
NormalisableRange(ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue) noexcept
Creates a NormalisableRange with a given range and interval, but a dummy skew-factor.
Range< ValueType > getRange() const noexcept
Returns the extent of the normalisable range.
ValueType interval
The snapping interval that should be used (for a non-normalised value).
NormalisableRange(Range< ValueType > range, ValueType intervalValue) noexcept
Creates a NormalisableRange with a given range and interval, but a dummy skew-factor.
NormalisableRange(ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue, ValueType skewFactor, bool useSymmetricSkew=false) noexcept
Creates a NormalisableRange with a given range, interval and skew factor.
ValueType convertTo0to1(ValueType v) const noexcept
Uses the properties of this mapping to convert a non-normalised value to its 0->1 representation.
NormalisableRange(Range< ValueType > range) noexcept
Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor.
A general-purpose range object, that simply represents any linear range with a start and end point.
constexpr bool exactlyEqual(Type a, Type b)
Equivalent to operator==, but suppresses float-equality warnings.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...