Clapkit
Loading...
Searching...
No Matches
CKProperty< T > Class Template Reference

Defines an observable value. More...

#include <ckProperty.h>

Public Member Functions

 CKProperty ()=default
 
 CKProperty (T v)
 
 operator const T & () const
 
const T & get () const
 
T & get ()
 
template<typename U = T>
auto operator-> () -> typename std::enable_if<!std::is_pointer< U >::value, U * >::type
 
template<typename U = T>
auto operator-> () const -> typename std::enable_if<!std::is_pointer< U >::value, const U * >::type
 
template<typename U = T>
auto operator-> () -> typename std::enable_if< std::is_pointer< U >::value, typename std::remove_pointer< U >::type * >::type
 
template<typename U = T>
auto operator-> () const -> typename std::enable_if< std::is_pointer< U >::value, typename std::remove_pointer< U >::type * >::type
 
CKPropertyoperator= (const T &v)
 
CKPropertyoperator+= (const T &v)
 
CKPropertyoperator-= (const T &v)
 
CKPropertyoperator*= (const T &v)
 
CKPropertyoperator/= (const T &v)
 
CKPropertyoperator%= (const T &v)
 
CKPropertyoperator++ ()
 
CKProperty operator++ (int)
 
CKPropertyoperator-- ()
 
CKProperty operator-- (int)
 

Public Attributes

std::function< void()> onChange
 The function to be called when the value changes.
 

Detailed Description

template<typename T>
class CKProperty< T >

Defines an observable value.

These are mostly used to react to property changes on UI elements to refresh the screen.

In most cases, you can use a CKProperty just like a regular data type like an int or bool, but in some cases you will need to use get() to get the raw data type.

auto& vec = items.get();
for (auto& sm : vec) { ... }
Defines an observable value.
Definition ckProperty.h:60
const T & get() const
Definition ckProperty.h:68

In most cases, you'll need to set the onChange to your control's property change handler, using the macro CKOBSERVEVALUE.

this->text.onChange = CKOBSERVEVALUE("text");
#define CKOBSERVEVALUE(name)
Simple wrapper for tying an CKProperty::onChange of CKProperty to an object.
Definition ckObject.h:23

Then you can use RaisePropertyChange to respond to changes.

void CKLabel::RaisePropertyChange(const char* propertyName) {
if (!strcmp("text")) {
// Redraw the text.
}
}
virtual void RaisePropertyChange(const char *propertyName)
Definition ckLabel.cpp:378
Template Parameters
T

Constructor & Destructor Documentation

◆ CKProperty() [1/2]

template<typename T >
CKProperty< T >::CKProperty ( )
default

◆ CKProperty() [2/2]

template<typename T >
CKProperty< T >::CKProperty ( v)
inline

Member Function Documentation

◆ get() [1/2]

template<typename T >
T & CKProperty< T >::get ( )
inline

◆ get() [2/2]

template<typename T >
const T & CKProperty< T >::get ( ) const
inline

◆ operator const T &()

template<typename T >
CKProperty< T >::operator const T & ( ) const
inline

◆ operator%=()

template<typename T >
CKProperty & CKProperty< T >::operator%= ( const T &  v)
inline

◆ operator*=()

template<typename T >
CKProperty & CKProperty< T >::operator*= ( const T &  v)
inline

◆ operator++() [1/2]

template<typename T >
CKProperty & CKProperty< T >::operator++ ( )
inline

◆ operator++() [2/2]

template<typename T >
CKProperty CKProperty< T >::operator++ ( int  )
inline

◆ operator+=()

template<typename T >
CKProperty & CKProperty< T >::operator+= ( const T &  v)
inline

◆ operator--() [1/2]

template<typename T >
CKProperty & CKProperty< T >::operator-- ( )
inline

◆ operator--() [2/2]

template<typename T >
CKProperty CKProperty< T >::operator-- ( int  )
inline

◆ operator-=()

template<typename T >
CKProperty & CKProperty< T >::operator-= ( const T &  v)
inline

◆ operator->() [1/4]

template<typename T >
template<typename U = T>
auto CKProperty< T >::operator-> ( ) -> typename std::enable_if<std::is_pointer<U>::value, typename std::remove_pointer<U>::type*>::type
inline

◆ operator->() [2/4]

template<typename T >
template<typename U = T>
auto CKProperty< T >::operator-> ( ) -> typename std::enable_if<!std::is_pointer<U>::value, U*>::type
inline

◆ operator->() [3/4]

template<typename T >
template<typename U = T>
auto CKProperty< T >::operator-> ( ) const -> typename std::enable_if<std::is_pointer<U>::value, typename std::remove_pointer<U>::type*>::type
inline

◆ operator->() [4/4]

template<typename T >
template<typename U = T>
auto CKProperty< T >::operator-> ( ) const -> typename std::enable_if<!std::is_pointer<U>::value, const U*>::type
inline

◆ operator/=()

template<typename T >
CKProperty & CKProperty< T >::operator/= ( const T &  v)
inline

◆ operator=()

template<typename T >
CKProperty & CKProperty< T >::operator= ( const T &  v)
inline

Member Data Documentation

◆ onChange

template<typename T >
std::function<void()> CKProperty< T >::onChange

The function to be called when the value changes.


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