Allolib  1.0
C++ Components For Interactive Multimedia
al::ParameterChoice Class Reference

A parameter representing selected items from a list. More...

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/ui/al_Parameter.hpp>

Inheritance diagram for al::ParameterChoice:
al::ParameterWrapper< uint64_t > al::ParameterMeta

Public Types

typedef const std::function< uint64_t(uint64_t)> ParameterProcessCallback
 
typedef const std::function< void(uint64_t)> ParameterChangeCallback
 
typedef const std::function< void(uint64_t, ValueSource *)> ParameterChangeCallbackSrc
 
typedef const std::function< void(ValueSource *)> ParameterMetaChangeCallbackSrc
 

Public Member Functions

 ParameterChoice (std::string parameterName, std::string Group="", uint64_t defaultValue=0)
 
ParameterChoiceoperator= (const uint64_t value)
 
void setElements (std::vector< std::string > &elements, bool allOn=false)
 
void setElementSelected (std::string name, bool selected=true)
 
std::vector< std::string > getElements ()
 
std::vector< std::string > getSelectedElements ()
 
void set (std::vector< int8_t > on)
 
virtual float toFloat () override
 Generic function to return the value of the parameter as a float. More...
 
virtual bool fromFloat (float value) override
 Generic function to set the parameter from a single float value. More...
 
virtual void sendValue (osc::Send &sender, std::string prefix="") override
 
virtual void getFields (std::vector< ParameterField > &fields) override
 
virtual void setFields (std::vector< ParameterField > &fields) override
 
virtual void set (uint64_t value, ValueSource *src=nullptr)
 set the parameter's value More...
 
void set (ParameterMeta *p)
 
virtual void reset ()
 reset value to default value
 
virtual void setNoCalls (uint64_t value, void *blockReceiver=nullptr)
 set the parameter's value without calling callbacks More...
 
void setLocking (uint64_t value)
 set the parameter's value forcing a lock More...
 
virtual uint64_t get ()
 get the parameter's value More...
 
virtual uint64_t getPrevious ()
 Get previous value. More...
 
void min (uint64_t minValue, ValueSource *src=nullptr)
 set the minimum value for the parameter More...
 
uint64_t min () const
 
void max (uint64_t maxValue, ValueSource *src=nullptr)
 set the maximum value for the parameter More...
 
uint64_t max () const
 
void setDefault (const uint64_t &defaultValue)
 
uint64_t getDefault () const
 
void setProcessingCallback (ParameterProcessCallback cb)
 setProcessingCallback sets a callback to be called whenever the parameter value changes More...
 
void registerChangeCallback (ParameterChangeCallback cb)
 registerChangeCallback adds a callback to be called when the value changes More...
 
void registerChangeCallback (ParameterChangeCallbackSrc cb)
 
void registerMetaChangeCallback (ParameterMetaChangeCallbackSrc cb)
 
void setSynchronousCallbacks (bool synchronous=true)
 Determines whether value change callbacks are called synchronously. More...
 
bool hasChange ()
 
bool processChange ()
 call change callbacks if value has changed since last call
 
std::vector< ParameterWrapper< uint64_t > * > operator<< (ParameterWrapper< uint64_t > &newParam)
 
std::vector< ParameterWrapper< uint64_t > * > & operator<< (std::vector< ParameterWrapper< uint64_t > * > &paramVector)
 
 operator uint64_t ()
 
std::string getFullAddress ()
 return the full OSC address for the parameter More...
 
std::string getName ()
 getName returns the name of the parameter
 
std::string displayName ()
 returns the text that should accompany parameters when displayed
 
void displayName (std::string displayName)
 sets the text that should accompany parameters when displayed
 
std::string getGroup ()
 getGroup returns the name of the group for the parameter
 
void setHint (std::string hintName, float hintValue)
 
float getHint (std::string hintName, bool *exists=nullptr)
 
virtual void sendMeta (osc::Send &sender, std::string bundleName="", std::string id="")
 

Protected Member Functions

void runChangeCallbacksSynchronous (uint64_t &value, ValueSource *src)
 

Protected Attributes

uint64_t mMin
 
uint64_t mMax
 
uint64_t mValue
 
uint64_t mValueCache
 
uint64_t mDefault
 
std::shared_ptr< ParameterProcessCallback > mProcessCallback
 
bool mChanged
 
std::string mFullAddress
 
std::string mParameterName
 
std::string mDisplayName
 
std::string mGroup
 
std::map< std::string, float > mHints
 

Detailed Description

A parameter representing selected items from a list.

The unsigned int value is a bit field, each bit representing whether an element is selected or not.

Definition at line 1304 of file al_Parameter.hpp.

Member Function Documentation

◆ fromFloat()

virtual bool al::ParameterChoice::fromFloat ( float  value)
inlineoverridevirtual

