class GUIMenu

Class that allows creation of menus with drop down functionality.

Menu consists out of a number of top level elements, each of which opens a drop down menu which may internally hold a deeper hierarchy of menus.

Public

Constructors

GUIMenu

GUIMenu()

Methods

~GUIMenu

virtual ~GUIMenu() noexcept

AddMenuItem

GUIMenuItem *AddMenuItem(const String &path, std::function<void ()> callback, i32 priority, const ShortcutKey &key = ShortcutKey::kNone)

Adds a new menu item with the specified callback.

path
Path that determines where to add the element. See class information on how to specify paths. All sub-elements of a path will be added automatically.
callback
Callback that triggers when the path element is selected.
priority
Priority determines the position of the menu item relative to its siblings. Higher priority means it will be placed earlier in the menu.
key
Keyboard shortcut that can be used for triggering the menu item.

Returns: A menu item object that you may use for removing the menu item later. Its lifetime is managed internally.

AddSeparator

GUIMenuItem *AddSeparator(const String &path, i32 priority)

Adds a new separator menu item with the specified callback.

path
Path that determines where to add the element. See class information on how to specify paths. All sub-elements of a path will be added automatically.
priority
Priority determines the position of the menu item relative to its siblings. Higher priority means it will be placed earlier in the menu.

Returns: A menu item object that you may use for removing the menu item later. Its lifetime is managed internally.

GetMenuItem

GUIMenuItem *GetMenuItem(const String &path)

Returns a menu item at the specified path, or null if one is not found.

RemoveMenuItem

void RemoveMenuItem(const GUIMenuItem *item)

Removes the specified menu item from the path.

If the menu item has any sub-menus they will also be removed.

SetLocalizedName

void SetLocalizedName(const String &menuItemLabel, const HString &localizedName)

Normally menu items use values from their paths as their names.

However path labels don't provide a way of localizing the menu item. This method allows you to set specific names (different from path labels) to each menu item. All the values are localized so they will also be updated according to the string table.

menuItemLabel
The menu item label. (for example if you have a menu like "View/Toolbars/Find, this parameter would be either "View", "Toolbars" or "Find" depending which entry you want to localize)
localizedName
Localized string with the name.

GetDropDownData

GUIDropDownData GetDropDownData() const

Returns data used for initializing a drop down list, for all elements.

Protected

Methods

AddMenuItemInternal

GUIMenuItem *AddMenuItemInternal(const String &path, std::function<void ()> callback, bool isSeparator, i32 priority, const ShortcutKey &key)

Adds a menu item at the specified path, as a normal button or as a separator.

GetDropDownDataInternal

GUIDropDownData GetDropDownDataInternal(const GUIMenuItem &menu) const

Return drop down data for the specified menu.

Fields

mRootElement

GUIMenuItem mRootElement

mLocalizedEntryNames

UnorderedMap<String, HString> mLocalizedEntryNames

mNextIdx

u32 mNextIdx