Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::UISlider Class Reference

An interactive value-selector bar supporting mouse dragging and gamepad focus adjustments. More...

#include <flint/ui/widgets/slider.h>

+ Inheritance diagram for Flint::UISlider:
+ Collaboration diagram for Flint::UISlider:

Classes

struct  SliderProperties
 Architectural constraints governing value clamping and stepping metrics. More...
 
struct  SliderStyle
 Visual properties defining the slider track, fill area, and thumb indicator. More...
 

Public Member Functions

FLINT_API void setProperties (SliderProperties properties)
 Assigns minimum, maximum, and quantization stepping properties.
 
FLINT_API void setRange (float min, float max)
 Sets the absolute functional minimum and maximum selection boundaries.
 
FLINT_API void setStyle (const SliderStyle &style)
 Overrides the visual style parameters for the track and slider handles.
 
FLINT_API void setTrackHeight (float height)
 
FLINT_API void setThumbWidth (float width)
 
FLINT_API void setThumbHeight (float height)
 
FLINT_API void setThumbColor (const Color &color)
 
FLINT_API void setFillColor (const Color &color)
 
FLINT_API void setTrackColor (const Color &color)
 
FLINT_API float applyStep (float value) const
 Snaps a raw value to the nearest incremental step boundary configuration.
 
FLINT_API void setValue (float value)
 Sets the tracking selection value directly, applying steps and clamps.
 
const SliderProperties & getProperties () const
 
const SliderStyle & getStyle () const
 
const float & getValue () const
 Gets the current stepped, clamped value of the slider.
 
FLINT_API void setFocused (bool focused) override
 Sets whether this node is currently focused.
 
FLINT_API void measure (UIConstraints constraints) override
 Pass 1 of the layout engine: Crawls branches recursively to compute base display boundaries requested by child assets.
 
FLINT_API void arrange (const Rect< float > &rect) override
 Pass 2 of the layout engine: Evaluates layout adjustments to pin final screen coordinate values to the tree structures.
 
FLINT_API void handleEvent (const UIEvent &event) override
 Routes interaction updates, translating drag motions and directional navigations.
 
FLINT_API void render (UICanvas &canvas) const override
 Draws the slider track background, active fill bar, and handle quad.
 
bool consumesDirectionalInput () const override
 Dictates whether this widget captures directional inputs instead of passing them to focus navigation.
 
bool isFocusable () const override
 Dictates if keyboard selection trackers or gamepad vectors can snap control focuses onto this item.
 
FLINT_API void onChange (std::function< void(float)> callback)
 Registers a function callback to execute whenever the slider value mutations occur.
 
FLINT_API bool hitTest (Vec2f point) const override
 Computes true if a vector coordinate sits inside the spatial arrangement bounding tracking layout box.
 
- Public Member Functions inherited from Flint::UINode
FLINT_API void setContext (UIContext *context)
 Recursively propagates a pointer back to the parent-managing workspace layer.
 
FLINT_API void addChild (std::unique_ptr< UINode > child)
 Inserts a child widget to live inside this layout element container boundary.
 
FLINT_API void setPosition (Vec2f position)
 Updates the relative local rendering position coordinates of this element block.
 
Vec2f getPosition () const
 Get the node's relative local position.
 
FLINT_API void setSize (Vec2f size)
 Assigns a manual static override layout budget footprint dimensions limit.
 
Vec2f getSize () const
 Get the node's base size.
 
FLINT_API void setVisible (bool visible)
 Sets widget visibility.
 
FLINT_API void setEnabled (bool enabled)
 Enables or disables user interaction for this widget.
 
FLINT_API void setID (std::string id)
 Sets a unique string identifier for this node.
 
FLINT_API const std::string & getId () const
 Gets the unique lookup ID string of this node.
 
FLINT_API const Rect< float > & getLayoutRect () const
 Gets the final screen-space bounding box calculated during the arrange pass.
 
bool isVisible () const
 
bool isEnabled () const
 
Vec2f getDesiredSize () const
 Get the node's requested size from the measure pass.
 
const std::vector< std::unique_ptr< UINode > > & getChildren () const
 Get the list of this node's child nodes.
 
FLINT_API void setText (std::string text)
 Sets the text content for widgets that display text.
 
FLINT_API const std::string & getText () const
 Gets the current text content of the widget.
 
FLINT_API void setFontSize (uint16_t fontSize)
 Set the rendering font size in points.
 
FLINT_API uint16_t getFontSize () const
 
FLINT_API void setColor (Color color)
 Sets the base color of the widget.
 
FLINT_API Color getColor () const
 
virtual void setNormalColor (Color color)
 Sets the base color of the widget.
 
virtual void setActiveColor (Color color)
 Sets visual colors used when inputs hover across or lock selections on the widget container.
 
void setFont (std::string name)
 Assigns a custom typography description token mapping back to cached font elements.
 
void setFontWeight (uint16_t weight)
 Assigns thickness parameters across structural type vectors (e.g., 400 for regular, 700 for bold).
 
void setTextOpticalBias (float bias)
 
float getTextOpticalBias () const
 
bool isFocused () const
 
FLINT_API void setHorizontalAlign (UIAlign align)
 
FLINT_API void setVerticalAlign (UIAlign align)
 
