20 #include <base/source/fobject.h> 55 virtual tresult
writeToStream(IBStreamer &oStreamer)
const = 0;
91 using FObject::update;
97 fValue{iParamDef->fDefaultValue}
129 if constexpr(Utils::is_operator_not_eq_defined<ParamType>)
150 template<
class ValueModifier>
153 if(iValueModifier(&
fValue))
170 if constexpr(std::is_copy_assignable_v<ParamType>)
178 DLOG_F(ERROR,
"%s is not copy_assignable. Call updateIf instead.",
typeid(
ParamType).name());
189 fValue = std::move(iValue);
257 std::unique_ptr<EditorType>
edit()
override 259 return std::make_unique<DefaultEditorImpl<T>>(
this,
getValue());
272 return std::make_unique<GUIParamCx>(
getJmbParamID(), const_cast<GUIJmbParameter *>(
this), iChangeListener);
280 return std::make_unique<FObjectCxCallback>(const_cast<GUIJmbParameter *>(
this), std::move(iChangeCallback));
295 static std::shared_ptr<GUIJmbParameter<T>>
castToJmb(std::shared_ptr<IGUIParameter> iParam)
358 if(res == kResultFalse)
359 DLOG_F(WARNING,
"Cannot convert current value of Jmb param [%d] to a discrete value",
getParamID());
368 if(
getValue(discreteValue) == kResultOk)
370 iGetter(discreteValue);
377 bool update(int32
const &iDiscreteValue)
override 379 int32 currentDiscreteValue;
380 tresult res =
getValue(currentDiscreteValue);
384 if(iDiscreteValue != currentDiscreteValue)
386 if(
setValue(iDiscreteValue) == kResultOk)
395 tresult
setValue(int32
const &iDiscreteValue)
override 397 int32 currentDiscreteValue;
398 tresult res =
getValue(currentDiscreteValue);
401 if(iDiscreteValue != currentDiscreteValue)
404 if constexpr(std::is_copy_assignable_v<T>)
407 if(
fConverter->convertFromDiscreteValue(iDiscreteValue, jmbValue) == kResultOk)
410 DLOG_F(WARNING,
"Cannot convert discrete value [%d] to a [%s] value of Jmb param [%d]",
422 std::unique_ptr<EditorType>
edit()
override 424 int32 currentDiscreteValue;
425 tresult res =
getValue(currentDiscreteValue);
427 return std::make_unique<DefaultEditorImpl<int32>>(
this, currentDiscreteValue);
450 auto converter = getParamDefT()->getDiscreteConverter();
452 if(converter && converter->getStepCount() > 0)
454 std::move(converter));
461 if constexpr(Utils::is_static_cast_defined<int32, T> && Utils::is_static_cast_defined<T, int32>)
463 converter = std::make_shared<StaticCastDiscreteConverter<T>>(iStepCount);
465 std::move(converter));
469 DLOG_F(WARNING,
"Jmb param [%d] (type [%s]) cannot be converted to a discrete parameter",
471 Utils::typeString<T>().c_str());
492 fPtr{std::move(iPtr)}
508 inline bool update(T
const &iNewValue) { DCHECK_F(
exists());
return fPtr->update(iNewValue); }
514 template<
class ValueModifier>
515 inline bool updateIf(ValueModifier
const &iValueModifier) { DCHECK_F(
exists());
return fPtr->updateIf(iValueModifier); }
535 inline operator T
const &()
const { DCHECK_F(
exists());
return fPtr->getValue(); }
564 std::shared_ptr<GUIJmbParameter<T>>
fPtr;
ParamID getParamID() const override
Each parameter has a unique ID returned by this method.
Definition: GUIJmbParameter.h:109
std::unique_ptr< EditorType > edit() override
Creates an editor to modify the parameter in a transactional fashion.
Definition: GUIJmbParameter.h:422
bool updateIf(ValueModifier const &iValueModifier)
Use this flavor of update if you want to modify the value itself.
Definition: GUIJmbParameter.h:515
void resetToDefault()
Resets the param to its default value.
Definition: GUIJmbParameter.h:196
bool update(T const &iNewValue)
This method is typically called by a view to change the value of the parameter.
Definition: GUIJmbParameter.h:508
void broadcast(T const &iValue)
Definition: GUIJmbParameter.h:544
std::shared_ptr< IJmbParamDef > fParamDef
Definition: GUIJmbParameter.h:76
tresult accessValue(typename ITGUIParameter< T >::ValueAccessor const &iGetter) const override
Definition: GUIJmbParameter.h:244
typename ITGUIParameter< T >::ITEditor EditorType
Definition: GUIJmbParameter.h:89
Base class for a Jamba (Jmb) GUI parameter.
Definition: GUIJmbParameter.h:39
Abstraction for allocating and sending a message.
Definition: MessageProducer.h:33
Simple wrapper class with better api.
Definition: Messaging.h:42
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 getValue(int32 &oDiscreteValue) const
Because converting the current Jmb value to an int32 may fail this api returns kResultOk if it works ...
Definition: GUIJmbParameter.h:354
ParamID getParamID() const override
Each parameter has a unique ID returned by this method.
Definition: GUIJmbParameter.h:320
IMessageProducer * fMessageProducer
Definition: GUIJmbParameter.h:77
JmbParamDef< T > const * getParamDefT() const
Definition: GUIJmbParameter.h:114
tresult readFromStream(IBStreamer &iStreamer) override
Definition: GUIJmbParameter.h:202
bool update(int32 const &iDiscreteValue) override
First check if the value provided (iValue) is different from the current value and if that is the cas...
Definition: GUIJmbParameter.h:377
Interface defining a message handler.
Definition: MessageHandler.h:30
void writeToStream(std::ostream &oStream) const override
Definition: GUIJmbParameter.h:217
tresult broadcast() const
Definition: GUIJmbParameter.cpp:29
IGUIJmbParameter(std::shared_ptr< IJmbParamDef > iParamDef)
Definition: GUIJmbParameter.h:43
GUIJmbParam< T > & operator=(GUIJmbParam< T > const &iOther)=default
Assignment operator: fMyParam = registerParam(...);
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const override
Definition: GUIJmbParameter.h:278
tresult accessValue(ValueAccessor const &iGetter) const override
API to access the underlying value.
Definition: GUIJmbParameter.h:365
tresult setValue(ParamType &&iValue)
Sets the value.
Definition: GUIJmbParameter.h:187
std::function< void(T const &)> ValueAccessor
API to access the value of the param.
Definition: IGUIParameter.h:178
void setValue(T const &iNewValue)
The difference with update is that it does not check for equality (case when T is not comparable)
Definition: GUIJmbParameter.h:520
tresult writeToMessage(Message &oMessage) const override
Definition: GUIJmbParameter.h:238
T ParamType
Definition: GUIJmbParameter.h:88
void setMessageProducer(IMessageProducer *iMessageProducer)
Definition: GUIJmbParameter.h:73
T const * operator->() const
Definition: GUIJmbParameter.h:538
typename GUIDiscreteParameter::ITEditor EditorType
Definition: GUIJmbParameter.h:307
std::string toUTF8String(int32 iPrecision) const override
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
Definition: GUIJmbParameter.h:433
Definition: GUIState.h:36
tresult handleMessage(Message const &iMessage) override
Definition: GUIJmbParameter.h:67
tresult setValue(int32 const &iDiscreteValue) override
Unconditionaly sets the value of the parameter to the value provided.
Definition: GUIJmbParameter.h:395
bool updateIf(ValueModifier const &iValueModifier)
Use this flavor of update if you want to modify the value itself.
Definition: GUIJmbParameter.h:151
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener)
Definition: GUIJmbParameter.h:558
std::shared_ptr< GUIJmbParameter< T > > fPtr
Definition: GUIJmbParameter.h:564
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIJmbParameter.h:488
std::shared_ptr< GUIJmbParameter< T > > fJmbParameter
Definition: GUIJmbParameter.h:439
virtual tresult writeToMessage(Message &oMessage) const =0
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const override
Creates a connection between this parameter and the change listener: whenever the parameter changes,...
Definition: GUIJmbParameter.h:332
bool exists() const
Definition: GUIJmbParameter.h:499
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIJmbParameter.h:344
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const override
Definition: GUIJmbParameter.h:270
This is the templated version providing serializer methods, very similar to the GUIVstParameter conce...
Definition: GUIJmbParameter.h:85
T const & getValue() const
Definition: GUIJmbParameter.h:532
int32 getStepCount() const override
When a parameter is a discrete parameter (which means its underlying backing type is an int32 with va...
Definition: GUIJmbParameter.h:326
~GUIJmbParameter() override
Definition: GUIJmbParameter.h:103
bool update(ParamType const &iValue) override
Update the parameter with a value.
Definition: GUIJmbParameter.h:124
GUIJmbParam(std::shared_ptr< GUIJmbParameter< T >> iPtr=nullptr)
Definition: GUIJmbParameter.h:491
void resetToDefault()
Resets the param to its default value.
Definition: GUIJmbParameter.h:529
ParamType const & getValue() const
Definition: GUIJmbParameter.h:251
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIJmbParameter.h:447
void broadcast(T &&iValue)
Definition: GUIJmbParameter.h:551
Interface that defines a converter from a type T to an int32 given a number of steps (provided by get...
Definition: ParamSerializers.h:45
ParamType fValue
Definition: GUIJmbParameter.h:287
virtual tresult writeToStream(IBStreamer &oStreamer) const =0
GUIJmbParameter(std::shared_ptr< JmbParamDef< T >> iParamDef)
Definition: GUIJmbParameter.h:94
IJmbParamDef const * getParamDef() const
Definition: GUIJmbParameter.h:46
Wraps a GUIJmbParameter<T> to interpret it as a discrete parameter using the converter.
Definition: GUIJmbParameter.h:304
int32 getStepCount() const override
When a parameter is a discrete parameter (which means its underlying backing type is an int32 with va...
Definition: GUIJmbParameter.h:111
tresult writeToStream(IBStreamer &oStreamer) const override
Definition: GUIJmbParameter.h:211
ParamID getJmbParamID() const
Definition: GUIJmbParameter.h:49
tresult setValue(ParamType const &iValue) override
Sets the value.
Definition: GUIJmbParameter.h:165
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback)
Definition: GUIJmbParameter.h:561
static std::shared_ptr< GUIJmbParameter< T > > castToJmb(std::shared_ptr< IGUIParameter > iParam)
Convenient function to cast a generic IGUIParameter to a GUIJmbParameter<T>.
Definition: GUIJmbParameter.h:295
ParamID getParamID() const
Definition: GUIJmbParameter.h:502
GUIDiscreteJmbParameter(std::shared_ptr< GUIJmbParameter< T >> iJmbParameter, std::shared_ptr< IDiscreteConverter< T >> iConverter)
Definition: GUIJmbParameter.h:310
void setValue(T &&iNewValue)
The difference with update is that it does not check for equality (case when T is not comparable)
Definition: GUIJmbParameter.h:525
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const override
Creates a connection between this parameter and the callback: whenever the parameter changes,...
Definition: GUIJmbParameter.h:338
Defines the API for the editor which can be obtained by calling ITGUIParameter::edit().
Definition: IGUIParameter.h:232
virtual tresult readFromStream(IBStreamer &iStreamer)=0
std::shared_ptr< IDiscreteConverter< T > > fConverter
Definition: GUIJmbParameter.h:440
Base class for all non vst parameters (need to provide serialization/deserialization)
Definition: ParamDef.h:273
tresult broadcast() const
Definition: GUIJmbParameter.h:541
std::string toUTF8String(int32 iPrecision) const override
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
Definition: GUIJmbParameter.h:223
virtual tresult readFromMessage(Message const &iMessage)=0
Base class for jamba parameters (non templated)
Definition: ParamDef.h:237
std::unique_ptr< EditorType > edit() override
Creates an editor to modify the parameter in a transactional fashion.
Definition: GUIJmbParameter.h:257
ParamType & getValue()
Definition: GUIJmbParameter.h:254
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
tresult readFromMessage(Message const &iMessage) override
Definition: GUIJmbParameter.h:229