Generic function to set the parameter from a single float value.

Will only have effect on parameters that have a single internal value and have implemented this function. Returns true if paramter is able to set value from float

Reimplemented from al::ParameterMeta.

Definition at line 1378 of file al_Parameter.hpp.

◆ get()

uint64_t al::ParameterWrapper< uint64_t >::get
virtualinherited

get the parameter's value

This function is thread-safe and can be called from any number of threads

Returns
the parameter value

Definition at line 470 of file al_Parameter.hpp.

◆ getFullAddress()

std::string al::ParameterMeta::getFullAddress ( )
inlineinherited

return the full OSC address for the parameter

The parameter needs to be registered to a ParameterServer to listen to OSC values on this address

Definition at line 267 of file al_Parameter.hpp.

◆ getPrevious()

uint64_t al::ParameterWrapper< uint64_t >::getPrevious
virtualinherited

Get previous value.

Returns

This function is only useful when queried from a value callback. It will represent the previous value of the parameter in that case.

Definition at line 479 of file al_Parameter.hpp.

◆ max()

void al::ParameterWrapper< uint64_t >::max ( uint64_t  maxValue,
ValueSource src = nullptr 
)
inlineinherited

set the maximum value for the parameter

The value returned by the get() function will be clamped and will not go over the value set by this function.

Definition at line 501 of file al_Parameter.hpp.

◆ min()

void al::ParameterWrapper< uint64_t >::min ( uint64_t  minValue,
ValueSource src = nullptr 
)
inlineinherited

set the minimum value for the parameter

The value returned by the get() function will be clamped and will not go under the value set by this function.

Definition at line 487 of file al_Parameter.hpp.

◆ registerChangeCallback()

void al::ParameterWrapper< uint64_t >::registerChangeCallback ( ParameterChangeCallback  cb)
inherited

registerChangeCallback adds a callback to be called when the value changes

This function appends the callback to a list of callbacks to be called whenever a value changes.

Parameters
cb

Definition at line 553 of file al_Parameter.hpp.

◆ set()

virtual void al::ParameterWrapper< uint64_t >::set ( uint64_t  value,
ValueSource src = nullptr 
)
inlinevirtualinherited

set the parameter's value

This function is thread-safe and can be called from any number of threads. It blocks to lock a mutex so its use in critical contexts should be avoided.

Definition at line 405 of file al_Parameter.hpp.

◆ setLocking()

void al::ParameterWrapper< uint64_t >::setLocking ( uint64_t  value)
inlineinherited

set the parameter's value forcing a lock

No callbacks are called.

Definition at line 457 of file al_Parameter.hpp.

◆ setNoCalls()

virtual void al::ParameterWrapper< uint64_t >::setNoCalls ( uint64_t  value,
void *  blockReceiver = nullptr 
)
inlinevirtualinherited

set the parameter's value without calling callbacks

This function is thread-safe and can be called from any number of threads. It blocks to lock a mutex so its use in critical contexts should be avoided. The processing callback is called, but the callbacks registered with registerChangeCallback() are not called. This is useful to avoid infinite recursion when a widget sets the parameter that then sets the widget.

This function marks the parameter as changed, so you can process callbacks by calling processChange()

Definition at line 436 of file al_Parameter.hpp.

◆ setProcessingCallback()

void al::ParameterWrapper< uint64_t >::setProcessingCallback ( typename ParameterWrapper< uint64_t >::ParameterProcessCallback  cb)
inherited

setProcessingCallback sets a callback to be called whenever the parameter value changes

Setting a callback can be useful when specific actions need to be taken whenever a parameter changes, but it can also be used to modify the value of the incoming parameter value before it is stored in the parameter. The registered callback must return the value to be stored in the parameter. Only one callback may be registered here.

Parameters
cbThe callback function
Returns
the transformed value

Definition at line 542 of file al_Parameter.hpp.

◆ setSynchronousCallbacks()

void al::ParameterWrapper< uint64_t >::setSynchronousCallbacks ( bool  synchronous = true)
inlineinherited

Determines whether value change callbacks are called synchronously.

Parameters
synchronousIf set to true, parameter change callbacks are called directly from the setter function, i.e. as soon as the parameter value changes. This behavior might be problematic in some cases, for example when an OSC message triggers a change in the opengl state. This will cause a crash as the opengl functions need to be called from the opengl context instead of from a thread in the network context. By setting this to false and then calling runChangeCallbacks within the opengl thread will call the callbacks whenever the value has changed, but at the right time, in the right context.

Definition at line 573 of file al_Parameter.hpp.

◆ toFloat()

virtual float al::ParameterChoice::toFloat ( )
inlineoverridevirtual

Generic function to return the value of the parameter as a float.

If not implemented, it will return 0.

Reimplemented from al::ParameterMeta.

Definition at line 1373 of file al_Parameter.hpp.


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