Manages focus navigation for UI widgets.
More...
#include <context.h>
|
| Widget * | default_focus = nullptr |
| | Widget focused by the first navigation press when nothing has focus. The first focusable widget when null.
|
| |
Manages focus navigation for UI widgets.
Definition at line 23 of file context.h.
◆ dfs()
| void asw::ui::FocusManager::dfs |
( |
Widget & | w | ) |
|
|
private |
◆ focus_dir()
| void asw::ui::FocusManager::focus_dir |
( |
Context & | ctx, |
|
|
int | dx, |
|
|
int | dy ) |
Move focus in a direction based on widget positions.
A widget's nav_up, nav_down, nav_left or nav_right wins when set. Otherwise widgets in the same lane (overlapping across the direction) win over the rest, then the nearest edge to edge, then the one closest to the lane repeated moves started in.
- Parameters
-
| ctx | The UI context. |
| dx | Horizontal direction (-1, 0, or 1). |
| dy | Vertical direction (-1, 0, or 1). |
Definition at line 94 of file context.cpp.
◆ focus_next()
| void asw::ui::FocusManager::focus_next |
( |
Context & | ctx | ) |
|
Move focus to the next focusable widget.
- Parameters
-
Definition at line 50 of file context.cpp.
◆ focus_prev()
| void asw::ui::FocusManager::focus_prev |
( |
Context & | ctx | ) |
|
Move focus to the previous focusable widget.
- Parameters
-
Definition at line 71 of file context.cpp.
◆ focus_start()
| bool asw::ui::FocusManager::focus_start |
( |
Context & | ctx | ) |
|
Focus default_focus, or the first focusable widget, when nothing has focus.
- Parameters
-
- Returns
- True if focus was set.
Definition at line 19 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 29 of file context.h.
◆ rebuild()
| void asw::ui::FocusManager::rebuild |
( |
Context & | ctx, |
|
|
Widget & | root ) |
|
private |
◆ set_focus()
| void asw::ui::FocusManager::set_focus |
( |
Context & | ctx, |
|
|
Widget * | w ) |
Set focus to a specific widget.
- Parameters
-
| ctx | The UI context. |
| w | The widget to focus. |
Definition at line 31 of file context.cpp.
◆ Root
◆ _focusables
| std::vector<Widget*> asw::ui::FocusManager::_focusables |
|
private |
◆ _focused
| Widget* asw::ui::FocusManager::_focused = nullptr |
|
private |
◆ _focused_found
| bool asw::ui::FocusManager::_focused_found = false |
|
private |
◆ _lane_x
| std::optional<float> asw::ui::FocusManager::_lane_x |
|
private |
◆ _lane_y
| std::optional<float> asw::ui::FocusManager::_lane_y |
|
private |
◆ default_focus
| Widget* asw::ui::FocusManager::default_focus = nullptr |
Widget focused by the first navigation press when nothing has focus. The first focusable widget when null.
Definition at line 43 of file context.h.
The documentation for this class was generated from the following files: