NAP
Public Member Functions | Protected Member Functions | List of all members
BaseParameterBlender Class Referenceabstract

#include <parameterblender.h>

Public Member Functions

 BaseParameterBlender (Parameter &parameter)
 
virtual ~BaseParameterBlender ()=default
 
void blend (float value)
 
void setTarget (const Parameter *target)
 
void clearTarget ()
 
void sync ()
 
bool hasTarget () const
 
const ParametergetTarget () const
 
const ParametergetParameter () const
 
template<typename T >
const T & getTarget () const
 
template<typename T >
T & getParameter ()
 

Protected Member Functions

virtual void onBlend (float value)=0
 
virtual void onSync ()=0
 
virtual void onTargetSet ()=0
 

Description

Base class of all parameter blenders. Blends a parameter (source) towards a target parameter based on a lerp value from 0 to 1. Override the virtual methods to create a blender for a specific parameter type.

Inheritance diagram for BaseParameterBlender:
[legend]

Constructor & Destructor Documentation

◆ BaseParameterBlender()

BaseParameterBlender ( Parameter parameter)

Constructs the blender based on the given parameter. This parameter is updated based on the target blend value.

Parameters
parameterthe parameter to update.

◆ ~BaseParameterBlender()

virtual ~BaseParameterBlender ( )
virtualdefault

Member Function Documentation

◆ blend()

void blend ( float  value)

Blends parameters based on the given value (0-1). Result is immediately applied to the parameter.

Parameters
valuenormalized blend value

◆ clearTarget()

void clearTarget ( )

Clears blending target

◆ getParameter() [1/2]

T & getParameter
Returns
parameter as parameter of type T, asserts if the parameter is not of type T

◆ getParameter() [2/2]

const Parameter& getParameter ( ) const
Returns
the parameter this blender updates

◆ getTarget() [1/2]

const Parameter& getTarget ( ) const
Returns
target parameter

◆ getTarget() [2/2]

const T & getTarget
Returns
target parameter as parameter of type T, asserts if target is not of type T

◆ hasTarget()

bool hasTarget ( ) const
Returns
if the blender has a target

◆ onBlend()

virtual void onBlend ( float  value)
protectedpure virtual

◆ onSync()

virtual void onSync ( )
protectedpure virtual

Called after calling sync(). Override in derived class to sync the current parameter source value.

Implemented in ParameterBlender< ParamType, ValueType >.

◆ onTargetSet()

virtual void onTargetSet ( )
protectedpure virtual

Called when a new target is set, only occurs when target is derived from the source parameter.

Implemented in ParameterBlender< ParamType, ValueType >.

◆ setTarget()

void setTarget ( const Parameter target)

Sets the target parameter. Note that the target must be of the same type as the source parameter

Parameters
targetparameter to blend towards

◆ sync()

void sync ( )

Ensures that subsequent calls to blend() are computed relative to the current parameter value.