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

Manages a value in a range. More...

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. More...
 
void end (T end)
 Set the end value. More...
 
 operator T () const
 Get the current value. More...
 
RangeValue< T > & operator= (T value)
 Assign the current value. More...
 
EGT_NODISCARD T start () const
 Get the start value. More...
 
void start (T start)
 Set the start value. More...
 
EGT_NODISCARD T value () const
 Get the current value. More...
 
bool value (T value)
 Set value. More...
 
- 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. More...
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event. More...
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId. More...
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object. More...
 
void name (const std::string &name)
 Set the name of the Object. More...
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event. More...
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler. More...
 

Public Attributes

Signal on_value_changed
 Event signal. More...
 

Protected Attributes

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

Additional Inherited Members

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

Detailed Description

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

Manages a value in a range.

Constructor & Destructor Documentation

◆ RangeValue()

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]

EGT_NODISCARD T end ( ) const
inline

Get the end value.

◆ end() [2/2]

void end ( end)
inline

Set the end value.

Parameters
[in]endThe end value.

◆ operator T()

operator T ( ) const
inlineexplicit

Get the current value.

◆ operator=()

RangeValue<T>& operator= ( value)
inline

Assign the current value.

◆ start() [1/2]

EGT_NODISCARD T start ( ) const
inline

Get the start value.

◆ start() [2/2]

void start ( start)
inline

Set the start value.

Parameters
[in]startThe start value.

◆ value() [1/2]

EGT_NODISCARD T value ( ) const
inline

Get the current value.

◆ value() [2/2]

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

T m_end {}
protected

The end value.

◆ m_start

T m_start {}
protected

The start value.

◆ m_value

T m_value {}
protected

The current value.

◆ on_value_changed

Signal on_value_changed

Event signal.

Invoked when the value of the widget changes.