20 #include <pluginterfaces/vst/vsttypes.h> 21 #include <pongasoft/logging/logging.h> 27 using namespace Steinberg::Vst;
39 static_assert(std::is_default_constructible_v<T>,
"T must have a default/empty constructor: T()");
40 static_assert(std::is_copy_constructible_v<T>,
"T must have a copy constructor: T(T const &)");
41 static_assert(std::is_copy_assignable_v<T>,
"T must be copy assignable: T& operator=(T const &)");
47 using FObject::update;
53 fDefaultValue{iDefaultValue},
67 void setParamID(ParamID iParamID) { fParamID = iParamID; }
81 if constexpr(Utils::is_operator_not_eq_defined<ParamType>)
85 if(setValue(iValue) == kResultOk)
91 if(setValue(iValue) == kResultOk)
100 std::unique_ptr<EditorType>
edit()
override 102 return std::make_unique<DefaultEditorImpl<T>>(
this, getValue());
110 template<
class ValueModifier>
113 if(iValueModifier(&fValue))
136 return update(fDefaultValue);
163 return std::make_unique<GUIParamCx>(getParamID(), const_cast<GUIValParameter *>(
this), iChangeListener);
171 return std::make_unique<FObjectCxCallback>(const_cast<GUIValParameter *>(
this), iChangeCallback);
175 std::shared_ptr<GUIDiscreteParameter> asDiscreteParameter(int32 iStepCount)
override;
198 fStepCount(iStepCount)
200 DCHECK_F(fStepCount > 0);
218 if constexpr(Utils::is_static_cast_defined<int32, T> && Utils::is_static_cast_defined<T, int32>)
220 return VstUtils::make_sfo<GUIDiscreteValParameter>(fParamID, static_cast<int32>(fValue), iStepCount);
GUIDiscreteValParameter(ParamID iParamID, int32 iDefaultValue, int32 iStepCount)
Definition: GUIValParameter.h:196
~GUIValParameter() override
Definition: GUIValParameter.h:60
GUIValParameter(ParamID iParamID, ParamType const &iDefaultValue)
Definition: GUIValParameter.h:51
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
T fValue
Definition: GUIValParameter.h:180
int32 ParamType
Definition: GUIValParameter.h:44
std::string toUTF8String(T const &iValue, Steinberg::int32 iPrecision)
This generic function will determine (at compilation time) whether T can be written to an ostream and...
Definition: Utils.h:57
std::function< void(T const &)> ValueAccessor
API to access the value of the param.
Definition: IGUIParameter.h:182
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const override
Definition: GUIValParameter.h:169
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIValParameter.h:214
Definition: GUIState.h:37
int32 getStepCount() const override
When a parameter is a discrete parameter (which means its underlying backing type is an int32 with va...
Definition: GUIValParameter.h:69
std::string toUTF8String(int32 iPrecision) const override
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
Definition: GUIValParameter.h:153
ParamID getParamID() const override
Each parameter has a unique ID returned by this method.
Definition: GUIValParameter.h:66
std::unique_ptr< EditorType > edit() override
Definition: GUIValParameter.h:100
T fDefaultValue
Definition: GUIValParameter.h:179
int32 fStepCount
Definition: GUIValParameter.h:207
tresult setValue(ParamType const &iValue) override
Sets the value.
Definition: GUIValParameter.h:125
ParamType const & getValue() const
Definition: GUIValParameter.h:147
typename ITGUIParameter< int32 >::ITEditor EditorType
Definition: GUIValParameter.h:45
bool updateIf(ValueModifier const &iValueModifier)
Use this flavor of update if you want to modify the value itself.
Definition: GUIValParameter.h:111
tresult resetToDefault() override
Resets the param to its default value.
Definition: GUIValParameter.h:134
This parameter is not tied to any parameter definition/registration and is primarily used by the opti...
Definition: GUIValParameter.h:36
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const override
Definition: GUIValParameter.h:161
Defines the API for the editor which can be obtained by calling ITGUIParameter::edit().
Definition: IGUIParameter.h:236
Simple extension class to treat a Val parameter as a discrete one.
Definition: GUIValParameter.h:193
ParamType & getValue()
Definition: GUIValParameter.h:150
void setParamID(ParamID iParamID)
Definition: GUIValParameter.h:67
bool update(ParamType const &iValue) override
Update the parameter with a value.
Definition: GUIValParameter.h:76
ParamID fParamID
Definition: GUIValParameter.h:178
int32 getStepCount() const override
When a parameter is a discrete parameter (which means its underlying backing type is an int32 with va...
Definition: GUIValParameter.h:204
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
tresult accessValue(typename ITGUIParameter< T >::ValueAccessor const &iGetter) const override
Definition: GUIValParameter.h:140