Menu state that supports controller and keyboard navigation.
More...
#include <src/ui/menu_model.h>
|
|
static constexpr std::size_t | npos = std::numeric_limits<std::size_t>::max() |
| | Sentinel index used when no menu item is selectable.
|
| |
Menu state that supports controller and keyboard navigation.
◆ MenuModel()
| ui::MenuModel::MenuModel |
( |
std::vector< MenuItem > | items = {} | ) |
|
|
explicit |
Construct a menu from a list of items.
- Parameters
-
| items | Menu items in display order. |
◆ handle_command()
Apply a UI command to the menu.
- Parameters
-
| command | Command from controller or keyboard input. |
- Returns
- Details about selection changes and passthrough actions.
◆ items()
| const std::vector< MenuItem > & ui::MenuModel::items |
( |
| ) |
const |
|
nodiscard |
Return the configured items.
- Returns
- Immutable view of the menu items in display order.
◆ select_item_by_id()
| bool ui::MenuModel::select_item_by_id |
( |
std::string_view | itemId | ) |
|
Select a specific enabled item by its stable identifier.
- Parameters
-
| itemId | Identifier to select. |
- Returns
- true when the selection changed.
◆ selected_index()
| std::size_t ui::MenuModel::selected_index |
( |
| ) |
const |
|
nodiscard |
Return the selected item index or npos when none is selectable.
- Returns
- Selected item index or npos.
◆ selected_item()
| const MenuItem * ui::MenuModel::selected_item |
( |
| ) |
const |
|
nodiscard |
Return the selected item or nullptr when none is selectable.
- Returns
- Pointer to the selected item, or nullptr when unavailable.
◆ set_items()
| void ui::MenuModel::set_items |
( |
std::vector< MenuItem > | items | ) |
|
Replace the menu items and select the first enabled entry.
- Parameters
-
| items | Menu items in display order. |
The documentation for this class was generated from the following files: