class GUIMenuBar

A menu bar GUI element that contains a horizontal list of elements that can each be expanded into a hierarchical sub-menus, as well as a list of tool bar buttons.

Contents of the menu and tool bar are customizable.

The menu bar also displays the minimize, maximize and close buttons for the window.

Public

Constructors

GUIMenuBar

GUIMenuBar(const HGUIWidget &parent, RenderWindow *parentWindow)

Constructs a new menu bar.

parent
Parent GUI widget the menu bar will be docked in.
parentWindow
Window to trigger the min/max/close events on.

Methods

staticGetLogoStyleType

static const String &GetLogoStyleType()

Returns the style type for the menu bar logo.

staticGetToolBarButtonStyleType

static const String &GetToolBarButtonStyleType()

Returns the style type for tool bar buttons.

~GUIMenuBar

virtual ~GUIMenuBar()

SetArea

void SetArea(const GUILogicalArea &area)

Sets the area of the menu bar, in pixels relative to the parent GUI widget.

AddMenuItem

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

Adds a new menu item to the menu bar.

path
Path to the menu item. Each element of the path must be separated using "/". First element of the path will create the top level menu, and any further element will create a new sub-menu. Last element will be the interactable element.
callback
Callback to trigger when user click on the interactable element (last element in the provided path). Can be null.
priority
Determines where is the element positioned compared to other elements in the same sub-menu. Higher priority elements get placed higher up in the sub-menu. This only applies to the last element. If you need to customize its parent element priority call this method with with their specific paths.
shortcut
Keyboard shortcut key to display next to the interactable element, and register with the global shortcut manager.

AddMenuItemSeparator

GUIMenuItem *AddMenuItemSeparator(const String &path, i32 priority = 0)

Adds a menu item separator element at the specified path.

The separator is added as a child of the path.

path
Parent path of the sub-menu to add the separator.
priority
Determines where is the separator positioned compared to other elements in the same sub-menu. Higher priority elements get placed higher up in the sub-menu.

GetMenuItem

GUIMenuItem *GetMenuItem(const String &path)

Returns an existing menu item at the specified path, or null if one cannot be found.

RemoveMenuItem

void RemoveMenuItem(const String &path)

Removes a menu item from the specified path.

If this path points to a sub-menu entire sub-menu will be removed.

RemoveMenuItem

void RemoveMenuItem(GUIMenuItem *item)

Removes the specified menu item.

AddToolBarButton

void AddToolBarButton(const String &name, const GUIContent &content, std::function<void ()> callback, i32 priority = 0)

Adds a new button to the tool bar.

name
Unique name of the button that can be used for identifiying it.
content
Content to display on the button.
callback
Callback to trigger when the button is pressed.
priority
Determines where is the button positioned compared to other elements on the tool bar. Higher priority elements get placed before lower priority ones.

ToggleToolbarButton

void ToggleToolbarButton(const String &name, bool on)

Toggles an existing toolbar button into an on or off state which changes the visuals of the button.

name
Name of the existing button to toggle.
on
True to toggle on, false to toggle off (default).

AddToolBarSeparator

void AddToolBarSeparator(const String &name, i32 priority = 0)

Adds a new separator element to the tool bar.

name
Unique name of the separator that can be used for identifiying it.
priority
Determines where is the separator positioned compared to other elements on the tool bar. Higher priority elements get placed before lower priority ones.

RemoveToolBarButton

void RemoveToolBarButton(const String &name)

Removes an element from the tool bar.

name
Unique name of the element to remove.

Private

Methods

GetSubMenu

const GUIMenuBarData *GetSubMenu(const String &name) const

Finds a top level sub-menu with the specified name.

AddNewButton

GUIMenuBarData *AddNewButton(const String &name, i32 priority)

Adds a new top level sub-menu button.

StripPath

bool StripPath(String &path, String &pathRoot) const

Attempts to remove the first element from the specified path.

First element returned in specified in , and original is modified so it no longer includes the first element.

Returns: False if first element doesn't exist, true otherwise.

RegisterShortcut

void RegisterShortcut(const String &path, const ShortcutKey &shortcut, std::function<void ()> callback)

Registers a shortcut with the global shortcut manager.

Pressing the shortcut will trigger the provided callback.

UnregisterShortcut

void UnregisterShortcut(const String &path)

Unregisters a shortcut assigned to the provided path from the global shortcut manager.

OpenSubMenu

void OpenSubMenu(const String &name)

Opens a top level sub-menu with the provided name.

CloseSubMenu

void CloseSubMenu()

Closes any currently active sub-menu.

OnSubMenuHover

void OnSubMenuHover(const String &name)

Triggered when a sub-menu is open and a user hovers over another top level sub-menu button.

name
Name of the sub-menu the user is hovering over.

OnSubMenuClosed

void OnSubMenuClosed()

Triggered when a sub-menu is closed.

OnMinimizeClicked

void OnMinimizeClicked()

Triggered when the minimize button is clicked.

Minimizes the attached window.

OnMaximizeClicked

void OnMaximizeClicked()

Triggered when the maximize button is clicked.

Maximizes the attached window.

OnCloseClicked

void OnCloseClicked()

Triggered when the close button is clicked.

Closes the attached window.

RefreshNonClientAreas

void RefreshNonClientAreas()

Refreshes the OS client area that allow the window to be dragged by dragging the empty areas on the menu bar.

Should be called when top level button configuration changes or menu bar area changes.

Fields

mParentWindow

RenderWindow * mParentWindow

mMainPanel

GUIPanel * mMainPanel

mBgPanel

GUIPanel * mBgPanel

mMenuItemLayout

GUILayout * mMenuItemLayout

mToolBarLayout

GUILayout * mToolBarLayout

mBgTexture

GUITexture * mBgTexture

mLogoTexture

GUITexture * mLogoTexture

mSplitterLine

GUITexture * mSplitterLine

mMinBtn

GUIButton * mMinBtn

mMaxBtn

GUIButton * mMaxBtn

mCloseBtn

GUIButton * mCloseBtn

mChildMenus

Vector<GUIMenuBarData> mChildMenus

mEntryShortcuts

UnorderedMap<String, ShortcutKey> mEntryShortcuts

mToolbarElements

Vector<GUIToolBarData> mToolbarElements

mSubMenuButton

GUIButton * mSubMenuButton

mSubMenuOpen

bool mSubMenuOpen