#include <shortcut_manager.h>
Public Types | |
| using | ActiveEditorProvider = std::function<std::optional<EditorType>()> |
Public Member Functions | |
| void | RegisterShortcut (const std::string &name, const std::vector< ImGuiKey > &keys, Shortcut::Scope scope=Shortcut::Scope::kGlobal) |
| void | RegisterShortcut (const std::string &name, const std::vector< ImGuiKey > &keys, std::function< void()> callback, Shortcut::Scope scope=Shortcut::Scope::kGlobal) |
| void | RegisterShortcut (const std::string &name, ImGuiKey key, std::function< void()> callback, Shortcut::Scope scope=Shortcut::Scope::kGlobal) |
| void | RegisterEditorShortcut (const std::string &name, const std::vector< ImGuiKey > &keys, std::function< void()> callback, EditorType editor_type) |
| Register an editor-owned shortcut (Scope::kEditor). | |
| void | RegisterCommand (const std::string &name, std::function< void()> callback, Shortcut::Scope scope=Shortcut::Scope::kGlobal) |
| Register a command without keyboard shortcut (command palette only) | |
| bool | SetShortcutEditor (const std::string &name, std::optional< EditorType > editor_type) |
| Restrict an existing shortcut to one editor. Returns false if unknown. | |
| bool | SetShortcutEnabled (const std::string &name, std::function< bool()> enabled) |
| Attach an applicability predicate. Returns false if unknown. | |
| void | SetActiveEditorProvider (ActiveEditorProvider provider) |
| std::optional< EditorType > | GetActiveEditorType () const |
| bool | IsShortcutApplicable (const Shortcut &shortcut) const |
| True when the shortcut may fire now (editor owner + enabled predicate). | |
| void | ExecuteShortcut (const std::string &name) const |
| const Shortcut & | GetShortcut (const std::string &name) const |
| const Shortcut * | FindShortcut (const std::string &name) const |
| std::function< void()> | GetCallback (const std::string &name) const |
| const std::string | GetKeys (const std::string &name) const |
| std::string | GetDisplayString (const std::string &name) const |
| Live, platform-formatted binding for a shortcut name. | |
| const std::unordered_map< std::string, Shortcut > & | GetShortcuts () const |
| bool | UpdateShortcutKeys (const std::string &name, const std::vector< ImGuiKey > &keys) |
| bool | ResetShortcutKeys (const std::string &name) |
| Restore the keys the shortcut was registered with. | |
| std::vector< std::string > | FindConflicts (const std::string &name) const |
| Names of other shortcuts bound to the same chord that can be active at the same time (same editor owner, or either one unowned). Sorted by name. Keyless shortcuts never conflict. | |
| std::vector< std::string > | FindConflicts (const std::vector< ImGuiKey > &keys, std::optional< EditorType > editor_type, const std::string &exclude_name="") const |
| std::vector< Shortcut > | GetShortcutsByScope (Shortcut::Scope scope) const |
| void | RegisterStandardShortcuts (std::function< void()> save_callback, std::function< void()> open_callback, std::function< void()> close_callback, std::function< void()> find_callback, std::function< void()> settings_callback) |
| void | RegisterWindowNavigationShortcuts (std::function< void()> focus_left, std::function< void()> focus_right, std::function< void()> focus_up, std::function< void()> focus_down, std::function< void()> close_window, std::function< void()> split_horizontal, std::function< void()> split_vertical) |
Private Member Functions | |
| void | Store (Shortcut shortcut) |
Private Attributes | |
| std::unordered_map< std::string, Shortcut > | shortcuts_ |
| ActiveEditorProvider | active_editor_provider_ |
Definition at line 52 of file shortcut_manager.h.
| using yaze::editor::ShortcutManager::ActiveEditorProvider = std::function<std::optional<EditorType>()> |
Definition at line 54 of file shortcut_manager.h.
|
inline |
Definition at line 56 of file shortcut_manager.h.
References Store().
Referenced by yaze::editor::anonymous_namespace{shortcut_configurator.cc}::RegisterIfValid(), yaze::editor::anonymous_namespace{shortcut_configurator.cc}::RegisterIfValid(), RegisterStandardShortcuts(), and RegisterWindowNavigationShortcuts().

|
inline |
Definition at line 61 of file shortcut_manager.h.
References Store().

