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

Manages an isolated user interface canvas workspace sandbox, hosting its own independent node tree and interaction state trackers. More...

#include <flint/ui/ui-context.h>

+ Collaboration diagram for Flint::UIContext:

Public Member Functions

FLINT_API UIContext (std::string name)
 Instantiates a named user interface workspace canvas.
 
 UIContext (const UIContext &)=delete
 
UIContext & operator= (const UIContext &)=delete
 
 UIContext (UIContext &&)=delete
 
UIContext & operator= (UIContext &&)=delete
 
FLINT_API const std::string & getName () const
 Returns the identifier lookup key string assigned to this workspace context layer.
 
FLINT_API void setRoot (std::unique_ptr< UINode > root)
 Sets the root node of the UI hierarchy.
 
FLINT_API UINode * getRoot () const
 Extracts a non-owning pointer to the base root element layout tracking map.
 
FLINT_API void update (float deltaTime)
 Advances internal animation chronometers or custom ticking scripts linked across the canvas layer.
 
FLINT_API void handleEvent (const UIEvent &event)
 Intercepts semantic UI framework event packets to calculate canvas spatial routing updates.
 
FLINT_API void render (UICanvas &canvas) const
 Intercepts semantic UI framework event packets to calculate canvas spatial routing updates.
 
FLINT_API UINode * findById (const std::string &id) const
 Performs a linear tree-search traversal to locate a specific element matching the provided identifier token.
 
FLINT_API UINode * getHoveredNode () const
 Returns a non-owning pointer to the interactive widget currently sitting directly beneath the mouse cursor bounding box.
 
FLINT_API UINode * getFocusedNode () const
 Returns a non-owning pointer to the interactive widget currently holding active keyboard or gamepad directional input priorities.
 
FLINT_API UIInputMode getInputMode () const
 Extracts the persistent context tracking mode used to choose visual layouts and prompt glyph representations.
 
FLINT_API void setFocusedNode (UINode *node)
 Explicitly shifts directional focus priorities straight to a target element node.
 
FLINT_API void clearFocus ()
 Strips focus flags cleanly away from all active tree elements, returning the canvas interaction state back to resting values.
 
void setDisplayScale (float scale)
 Sets a local resolution scale coefficient factor to properly offset layout metrics for DPI matching targets.
 
FLINT_API void setInputMode (UIInputMode mode)
 Modifies the active user interaction mode tracker state context.
 
float getDisplayScale () const
 Extracts the local scale coefficient factor used to translate base pixel assets for resolution alignment metrics.
 
void addTexture (std::shared_ptr< GPUTexture > tex)
 
std::unique_ptr< UINode > releaseRoot ()
 

Detailed Description

Manages an isolated user interface canvas workspace sandbox, hosting its own independent node tree and interaction state trackers.

UIContext represents a distinct UI layout layer (such as a Main Menu, Pause Overlay, or HUD). It handles specialized spatial queries like pointer hit-testing, orchestrates keyboard/gamepad focus tree navigation, and triggers the top-level dual-pass layout pipeline initialization during the frame's rendering cycle.

Definition at line 28 of file ui-context.h.

Member Function Documentation

◆ addTexture()

void Flint::UIContext::addTexture ( std::shared_ptr< GPUTexture > tex)
inline

Definition at line 137 of file ui-context.h.

◆ findById()

FLINT_API UINode * Flint::UIContext::findById ( const std::string & id) const
nodiscard

Performs a linear tree-search traversal to locate a specific element matching the provided identifier token.

Note
Runs at O(N) traversal costs across layout branches. For highly active frame loops, cache the extracted widget pointer output locally inside the state initializer.
Parameters
idThe descriptive identifier search key string assigned via setID().
Returns
Pointer to the targeted object element, or nullptr if no matching ID block is found.

◆ getDisplayScale()

float Flint::UIContext::getDisplayScale ( ) const
inlinenodiscard

Extracts the local scale coefficient factor used to translate base pixel assets for resolution alignment metrics.

Definition at line 133 of file ui-context.h.

◆ handleEvent()

FLINT_API void Flint::UIContext::handleEvent ( const UIEvent & event)

Intercepts semantic UI framework event packets to calculate canvas spatial routing updates.

Note
Dynamically mutates focus states based on hardware transitions (e.g., clearing focused nodes if a mouse movement event fires while currently navigating via gamepad or keyboard mode).
Parameters
eventThe translated input payload configuration packet.
See also
UIInputMode, UIEventType

◆ releaseRoot()

std::unique_ptr< UINode > Flint::UIContext::releaseRoot ( )
inline

Definition at line 141 of file ui-context.h.

◆ render()

FLINT_API void Flint::UIContext::render ( UICanvas & canvas) const

Intercepts semantic UI framework event packets to calculate canvas spatial routing updates.

Note
Dynamically mutates focus states based on hardware transitions (e.g., clearing focused nodes if a mouse movement event fires while currently navigating via gamepad or keyboard mode).
Parameters
eventThe translated input payload configuration packet.
See also
UIInputMode, UIEventType

◆ setDisplayScale()

void Flint::UIContext::setDisplayScale ( float scale)
inline

Sets a local resolution scale coefficient factor to properly offset layout metrics for DPI matching targets.

Definition at line 121 of file ui-context.h.

◆ setFocusedNode()

FLINT_API void Flint::UIContext::setFocusedNode ( UINode * node)

Explicitly shifts directional focus priorities straight to a target element node.

Note
Safely informs the preceding node of its focus loss and updates internal highlight state tracking variables.
Parameters
nodeNon-owning raw reference pointer mapping to the prioritized target widget element.

◆ setRoot()

FLINT_API void Flint::UIContext::setRoot ( std::unique_ptr< UINode > root)

Sets the root node of the UI hierarchy.

Note
Takes absolute ownership of the node tree. Any existing root node, along with active hover and focus states, is immediately dropped and cleared. Assigning a new root automatically propagates this context pointer recursively down the subtree.
Parameters
rootUnique pointer to the new root widget node.
See also
UINode::setContext

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