ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::ui::FocusManager Class Reference

Manages focus navigation for UI widgets. More...

#include <context.h>

Collaboration diagram for asw::ui::FocusManager:
[legend]

Public Member Functions

void rebuild (Context &ctx, Widget &root)
 Rebuild the focusable widget list from the widget tree.
 
Widgetfocused () const
 Get the currently focused widget.
 
void set_focus (Context &ctx, Widget *w)
 Set focus to a specific widget.
 
void focus_next (Context &ctx)
 Move focus to the next focusable widget.
 
void focus_prev (Context &ctx)
 Move focus to the previous focusable widget.
 
void focus_dir (Context &ctx, int dx, int dy)
 Move focus in a direction based on widget positions.
 

Private Member Functions

void dfs (Widget &w)
 

Private Attributes

std::vector< Widget * > focusables_
 
Widgetfocused_ = nullptr
 

Detailed Description

Manages focus navigation for UI widgets.

Definition at line 21 of file context.h.

Member Function Documentation

◆ dfs()

void asw::ui::FocusManager::dfs ( Widget & w)
private

Definition at line 138 of file context.cpp.

◆ focus_dir()

void asw::ui::FocusManager::focus_dir ( Context & ctx,
int dx,
int dy )

Move focus in a direction based on widget positions.

Parameters
ctxThe UI context.
dxHorizontal direction (-1, 0, or 1).
dyVertical direction (-1, 0, or 1).

Definition at line 82 of file context.cpp.

◆ focus_next()

void asw::ui::FocusManager::focus_next ( Context & ctx)

Move focus to the next focusable widget.

Parameters
ctxThe UI context.

Definition at line 36 of file context.cpp.

◆ focus_prev()

void asw::ui::FocusManager::focus_prev ( Context & ctx)

Move focus to the previous focusable widget.

Parameters
ctxThe UI context.

Definition at line 58 of file context.cpp.

◆ focused()

Widget * asw::ui::FocusManager::focused ( ) const
inline

Get the currently focused widget.

Returns
Pointer to the focused widget, or nullptr.

Definition at line 34 of file context.h.

◆ rebuild()

void asw::ui::FocusManager::rebuild ( Context & ctx,
Widget & root )

Rebuild the focusable widget list from the widget tree.

Parameters
ctxThe UI context.
rootThe root widget to traverse.

Definition at line 6 of file context.cpp.

◆ set_focus()

void asw::ui::FocusManager::set_focus ( Context & ctx,
Widget * w )

Set focus to a specific widget.

Parameters
ctxThe UI context.
wThe widget to focus.

Definition at line 22 of file context.cpp.

Member Data Documentation

◆ focusables_

std::vector<Widget*> asw::ui::FocusManager::focusables_
private

Definition at line 69 of file context.h.

◆ focused_

Widget* asw::ui::FocusManager::focused_ = nullptr
private

Definition at line 70 of file context.h.


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