18 #ifndef __PONGASOFT_VST_GUI_PARAMETER_H__ 19 #define __PONGASOFT_VST_GUI_PARAMETER_H__ 32 class GUIVstParameter :
public ITGUIParameter<T>
95 using EditorType::commit;
167 if(previousValue !=
fConverter->normalize(iValue))
223 std::unique_ptr<EditorType>
edit()
override 275 fPtr{std::move(iPtr)}
333 std::unique_ptr<typename GUIVstParameter<T>::EditorType>
edit() { DCHECK_F(
exists());
return fPtr->edit(); }
340 std::unique_ptr<typename GUIVstParameter<T>::EditorType>
edit(T
const &iValue) { DCHECK_F(
exists());
return fPtr->edit(iValue); }
343 inline operator T()
const { DCHECK_F(
exists());
return fPtr->getValue(); }
365 std::shared_ptr<GUIVstParameter<T>>
fPtr;
375 if(vstParamDef && vstParamDef->fConverter)
376 return std::make_shared<GUIVstParameter<T>>(std::dynamic_pointer_cast<GUIRawVstParameter>(shared_from_this()),
377 vstParamDef->fConverter);
393 #endif // __PONGASOFT_VST_GUI_PARAMETER_H__ typename ITGUIParameter< T >::ITEditor EditorType
Definition: GUIVstParameter.h:36
T getValue() const
Definition: GUIVstParameter.h:290
std::unique_ptr< typename GUIVstParameter< T >::EditorType > edit()
Definition: GUIVstParameter.h:333
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:101
tresult setValue(ParamType const &iValue) override
Sets the value of this parameter.
Definition: GUIVstParameter.h:179
ParamType getValue() const
Definition: GUIVstParameter.h:145
bool update(ParamType const &iValue) override
Update the parameter with a value.
Definition: GUIVstParameter.h:163
int32 getStepCount() const
Definition: GUIVstParameter.h:318
std::shared_ptr< IParamConverter< T > > fConverter
Definition: GUIVstParameter.h:257
bool operator!=(const GUIVstParam &rhs) const
Allow to write param1 != param2.
Definition: GUIVstParameter.h:352
tresult copyValueFrom(GUIVstParam< T > const &iParam)
Shortcut to copy the value from another param to this one.
Definition: GUIVstParameter.h:313
ParamValue getNormalizedValue() const
Definition: GUIVstParameter.h:153
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:307
~Editor() override
Definition: GUIVstParameter.h:62
bool exists() const
Definition: GUIVstParameter.h:282
std::unique_ptr< EditorType > edit() override
Definition: GUIVstParameter.h:223
void toString(String128 oString)
Populates the oString with a string representation of this parameter.
Definition: GUIVstParameter.h:323
std::shared_ptr< GUIVstParameter< T > > fPtr
Definition: GUIVstParameter.h:365
GUIVstParam< T > & operator=(T const &iValue)
Allow to write param = 3.0.
Definition: GUIVstParameter.h:346
std::shared_ptr< RawVstParamDef > fParamDef
Definition: GUIRawVstParameter.h:247
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:301
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIVstParameter.h:270
std::unique_ptr< typename GUIVstParameter< T >::EditorType > GUIVstParamEditor
Definition: GUIVstParameter.h:386
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const
Definition: GUIVstParameter.h:357
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIVstParameter.h:250
Definition: GUIState.h:36
tresult setValue(ParamType const &iValue) override
Change the value of the parameter.
Definition: GUIVstParameter.h:71
bool updateValue(ParamType const &iValue) override
Change the value of the parameter.
Definition: GUIVstParameter.h:80
~GUIVstParameter()
Definition: GUIVstParameter.h:124
void toString(String128 oString)
Populates the oString with a string representation of this parameter.
Definition: GUIVstParameter.h:201
GUIVstParam(std::shared_ptr< GUIVstParameter< T >> iPtr=nullptr)
Definition: GUIVstParameter.h:274
Editor & operator=(Editor const &)=delete
Editor(GUIRawVstParamEditor iRawEditor, std::shared_ptr< IParamConverter< T >> iConverter)
Definition: GUIVstParameter.h:55
GUIRawVstParamEditor fRawEditor
Definition: GUIVstParameter.h:107
std::shared_ptr< GUIRawVstParameter > fRawParameter
Definition: GUIVstParameter.h:256
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const override
Definition: GUIVstParameter.h:236
tresult accessValue(typename ITGUIParameter< T >::ValueAccessor const &iGetter) const override
Definition: GUIVstParameter.h:136
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const override
Definition: GUIVstParameter.h:244
This class wraps a GUIRawVstParameter to deal with any type T.
Definition: GUIRawVstParameter.h:30
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:215
tresult setNormalizedValue(ParamValue const &iNormalizedValue)
Sets the value of this parameter as a normalized value.
Definition: GUIVstParameter.h:188
GUIVstParameter(std::shared_ptr< GUIRawVstParameter > iRawParameter, std::shared_ptr< IParamConverter< T >> iConverter)
Definition: GUIVstParameter.h:113
std::unique_ptr< GUIRawVstParameter::EditorType > GUIRawVstParamEditor
Definition: GUIRawVstParameter.h:346
GUIVstParam< T > & operator=(GUIVstParam< T > const &iOther)=default
Assignment operator: fMyParam = registerParam(...);
String toString()
Returns a string representation of this parameter.
Definition: GUIVstParameter.h:209
ParamID getParamID() const
Definition: GUIVstParameter.h:285
Typed parameter definition.
Definition: ParamDef.h:148
T ParamType
Definition: GUIVstParameter.h:35
Defines the API for the editor which can be obtained by calling ITGUIParameter::edit().
Definition: IGUIParameter.h:232
ParamValue getNormalizedValue() const
Definition: GUIVstParameter.h:295
Wrapper to edit a single parameter.
Definition: GUIVstParameter.h:52
std::shared_ptr< GUIVstParameter< T > > asVstParameter()
Converts to a typed parameter.
Definition: GUIVstParameter.h:372
tresult commit() override
Definition: GUIVstParameter.h:89
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:340
std::shared_ptr< IParamConverter< T > > fConverter
Definition: GUIVstParameter.h:108
String toString()
Returns a string representation of this parameter.
Definition: GUIVstParameter.h:328
int32 getStepCount() const override
Definition: GUIVstParameter.h:196
ParamID getParamID() const override
Each parameter has a unique ID returned by this method.
Definition: GUIVstParameter.h:130
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const
Definition: GUIVstParameter.h:362
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
bool operator==(const GUIVstParam< T > &rhs) const
Allow to write param1 == param2.
Definition: GUIVstParameter.h:349
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamConverters.h:53