5#ifndef YAZE_APP_GUI_KEYBOARD_SHORTCUTS_H
6#define YAZE_APP_GUI_KEYBOARD_SHORTCUTS_H
13#ifndef IMGUI_DEFINE_MATH_OPERATORS
14#define IMGUI_DEFINE_MATH_OPERATORS
17#include "imgui/imgui.h"
59 bool Matches(ImGuiKey pressed_key,
bool ctrl,
bool shift,
bool alt)
const;
95 const std::string& description,
97 bool ctrl,
bool shift,
bool alt,
98 const std::string& category,
100 std::function<
void()> action);
137 std::function<
void()> open_callback,
138 std::function<
void()> save_callback,
139 std::function<
void()> save_as_callback,
140 std::function<
void()> close_callback,
141 std::function<
void()> undo_callback,
142 std::function<
void()> redo_callback,
143 std::function<
void()> copy_callback,
144 std::function<
void()> paste_callback,
145 std::function<
void()> cut_callback,
146 std::function<
void()> find_callback);
165 const std::vector<const Shortcut*>& shortcuts);
175 "File",
"Edit",
"View",
"Navigation",
"Tools",
"Editor",
"Other"
Manages keyboard shortcuts and provides an overlay UI.
KeyboardShortcuts(const KeyboardShortcuts &)=delete
void SetShortcutEnabled(const std::string &id, bool enabled)
void UnregisterShortcut(const std::string &id)
ShortcutContext GetCurrentContext() const
std::string expanded_category_
void SetCurrentContext(ShortcutContext context)
std::vector< std::string > category_order_
std::vector< std::string > GetCategories() const
std::map< std::string, Shortcut > shortcuts_
void DrawShortcutRow(const Shortcut &shortcut)
bool toggle_key_was_pressed_
std::vector< const Shortcut * > GetContextShortcuts() const
static bool IsTextInputActive()
void DrawOverlayContent()
KeyboardShortcuts & operator=(const KeyboardShortcuts &)=delete
std::vector< const Shortcut * > GetShortcutsInCategory(const std::string &category) const
~KeyboardShortcuts()=default
static KeyboardShortcuts & Get()
void DrawCategorySection(const std::string &category, const std::vector< const Shortcut * > &shortcuts)
bool IsOverlayVisible() const
void RegisterShortcut(const Shortcut &shortcut)
KeyboardShortcuts()=default
ShortcutContext current_context_
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)
bool IsShortcutActiveInContext(const Shortcut &shortcut) const
const char * ShortcutContextToString(ShortcutContext context)
Convert ShortcutContext to display string.
ShortcutContext EditorNameToContext(const std::string &editor_name)
Convert editor type name to ShortcutContext.
ShortcutContext
Defines the context in which a shortcut is active.
Represents a keyboard shortcut with its associated action.
std::string GetDisplayString() const
std::function< void()> action
bool Matches(ImGuiKey pressed_key, bool ctrl, bool shift, bool alt) const