18 #ifndef __PONGASOFT_VST_GUI_PARAMETER_H__ 19 #define __PONGASOFT_VST_GUI_PARAMETER_H__ 33 class GUIVstParameter :
public ITGUIParameter<T>
96 using EditorType::commit;
168 auto newNormalizedValued =
fConverter->normalize(iValue);
169 if(currentNormalizedValue != newNormalizedValued)
225 std::unique_ptr<EditorType>
edit()
override 291 fPtr{std::move(iPtr)}
365 std::unique_ptr<typename GUIVstParameter<T>::EditorType>
edit() { DCHECK_F(
exists());
return fPtr->edit(); }
372 std::unique_ptr<typename GUIVstParameter<T>::EditorType>
edit(T
const &iValue) { DCHECK_F(
exists());
return fPtr->edit(iValue); }
381 [[deprecated(
"Since 4.1.0 - use operator* or .value() instead (ex: if(*param) {...} or if(param.value()) {...}")]]
382 inline operator T()
const { DCHECK_F(
exists());
return fPtr->getValue(); }
401 std::shared_ptr<GUIVstParameter<T>>
fPtr;
412 if(vstParamDef && vstParamDef->fConverter)
413 return std::make_shared<GUIVstParameter<T>>(std::dynamic_pointer_cast<GUIRawVstParameter>(shared_from_this()),
414 vstParamDef->fConverter);
430 #endif // __PONGASOFT_VST_GUI_PARAMETER_H__ typename ITGUIParameter< T >::ITEditor EditorType
Definition: GUIVstParameter.h:37
T getValue() const
Definition: GUIVstParameter.h:306
std::unique_ptr< typename GUIVstParameter< T >::EditorType > edit()
Definition: GUIVstParameter.h:365
T value() const
Synonym to getValue()
Definition: GUIVstParameter.h:309
tresult rollback() override
Call this if you want to revert to the original value of the parameter (when the editor is created).
Definition: GUIVstParameter.h:102
tresult setValue(ParamType const &iValue) override
Sets the value of this parameter.
Definition: GUIVstParameter.h:181
ParamType getValue() const
Definition: GUIVstParameter.h:146
bool update(ParamType const &iValue) override
Update the parameter with a value.
Definition: GUIVstParameter.h:164
int32 getStepCount() const
Definition: GUIVstParameter.h:350
std::shared_ptr< IParamConverter< T > > fConverter
Definition: GUIVstParameter.h:259
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIRawVstParameter.h:258
ParamValue getNormalizedValue() const
Definition: GUIVstParameter.h:154
std::function< void()> ChangeCallback
A callback that will be invoked for changes.
Definition: Parameters.h:55
Represents a gui parameter with its underlying backing type T (aka ParamType).
Definition: IGUIParameter.h:33
tresult setNormalizedValue(ParamValue const &iNormalizedValue)
Sets the value of this parameter as a normalized value.
Definition: GUIVstParameter.h:333
~Editor() override
Definition: GUIVstParameter.h:63
bool exists() const
Definition: GUIVstParameter.h:298
std::unique_ptr< EditorType > edit() override
Definition: GUIVstParameter.h:225
Value(T const &iValue)
Definition: GUIVstParameter.h:284
void toString(String128 oString)
Populates the oString with a string representation of this parameter.
Definition: GUIVstParameter.h:355
std::shared_ptr< GUIVstParameter< T > > fPtr
Definition: GUIVstParameter.h:401
GUIVstParam< T > & operator=(T const &iValue)
Allow to write param = 3.0.
Definition: GUIVstParameter.h:385
tresult copyValueFrom(GUIVstParam< V > const &iParam)
Shortcut to copy the value from another param to this one.
Definition: GUIVstParameter.h:340
std::shared_ptr< RawVstParamDef > fParamDef
Definition: GUIRawVstParameter.h:248
Implements all the various equality and relational operators for the type T which is assumed to encap...
Definition: Operators.h:54
std::function< void(T const &)> ValueAccessor
API to access the value of the param.
Definition: IGUIParameter.h:178
tresult setValue(T const &iValue)
Sets the value of this parameter.
Definition: GUIVstParameter.h:327
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIVstParameter.h:272
bool update(T const &iValue)
Update the parameter with a value.
Definition: GUIVstParameter.h:321
std::unique_ptr< typename GUIVstParameter< T >::EditorType > GUIVstParamEditor
Definition: GUIVstParameter.h:423
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const
Allow to write param1 == param2.
Definition: GUIVstParameter.h:393
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIVstParameter.h:252
Definition: GUIState.h:36
tresult setValue(ParamType const &iValue) override
Change the value of the parameter.
Definition: GUIVstParameter.h:72
bool updateValue(ParamType const &iValue) override
Change the value of the parameter.
Definition: GUIVstParameter.h:81
~GUIVstParameter()
Definition: GUIVstParameter.h:125
void toString(String128 oString)
Populates the oString with a string representation of this parameter.
Definition: GUIVstParameter.h:203
The purpose of this class is to copy the value so that it can be accessed via -> thus allowing to wri...
Definition: GUIVstParameter.h:279
GUIVstParam(std::shared_ptr< GUIVstParameter< T >> iPtr=nullptr)
Definition: GUIVstParameter.h:290
Editor & operator=(Editor const &)=delete
Editor(GUIRawVstParamEditor iRawEditor, std::shared_ptr< IParamConverter< T >> iConverter)
Definition: GUIVstParameter.h:56
GUIRawVstParamEditor fRawEditor
Definition: GUIVstParameter.h:108
std::shared_ptr< GUIRawVstParameter > fRawParameter
Definition: GUIVstParameter.h:258
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const override
Definition: GUIVstParameter.h:238
ParamValue getValue() const
Definition: GUIRawVstParameter.h:278
tresult accessValue(typename ITGUIParameter< T >::ValueAccessor const &iGetter) const override
Definition: GUIVstParameter.h:137
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const override
Definition: GUIVstParameter.h:246
constexpr Value operator ->() const
allow writing param->x to access the underlying value when T is a struct or class
Definition: GUIVstParameter.h:378
This class wraps a GUIRawVstParameter to deal with any type T.
Definition: GUIRawVstParameter.h:31
std::string toUTF8String(int32 iPrecision) const override
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
Definition: GUIVstParameter.h:217
tresult setNormalizedValue(ParamValue const &iNormalizedValue)
Sets the value of this parameter as a normalized value.
Definition: GUIVstParameter.h:190
GUIVstParameter(std::shared_ptr< GUIRawVstParameter > iRawParameter, std::shared_ptr< IParamConverter< T >> iConverter)
Definition: GUIVstParameter.h:114
std::unique_ptr< GUIRawVstParameter::EditorType > GUIRawVstParamEditor
Definition: GUIRawVstParameter.h:355
GUIVstParam< T > & operator=(GUIVstParam< T > const &iOther)=default
Assignment operator: fMyParam = registerParam(...);
String toString()
Returns a string representation of this parameter.
Definition: GUIVstParameter.h:211
ParamID getParamID() const
Definition: GUIVstParameter.h:301
Typed parameter definition.
Definition: ParamDef.h:176
tresult copyValueFrom(GUIRawVstParam const &iParam)
Shortcut to copy the value from another param to this one (raw value)
Definition: GUIVstParameter.h:345
T ParamType
Definition: GUIVstParameter.h:36
Defines the API for the editor which can be obtained by calling ITGUIParameter::edit().
Definition: IGUIParameter.h:232
ParamValue getNormalizedValue() const
Definition: GUIVstParameter.h:314
Wrapper to edit a single parameter.
Definition: GUIVstParameter.h:53
constexpr T const * operator ->() const
Definition: GUIVstParameter.h:281
std::shared_ptr< GUIVstParameter< T > > asVstParameter()
Converts to a typed parameter.
Definition: GUIVstParameter.h:409
T fValue
Definition: GUIVstParameter.h:285
tresult commit() override
Definition: GUIVstParameter.h:90
std::unique_ptr< typename GUIVstParameter< T >::EditorType > edit(T const &iValue)
Shortcut to create an editor and set the value to it.
Definition: GUIVstParameter.h:372
std::shared_ptr< IParamConverter< T > > fConverter
Definition: GUIVstParameter.h:109
String toString()
Returns a string representation of this parameter.
Definition: GUIVstParameter.h:360
int32 getStepCount() const override
Definition: GUIVstParameter.h:198
ParamID getParamID() const override
Each parameter has a unique ID returned by this method.
Definition: GUIVstParameter.h:131
constexpr T operator *() const
allow writing *param to access the underlying value (or in other words, *param is the same param....
Definition: GUIVstParameter.h:375
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const
Definition: GUIVstParameter.h:398
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamConverters.h:53