Manages keyboard shortcuts and provides an overlay UI. More...
#include <keyboard_shortcuts.h>
Public Member Functions | |
| void | RegisterShortcut (const Shortcut &shortcut) |
| void | RegisterShortcut (const std::string &id, const std::string &description, ImGuiKey key, bool ctrl, bool shift, bool alt, const std::string &category, ShortcutContext context, std::function< void()> action) |
| void | UnregisterShortcut (const std::string &id) |
| void | SetShortcutEnabled (const std::string &id, bool enabled) |
| void | ProcessInput () |
| void | DrawOverlay () |
| void | ToggleOverlay () |
| void | ShowOverlay () |
| void | HideOverlay () |
| bool | IsOverlayVisible () const |
| void | SetCurrentContext (ShortcutContext context) |
| ShortcutContext | GetCurrentContext () const |
| std::vector< const Shortcut * > | GetShortcutsInCategory (const std::string &category) const |
| std::vector< const Shortcut * > | GetContextShortcuts () const |
| std::vector< std::string > | GetCategories () const |
| void | RegisterDefaultShortcuts (std::function< void()> open_callback, std::function< void()> save_callback, std::function< void()> save_as_callback, std::function< void()> close_callback, std::function< void()> undo_callback, std::function< void()> redo_callback, std::function< void()> copy_callback, std::function< void()> paste_callback, std::function< void()> cut_callback, std::function< void()> find_callback) |
Static Public Member Functions | |
| static KeyboardShortcuts & | Get () |
| static bool | IsTextInputActive () |
Private Member Functions | |
| KeyboardShortcuts ()=default | |
| ~KeyboardShortcuts ()=default | |
| KeyboardShortcuts (const KeyboardShortcuts &)=delete | |
| KeyboardShortcuts & | operator= (const KeyboardShortcuts &)=delete |
| void | DrawOverlayContent () |
| void | DrawShortcutRow (const Shortcut &shortcut) |
| void | DrawCategorySection (const std::string &category, const std::vector< const Shortcut * > &shortcuts) |
| bool | IsShortcutActiveInContext (const Shortcut &shortcut) const |
Private Attributes | |
| std::map< std::string, Shortcut > | shortcuts_ |
| std::vector< std::string > | category_order_ |
| bool | show_overlay_ = false |
| char | search_filter_ [256] = {} |
| std::string | expanded_category_ |
| ShortcutContext | current_context_ = ShortcutContext::kGlobal |
| bool | toggle_key_was_pressed_ = false |
Manages keyboard shortcuts and provides an overlay UI.
This class provides a centralized system for registering, displaying, and processing keyboard shortcuts. It includes an overlay UI that can be toggled with the '?' key to show all available shortcuts.
Usage:
KeyboardShortcuts::Get().RegisterShortcut({ .id = "file.save", .description = "Save Project", .key = ImGuiKey_S, .requires_ctrl = true, .category = "File", .context = ShortcutContext::kGlobal, .action = []() { SaveProject(); } });
KeyboardShortcuts::Get().ProcessInput(); KeyboardShortcuts::Get().DrawOverlay();
Definition at line 85 of file keyboard_shortcuts.h.
|
privatedefault |
|
privatedefault |
|
privatedelete |
|
static |
Definition at line 144 of file keyboard_shortcuts.cc.
| void yaze::gui::KeyboardShortcuts::RegisterShortcut | ( | const Shortcut & | shortcut | ) |
Definition at line 149 of file keyboard_shortcuts.cc.
References yaze::gui::Shortcut::id, and shortcuts_.
Referenced by RegisterDefaultShortcuts(), and RegisterShortcut().
| void yaze::gui::KeyboardShortcuts::RegisterShortcut | ( | const std::string & | id, |
| const std::string & | description, | ||
| ImGuiKey | key, | ||
| bool | ctrl, | ||
| bool | shift, | ||
| bool | alt, | ||
| const std::string & | category, | ||
| ShortcutContext | context, | ||
| std::function< void()> | action ) |
Definition at line 153 of file keyboard_shortcuts.cc.
References yaze::gui::Shortcut::action, yaze::gui::Shortcut::category, yaze::gui::Shortcut::context, yaze::gui::Shortcut::description, yaze::gui::Shortcut::enabled, yaze::gui::Shortcut::id, yaze::gui::Shortcut::key, RegisterShortcut(), yaze::gui::Shortcut::requires_alt, yaze::gui::Shortcut::requires_ctrl, and yaze::gui::Shortcut::requires_shift.

| void yaze::gui::KeyboardShortcuts::UnregisterShortcut | ( | const std::string & | id | ) |
Definition at line 173 of file keyboard_shortcuts.cc.
References shortcuts_.
| void yaze::gui::KeyboardShortcuts::SetShortcutEnabled | ( | const std::string & | id, |
| bool | enabled ) |
Definition at line 177 of file keyboard_shortcuts.cc.
References shortcuts_.
| void yaze::gui::KeyboardShortcuts::ProcessInput | ( | ) |
Definition at line 191 of file keyboard_shortcuts.cc.
References HideOverlay(), IsShortcutActiveInContext(), IsTextInputActive(), shortcuts_, show_overlay_, toggle_key_was_pressed_, and ToggleOverlay().

