1.10
Public Member Functions | Protected Attributes | List of all members
RangeValue< T > Class Template Reference

Manages a value in a range. More...

#include <value.h>

Inheritance diagram for RangeValue< T >:
Inheritance graph
[legend]

Public Member Functions

 RangeValue (T start, T end, T value={}) noexcept
 
EGT_NODISCARD T end () const
 Get the end value.
 
void end (T end)
 Set the end value.
 
 operator T () const
 Get the current value.
 
RangeValue< T > & operator= (T value)
 Assign the current value.
 
EGT_NODISCARD T start () const
 Get the start value.
 
void start (T start)
 Set the start value.
 
EGT_NODISCARD T value () const
 Get the current value.
 
bool value (T value)
 Set value.
 
- Public Member Functions inherited from Object
 Object () noexcept=default
 
 Object (const Object &)=delete
 
 Object (Object &&)=default
 
virtual ~Object () noexcept=default
 
void clear_handlers ()
 Clear all registered event handlers.
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event.
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId.
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object.
 
void name (const std::string &name)
 Set the name of the Object.
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event.
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler.
 

Public Attributes

Signal on_value_changed
 Event signal.
 

Protected Attributes

m_end {}
 The end value.
 
m_start {}
 The start value.
 
m_value {}
 The current value.
 
- Protected Attributes inherited from Object
detail::CopyOnWriteAllocate< CallbackArraym_callbacks
 Array of callbacks.
 
RegisterHandle m_handle_counter {0}
 Counter used to generate unique handles for each callback registration.
 
std::string m_name
 A user defined name for the Object.
 

Additional Inherited Members

- Public Types inherited from Object
using EventCallback = std::function< void(Event &event)>
 Event handler callback function.
 
using FilterFlags = FlagsBase< EventId >
 Event handler EventId filter.
 
using RegisterHandle = uint64_t
 Handle type.
 
- Protected Types inherited from Object
using CallbackArray = std::vector< CallbackMeta >
 Helper type for an array of callbacks.
 

Detailed Description

template<class T>
class egt::v1::RangeValue< T >

Manages a value in a range.

Constructor & Destructor Documentation

◆ RangeValue()

template<class T >
RangeValue ( start,
end,
value = {} 
)
inlinenoexcept
Parameters
[in]startStart value for the range.
[in]endEnd value in the range.
[in]valueCurrent value in the range.

Member Function Documentation

◆ end() [1/2]

template<class T >
EGT_NODISCARD T end ( ) const
inline

Get the end value.

◆ end() [2/2]

template<class T >
void end ( end)
inline

Set the end value.

Parameters
[in]endThe end value.

◆ operator T()

template<class T >
operator T ( ) const
inlineexplicit

Get the current value.

◆ operator=()

template<class T >
RangeValue< T > & operator= ( value)
inline

Assign the current value.

◆ start() [1/2]

template<class T >
EGT_NODISCARD T start ( ) const
inline

Get the start value.

◆ start() [2/2]

template<class T >
void start ( start)
inline

Set the start value.

Parameters
[in]startThe start value.

◆ value() [1/2]

template<class T >
EGT_NODISCARD T value ( ) const
inline

Get the current value.

◆ value() [2/2]

template<class T >
bool value ( value)
inline

Set value.

If the value is above end, the value will be set to end. If the value is below start, the value will be set to start.

Parameters
[in]valueValue to set.
Returns
true if changed.

Member Data Documentation

◆ m_end

template<class T >
T m_end {}
protected

The end value.

◆ m_start

template<class T >
T m_start {}
protected

The start value.

◆ m_value

template<class T >
T m_value {}
protected

The current value.

◆ on_value_changed

template<class T >
Signal on_value_changed

Event signal.

Invoked when the value of the widget changes.