Represents an optional parameter (Jmb, Vst or no param at all).
More...
#include <GUIOptionalParam.h>
Inherits Dereferenceable< GUIOptionalParam< T > >.
|
| class | Value |
| | The purpose of this class is to copy the value so that it can be accessed via -> thus allowing to write param->x to access the underlying type (T) when it is a struct or a class. More...
|
| |
template<typename T>
class pongasoft::VST::GUI::Params::GUIOptionalParam< T >
Represents an optional parameter (Jmb, Vst or no param at all).
Like GUIVstParam and GUIJmbParam, this class is a wrapper around the underlying parameter. This parameter is used in very generic views that need to handle a Vst or Jmb parameter, as well as no parameter at all (which is for example the case when adding a brand new view in the VSTGUI editor) and still be functional.
You can obtain an instance of an optional parameter by calling any ParamAware::registerOptionalXXX (resp. ParamAware::registerOptionalDiscreteXX) method.
- Note
- Because
GUIOptionalParam can represent a Vst parameter or a Jmb parameter, there are some restrictions on T itself (which do not exist if you use GUIJmbParam):
T must have empty constructor: T()
T have a copy constructor: T(T const &)
T must be copy assignable: T& operator=(T const &)
◆ class_type
◆ Editor
◆ EditorType
◆ ParamType
◆ GUIOptionalParam() [1/3]
◆ GUIOptionalParam() [2/3]
◆ GUIOptionalParam() [3/3]
◆ connect() [1/2]
Creates a connection between this parameter and the change listener: whenever the parameter changes, the listener will be notified of the changes (Parameters::IChangeListener::onParameterChange(ParamID)).
- Note
- This method is usually invoked by the framework but it may be used in the rare cases when the caller requires to handle the duration of the connection in a more granular fashion
- Parameters
-
| iChangeListener | the listener that will be notified on parameter changes. nullptr is allowed and will be a noop. |
- Returns
- the connection between this parameter and the listener and is maintained for as long as this pointer exists
◆ connect() [2/2]
Creates a connection between this parameter and the callback: whenever the parameter changes, the callback will be invoked (std::function<void()>).
- Note
- This method is usually invoked by the framework but it may be used in the rare cases when the caller requires to handle the duration of the connection in a more granular fashion
- Parameters
-
| iChangeCallback | the callback that will be invoked on parameter changes. |
- Returns
- the connection between this parameter and the callback and is maintained for as long as this pointer exists
◆ edit() [1/2]
◆ edit() [2/2]
Shortcut api which creates an editor followed by ITEditor::setValue(ParamType const &) to set the parameter value to iValue.
◆ exists()
Always return true because by definition an optional parameter always exist.
◆ getParamID()
| ParamID getParamID |
( |
| ) |
const |
|
inline |
◆ getStepCount()
| int32 getStepCount |
( |
| ) |
const |
|
inline |
When a parameter is a discrete parameter (which means its underlying backing type is an int32 with values in the discrete range [0, getStepCount()]), this method will return the number of steps (> 0).
- Note
- Although a parameter may not be a discrete parameter itself, the method
asDiscreteParameter(int32) may be able to convert/adapt it to one.
- Returns
- the number of steps which is
> 0 if and only if this parameter is a discrete parameter.
◆ getValue()
- Returns
- the current value of the parameter as a
T
◆ operator *()
allow writing *param to access the underlying value (or in other words, *param is the same param.value())
◆ operator ->()
| constexpr Value operator -> |
( |
| ) |
const |
|
inline |
allow writing param->x to access the underlying value when T is a struct or class
◆ operator ParamType()
Allow to use the param as the underlying ParamType.
Example: if(param) in the case T is bool
◆ operator=()
Allow to write param = 3 instead of param.update(3) for example.
◆ resetToDefault()
| tresult resetToDefault |
( |
| ) |
|
|
inline |
Resets the param to its default value.
◆ setValue()
Unconditionally sets the value of the parameter to the value provided.
- Parameters
-
- Returns
kResultOk if successful
◆ toUTF8String()
| std::string toUTF8String |
( |
int32 |
iPrecision | ) |
const |
|
inline |
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
- Parameters
-
| iPrecision | if iPrecision < 0 the parameter is free to use whichever precision is tied to the parameter otherwise it should use the one provided |
◆ update()
First check if the value provided (iValue) is different from the current value and if that is the case then updates it to the new value.
- Note
- If the type
T does not provide a way to compare the value, then this call will delegate to setValue(ParamType const &) and return true.
- Parameters
-
| iValue | the value to update |
- Returns
true if the value was updated
◆ value()
◆ fParameter
The documentation for this class was generated from the following file: