BlankMat 0.1.0
Free open-source 3D texture creation application
Loading...
Searching...
No Matches
IUIVariable< T > Class Template Referenceabstract

Class to store a variable that can be edited in the UI. This class sends a Command to the ActionStack whenever the value of the variable is changed. More...

Collaboration diagram for IUIVariable< T >:

Public Member Functions

virtual void Display ()=0
 Displays the variable as an editable field in the UI. Each variable type needs to handle this differently, so this method must be overridden by implementations.
 
bool Equals (const T &value) const
 Returns whether the value is equal to the given value.
 
Get () const
 Returns the current value of this variable.
 
T * GetRef () const
 Returns a reference to the value stored in this variable. This is unsafe, but is necessary for Commands outside of the class to update the value.
 
 operator T ()
 Explicitly converts this variable to its internal value.
 
T & operator* ()
 Returns a reference to the value stored in this variable.
 
T * operator-> ()
 Returns a reference to the value stored in this variable.
 
std::string Name () const
 Returns the name of the variable.
 
void Set (const T &newValue)
 Sets the value of the variable to the new value only if it is different. Sends a Command to the action stack indicating the changed value.
 
void SetNoUpdate (const T &newValue)
 Sets the value of the variable to the new value without creating a command.
 

Protected Attributes

std::string mName = ""
 Name of the variable.
 
mValue
 Value of the variable.
 
ActionStackmActionStack = nullptr
 Reference to the global action stack.
 
std::function< void()> mSetCallback
 Callback function that runs whenever set is modified.
 

Detailed Description

template<typename T>
class IUIVariable< T >

Class to store a variable that can be edited in the UI. This class sends a Command to the ActionStack whenever the value of the variable is changed.

Template Parameters
TType of variable to store


Member Function Documentation

◆ Display()

template<typename T >
virtual void IUIVariable< T >::Display ( )
pure virtual

Displays the variable as an editable field in the UI. Each variable type needs to handle this differently, so this method must be overridden by implementations.

Implemented in UIBool, UIInt, UIFloat, UIVec3, UIColor, and UIString.

◆ Equals()

template<typename T >
bool IUIVariable< T >::Equals ( const T &  value) const
inline

Returns whether the value is equal to the given value.

Parameters
valueValue to check
Returns
Whether the values are equals

◆ Get()

template<typename T >
T IUIVariable< T >::Get ( ) const
inline

Returns the current value of this variable.

Returns
The current value

◆ GetRef()

template<typename T >
T * IUIVariable< T >::GetRef ( ) const
inline

Returns a reference to the value stored in this variable. This is unsafe, but is necessary for Commands outside of the class to update the value.

Returns
Reference of the current value

◆ Name()

template<typename T >
std::string IUIVariable< T >::Name ( ) const
inline

Returns the name of the variable.

Returns
Name of the variable

◆ operator T()

template<typename T >
IUIVariable< T >::operator T ( )
inline

Explicitly converts this variable to its internal value.

◆ operator*()

template<typename T >
T & IUIVariable< T >::operator* ( )
inline

Returns a reference to the value stored in this variable.

Returns
Reference of the value of the variable

◆ operator->()

template<typename T >
T * IUIVariable< T >::operator-> ( )
inline

Returns a reference to the value stored in this variable.

Returns
Reference of the value of the variable

◆ Set()

template<typename T >
void IUIVariable< T >::Set ( const T &  newValue)
inline

Sets the value of the variable to the new value only if it is different. Sends a Command to the action stack indicating the changed value.

Parameters
newValueNew value to set it to

◆ SetNoUpdate()

template<typename T >
void IUIVariable< T >::SetNoUpdate ( const T &  newValue)
inline

Sets the value of the variable to the new value without creating a command.

Parameters
newValueNew value to set it to

Member Data Documentation

◆ mActionStack

template<typename T >
ActionStack* IUIVariable< T >::mActionStack = nullptr
protected

Reference to the global action stack.

◆ mName

template<typename T >
std::string IUIVariable< T >::mName = ""
protected

Name of the variable.

◆ mSetCallback

template<typename T >
std::function<void()> IUIVariable< T >::mSetCallback
protected

Callback function that runs whenever set is modified.

◆ mValue

template<typename T >
T IUIVariable< T >::mValue
protected

Value of the variable.