| void yaze::gui::KeyboardShortcuts::DrawOverlay | ( | ) |
Definition at line 249 of file keyboard_shortcuts.cc.
References DrawOverlayContent(), yaze::gui::ThemeManager::Get(), yaze::gui::ThemeManager::GetCurrentTheme(), HideOverlay(), and show_overlay_.

| void yaze::gui::KeyboardShortcuts::ToggleOverlay | ( | ) |
Definition at line 241 of file keyboard_shortcuts.cc.
References search_filter_, and show_overlay_.
Referenced by ProcessInput().
|
inline |
Definition at line 118 of file keyboard_shortcuts.h.
References show_overlay_.
|
inline |
Definition at line 119 of file keyboard_shortcuts.h.
References show_overlay_.
Referenced by DrawOverlay(), DrawOverlayContent(), and ProcessInput().
|
inline |
Definition at line 120 of file keyboard_shortcuts.h.
References show_overlay_.
|
inline |
Definition at line 123 of file keyboard_shortcuts.h.
References current_context_.
|
inline |
Definition at line 124 of file keyboard_shortcuts.h.
References current_context_.
| std::vector< const Shortcut * > yaze::gui::KeyboardShortcuts::GetShortcutsInCategory | ( | const std::string & | category | ) | const |
Definition at line 507 of file keyboard_shortcuts.cc.
References shortcuts_.
| std::vector< const Shortcut * > yaze::gui::KeyboardShortcuts::GetContextShortcuts | ( | ) | const |
Definition at line 518 of file keyboard_shortcuts.cc.
References IsShortcutActiveInContext(), and shortcuts_.

| std::vector< std::string > yaze::gui::KeyboardShortcuts::GetCategories | ( | ) | const |
Definition at line 528 of file keyboard_shortcuts.cc.
References shortcuts_.
| void yaze::gui::KeyboardShortcuts::RegisterDefaultShortcuts | ( | std::function< void()> | open_callback, |
| std::function< void()> | save_callback, | ||
| std::function< void()> | save_as_callback, | ||
| std::function< void()> | close_callback, | ||
| std::function< void()> | undo_callback, | ||
| std::function< void()> | redo_callback, | ||
| std::function< void()> | copy_callback, | ||
| std::function< void()> | paste_callback, | ||
| std::function< void()> | cut_callback, | ||
| std::function< void()> | find_callback ) |
Definition at line 545 of file keyboard_shortcuts.cc.
References yaze::gui::kDungeon, yaze::gui::kEmulator, yaze::gui::kGlobal, yaze::gui::kOverworld, and RegisterShortcut().

|
static |
Definition at line 185 of file keyboard_shortcuts.cc.
Referenced by ProcessInput().
|
privatedelete |
|
private |
Definition at line 291 of file keyboard_shortcuts.cc.
References category_order_, yaze::gui::ConvertColorToImVec4(), current_context_, DrawCategorySection(), yaze::gui::ThemeManager::Get(), yaze::gui::ThemeManager::GetCurrentTheme(), HideOverlay(), search_filter_, yaze::gui::ShortcutContextToString(), and shortcuts_.
Referenced by DrawOverlay().
|
private |
Definition at line 461 of file keyboard_shortcuts.cc.
References yaze::gui::Shortcut::context, yaze::gui::ConvertColorToImVec4(), yaze::gui::Shortcut::description, yaze::gui::ThemeManager::Get(), yaze::gui::ThemeManager::GetCurrentTheme(), yaze::gui::Shortcut::GetDisplayString(), IsShortcutActiveInContext(), yaze::gui::kGlobal, and yaze::gui::ShortcutContextToString().
Referenced by DrawCategorySection().
|
private |
Definition at line 420 of file keyboard_shortcuts.cc.
References yaze::gui::ConvertColorToImVec4(), DrawShortcutRow(), yaze::gui::ThemeManager::Get(), and yaze::gui::ThemeManager::GetCurrentTheme().
Referenced by DrawOverlayContent().

|
private |
Definition at line 499 of file keyboard_shortcuts.cc.
References yaze::gui::Shortcut::context, current_context_, and yaze::gui::kGlobal.
Referenced by DrawShortcutRow(), GetContextShortcuts(), and ProcessInput().
|
private |
Definition at line 171 of file keyboard_shortcuts.h.
Referenced by DrawOverlayContent(), GetCategories(), GetContextShortcuts(), GetShortcutsInCategory(), ProcessInput(), RegisterShortcut(), SetShortcutEnabled(), and UnregisterShortcut().
|
private |
Definition at line 174 of file keyboard_shortcuts.h.
Referenced by DrawOverlayContent().
|
private |
Definition at line 179 of file keyboard_shortcuts.h.
Referenced by DrawOverlay(), HideOverlay(), IsOverlayVisible(), ProcessInput(), ShowOverlay(), and ToggleOverlay().
|
private |
Definition at line 180 of file keyboard_shortcuts.h.
Referenced by DrawOverlayContent(), and ToggleOverlay().
|
private |
Definition at line 181 of file keyboard_shortcuts.h.
|
private |
Definition at line 182 of file keyboard_shortcuts.h.
Referenced by DrawOverlayContent(), GetCurrentContext(), IsShortcutActiveInContext(), and SetCurrentContext().
|
private |
Definition at line 185 of file keyboard_shortcuts.h.
Referenced by ProcessInput().