Implement shortcut execution logic and update Cut command handling in EditorManager
This commit is contained in:
@@ -137,5 +137,34 @@ std::vector<ImGuiKey> ParseShortcut(const std::string& shortcut) {
|
||||
return shortcuts;
|
||||
}
|
||||
|
||||
void ExecuteShortcuts(const ShortcutManager& shortcut_manager) {
|
||||
// Check for keyboard shortcuts using the shortcut manager
|
||||
for (const auto& shortcut : shortcut_manager.GetShortcuts()) {
|
||||
bool ctrl_pressed = ImGui::GetIO().KeyCtrl;
|
||||
bool alt_pressed = ImGui::GetIO().KeyAlt;
|
||||
bool shift_pressed = ImGui::GetIO().KeyShift;
|
||||
bool super_pressed = ImGui::GetIO().KeySuper;
|
||||
bool keys_pressed = false;
|
||||
// Check for all the keys in the shortcut
|
||||
for (const auto& key : shortcut.second.keys) {
|
||||
if (key == ImGuiMod_Ctrl) {
|
||||
keys_pressed = ctrl_pressed;
|
||||
} else if (key == ImGuiMod_Alt) {
|
||||
keys_pressed = alt_pressed;
|
||||
} else if (key == ImGuiMod_Shift) {
|
||||
keys_pressed = shift_pressed;
|
||||
} else if (key == ImGuiMod_Super) {
|
||||
keys_pressed = super_pressed;
|
||||
} else {
|
||||
keys_pressed = ImGui::IsKeyDown(key);
|
||||
}
|
||||
|
||||
if (!keys_pressed) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
@@ -55,10 +55,14 @@ class ShortcutManager {
|
||||
return PrintShortcut(shortcuts_.at(name).keys);
|
||||
}
|
||||
|
||||
auto GetShortcuts() const { return shortcuts_; }
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, Shortcut> shortcuts_;
|
||||
};
|
||||
|
||||
void ExecuteShortcuts(const ShortcutManager &shortcut_manager);
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
|
||||
Reference in New Issue
Block a user