MenuComponent Class
Manages a collection of menu items for UI navigation. More...
Declaration
Public Member Functions Index
| void | setMenuId (helios::engine::modules::ui::widgets::types::MenuId id) noexcept |
|
Sets the menu identifier. More... | |
| helios::engine::modules::ui::widgets::types::MenuId | menuId () const noexcept |
|
Returns the menu identifier. More... | |
| void | setSelectedIndex (const size_t index) noexcept |
|
Sets the currently selected item index. More... | |
| void | selectDefaultIndex () |
|
Resets selection to the default index. More... | |
| size_t | selectedIndex () const noexcept |
|
Returns the currently selected item index. More... | |
| void | addMenuItem (const helios::engine::ecs::GameObject menuItem) |
|
Adds a menu item to the end of the list. More... | |
| std::span< helios::engine::ecs::EntityHandle > | menuItems () noexcept |
|
Returns a span of all menu item handles. More... | |
| void | clearDirty () |
|
Clears the dirty flag. More... | |
| void | markDirty () |
|
Marks the menu as dirty. More... | |
| bool | isDirty () const noexcept |
|
Returns whether the menu state has changed. More... | |
| size_t | previousSelectedIndex () const noexcept |
|
Returns the index of the previous selected menu index. More... | |
| void | insert (const helios::engine::ecs::GameObject menuItem, const size_t index) |
|
Inserts a menu item at a specific index. More... | |
Private Member Attributes Index
| std::vector< helios::engine::ecs::EntityHandle > | menuItems_ |
|
Entity handles of the menu items. More... | |
| helios::engine::modules::ui::widgets::types::MenuId | menuId_ {} |
|
Unique identifier for this menu. More... | |
| size_t | selectedIndex_ = 0 |
|
Currently selected item index. More... | |
| size_t | previousSelectedIndex_ = 0 |
|
Previously selected item index. More... | |
| size_t | defaultSelectedIndex_ = 0 |
|
Default selection index when menu is focused. More... | |
| bool | isDirty_ = true |
|
Whether the menu state has changed. More... | |
Description
Manages a collection of menu items for UI navigation.
Stores entity handles to menu items and tracks the currently selected item index. Supports dirty tracking for efficient updates.
- See Also
MenuDisplaySystem
- See Also
MenuNavigationSystem
Definition at line 27 of file MenuComponent.ixx.
Public Member Functions
addMenuItem()
| inline |
Adds a menu item to the end of the list.
- Parameters
-
menuItem The GameObject to add as a menu item.
Definition at line 116 of file MenuComponent.ixx.
References helios::engine::ecs::GameObject::entityHandle and markDirty.
clearDirty()
| inline |
Clears the dirty flag.
Definition at line 133 of file MenuComponent.ixx.
insert()
| inline |
Inserts a menu item at a specific index.
Resizes the internal vector if necessary. If the item already exists at the index, no action is taken.
- Parameters
-
menuItem The GameObject to insert.
index The index at which to insert.
Definition at line 171 of file MenuComponent.ixx.
isDirty()
| inline nodiscard noexcept |
Returns whether the menu state has changed.
- Returns
True if dirty.
Definition at line 149 of file MenuComponent.ixx.
markDirty()
| inline |
Marks the menu as dirty.
Definition at line 140 of file MenuComponent.ixx.
Referenced by addMenuItem and setSelectedIndex.
menuId()
| inline nodiscard noexcept |
Returns the menu identifier.
- Returns
The MenuId for this menu.
Definition at line 75 of file MenuComponent.ixx.
menuItems()
| inline nodiscard noexcept |
Returns a span of all menu item handles.
- Returns
Span of EntityHandle for all menu items.
Definition at line 126 of file MenuComponent.ixx.
Referenced by helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update.
previousSelectedIndex()
| inline nodiscard noexcept |
Returns the index of the previous selected menu index.
- Returns
The index of the previous selected menu item.
Definition at line 158 of file MenuComponent.ixx.
selectDefaultIndex()
| inline |
Resets selection to the default index.
Definition at line 97 of file MenuComponent.ixx.
Reference setSelectedIndex.
selectedIndex()
| inline nodiscard noexcept |
Returns the currently selected item index.
- Returns
The selected index.
Definition at line 106 of file MenuComponent.ixx.
Referenced by helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update.
setMenuId()
| inline noexcept |
Sets the menu identifier.
- Parameters
-
id The menu ID.
Definition at line 66 of file MenuComponent.ixx.
setSelectedIndex()
| inline noexcept |
Sets the currently selected item index.
Marks the menu as dirty if the index changes.
- Parameters
-
index The index to select.
Definition at line 86 of file MenuComponent.ixx.
Reference markDirty.
Referenced by selectDefaultIndex.
Private Member Attributes
defaultSelectedIndex_
|
Default selection index when menu is focused.
Definition at line 52 of file MenuComponent.ixx.
isDirty_
|
Whether the menu state has changed.
Definition at line 57 of file MenuComponent.ixx.
menuId_
|
Unique identifier for this menu.
Definition at line 37 of file MenuComponent.ixx.
menuItems_
|
Entity handles of the menu items.
Definition at line 32 of file MenuComponent.ixx.
previousSelectedIndex_
|
Previously selected item index.
Definition at line 47 of file MenuComponent.ixx.
selectedIndex_
|
Currently selected item index.
Definition at line 42 of file MenuComponent.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.