Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
ui::MenuModel Class Reference

Menu state that supports controller and keyboard navigation. More...

#include <src/ui/menu_model.h>

Public Member Functions

MenuUpdate handle_command (input::UiCommand command)
 Apply a UI command to the menu.
 
const std::vector< MenuItem > & items () const
 Return the configured items.
 
 MenuModel (std::vector< MenuItem > items={})
 Construct a menu from a list of items.
 
bool select_item_by_id (std::string_view itemId)
 Select a specific enabled item by its stable identifier.
 
std::size_t selected_index () const
 Return the selected item index or npos when none is selectable.
 
const MenuItemselected_item () const
 Return the selected item or nullptr when none is selectable.
 
void set_items (std::vector< MenuItem > items)
 Replace the menu items and select the first enabled entry.
 

Static Public Attributes

static constexpr std::size_t npos = std::numeric_limits<std::size_t>::max()
 Sentinel index used when no menu item is selectable.
 

Detailed Description

Menu state that supports controller and keyboard navigation.

Constructor & Destructor Documentation

◆ MenuModel()

ui::MenuModel::MenuModel ( std::vector< MenuItem > items = {})
explicit

Construct a menu from a list of items.

Parameters
itemsMenu items in display order.

Member Function Documentation

◆ handle_command()

MenuUpdate ui::MenuModel::handle_command ( input::UiCommand command)

Apply a UI command to the menu.

Parameters
commandCommand 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
itemIdIdentifier 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
itemsMenu items in display order.

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