JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::NormalisableRange< ValueType > Class Template Reference

Represents a mapping between an arbitrary range of values and a normalised 0->1 range. More...

#include <juce_NormalisableRange.h>

Inheritance diagram for juce::NormalisableRange< ValueType >:
Collaboration diagram for juce::NormalisableRange< ValueType >:

Public Member Functions

 NormalisableRange () noexcept
 Creates a continuous range that performs a dummy mapping. More...
 
 NormalisableRange (const NormalisableRange &)=default
 
 NormalisableRange (NormalisableRange &&other)
 
 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) noexcept
 Creates a NormalisableRange with a given range, continuous interval, but a dummy 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 (Range< ValueType > range) noexcept
 Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor. More...
 
 NormalisableRange (Range< ValueType > range, ValueType intervalValue) noexcept
 Creates a NormalisableRange with a given range and 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...
 
NormalisableRangeoperator= (const NormalisableRange &)=default
 
NormalisableRangeoperator= (NormalisableRange &&other)
 
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 = 1
 The maximum value of the non-normalised range. More...
 
ValueType interval = 0
 The snapping interval that should be used (for a non-normalised value). More...
 
ValueType skew = 1
 An optional skew factor that alters the way values are distribute across the range. More...
 
ValueType start = 0
 The minimum value of the non-normalised range. More...
 
bool symmetricSkew = false
 If true, the skew factor applies from the middle of the slider to each of its ends. More...
 

Private Types

using ConversionFunction = std::function< ValueType(ValueType, ValueType, ValueType)>
 

Private Member Functions

void checkInvariants () const
 

Static Private Member Functions

static ValueType clampTo0To1 (ValueType value)
 

Private Attributes

ConversionFunction convertFrom0To1Function = {}
 
ConversionFunction convertTo0To1Function = {}
 
ConversionFunction snapToLegalValueFunction = {}
 

Detailed Description

template<typename ValueType>
class juce::NormalisableRange< ValueType >

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.

See also
Range

{Core}

Member Typedef Documentation

◆ ConversionFunction

template<typename ValueType>
using juce::NormalisableRange< ValueType >::ConversionFunction = std::function<ValueType(ValueType, ValueType, ValueType)>
private

Constructor & Destructor Documentation

◆ NormalisableRange() [1/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( )
inlinenoexcept

Creates a continuous range that performs a dummy mapping.

Referenced by juce::NormalisableRange< float >::NormalisableRange().

◆ NormalisableRange() [2/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( const NormalisableRange< ValueType > &  )
default

◆ NormalisableRange() [3/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( NormalisableRange< ValueType > &&  other)
inline

◆ NormalisableRange() [4/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( ValueType  rangeStart,
ValueType  rangeEnd,
ValueType  intervalValue,
ValueType  skewFactor,
bool  useSymmetricSkew = false 
)
inlinenoexcept

Creates a NormalisableRange with a given range, interval and skew factor.

◆ NormalisableRange() [5/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( ValueType  rangeStart,
ValueType  rangeEnd 
)
inlinenoexcept

Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor.

◆ NormalisableRange() [6/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( ValueType  rangeStart,
ValueType  rangeEnd,
ValueType  intervalValue 
)
inlinenoexcept

Creates a NormalisableRange with a given range and interval, but a dummy skew-factor.

◆ NormalisableRange() [7/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( Range< ValueType >  range)
inlinenoexcept

Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor.

◆ NormalisableRange() [8/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::NormalisableRange ( Range< ValueType >  range,
ValueType  intervalValue 
)
inlinenoexcept

Creates a NormalisableRange with a given range and interval, but a dummy skew-factor.

◆ NormalisableRange() [9/9]

template<typename ValueType>
juce::NormalisableRange< ValueType >::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 
)
inlinenoexcept

Creates a NormalisableRange with a given range and an injective mapping function.

Parameters
rangeStartThe minimum value in the range.
rangeEndThe maximum value in the range.
convertFrom0To1FuncA function which uses the current start and end of this NormalisableRange and produces a mapped value from a normalised value.
convertTo0To1FuncA function which uses the current start and end of this NormalisableRange and produces a normalised value from a mapped value.
snapToLegalValueFuncA function which uses the current start and end of this NormalisableRange to take a mapped value and snap it to the nearest legal value.

Member Function Documentation

◆ checkInvariants()

template<typename ValueType>
void juce::NormalisableRange< ValueType >::checkInvariants ( ) const
inlineprivate

◆ clampTo0To1()

template<typename ValueType>
static ValueType juce::NormalisableRange< ValueType >::clampTo0To1 ( ValueType  value)
inlinestaticprivate

◆ convertFrom0to1()

template<typename ValueType>
ValueType juce::NormalisableRange< ValueType >::convertFrom0to1 ( ValueType  proportion) const
inlinenoexcept

Uses the properties of this mapping to convert a normalised 0->1 value to its full-range representation.

◆ convertTo0to1()

template<typename ValueType>
ValueType juce::NormalisableRange< ValueType >::convertTo0to1 ( ValueType  v) const
inlinenoexcept

Uses the properties of this mapping to convert a non-normalised value to its 0->1 representation.

◆ getRange()

template<typename ValueType>
Range<ValueType> juce::NormalisableRange< ValueType >::getRange ( ) const
inlinenoexcept

Returns the extent of the normalisable range.

◆ operator=() [1/2]

template<typename ValueType>
NormalisableRange& juce::NormalisableRange< ValueType >::operator= ( const NormalisableRange< ValueType > &  )
default

◆ operator=() [2/2]

template<typename ValueType>
NormalisableRange& juce::NormalisableRange< ValueType >::operator= ( NormalisableRange< ValueType > &&  other)
inline

◆ setSkewForCentre()

template<typename ValueType>
void juce::NormalisableRange< ValueType >::setSkewForCentre ( ValueType  centrePointValue)
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.

Parameters
centrePointValuethis must be greater than the start of the range and less than the end.

◆ snapToLegalValue()

template<typename ValueType>
ValueType juce::NormalisableRange< ValueType >::snapToLegalValue ( ValueType  v) const
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.

Member Data Documentation

◆ convertFrom0To1Function

template<typename ValueType>
ConversionFunction juce::NormalisableRange< ValueType >::convertFrom0To1Function = {}
private

◆ convertTo0To1Function

template<typename ValueType>
ConversionFunction juce::NormalisableRange< ValueType >::convertTo0To1Function = {}
private

◆ end

◆ interval

template<typename ValueType>
ValueType juce::NormalisableRange< ValueType >::interval = 0

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 juce::NormalisableRange< float >::operator=(), and juce::NormalisableRange< float >::snapToLegalValue().

◆ skew

template<typename ValueType>
ValueType juce::NormalisableRange< ValueType >::skew = 1

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 juce::NormalisableRange< float >::convertFrom0to1(), juce::NormalisableRange< float >::convertTo0to1(), juce::NormalisableRange< float >::operator=(), and juce::NormalisableRange< float >::setSkewForCentre().

◆ snapToLegalValueFunction

template<typename ValueType>
ConversionFunction juce::NormalisableRange< ValueType >::snapToLegalValueFunction = {}
private

◆ start

◆ symmetricSkew

template<typename ValueType>
bool juce::NormalisableRange< ValueType >::symmetricSkew = false

The documentation for this class was generated from the following file: