Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::NumericSpinBox< TType > Class Template Reference

Numeric input widget with increment/decrement controls. More...

#include <spk_numeric_spin_box.hpp>

Inheritance diagram for spk::NumericSpinBox< TType >:
Inheritance graph
Collaboration diagram for spk::NumericSpinBox< TType >:
Collaboration graph

Public Types

using value_type = TType
 Underlying numeric value type.
using ValidationState = spk::TextEdit::ValidationState
 Validation state type for the text edit.
using ValidationStatus = spk::TextEdit::ValidationStatus
 Validation status type for the text edit.
using ValidationCallback = spk::TextEdit::ValidationCallback
 Validation callback type for the text edit.
using EditionJob = spk::ObservableValue<value_type>::Job
 Edition job type for value changes.
using EditionContract = spk::ObservableValue<value_type>::Contract
 Edition contract type for value changes.
using ParseResult = spk::Expected<value_type, ValidationState>
 Parse result type for numeric text.
Public Types inherited from spk::Widget
enum class  FocusType { Keyboard = 0 , Mouse = 1 }
 Types of focus a widget can own.
Public Types inherited from spk::ActivableObject
using Contract = StatefulObject<ActivationStatus>::Contract
 Subscription handle controlling callback lifetime.
using Job = StatefulObject<ActivationStatus>::Job
 Callback signature executed on activation state changes.
Public Types inherited from spk::StatefulObject< ActivationStatus >
using Contract
 Handle allowing subscribers to manage callback lifetimes.
using Job
 Callable invoked when the object transitions to a state.

Public Member Functions

 NumericSpinBox (const std::wstring &p_name, spk::Widget *p_parent)
 Builds a numeric spin box widget.
EditionContract subscribeToEdition (const EditionJob &p_job)
 Subscribes to value edition notifications.
void setMinimalTextEditSize (uint32_t p_minimalTextEditSize)
 Sets the minimal width of the text edit field.
void setValue (const value_type &p_value)
 Sets the current numeric value.
const value_typevalue () const
 Returns the current numeric value.
void setStep (const value_type &p_step)
 Sets the increment/decrement step.
const value_typestep () const
 Returns the increment/decrement step.
void increase ()
 Increases the value by the current step.
void decrease ()
 Decreases the value by the current step.
TextEditvalueEdit ()
 Returns the value text edit.
const TextEditvalueEdit () const
 Returns the value text edit.
IconButtonraiseButton ()
 Returns the increment button.
IconButtonlowerButton ()
 Returns the decrement button.
Public Member Functions inherited from spk::Widget
void takeFocus (FocusType p_focusType)
 Grants this widget ownership of the requested focus type.
void releaseFocus (FocusType p_focusType)
 Releases a previously acquired focus type.
bool hasFocus (FocusType p_focusType) const
 Checks if this widget currently owns a focus type.
void takeAllFocus ()
 Acquires both keyboard and mouse focus.
void releaseAllFocus ()
 Releases both keyboard and mouse focus types.
 Widget (const std::wstring &p_name, Widget *p_parent)
 Builds a widget optionally attached to a parent.
void addChild (Widget *p_child) override
 Adds a child widget and sorts the hierarchy by layer.
const float & layer () const
 Current rendering layer of the widget.
void setLayer (const float &p_newLayer)
 Updates the widget layer and propagates relative offsets to children.
const std::wstring & name () const
 Retrieves the widget name.
void setName (const std::wstring &p_name)
 Sets the widget name.
void setGeometry (const spk::Extend2D &p_geometry) override
 Requests a specific viewport and scissor region for the widget.
const spk::Extend2Dgeometry () const
 Returns the current widget geometry.
const spk::OpenGL::ViewRegionviewRegion () const
 Accesses the computed view region.
const spk::OpenGL::FrameBufferObjectframeBufferObject () const
 Returns the frame buffer object used for widget rendering.
const spk::OpenGL::FrameBufferObjectfbo () const
 Alias for frameBufferObject().
void requireGeometryChange ()
 Marks the widget view region as needing recomputation.
Public Member Functions inherited from spk::InherenceObject< Widget >
virtual void removeChild (Widget *p_child)
 Removes a child from this node.
Widgetparent () const
 Returns the parent pointer.
virtual std::vector< Widget * > & children ()
 Returns the children vector.
void clearChildren ()
 Clears the children list and resets each child's parent pointer.
Public Member Functions inherited from spk::ActivableObject
 ActivableObject ()
 Builds a deactivated object.
 ActivableObject (ActivationStatus p_initial)
 Builds with a custom initial activation state.
void activate ()
 Sets the state to Activated.
void deactivate ()
 Sets the state to Deactivated.
void toggle ()
 Toggles between activated and deactivated states.
bool isActive () const
 Checks whether the object is currently activated.
Contract addActivationCallback (const Job &p_callback)
 Registers a callback executed when the object activates.
Contract addDeactivationCallback (const Job &p_callback)
 Registers a callback executed when the object deactivates.
Public Member Functions inherited from spk::StatefulObject< ActivationStatus >
 StatefulObject (const ActivationStatus &p_initialState)
 Builds with an initial state.
StatefulObjectoperator= (const StatefulObject &p_other)=delete
void setState (const ActivationStatus &p_newState)
 Sets a new state and triggers callbacks registered for it.
ActivationStatus state () const
 Returns the current state.
Contract addCallback (const ActivationStatus &p_state, const Job &p_callback)
 Subscribes a callback for a specific state.
Public Member Functions inherited from spk::ResizableElement
SizeHintsizeHint ()
 Returns mutable size hint data.
const SizeHintsizeHint () const
 Returns const size hint data.

