Study Dungeon  1.0.0
A group project for COSC345
Public Member Functions
ConsoleUI::Menu Class Reference

Defines the menu that is made of buttons. More...

#include <menu.h>

Public Member Functions

 Menu (bool horizontal=false)
 Construct a new Menu object. More...
 
void addButton (const std::string &label, std::function< void()> action)
 Add a button to the menu. More...
 
void draw (int x, int y)
 Draw the menu. More...
 
void handleInput ()
 Handle the user input on the menu.
 
bool isBackButtonPressed () const
 determines if the menu back button has been pressed More...
 
size_t getButtonCount () const
 Get the number of buttons in the menu. More...
 
size_t getButtonWidth (size_t index) const
 Get the width of the button by index. More...
 
size_t getSelectedIndex () const
 Get the index of the selected menu button. More...
 
void selectPreviousButton ()
 select the previous button in the menu
 
void selectNextButton ()
 selecte the next button in the menu
 
size_t getMaxWidth () const
 Get the width of the widest button in the menu. More...
 
void activateSelectedButton ()
 Perform the associated function from the button.
 
void clear ()
 removes all buttons in the menu
 

Detailed Description

Defines the menu that is made of buttons.

Constructor & Destructor Documentation

◆ Menu()

ConsoleUI::Menu::Menu ( bool  horizontal = false)

Construct a new Menu object.

Parameters
horizontalis the menu horizontal or vertical

Member Function Documentation

◆ addButton()

void ConsoleUI::Menu::addButton ( const std::string &  label,
std::function< void()>  action 
)

Add a button to the menu.

Parameters
labelthe label on the button
actionthe function associtated with the button

◆ draw()

void ConsoleUI::Menu::draw ( int  x,
int  y 
)

Draw the menu.

Parameters
xleft most position
ytop most position

◆ getButtonCount()

size_t ConsoleUI::Menu::getButtonCount ( ) const

Get the number of buttons in the menu.

Returns
size_t

◆ getButtonWidth()

size_t ConsoleUI::Menu::getButtonWidth ( size_t  index) const

Get the width of the button by index.

Parameters
indexindex of the button in the menu
Returns
size_t

◆ getMaxWidth()

size_t ConsoleUI::Menu::getMaxWidth ( ) const

Get the width of the widest button in the menu.

Returns
size_t

◆ getSelectedIndex()

size_t ConsoleUI::Menu::getSelectedIndex ( ) const
inline

Get the index of the selected menu button.

Returns
size_t

◆ isBackButtonPressed()

bool ConsoleUI::Menu::isBackButtonPressed ( ) const

determines if the menu back button has been pressed

Returns
true back button pressed
false back button not pressed

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