|
inline |
Definition at line 68 of file shortcut_manager.h.
References Store().

|
inline |
Register an editor-owned shortcut (Scope::kEditor).
The shortcut is ignored during arbitration unless editor_type is the active editor, so another editor's binding for the same chord can win.
Definition at line 80 of file shortcut_manager.h.
References yaze::editor::Shortcut::kEditor, and Store().
Referenced by yaze::editor::anonymous_namespace{shortcut_configurator.cc}::RegisterEditorIfValid().

|
inline |
Register a command without keyboard shortcut (command palette only)
These commands appear in the command palette but have no keyboard binding. Useful for layout presets and other infrequently used commands.
Definition at line 96 of file shortcut_manager.h.
References Store().
Referenced by yaze::editor::ConfigureEditorShortcuts(), and yaze::editor::anonymous_namespace{shortcut_configurator.cc}::RegisterAlias().

| bool yaze::editor::ShortcutManager::SetShortcutEditor | ( | const std::string & | name, |
| std::optional< EditorType > | editor_type ) |
Restrict an existing shortcut to one editor. Returns false if unknown.
Definition at line 472 of file shortcut_manager.cc.
References shortcuts_.
Referenced by yaze::editor::ConfigurePanelShortcuts().
| bool yaze::editor::ShortcutManager::SetShortcutEnabled | ( | const std::string & | name, |
| std::function< bool()> | enabled ) |
Attach an applicability predicate. Returns false if unknown.
Definition at line 482 of file shortcut_manager.cc.
References shortcuts_.
|
inline |
Supplies the active editor used to filter editor-owned shortcuts. When unset, editor-owned shortcuts are treated as applicable.
Definition at line 110 of file shortcut_manager.h.
References active_editor_provider_.
Referenced by yaze::editor::ConfigureEditorShortcuts().
|
inline |
Definition at line 113 of file shortcut_manager.h.
References active_editor_provider_.
| bool yaze::editor::ShortcutManager::IsShortcutApplicable | ( | const Shortcut & | shortcut | ) | const |
True when the shortcut may fire now (editor owner + enabled predicate).
Definition at line 492 of file shortcut_manager.cc.
References active_editor_provider_, yaze::editor::Shortcut::editor_type, and yaze::editor::Shortcut::enabled.
Referenced by yaze::editor::ExecuteShortcuts().
|
inline |
Definition at line 120 of file shortcut_manager.h.
References shortcuts_.
|
inline |
Definition at line 125 of file shortcut_manager.h.
References shortcuts_.
|
inline |
Definition at line 129 of file shortcut_manager.h.
References shortcuts_.
Referenced by yaze::editor::ApplyUserShortcutOverrides(), yaze::editor::anonymous_namespace{settings_panel.cc}::DrawShortcutBindingRow(), yaze::editor::RightDrawerManager::GetShortcutLabel(), yaze::platform::native_menu::PerformAction(), yaze::editor::ShortcutCommandsProvider::Provide(), yaze::editor::anonymous_namespace{shortcut_configurator.cc}::RegisterAlias(), yaze::platform::native_menu::ResolveItem(), and yaze::editor::anonymous_namespace{menu_orchestrator.cc}::RunShortcutAction().
|
inline |
Definition at line 135 of file shortcut_manager.h.
References shortcuts_.
|
inline |
Definition at line 139 of file shortcut_manager.h.
References yaze::editor::PrintShortcut(), and shortcuts_.

| std::string yaze::editor::ShortcutManager::GetDisplayString | ( | const std::string & | name | ) | const |
Live, platform-formatted binding for a shortcut name.
Returns e.g. "Cmd+Shift+Z" on macOS or "Ctrl+Shift+Z" elsewhere, reflecting user rebinds. Returns an empty string for unknown or unbound names, so menus and the command palette can omit the hint.
Definition at line 505 of file shortcut_manager.cc.
References yaze::editor::PrintShortcut(), and shortcuts_.
Referenced by yaze::editor::OverworldToolbar::Draw(), yaze::editor::OverworldToolbar::DrawViewControls(), yaze::editor::DungeonEditorV2::Initialize(), yaze::editor::OverworldEditor::Initialize(), yaze::editor::LookupShortcutHint(), yaze::editor::ShortcutLabelForAction(), and yaze::editor::OverworldToolbar::WithHint().