Protected Member Functions

void _onGeometryChange () override
 Updates layout geometry when size changes.
Protected Member Functions inherited from spk::Widget
virtual void _onPaintEvent (spk::PaintEvent &p_event)
 Paint event hook for derived widgets.
virtual void _onKeyPressEvent (spk::KeyPressEvent &p_event)
 Keyboard press handler for derived widgets.
virtual void _onKeyReleaseEvent (spk::KeyReleaseEvent &p_event)
 Keyboard release handler for derived widgets.
virtual void _onGlyphEvent (spk::GlyphEvent &p_event)
 Text glyph input handler for derived widgets.
virtual void _onMousePressEvent (spk::MousePressEvent &p_event)
 Mouse button press handler for derived widgets.
virtual void _onMouseReleaseEvent (spk::MouseReleaseEvent &p_event)
 Mouse button release handler for derived widgets.
virtual void _onMouseDoubleClickEvent (spk::MouseDoubleClickEvent &p_event)
 Mouse double click handler for derived widgets.
virtual void _onMouseMotionEvent (spk::MouseMotionEvent &p_event)
 Mouse motion handler for derived widgets.
virtual void _onMouseWheelEvent (spk::MouseWheelEvent &p_event)
 Mouse wheel handler for derived widgets.
virtual void _onEnterResizeModeEvent (spk::EnterResizeModeEvent &p_event)
 Callback for entering resize mode.
virtual void _onResizeEvent (spk::ResizeEvent &p_event)
 Resize handling hook.
virtual void _onExitResizeModeEvent (spk::ExitResizeModeEvent &p_event)
 Callback invoked when leaving resize mode.
virtual void _onQuitEvent (spk::QuitEvent &p_event)
 Quit event handler hook.
virtual void _onMoveEvent (spk::MoveEvent &p_event)
 Window move handler hook.
virtual void _onFullScreenModeEvent (spk::FullScreenModeEvent &p_event)
 Full screen toggle handler hook.
virtual void _onMaximizedModeEvent (spk::MaximizedModeEvent &p_event)
 Maximized mode change handler.
virtual void _onFocusEvent (spk::FocusEvent &p_event)
 Focus change handler hook.
virtual void _onUpdateEvent (spk::UpdateEvent &p_event)
 Frame update handler hook.

Additional Inherited Members

Static Public Member Functions inherited from spk::Widget
static WidgetfocusedWidget (FocusType p_focusType)
 Retrieves the widget currently owning a focus type.
Static Public Attributes inherited from spk::Widget
static const size_t NbFocusType = 2
 Number of focus slots tracked at runtime.

Detailed Description

template<typename TType>
class spk::NumericSpinBox< TType >

Numeric input widget with increment/decrement controls.

Template Parameters
TTypeNumeric value type.
spin.setValue(10);
Widget * parent() const
Definition spk_inherence_object.hpp:85
Numeric input widget with increment/decrement controls.
Definition spk_numeric_spin_box.hpp:31

Constructor & Destructor Documentation

◆ NumericSpinBox()

template<typename TType>
spk::NumericSpinBox< TType >::NumericSpinBox ( const std::wstring & p_name,
spk::Widget * p_parent )
inline

Builds a numeric spin box widget.

Parameters
p_nameWidget name.
p_parentParent widget.

Member Function Documentation

◆ _onGeometryChange()

template<typename TType>
void spk::NumericSpinBox< TType >::_onGeometryChange ( )
inlineoverrideprotectedvirtual

Updates layout geometry when size changes.

Reimplemented from spk::Widget.

◆ lowerButton()

template<typename TType>
IconButton & spk::NumericSpinBox< TType >::lowerButton ( )
inline

Returns the decrement button.

Returns
Decrement button reference.

◆ raiseButton()

template<typename TType>
IconButton & spk::NumericSpinBox< TType >::raiseButton ( )
inline

Returns the increment button.

Returns
Increment button reference.

◆ setMinimalTextEditSize()

template<typename TType>
void spk::NumericSpinBox< TType >::setMinimalTextEditSize ( uint32_t p_minimalTextEditSize)
inline

Sets the minimal width of the text edit field.

Parameters
p_minimalTextEditSizeMinimum width in pixels.

◆ setStep()

template<typename TType>
void spk::NumericSpinBox< TType >::setStep ( const value_type & p_step)
inline

Sets the increment/decrement step.

Parameters
p_stepStep value.

◆ setValue()

template<typename TType>
void spk::NumericSpinBox< TType >::setValue ( const value_type & p_value)
inline

Sets the current numeric value.

Parameters
p_valueValue to assign.
Here is the caller graph for this function:

◆ step()

template<typename TType>
const value_type & spk::NumericSpinBox< TType >::step ( ) const
inline

Returns the increment/decrement step.

Returns
Step value.

◆ subscribeToEdition()

template<typename TType>
EditionContract spk::NumericSpinBox< TType >::subscribeToEdition ( const EditionJob & p_job)
inline

Subscribes to value edition notifications.

Parameters
p_jobCallback invoked on value change.
Returns
Subscription contract.

◆ value()

template<typename TType>
const value_type & spk::NumericSpinBox< TType >::value ( ) const
inline

Returns the current numeric value.

Returns
Value reference.

◆ valueEdit() [1/2]

template<typename TType>
TextEdit & spk::NumericSpinBox< TType >::valueEdit ( )
inline

Returns the value text edit.

Returns
Mutable text edit reference.

◆ valueEdit() [2/2]

template<typename TType>
const TextEdit & spk::NumericSpinBox< TType >::valueEdit ( ) const
inline

Returns the value text edit.

Returns
Const text edit reference.

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