R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
UI::IMenu Class Referenceabstract

Abstract interface for UI menus. More...

#include <IMenu.hpp>

Inheritance diagram for UI::IMenu:
Inheritance graph
Collaboration diagram for UI::IMenu:
Collaboration graph

Public Member Functions

virtual ~IMenu ()=default
 Virtual destructor.
 
virtual void Update ()=0
 Update all menu elements.
 
virtual void Render ()=0
 Render all menu elements.
 
virtual void AddButton (std::shared_ptr< IButton > button)=0
 Add a button to the menu.
 
virtual void RemoveButton (size_t index)=0
 Remove a button from the menu by index.
 
virtual std::shared_ptr< IButtonGetButton (size_t index)=0
 Get a button by index.
 
virtual size_t GetButtonCount () const =0
 Get the number of buttons in the menu.
 
virtual void Clear ()=0
 Remove all buttons from the menu.
 
virtual void SetVisible (bool visible)=0
 Set menu visibility.
 
virtual bool IsVisible () const =0
 Check menu visibility.
 
virtual void HandleKeyboardNavigation ()=0
 Handle keyboard navigation input.
 
virtual void SelectNext ()=0
 Select the next navigable element.
 
virtual void SelectPrevious ()=0
 Select the previous navigable element.
 
virtual void TriggerSelected ()=0
 Trigger the currently selected element (simulate click).
 
virtual int GetSelectedIndex () const =0
 Get the index of the currently selected element.
 
virtual void SetSelectedIndex (int index)=0
 Set the selected element by index.
 

Detailed Description

Abstract interface for UI menus.

A menu is a container of UI elements (currently: buttons only). It is responsible for:

  • updating contained elements (input handling)
  • rendering contained elements
  • controlling visibility

This interface is part of the UI library layer and is designed to be backend-agnostic.

Definition at line 29 of file IMenu.hpp.

Constructor & Destructor Documentation

◆ ~IMenu()

virtual UI::IMenu::~IMenu ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ AddButton()

virtual void UI::IMenu::AddButton ( std::shared_ptr< IButton button)
pure virtual

Add a button to the menu.

Parameters
buttonShared pointer to the button to add.

Implemented in UI::RaylibMenu.

◆ Clear()

virtual void UI::IMenu::Clear ( )
pure virtual

Remove all buttons from the menu.

Implemented in UI::RaylibMenu.

◆ GetButton()

virtual std::shared_ptr< IButton > UI::IMenu::GetButton ( size_t  index)
pure virtual

Get a button by index.

Parameters
indexIndex of the button.
Returns
Shared pointer to the button, or nullptr if out of range.

Implemented in UI::RaylibMenu.

◆ GetButtonCount()

virtual size_t UI::IMenu::GetButtonCount ( ) const
pure virtual

Get the number of buttons in the menu.

Returns
Number of buttons.

Implemented in UI::RaylibMenu.

◆ GetSelectedIndex()

virtual int UI::IMenu::GetSelectedIndex ( ) const
pure virtual

Get the index of the currently selected element.

Returns
Selected index, or -1 if none selected.

Implemented in UI::RaylibMenu.

◆ HandleKeyboardNavigation()

virtual void UI::IMenu::HandleKeyboardNavigation ( )
pure virtual

Handle keyboard navigation input.

Note
Call this in Update() to enable Tab/Shift+Tab/Enter navigation.

Implemented in UI::RaylibMenu.

◆ IsVisible()

virtual bool UI::IMenu::IsVisible ( ) const
pure virtual

Check menu visibility.

Returns
true if visible.

Implemented in UI::RaylibMenu.

◆ RemoveButton()

virtual void UI::IMenu::RemoveButton ( size_t  index)
pure virtual

Remove a button from the menu by index.

Parameters
indexIndex of the button to remove.

Implemented in UI::RaylibMenu.

◆ Render()

virtual void UI::IMenu::Render ( )
pure virtual

Render all menu elements.

Note
Must be called between the backend BeginDrawing/EndDrawing calls.

Implemented in UI::RaylibMenu.

◆ SelectNext()

virtual void UI::IMenu::SelectNext ( )
pure virtual

Select the next navigable element.

Note
Wraps around to first element when at the end.

Implemented in UI::RaylibMenu.

◆ SelectPrevious()

virtual void UI::IMenu::SelectPrevious ( )
pure virtual

Select the previous navigable element.

Note
Wraps around to last element when at the beginning.

Implemented in UI::RaylibMenu.

◆ SetSelectedIndex()

virtual void UI::IMenu::SetSelectedIndex ( int  index)
pure virtual

Set the selected element by index.

Parameters
indexIndex of element to select, or -1 to clear selection.

Implemented in UI::RaylibMenu.

◆ SetVisible()

virtual void UI::IMenu::SetVisible ( bool  visible)
pure virtual

Set menu visibility.

Parameters
visibletrue to show the menu, false to hide it.

Implemented in UI::RaylibMenu.

◆ TriggerSelected()

virtual void UI::IMenu::TriggerSelected ( )
pure virtual

Trigger the currently selected element (simulate click).

Implemented in UI::RaylibMenu.

◆ Update()

virtual void UI::IMenu::Update ( )
pure virtual

Update all menu elements.

Note
Should be called once per frame.

Implemented in UI::RaylibMenu.


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