|
inline |
Definition at line 152 of file shortcut_manager.h.
References shortcuts_.
Referenced by yaze::editor::UICoordinator::DrawShortcutsBrowser(), yaze::platform::native_menu::anonymous_namespace{native_menu_bridge.cc}::ExactShortcutConflict(), yaze::editor::ExecuteShortcuts(), and yaze::editor::ShortcutCommandsProvider::Provide().
| bool yaze::editor::ShortcutManager::UpdateShortcutKeys | ( | const std::string & | name, |
| const std::vector< ImGuiKey > & | keys ) |
Definition at line 453 of file shortcut_manager.cc.
References shortcuts_.
Referenced by yaze::editor::ApplyUserShortcutOverrides(), and yaze::editor::anonymous_namespace{settings_panel.cc}::DrawShortcutBindingRow().
| bool yaze::editor::ShortcutManager::ResetShortcutKeys | ( | const std::string & | name | ) |
Restore the keys the shortcut was registered with.
Definition at line 463 of file shortcut_manager.cc.
References shortcuts_.
Referenced by yaze::editor::anonymous_namespace{settings_panel.cc}::DrawShortcutBindingRow().
| std::vector< std::string > yaze::editor::ShortcutManager::FindConflicts | ( | const std::string & | name | ) | const |
Names of other shortcuts bound to the same chord that can be active at the same time (same editor owner, or either one unowned). Sorted by name. Keyless shortcuts never conflict.
Definition at line 513 of file shortcut_manager.cc.
References FindConflicts(), and shortcuts_.
Referenced by yaze::editor::ConfigurePanelShortcuts(), yaze::editor::anonymous_namespace{settings_panel.cc}::DrawShortcutBindingRow(), and FindConflicts().

| std::vector< std::string > yaze::editor::ShortcutManager::FindConflicts | ( | const std::vector< ImGuiKey > & | keys, |
| std::optional< EditorType > | editor_type, | ||
| const std::string & | exclude_name = "" ) const |
Definition at line 522 of file shortcut_manager.cc.
References yaze::editor::SameChord(), and shortcuts_.

|
inline |
Definition at line 170 of file shortcut_manager.h.
References shortcuts_.
Referenced by yaze::editor::SettingsPanel::DrawEditorShortcuts(), and yaze::editor::SettingsPanel::DrawGlobalShortcuts().
| void yaze::editor::ShortcutManager::RegisterStandardShortcuts | ( | std::function< void()> | save_callback, |
| std::function< void()> | open_callback, | ||
| std::function< void()> | close_callback, | ||
| std::function< void()> | find_callback, | ||
| std::function< void()> | settings_callback ) |
Definition at line 553 of file shortcut_manager.cc.
References RegisterShortcut().

| void yaze::editor::ShortcutManager::RegisterWindowNavigationShortcuts | ( | std::function< void()> | focus_left, |
| std::function< void()> | focus_right, | ||
| std::function< void()> | focus_up, | ||
| std::function< void()> | focus_down, | ||
| std::function< void()> | close_window, | ||
| std::function< void()> | split_horizontal, | ||
| std::function< void()> | split_vertical ) |
Definition at line 587 of file shortcut_manager.cc.
References RegisterShortcut().

|
inlineprivate |
Definition at line 196 of file shortcut_manager.h.
References yaze::editor::Shortcut::default_keys, yaze::editor::Shortcut::keys, yaze::editor::Shortcut::name, and shortcuts_.
Referenced by RegisterCommand(), RegisterEditorShortcut(), RegisterShortcut(), RegisterShortcut(), and RegisterShortcut().
|
private |
Definition at line 202 of file shortcut_manager.h.
Referenced by ExecuteShortcut(), FindConflicts(), FindConflicts(), FindShortcut(), GetCallback(), GetDisplayString(), GetKeys(), GetShortcut(), GetShortcuts(), GetShortcutsByScope(), ResetShortcutKeys(), SetShortcutEditor(), SetShortcutEnabled(), Store(), and UpdateShortcutKeys().
|
private |
Definition at line 203 of file shortcut_manager.h.
Referenced by GetActiveEditorType(), IsShortcutApplicable(), and SetActiveEditorProvider().