Represents a mapping between an arbitrary range of values and a normalised 0->1 range. More...
#include <juce_NormalisableRange.h>
Public Member Functions | |
NormalisableRange () noexcept | |
Creates a continuous range that performs a dummy mapping. More... | |
NormalisableRange (const NormalisableRange &other) noexcept | |
Creates a copy of another range. More... | |
NormalisableRange (ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue, ValueType skewFactor, bool useSymmetricSkew=false) noexcept | |
Creates a NormalisableRange with a given range, interval and skew factor. More... | |
NormalisableRange (ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue) noexcept | |
Creates a NormalisableRange with a given range and interval, but a dummy skew-factor. More... | |
NormalisableRange (ValueType rangeStart, ValueType rangeEnd) noexcept | |
Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor. More... | |
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 | |
Creates a NormalisableRange with a given range and an injective mapping function. More... | |
ValueType | convertFrom0to1 (ValueType proportion) const noexcept |
Uses the properties of this mapping to convert a normalised 0->1 value to its full-range representation. More... | |
ValueType | convertTo0to1 (ValueType v) const noexcept |
Uses the properties of this mapping to convert a non-normalised value to its 0->1 representation. More... | |
Range< ValueType > | getRange () const noexcept |
Returns the extent of the normalisable range. More... | |
NormalisableRange & | operator= (const NormalisableRange &other) noexcept |
Creates a copy of another range. More... | |
void | setSkewForCentre (ValueType centrePointValue) noexcept |
Given a value which is between the start and end points, this sets the skew such that convertFrom0to1 (0.5) will return this value. More... | |
ValueType | snapToLegalValue (ValueType v) const noexcept |
Takes a non-normalised value and snaps it based on either the interval property of this NormalisedRange or the lambda function supplied to the constructor. More... | |
Public Attributes | |
ValueType | end |
The maximum value of the non-normalised range. More... | |
ValueType | interval |
The snapping interval that should be used (for a non-normalised value). More... | |
ValueType | skew |
An optional skew factor that alters the way values are distribute across the range. More... | |
ValueType | start |
The minimum value of the non-normalised range. More... | |
bool | symmetricSkew |
If true, the skew factor applies from the middle of the slider to each of its ends. More... | |
Private Member Functions | |
void | checkInvariants () const |
Private Attributes | |
std::function< ValueType(ValueType, ValueType, ValueType)> | convertFrom0To1Function = nullptr |
std::function< ValueType(ValueType, ValueType, ValueType)> | convertTo0To1Function = nullptr |
std::function< ValueType(ValueType, ValueType, ValueType)> | snapToLegalValueFunction = nullptr |
Represents a mapping between an arbitrary range of values and a normalised 0->1 range.
The properties of the mapping also include an optional snapping interval and skew-factor.
|
inlinenoexcept |
Creates a continuous range that performs a dummy mapping.
|
inlinenoexcept |
Creates a copy of another range.
|
inlinenoexcept |
Creates a NormalisableRange with a given range, interval and skew factor.
|
inlinenoexcept |
Creates a NormalisableRange with a given range and interval, but a dummy skew-factor.
|
inlinenoexcept |
Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor.
|
inlinenoexcept |
Creates a NormalisableRange with a given range and an injective mapping function.
rangeStart | The minimum value in the range. |
rangeEnd | The maximum value in the range. |
convertFrom0To1Func | A function which uses the current start and end of this NormalisableRange and produces a mapped value from a normalised value. |
convertTo0To1Func | A function which uses the current start and end of this NormalisableRange and produces a normalised value from a mapped value. |
snapToLegalValueFunc | A function which uses the current start and end of this NormalisableRange to take a mapped value and snap it to the nearest legal value. |
|
inlineprivate |
|
inlinenoexcept |
Uses the properties of this mapping to convert a normalised 0->1 value to its full-range representation.
|
inlinenoexcept |
Uses the properties of this mapping to convert a non-normalised value to its 0->1 representation.
|
inlinenoexcept |
Returns the extent of the normalisable range.
|
inlinenoexcept |
Creates a copy of another range.
|
inlinenoexcept |
Given a value which is between the start and end points, this sets the skew such that convertFrom0to1 (0.5) will return this value.
If you have used lambda functions for convertFrom0to1Func and convertFrom0to1Func in the constructor of this class then the skew value is ignored.
centrePointValue | this must be greater than the start of the range and less than the end. |
|
inlinenoexcept |
Takes a non-normalised value and snaps it based on either the interval property of this NormalisedRange or the lambda function supplied to the constructor.
|
private |
Referenced by NormalisableRange< float >::convertFrom0to1(), and NormalisableRange< float >::operator=().
|
private |
Referenced by NormalisableRange< float >::convertTo0to1(), and NormalisableRange< float >::operator=().
ValueType NormalisableRange< ValueType >::end |
The maximum value of the non-normalised range.
Referenced by NormalisableRange< float >::convertFrom0to1(), NormalisableRange< float >::convertTo0to1(), NormalisableRange< float >::getRange(), NormalisableRange< float >::operator=(), NormalisableRange< float >::setSkewForCentre(), and NormalisableRange< float >::snapToLegalValue().
ValueType NormalisableRange< ValueType >::interval |
The snapping interval that should be used (for a non-normalised value).
Use 0 for a continuous range.
If you have used a lambda function for snapToLegalValueFunction in the constructor of this class then the interval is ignored.
Referenced by NormalisableRange< float >::operator=(), and NormalisableRange< float >::snapToLegalValue().
ValueType NormalisableRange< ValueType >::skew |
An optional skew factor that alters the way values are distribute across the range.
The skew factor lets you skew the mapping logarithmically so that larger or smaller values are given a larger proportion of the available space.
A factor of 1.0 has no skewing effect at all. If the factor is < 1.0, the lower end of the range will fill more of the slider's length; if the factor is > 1.0, the upper end of the range will be expanded.
If you have used lambda functions for convertFrom0to1Func and convertFrom0to1Func in the constructor of this class then the skew value is ignored.
Referenced by NormalisableRange< float >::convertFrom0to1(), NormalisableRange< float >::convertTo0to1(), NormalisableRange< float >::operator=(), and NormalisableRange< float >::setSkewForCentre().
|
private |
ValueType NormalisableRange< ValueType >::start |
The minimum value of the non-normalised range.
Referenced by NormalisableRange< float >::convertFrom0to1(), NormalisableRange< float >::convertTo0to1(), NormalisableRange< float >::getRange(), NormalisableRange< float >::operator=(), NormalisableRange< float >::setSkewForCentre(), and NormalisableRange< float >::snapToLegalValue().
bool NormalisableRange< ValueType >::symmetricSkew |
If true, the skew factor applies from the middle of the slider to each of its ends.
Referenced by NormalisableRange< float >::convertFrom0to1(), NormalisableRange< float >::convertTo0to1(), NormalisableRange< float >::operator=(), and NormalisableRange< float >::setSkewForCentre().