FLINT_API UIAlign getHorizontalAlign () const
 
FLINT_API UIAlign getVerticalAlign () const
 
FLINT_API void setLayoutGrow (float grow)
 Assigns dynamic expansion multipliers used to balance alignment distributions inside sequential layout panels.
 
FLINT_API float getLayoutGrow () const
 Gets the dynamic expansion weight used inside stack layout grids.
 

Protected Member Functions

FLINT_API const Color & currentColor () const override
 Resolves handle colors by evaluating hover, active focus, and dragging parameters.
 
- Protected Member Functions inherited from Flint::UINode

Additional Inherited Members

- Protected Attributes inherited from Flint::UINode
std::string m_id
 
UINode * m_parent = nullptr
 
std::vector< std::unique_ptr< UINode > > m_children
 
Vec2f m_localPosition {}
 
Vec2f m_desiredSize {}
 
Vec2f m_baseSize {}
 
Rect< float > m_layoutRect {}
 
bool m_visible = true
 
bool m_enabled = true
 
float m_displayScale = 1.0f
 
std::string m_fontName
 
uint16_t m_fontWeight = 400
 
uint16_t m_fontSize = 16
 
float m_textOpticalBias = 0.f
 
std::string m_text
 
Color m_normalColor = Colors::white
 
Color m_activeColor = {0, 255, 0, 255}
 
bool m_hovered = false
 
bool m_focused = false
 
UIAlign m_horizontalAlign = UIAlign::Stretch
 
UIAlign m_verticalAlign = UIAlign::Start
 
float m_layoutGrow = 0.f
 

Detailed Description

An interactive value-selector bar supporting mouse dragging and gamepad focus adjustments.

Definition at line 17 of file slider.h.

Member Function Documentation

◆ applyStep()

FLINT_API float Flint::UISlider::applyStep ( float value) const

Snaps a raw value to the nearest incremental step boundary configuration.

Parameters
valueThe raw unbound scalar input value.
Returns
The value rounded to the nearest active incremental step.

◆ arrange()

FLINT_API void Flint::UISlider::arrange ( const Rect< float > & rect)
overridevirtual

Pass 2 of the layout engine: Evaluates layout adjustments to pin final screen coordinate values to the tree structures.

Parameters
rectThe absolute coordinate grid budget segment assigned to this specific node box by the parent manager.

Reimplemented from Flint::UINode.

◆ consumesDirectionalInput()

bool Flint::UISlider::consumesDirectionalInput ( ) const
inlineoverridevirtual

Dictates whether this widget captures directional inputs instead of passing them to focus navigation.

Note
Override this to return true for widgets that use keyboard or gamepad navigation for internal values, like adjusting a slider or moving a text box caret.
Returns true to block focus shifts while adjusting slider values.

Reimplemented from Flint::UINode.

Definition at line 98 of file slider.h.

◆ currentColor()

FLINT_API const Color & Flint::UISlider::currentColor ( ) const
overrideprotectedvirtual

Resolves handle colors by evaluating hover, active focus, and dragging parameters.

Reimplemented from Flint::UINode.

◆ getProperties()

const SliderProperties & Flint::UISlider::getProperties ( ) const
inlinenodiscard

Definition at line 68 of file slider.h.

◆ getStyle()

const SliderStyle & Flint::UISlider::getStyle ( ) const
inlinenodiscard

Definition at line 72 of file slider.h.

◆ getValue()

const float & Flint::UISlider::getValue ( ) const
inlinenodiscard

Gets the current stepped, clamped value of the slider.

Definition at line 77 of file slider.h.

◆ handleEvent()

FLINT_API void Flint::UISlider::handleEvent ( const UIEvent & event)
overridevirtual

Routes interaction updates, translating drag motions and directional navigations.

Note
Catches UIEventType::NavigateLeft and UIEventType::NavigateRight packets while focused to allow gamepad/keyboard modifications.

Reimplemented from Flint::UINode.

◆ hitTest()

FLINT_API bool Flint::UISlider::hitTest ( Vec2f point) const
overridevirtual

Computes true if a vector coordinate sits inside the spatial arrangement bounding tracking layout box.

Reimplemented from Flint::UINode.

◆ isFocusable()

bool Flint::UISlider::isFocusable ( ) const
inlineoverridevirtual

Dictates if keyboard selection trackers or gamepad vectors can snap control focuses onto this item.

Note
Returns true.

Reimplemented from Flint::UINode.

Definition at line 105 of file slider.h.

◆ measure()

FLINT_API void Flint::UISlider::measure ( UIConstraints constraints)
overridevirtual

Pass 1 of the layout engine: Crawls branches recursively to compute base display boundaries requested by child assets.

Parameters
constraintsSpatial boundaries and global display density multipliers passed down by parent vectors.

Reimplemented from Flint::UINode.

◆ render()

FLINT_API void Flint::UISlider::render ( UICanvas & canvas) const
overridevirtual

Draws the slider track background, active fill bar, and handle quad.

Reimplemented from Flint::UINode.

◆ setFocused()

FLINT_API void Flint::UISlider::setFocused ( bool focused)
overridevirtual

Sets whether this node is currently focused.

Reimplemented from Flint::UINode.


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