|
TachyonUI 1.1.0
High-performance UI for building tools.
|
State of the open menus (menu bar dropdowns, context menus, submenus) and their mouse and keyboard behaviour; one per application. More...
#include <gui_controls/gui_menu_manager.h>
Classes | |
| struct | Level |
| One open menu: the root dropdown or a submenu. More... | |
| struct | PopupWindow |
Public Member Functions | |
| ID | PopupWindowFor (ID triggerID, IDManager &idManager) |
| The popup window ID of triggerID's menu. | |
| void | ReleaseWindowIDs (IDManager &idManager) |
| Gives back the window IDs its levels and popups were given: at exit. | |
| bool | IsMenuBarTrigger (ID id) const |
| True iff id was registered as a menu-bar trigger this frame. | |
| Level & | GetOrCreateNextLevel (IDManager &idManager) |
| The level below currentDepth, with a window ID assigned on first use. | |
| void | BeginFrame (GUIStateManager &guiStateManager, OSWindowManager &windowManager) |
| Unhides the cursor on real mouse movement and closes all menus once none has an active item or a focused trigger. | |
| void | EndFrame (ElementStorage &elementStorage, GUIStateManager &guiStateManager) |
| Updates the scroll indicators from this frame's layout. | |
| void | CloseFromDepth (int fromDepth) |
| Closes level fromDepth and every level below it; window IDs are kept for reuse. | |
| bool | IsOpen () const |
| True while the root menu is open. | |
| bool | IsBalanced () const |
| True iff every BeginMenu was matched by EndMenu. | |
| void | RequestCloseAll () |
| Closes all menus once construction is back outside them (in the outermost EndMenu). | |
| void | CloseOnInputOutside (const InputManager &inputManager, const ElementStorage &elementStorage, GUIStateManager &guiStateManager) |
| Closes all menus on a press or scroll this frame outside them and the open menu's trigger (which toggles it itself). | |
| void | PrepareLevelWindow (Level &level, ScrollManagement &scrollManagement) |
| Call before BeginWindow(level.windowID): a reopened level starts at the top (its window ID, and so its scroll offset, persists across close/reopen). | |
| void | OpenSubmenu (int parentDepth, ID triggerID) |
| Opens the level below parentDepth for submenu trigger triggerID, focusing its first item. | |
| void | CloseAll (GUIStateManager &guiStateManager) |
| Closes all menus and restores prior focus (the only place that does). | |
| void | CloseAll (GUIStateManager &guiStateManager, OSWindowManager &windowManager) |
| As CloseAll(), and also hides the OS windows at once, for when the frame loop isn't running (such as during the OS modal move/resize loop). | |
| void | ToggleOrOpenMenu (GUIStateManager &guiStateManager, ID id, bool focusIntoMenu=true) |
| Closes the root menu of trigger id when it is open, else opens it (see OpenMenu). | |
| void | OpenMenu (GUIStateManager &guiStateManager, ID id, bool focusIntoMenu=true) |
| Opens the root menu of trigger id, replacing any open menu. | |
| bool | ClickMenu (GUIStateManager &guiStateManager, bool isSubmenu, int depth, ID currentItemID, std::function< void()> onClick) |
| Activates item currentItemID at depth: runs onClick and closes all menus, or for a submenu trigger (isSubmenu) opens its submenu. | |
| bool | NavigateMenuSibling (GUIStateManager &guiStateManager, ElementStorage &elementStorage, bool isSubmenu, int depth, ID currentItemID, KeyCode key) |
| Handles Escape, Left/Right or Up/Down key on item currentItemID at depth. True if handled. | |
| bool | NavigateMenuBar (GUIStateManager &guiStateManager, ID currentTriggerID, KeyCode key) |
| Left/Right between menu-bar triggers; an open dropdown follows. True if handled. | |
| void | EnterMenuFromTrigger (GUIStateManager &guiStateManager, ID triggerID) |
| Focuses the first item of the trigger's dropdown, opening it if needed. | |
Public Attributes | |
| Level | levels [kMaxDepth] |
| int | currentDepth = -1 |
| int | maxOpenDepth = -1 |
| bool | requestCloseAll = false |
| ID | justClosedTriggerID = ID::Invalid() |
| Trigger whose menu closed this frame; its own click doesn't reopen it. | |
| ID | priorFocusID = ID::Invalid() |
| focus to restore when all menus close | |
| int | suppressedSubmenuTriggerDepth = -1 |
| Depth of a submenu the Left key closed; it doesn't auto-reopen until the parent's activeItemID changes. | |
| bool | skipActivityCheck = false |
| Set when a menu opens: skips the next BeginFrame auto-close (construction hasn't set the triggerIDs yet) and CloseOnInputOutside for the input that opened it. | |
| bool | mouseHiddenForMenu = false |
| set by keyboard nav, cleared on mouse move | |
| int2 | lastMousePos = {0, 0} |
| to detect real mouse movement | |
| bool | focusSubmenuOnOpen = false |
| select and focus the first item of the next opened level | |
| bool | navigatedThisFrame = false |
| throttle: at most one Up/Down navigation per frame | |
| std::unordered_map< ID, bool > | menuItemsHaveIcons |
| Per trigger ID: whether the menu had icons last time, so a reopen reserves the icon column on its first frame. | |
| std::vector< PopupWindow > | popupWindows |
| uint64_t | popupWindowUses = 0 |
| bool | buildingMenuBar = false |
| true while a menu bar is being built | |
| std::vector< ID > | menuBarTriggers |
| Menu-bar triggers in order, registered during construction for Left/Right navigation. | |
Static Public Attributes | |
| static constexpr int | kMaxDepth = 8 |
| deepest submenu nesting, root included | |
| static constexpr size_t | kMaxPopupWindows = 8 |
| The popup windows of the menus used last, one per trigger, so switching between them never shows another menu's last frame while the new one renders. | |
State of the open menus (menu bar dropdowns, context menus, submenus) and their mouse and keyboard behaviour; one per application.
The popup window ID of triggerID's menu.
| void tachyon::MenuManager::ReleaseWindowIDs | ( | IDManager & | idManager | ) |
Gives back the window IDs its levels and popups were given: at exit.
| bool tachyon::MenuManager::IsMenuBarTrigger | ( | ID | id | ) | const |
True iff id was registered as a menu-bar trigger this frame.
The level below currentDepth, with a window ID assigned on first use.
| void tachyon::MenuManager::BeginFrame | ( | GUIStateManager & | guiStateManager, |
| OSWindowManager & | windowManager ) |
Unhides the cursor on real mouse movement and closes all menus once none has an active item or a focused trigger.
| void tachyon::MenuManager::EndFrame | ( | ElementStorage & | elementStorage, |
| GUIStateManager & | guiStateManager ) |
Updates the scroll indicators from this frame's layout.
| void tachyon::MenuManager::CloseFromDepth | ( | int | fromDepth | ) |
Closes level fromDepth and every level below it; window IDs are kept for reuse.
|
inline |
True while the root menu is open.
|
inline |
True iff every BeginMenu was matched by EndMenu.
| void tachyon::MenuManager::RequestCloseAll | ( | ) |
Closes all menus once construction is back outside them (in the outermost EndMenu).
| void tachyon::MenuManager::CloseOnInputOutside | ( | const InputManager & | inputManager, |
| const ElementStorage & | elementStorage, | ||
| GUIStateManager & | guiStateManager ) |
Closes all menus on a press or scroll this frame outside them and the open menu's trigger (which toggles it itself).
Call before the input is dispatched.
| void tachyon::MenuManager::PrepareLevelWindow | ( | Level & | level, |
| ScrollManagement & | scrollManagement ) |
Call before BeginWindow(level.windowID): a reopened level starts at the top (its window ID, and so its scroll offset, persists across close/reopen).
| void tachyon::MenuManager::OpenSubmenu | ( | int | parentDepth, |
| ID | triggerID ) |
Opens the level below parentDepth for submenu trigger triggerID, focusing its first item.
| void tachyon::MenuManager::CloseAll | ( | GUIStateManager & | guiStateManager | ) |
Closes all menus and restores prior focus (the only place that does).
| void tachyon::MenuManager::CloseAll | ( | GUIStateManager & | guiStateManager, |
| OSWindowManager & | windowManager ) |
As CloseAll(), and also hides the OS windows at once, for when the frame loop isn't running (such as during the OS modal move/resize loop).
| void tachyon::MenuManager::ToggleOrOpenMenu | ( | GUIStateManager & | guiStateManager, |
| ID | id, | ||
| bool | focusIntoMenu = true ) |
Closes the root menu of trigger id when it is open, else opens it (see OpenMenu).
Does nothing for the trigger whose menu closed this frame.
| void tachyon::MenuManager::OpenMenu | ( | GUIStateManager & | guiStateManager, |
| ID | id, | ||
| bool | focusIntoMenu = true ) |
Opens the root menu of trigger id, replacing any open menu.
focusIntoMenu focuses the first item (context menus, dropdowns); false keeps focus on the trigger (menu bar).
| bool tachyon::MenuManager::ClickMenu | ( | GUIStateManager & | guiStateManager, |
| bool | isSubmenu, | ||
| int | depth, | ||
| ID | currentItemID, | ||
| std::function< void()> | onClick ) |
Activates item currentItemID at depth: runs onClick and closes all menus, or for a submenu trigger (isSubmenu) opens its submenu.
Returns true.
| bool tachyon::MenuManager::NavigateMenuSibling | ( | GUIStateManager & | guiStateManager, |
| ElementStorage & | elementStorage, | ||
| bool | isSubmenu, | ||
| int | depth, | ||
| ID | currentItemID, | ||
| KeyCode | key ) |
Handles Escape, Left/Right or Up/Down key on item currentItemID at depth. True if handled.
| bool tachyon::MenuManager::NavigateMenuBar | ( | GUIStateManager & | guiStateManager, |
| ID | currentTriggerID, | ||
| KeyCode | key ) |
Left/Right between menu-bar triggers; an open dropdown follows. True if handled.
| void tachyon::MenuManager::EnterMenuFromTrigger | ( | GUIStateManager & | guiStateManager, |
| ID | triggerID ) |
Focuses the first item of the trigger's dropdown, opening it if needed.
|
staticconstexpr |
deepest submenu nesting, root included
| int tachyon::MenuManager::currentDepth = -1 |
| int tachyon::MenuManager::maxOpenDepth = -1 |
| bool tachyon::MenuManager::requestCloseAll = false |
| ID tachyon::MenuManager::justClosedTriggerID = ID::Invalid() |
Trigger whose menu closed this frame; its own click doesn't reopen it.
| ID tachyon::MenuManager::priorFocusID = ID::Invalid() |
focus to restore when all menus close
| int tachyon::MenuManager::suppressedSubmenuTriggerDepth = -1 |
Depth of a submenu the Left key closed; it doesn't auto-reopen until the parent's activeItemID changes.
-1 = none.
| bool tachyon::MenuManager::skipActivityCheck = false |
Set when a menu opens: skips the next BeginFrame auto-close (construction hasn't set the triggerIDs yet) and CloseOnInputOutside for the input that opened it.
| bool tachyon::MenuManager::mouseHiddenForMenu = false |
set by keyboard nav, cleared on mouse move
| int2 tachyon::MenuManager::lastMousePos = {0, 0} |
to detect real mouse movement
| bool tachyon::MenuManager::focusSubmenuOnOpen = false |
select and focus the first item of the next opened level
| bool tachyon::MenuManager::navigatedThisFrame = false |
throttle: at most one Up/Down navigation per frame
| std::unordered_map<ID, bool> tachyon::MenuManager::menuItemsHaveIcons |
Per trigger ID: whether the menu had icons last time, so a reopen reserves the icon column on its first frame.
|
staticconstexpr |
The popup windows of the menus used last, one per trigger, so switching between them never shows another menu's last frame while the new one renders.
At most kMaxPopupWindows: the one used longest ago is handed to the next new trigger (each is an OS window with a swapchain; a list of dropdowns mustn't keep one each).
| std::vector<PopupWindow> tachyon::MenuManager::popupWindows |
| uint64_t tachyon::MenuManager::popupWindowUses = 0 |
| bool tachyon::MenuManager::buildingMenuBar = false |
true while a menu bar is being built
| std::vector<ID> tachyon::MenuManager::menuBarTriggers |
Menu-bar triggers in order, registered during construction for Left/Right navigation.