Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
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>

Public Types

using ValueRemapFunction
 A function object which can remap a value in some way based on the start and end of a range.
 

Public Member Functions

 NormalisableRange ()=default
 Creates a continuous range that performs a dummy mapping.
 
 NormalisableRange (const NormalisableRange &)=default
 
NormalisableRangeoperator= (const NormalisableRange &)=default
 
 NormalisableRange (NormalisableRange &&)=default
 
NormalisableRangeoperator= (NormalisableRange &&)=default
 
 NormalisableRange (ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue, ValueType skewFactor, bool useSymmetricSkew=false) noexcept
 Creates a NormalisableRange with a given range, interval and skew factor.
 
 NormalisableRange (ValueType rangeStart, ValueType rangeEnd) noexcept
 Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor.
 
 NormalisableRange (ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue) noexcept
 Creates a NormalisableRange with a given range and interval, but a dummy skew-factor.
 
 NormalisableRange (Range< ValueType > range) noexcept
 Creates a NormalisableRange with a given range, continuous interval, but a dummy skew-factor.
 
 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, ValueRemapFunction convertFrom0To1Func, ValueRemapFunction convertTo0To1Func, ValueRemapFunction snapToLegalValueFunc={}) noexcept
 Creates a NormalisableRange with a given range and an injective mapping function.
 
ValueType convertTo0to1 (ValueType v) const noexcept
 Uses the properties of this mapping to convert a non-normalised value to its 0->1 representation.
 
ValueType convertFrom0to1 (ValueType proportion) const noexcept
 Uses the properties of this mapping to convert a normalised 0->1 value to its full-range representation.
 
ValueType snapToLegalValue (ValueType v) const noexcept
 Takes a non-normalised value and snaps it based on either the interval property of this NormalisableRange or the lambda function supplied to the constructor.
 
Range< ValueType > getRange () const noexcept
 Returns the extent of the normalisable range.
 
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.
 

Public Attributes

ValueType start = 0
 The minimum value of the non-normalised range.
 
ValueType end = 1
 The maximum value of the non-normalised range.
 
ValueType interval = 0
 The snapping interval that should be used (for a non-normalised value).
 
ValueType skew = 1
 An optional skew factor that alters the way values are distribute across the range.
 
bool symmetricSkew = false
 If true, the skew factor applies from the middle of the slider to each of its ends.
 

Detailed Description

template<typename ValueType>
class 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

Member Typedef Documentation

◆ ValueRemapFunction

template<typename ValueType >
using NormalisableRange< ValueType >::ValueRemapFunction
Initial value:
std::function<ValueType(ValueType rangeStart,
ValueType rangeEnd,
ValueType valueToRemap)>

A function object which can remap a value in some way based on the start and end of a range.

Constructor & Destructor Documentation

◆ NormalisableRange() [1/9]

template<typename ValueType >
NormalisableRange< ValueType >::NormalisableRange ( )
default

Creates a continuous range that performs a dummy mapping.

◆ NormalisableRange() [2/9]

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

◆ NormalisableRange() [3/9]

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

◆ NormalisableRange() [4/9]

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

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

◆ NormalisableRange() [5/9]

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

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

◆ NormalisableRange() [6/9]

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

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

◆ NormalisableRange() [7/9]

template<typename ValueType >
NormalisableRange< ValueType >::NormalisableRange ( Range< ValueType > range)
noexcept

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

◆ NormalisableRange() [8/9]

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

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

◆ NormalisableRange() [9/9]

template<typename ValueType >
NormalisableRange< ValueType >::NormalisableRange ( ValueType rangeStart,
ValueType rangeEnd,
ValueRemapFunction convertFrom0To1Func,
ValueRemapFunction convertTo0To1Func,
ValueRemapFunction snapToLegalValueFunc = {} )
noexcept

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ convertTo0to1()

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

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

References NormalisableRange< ValueType >::end, exactlyEqual(), NormalisableRange< ValueType >::skew, NormalisableRange< ValueType >::start, and NormalisableRange< ValueType >::symmetricSkew.

◆ convertFrom0to1()

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

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

References NormalisableRange< ValueType >::end, exactlyEqual(), NormalisableRange< ValueType >::skew, NormalisableRange< ValueType >::start, and NormalisableRange< ValueType >::symmetricSkew.

◆ snapToLegalValue()

template<typename ValueType >
ValueType NormalisableRange< ValueType >::snapToLegalValue ( ValueType v) const
noexcept

Takes a non-normalised value and snaps it based on either the interval property of this NormalisableRange or the lambda function supplied to the constructor.

References NormalisableRange< ValueType >::end, NormalisableRange< ValueType >::interval, and NormalisableRange< ValueType >::start.

◆ getRange()

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

Returns the extent of the normalisable range.

References NormalisableRange< ValueType >::end, and NormalisableRange< ValueType >::start.

◆ setSkewForCentre()

template<typename ValueType >
void NormalisableRange< ValueType >::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.

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.

References NormalisableRange< ValueType >::end, jassert, NormalisableRange< ValueType >::skew, NormalisableRange< ValueType >::start, and NormalisableRange< ValueType >::symmetricSkew.

Member Data Documentation

◆ start

template<typename ValueType >
ValueType NormalisableRange< ValueType >::start = 0

◆ end

template<typename ValueType >
ValueType NormalisableRange< ValueType >::end = 1

◆ interval

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

◆ skew

template<typename ValueType >
ValueType 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 NormalisableRange< ValueType >::convertFrom0to1(), NormalisableRange< ValueType >::convertTo0to1(), and NormalisableRange< ValueType >::setSkewForCentre().

◆ symmetricSkew

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

If true, the skew factor applies from the middle of the slider to each of its ends.

Referenced by NormalisableRange< ValueType >::convertFrom0to1(), NormalisableRange< ValueType >::convertTo0to1(), and NormalisableRange< ValueType >::setSkewForCentre().


The documentation for this class was generated from the following file:
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram