Jamba C++ API  4.0.0
ITGUIParameter< T >::ITEditor Class Referenceabstract

Defines the API for the editor which can be obtained by calling ITGUIParameter::edit(). More...

#include <IGUIParameter.h>

Inherits IGUIParameter::Editor.

Inherited by DefaultEditorImpl< T >.

Public Member Functions

virtual tresult commit (ParamType const &iValue)
 Shortcut method which calls setValue(ParamType const &) followed by commit(). More...
 
virtual tresult setValue (ParamType const &iValue)=0
 Unconditionaly sets the value of the parameter to the value provided. More...
 
virtual bool updateValue (ParamType const &iValue)=0
 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. More...
 
- Public Member Functions inherited from IGUIParameter::Editor
virtual tresult commit ()=0
 Commits all the changes applied to the parameter. More...
 
virtual tresult rollback ()=0
 Rollback all the changes that were made to this parameter (since this editor was created). More...
 
virtual ~Editor ()=default
 Technically the destructor must only call rollback(), but due to the fact that it is a virtual method, it needs to be implemented by each subclass... More...
 

Detailed Description

template<typename T>
class pongasoft::VST::GUI::Params::ITGUIParameter< T >::ITEditor

Defines the API for the editor which can be obtained by calling ITGUIParameter::edit().

The editor is used in scenarios when you want to make multiple modifications to a parameter and then commit() or rollback() the set of changes. The typical use case is to create an editor on mouse down event in a view, modify the value on mouse move event and commit on mouse up event.

// Example
CMouseEventResult LCDDisplayView::onMouseDown(CPoint &where, const CButtonState &buttons)
{
fLCDInputXEditor = fLCDInputXParameter.edit(computeLCDInputX(where));
return kMouseEventHandled;
}
CMouseEventResult LCDDisplayView::onMouseMoved(CPoint &where, const CButtonState &buttons)
{
if(fLCDInputXEditor)
{
fLCDInputXEditor->setValue(computeLCDInputX(where));
return kMouseEventHandled;
}
return kMouseEventNotHandled;
}
CMouseEventResult LCDDisplayView::onMouseUp(CPoint &where, const CButtonState &buttons)
{
if(fLCDInputXEditor)
{
fLCDInputXEditor->commit(computeLCDInputX(where));
fLCDInputXEditor = nullptr;
return kMouseEventHandled;
}
return kMouseEventNotHandled;
}
CMouseEventResult LCDDisplayView::onMouseCancel()
{
if(fLCDInputXEditor)
{
fLCDInputXEditor->rollback();
fLCDInputXEditor = nullptr;
return kMouseEventHandled;
}
return kMouseEventNotHandled;
}

Member Function Documentation

◆ commit()

virtual tresult commit ( ParamType const &  iValue)
inlinevirtual

Shortcut method which calls setValue(ParamType const &) followed by commit().

◆ setValue()

virtual tresult setValue ( ParamType const &  iValue)
pure virtual

Unconditionaly sets the value of the parameter to the value provided.

Parameters
iValuethe value to set
Returns
kResultOk if successful

Implemented in DefaultEditorImpl< T >.

◆ updateValue()

virtual bool updateValue ( ParamType const &  iValue)
pure virtual

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
iValuethe value to update
Returns
true if the value was updated

Implemented in DefaultEditorImpl< T >.


The documentation for this class was generated from the following file: