Plutonium framework API 1.0.0
Easy-to-use, SDL2-based UI framework for Nintendo Switch homebrew
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pu::ui::elm::MenuItem Class Reference

Represents a menu item. More...

#include <elm_Menu.hpp>

Public Types

using OnKeyCallback = std::function<void()>
 Represents a function called when the specific key is pressed over a the MenuItem.
 

Public Member Functions

 MenuItem (const std::string &name)
 Creates a new instance of a MenuItem.
 
std::string GetName ()
 Gets the name of the MenuItem.
 
void SetName (const std::string &name)
 Sets the name of the MenuItem.
 
void AddOnKey (OnKeyCallback on_key_cb, const u64 key=HidNpadButton_A)
 Adds a new OnKeyCallback to the MenuItem.
 
u32 GetOnKeyCallbackCount ()
 Gets the amount of OnKeyCallbacks in the MenuItem.
 
OnKeyCallback GetOnKeyCallback (const u32 idx)
 Gets the OnKeyCallback at the specified index.
 
u64 GetOnKeyCallbackKey (const u32 idx)
 Gets the key of the OnKeyCallback at the specified index.
 
sdl2::TextureHandle::Ref GetIconTexture ()
 Gets the icon of the MenuItem.
 
void SetIcon (sdl2::TextureHandle::Ref icon)
 Sets the icon of the MenuItem.
 
bool HasIcon ()
 Gets whether the MenuItem has an icon.
 

Static Public Attributes

static constexpr Color DefaultColor = { 10, 10, 10, 0xFF }
 

Detailed Description

Represents a menu item.

Member Typedef Documentation

◆ OnKeyCallback

using pu::ui::elm::MenuItem::OnKeyCallback = std::function<void()>

Represents a function called when the specific key is pressed over a the MenuItem.

Constructor & Destructor Documentation

◆ MenuItem()

pu::ui::elm::MenuItem::MenuItem ( const std::string & name)
inline

Creates a new instance of a MenuItem.

Parameters
nameName of the MenuItem.

Member Function Documentation

◆ AddOnKey()

void pu::ui::elm::MenuItem::AddOnKey ( OnKeyCallback on_key_cb,
const u64 key = HidNpadButton_A )

Adds a new OnKeyCallback to the MenuItem.

Parameters
on_key_cbFunction to call when the key is pressed.
keyKey to call the function on. Default is A.

◆ GetIconTexture()

sdl2::TextureHandle::Ref pu::ui::elm::MenuItem::GetIconTexture ( )
inline

Gets the icon of the MenuItem.

Returns
Icon of the MenuItem.

◆ GetName()

std::string pu::ui::elm::MenuItem::GetName ( )
inline

Gets the name of the MenuItem.

Returns
Name of the MenuItem.

◆ GetOnKeyCallback()

OnKeyCallback pu::ui::elm::MenuItem::GetOnKeyCallback ( const u32 idx)
inline

Gets the OnKeyCallback at the specified index.

Parameters
idxIndex of the OnKeyCallback.
Returns
OnKeyCallback at the specified index.

◆ GetOnKeyCallbackCount()

u32 pu::ui::elm::MenuItem::GetOnKeyCallbackCount ( )
inline

Gets the amount of OnKeyCallbacks in the MenuItem.

Returns
Amount of OnKeyCallbacks in the MenuItem.

◆ GetOnKeyCallbackKey()

u64 pu::ui::elm::MenuItem::GetOnKeyCallbackKey ( const u32 idx)
inline

Gets the key of the OnKeyCallback at the specified index.

Parameters
idxIndex of the OnKeyCallback.
Returns
Key of the OnKeyCallback at the specified index.

◆ HasIcon()

bool pu::ui::elm::MenuItem::HasIcon ( )
inline

Gets whether the MenuItem has an icon.

Returns
Whether the MenuItem has an icon.

◆ SetIcon()

void pu::ui::elm::MenuItem::SetIcon ( sdl2::TextureHandle::Ref icon)

Sets the icon of the MenuItem.

Parameters
iconIcon to set.

◆ SetName()

void pu::ui::elm::MenuItem::SetName ( const std::string & name)
inline

Sets the name of the MenuItem.

Parameters
nameNew name of the MenuItem.

Member Data Documentation

◆ DefaultColor

Color pu::ui::elm::MenuItem::DefaultColor = { 10, 10, 10, 0xFF }
staticconstexpr

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