editor manager refactor

This commit is contained in:
scawful
2025-10-15 12:37:59 -04:00
parent f09e8c0a58
commit 16f2bfe15e
15 changed files with 1073 additions and 894 deletions

View File

@@ -549,15 +549,21 @@ void MenuOrchestrator::OnSwitchToEditor(EditorType editor_type) {
void MenuOrchestrator::OnShowEditorSelection() {
// Delegate to EditorManager
// TODO: Draw editor selection via UICoordinator
if (editor_manager_) {
editor_manager_->ShowEditorSelection();
if (auto* ui = editor_manager_->ui_coordinator()) {
ui->ShowEditorSelection();
}
}
}
void MenuOrchestrator::OnShowDisplaySettings() {
// Delegate to EditorManager
// TODO: Draw display settings via UICoordinator
if (editor_manager_) {
editor_manager_->ShowDisplaySettings();
if (auto* ui = editor_manager_->ui_coordinator()) {
ui->ShowDisplaySettings();
}
}
}
@@ -624,8 +630,11 @@ void MenuOrchestrator::OnSwitchToSession(size_t session_index) {
}
void MenuOrchestrator::OnShowSessionSwitcher() {
// TODO: Draw session switcher via UICoordinator
if (editor_manager_) {
editor_manager_->ShowSessionSwitcher();
if (auto* ui = editor_manager_->ui_coordinator()) {
ui->ShowSessionSwitcher();
}
}
}
@@ -879,7 +888,8 @@ void MenuOrchestrator::OnQuit() {
// Menu item validation helpers
bool MenuOrchestrator::CanSaveRom() const {
return rom_manager_.IsRomLoaded();
auto* rom = editor_manager_->GetCurrentRom();
return rom ? rom_manager_.IsRomLoaded(rom) : false;
}
bool MenuOrchestrator::CanSaveProject() const {
@@ -887,7 +897,8 @@ bool MenuOrchestrator::CanSaveProject() const {
}
bool MenuOrchestrator::HasActiveRom() const {
return rom_manager_.IsRomLoaded();
auto* rom = editor_manager_->GetCurrentRom();
return rom ? rom_manager_.IsRomLoaded(rom) : false;
}
bool MenuOrchestrator::HasActiveProject() const {
@@ -904,7 +915,8 @@ bool MenuOrchestrator::HasMultipleSessions() const {
// Menu item text generation
std::string MenuOrchestrator::GetRomFilename() const {
return rom_manager_.GetRomFilename();
auto* rom = editor_manager_->GetCurrentRom();
return rom ? rom_manager_.GetRomFilename(rom) : "";
}
std::string MenuOrchestrator::GetProjectName() const {

View File

@@ -2,37 +2,162 @@
#include <filesystem>
#include <fstream>
#include <chrono>
#include "absl/strings/str_format.h"
#include "app/editor/system/toast_manager.h"
#include "app/rom.h"
#include "util/file_util.h"
namespace yaze {
namespace editor {
namespace yaze::editor {
RomFileManager::RomFileManager(ToastManager* toast_manager)
: toast_manager_(toast_manager) {
}
: toast_manager_(toast_manager) {}
absl::Status RomFileManager::LoadRom(const std::string& filename) {
absl::Status RomFileManager::LoadRom(Rom* rom, const std::string& filename) {
if (!rom) {
return absl::InvalidArgumentError("ROM pointer cannot be null");
}
if (filename.empty()) {
// TODO: Show file dialog
return absl::InvalidArgumentError("No filename provided");
}
return LoadRomFromFile(filename);
return LoadRomFromFile(rom, filename);
}
absl::Status RomFileManager::LoadRomFromFile(const std::string& filename) {
absl::Status RomFileManager::SaveRom(Rom* rom) {
if (!IsRomLoaded(rom)) {
return absl::FailedPreconditionError("No ROM loaded to save");
}
Rom::SaveSettings settings;
settings.backup = true;
settings.save_new = false;
settings.z3_save = true;
auto status = rom->SaveToFile(settings);
if (!status.ok() && toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Failed to save ROM: %s", status.message()),
ToastType::kError);
} else if (toast_manager_) {
toast_manager_->Show("ROM saved successfully", ToastType::kSuccess);
}
return status;
}
absl::Status RomFileManager::SaveRomAs(Rom* rom, const std::string& filename) {
if (!IsRomLoaded(rom)) {
return absl::FailedPreconditionError("No ROM loaded to save");
}
if (filename.empty()) {
return absl::InvalidArgumentError(
"No filename provided for save as");
}
Rom::SaveSettings settings;
settings.backup = false;
settings.save_new = true;
settings.filename = filename;
settings.z3_save = true;
auto status = rom->SaveToFile(settings);
if (!status.ok() && toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Failed to save ROM as: %s", status.message()),
ToastType::kError);
} else if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("ROM saved as: %s", filename),
ToastType::kSuccess);
}
return status;
}
absl::Status RomFileManager::OpenRomOrProject(Rom* rom,
const std::string& filename) {
if (!rom) {
return absl::InvalidArgumentError("ROM pointer cannot be null");
}
if (filename.empty()) {
return absl::InvalidArgumentError("No filename provided");
}
std::string extension =
std::filesystem::path(filename).extension().string();
if (extension == ".yaze" || extension == ".json") {
return absl::UnimplementedError(
"Project file loading not yet implemented");
}
return LoadRom(rom, filename);
}
absl::Status RomFileManager::CreateBackup(Rom* rom) {
if (!IsRomLoaded(rom)) {
return absl::FailedPreconditionError("No ROM loaded to backup");
}
std::string backup_filename = GenerateBackupFilename(rom->filename());
Rom::SaveSettings settings;
settings.backup = true;
settings.filename = backup_filename;
settings.z3_save = true;
auto status = rom->SaveToFile(settings);
if (!status.ok() && toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Failed to create backup: %s", status.message()),
ToastType::kError);
} else if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Backup created: %s", backup_filename),
ToastType::kSuccess);
}
return status;
}
absl::Status RomFileManager::ValidateRom(Rom* rom) {
if (!IsRomLoaded(rom)) {
return absl::FailedPreconditionError("No valid ROM to validate");
}
if (rom->size() < 512 * 1024 || rom->size() > 8 * 1024 * 1024) {
return absl::InvalidArgumentError("ROM size is outside expected range");
}
if (rom->title().empty()) {
return absl::InvalidArgumentError("ROM title is empty or invalid");
}
if (toast_manager_) {
toast_manager_->Show("ROM validation passed", ToastType::kSuccess);
}
return absl::OkStatus();
}
bool RomFileManager::IsRomLoaded(Rom* rom) const {
return rom && rom->is_loaded();
}
std::string RomFileManager::GetRomFilename(Rom* rom) const {
if (!IsRomLoaded(rom)) {
return "";
}
return rom->filename();
}
absl::Status RomFileManager::LoadRomFromFile(
Rom* rom, const std::string& filename) {
if (!rom) {
return absl::InvalidArgumentError("ROM pointer cannot be null");
}
if (!IsValidRomFile(filename)) {
return absl::InvalidArgumentError(
absl::StrFormat("Invalid ROM file: %s", filename));
}
// Create new ROM instance
Rom new_rom;
auto status = new_rom.LoadFromFile(filename);
auto status = rom->LoadFromFile(filename);
if (!status.ok()) {
if (toast_manager_) {
toast_manager_->Show(
@@ -41,204 +166,23 @@ absl::Status RomFileManager::LoadRomFromFile(const std::string& filename) {
}
return status;
}
// Set as current ROM
current_rom_ = &new_rom;
if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("ROM loaded: %s", new_rom.title()),
ToastType::kSuccess);
toast_manager_->Show(absl::StrFormat("ROM loaded: %s", rom->title()),
ToastType::kSuccess);
}
return absl::OkStatus();
}
absl::Status RomFileManager::SaveRom() {
if (!IsRomLoaded()) {
return absl::FailedPreconditionError("No ROM loaded to save");
}
Rom::SaveSettings settings;
settings.backup = true;
settings.save_new = false;
settings.z3_save = true;
auto status = current_rom_->SaveToFile(settings);
if (!status.ok()) {
if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Failed to save ROM: %s", status.message()),
ToastType::kError);
}
return status;
}
if (toast_manager_) {
toast_manager_->Show("ROM saved successfully", ToastType::kSuccess);
}
return absl::OkStatus();
}
absl::Status RomFileManager::SaveRomAs(const std::string& filename) {
if (!IsRomLoaded()) {
return absl::FailedPreconditionError("No ROM loaded to save");
}
if (filename.empty()) {
return absl::InvalidArgumentError("No filename provided for save as");
}
Rom::SaveSettings settings;
settings.backup = false;
settings.save_new = true;
settings.filename = filename;
settings.z3_save = true;
auto status = current_rom_->SaveToFile(settings);
if (!status.ok()) {
if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Failed to save ROM as: %s", status.message()),
ToastType::kError);
}
return status;
}
if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("ROM saved as: %s", filename),
ToastType::kSuccess);
}
return absl::OkStatus();
}
absl::Status RomFileManager::OpenRomOrProject(const std::string& filename) {
if (filename.empty()) {
return absl::InvalidArgumentError("No filename provided");
}
// Check if it's a project file or ROM file
std::string extension = std::filesystem::path(filename).extension().string();
if (extension == ".yaze" || extension == ".json") {
// TODO: Handle project files
return absl::UnimplementedError("Project file loading not yet implemented");
} else {
// Assume it's a ROM file
return LoadRom(filename);
}
}
absl::Status RomFileManager::LoadAssets() {
if (!IsRomLoaded()) {
return absl::FailedPreconditionError("No ROM loaded to load assets from");
}
// TODO: Implement asset loading logic
// This would typically load graphics, music, etc. from the ROM
if (toast_manager_) {
toast_manager_->Show("Assets loaded", ToastType::kInfo);
}
return absl::OkStatus();
}
absl::Status RomFileManager::SetCurrentRom(Rom* rom) {
if (!rom) {
return absl::InvalidArgumentError("ROM pointer cannot be null");
}
current_rom_ = rom;
return absl::OkStatus();
}
std::string RomFileManager::GetRomFilename() const {
if (!IsRomLoaded()) {
return "";
}
return current_rom_->filename();
}
std::string RomFileManager::GetRomTitle() const {
if (!IsRomLoaded()) {
return "";
}
return current_rom_->title();
}
absl::Status RomFileManager::ValidateRom() {
return ValidateRom(current_rom_);
}
absl::Status RomFileManager::ValidateRom(Rom* rom) {
if (!rom || !rom->is_loaded()) {
return absl::FailedPreconditionError("No valid ROM to validate");
}
// TODO: Implement ROM validation logic
// This would check ROM integrity, checksums, expected data structures, etc.
// Basic validation: check if ROM size is reasonable
if (rom->size() < 512 * 1024 || rom->size() > 8 * 1024 * 1024) {
return absl::InvalidArgumentError("ROM size is outside expected range");
}
// Check if ROM title is readable
if (rom->title().empty()) {
return absl::InvalidArgumentError("ROM title is empty or invalid");
}
if (toast_manager_) {
toast_manager_->Show("ROM validation passed", ToastType::kSuccess);
}
return absl::OkStatus();
}
absl::Status RomFileManager::CreateBackup() {
if (!IsRomLoaded()) {
return absl::FailedPreconditionError("No ROM loaded to backup");
}
std::string backup_filename = GenerateBackupFilename(GetRomFilename());
Rom::SaveSettings settings;
settings.backup = true;
settings.filename = backup_filename;
settings.z3_save = true;
auto status = current_rom_->SaveToFile(settings);
if (!status.ok()) {
if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Failed to create backup: %s", status.message()),
ToastType::kError);
}
return status;
}
if (toast_manager_) {
toast_manager_->Show(
absl::StrFormat("Backup created: %s", backup_filename),
ToastType::kSuccess);
}
return absl::OkStatus();
}
std::string RomFileManager::GenerateBackupFilename(const std::string& original_filename) const {
std::string RomFileManager::GenerateBackupFilename(
const std::string& original_filename) const {
std::filesystem::path path(original_filename);
std::string stem = path.stem().string();
std::string extension = path.extension().string();
// Add timestamp to make it unique
auto now = std::chrono::system_clock::now();
auto time_t = std::chrono::system_clock::to_time_t(now);
return absl::StrFormat("%s_backup_%ld%s", stem, time_t, extension);
}
@@ -246,21 +190,17 @@ bool RomFileManager::IsValidRomFile(const std::string& filename) const {
if (filename.empty()) {
return false;
}
if (!std::filesystem::exists(filename)) {
return false;
}
// Check file size (SNES ROMs are typically 2MB, 3MB, 4MB, 6MB, etc.)
auto file_size = std::filesystem::file_size(filename);
if (file_size < 1024 * 1024 || file_size > 8 * 1024 * 1024) {
return false;
}
// TODO: Add more ROM validation (header checks, etc.)
return true;
}
} // namespace editor
} // namespace yaze
} // namespace yaze::editor

View File

@@ -27,34 +27,21 @@ class RomFileManager {
~RomFileManager() = default;
// ROM file operations
absl::Status LoadRom(const std::string& filename = "");
absl::Status SaveRom();
absl::Status SaveRomAs(const std::string& filename);
absl::Status OpenRomOrProject(const std::string& filename);
// Asset operations
absl::Status LoadAssets();
// ROM state management
absl::Status SetCurrentRom(Rom* rom);
Rom* GetCurrentRom() const { return current_rom_; }
// ROM information
bool IsRomLoaded() const { return current_rom_ && current_rom_->is_loaded(); }
std::string GetRomFilename() const;
std::string GetRomTitle() const;
// Validation and backup
absl::Status ValidateRom();
absl::Status ValidateRom(Rom* rom); // Validate a specific ROM
absl::Status CreateBackup();
absl::Status LoadRom(Rom* rom, const std::string& filename);
absl::Status SaveRom(Rom* rom);
absl::Status SaveRomAs(Rom* rom, const std::string& filename);
absl::Status OpenRomOrProject(Rom* rom, const std::string& filename);
absl::Status CreateBackup(Rom* rom);
absl::Status ValidateRom(Rom* rom);
// Utility helpers
bool IsRomLoaded(Rom* rom) const;
std::string GetRomFilename(Rom* rom) const;
private:
Rom* current_rom_ = nullptr;
ToastManager* toast_manager_ = nullptr;
// Helper methods
absl::Status LoadRomFromFile(const std::string& filename);
absl::Status LoadRomFromFile(Rom* rom, const std::string& filename);
std::string GenerateBackupFilename(const std::string& original_filename) const;
bool IsValidRomFile(const std::string& filename) const;
};

View File

@@ -0,0 +1,350 @@
#include "app/editor/system/shortcut_configurator.h"
#include "absl/functional/bind_front.h"
#include "absl/strings/str_format.h"
#include "app/editor/editor_manager.h"
#include "app/editor/system/editor_card_registry.h"
#include "app/editor/system/menu_orchestrator.h"
#include "app/editor/system/proposal_drawer.h"
#include "app/editor/system/rom_file_manager.h"
#include "app/editor/system/session_coordinator.h"
#include "app/editor/system/toast_manager.h"
#include "app/editor/ui/ui_coordinator.h"
#include "app/editor/ui/workspace_manager.h"
#include "app/editor/system/popup_manager.h"
#include "app/core/project.h"
namespace yaze::editor {
namespace {
void RegisterIfValid(ShortcutManager* shortcut_manager,
const std::string& name,
const std::vector<ImGuiKey>& keys,
std::function<void()> callback) {
if (!shortcut_manager || !callback) {
return;
}
shortcut_manager->RegisterShortcut(name, keys, std::move(callback));
}
void RegisterIfValid(ShortcutManager* shortcut_manager,
const std::string& name,
ImGuiKey key,
std::function<void()> callback) {
if (!shortcut_manager || !callback) {
return;
}
shortcut_manager->RegisterShortcut(name, key, std::move(callback));
}
} // namespace
void ConfigureEditorShortcuts(const ShortcutDependencies& deps,
ShortcutManager* shortcut_manager) {
if (!shortcut_manager) {
return;
}
auto* editor_manager = deps.editor_manager;
auto* ui_coordinator = deps.ui_coordinator;
auto* popup_manager = deps.popup_manager;
auto* card_registry = deps.card_registry;
RegisterIfValid(
shortcut_manager, "global.toggle_sidebar",
{ImGuiKey_LeftCtrl, ImGuiKey_B},
[ui_coordinator]() {
if (ui_coordinator) {
ui_coordinator->ToggleCardSidebar();
}
});
RegisterIfValid(shortcut_manager, "Open", {ImGuiMod_Ctrl, ImGuiKey_O},
[editor_manager]() {
if (editor_manager) {
editor_manager->LoadRom();
}
});
RegisterIfValid(shortcut_manager, "Save", {ImGuiMod_Ctrl, ImGuiKey_S},
[editor_manager]() {
if (editor_manager) {
editor_manager->SaveRom();
}
});
RegisterIfValid(shortcut_manager, "Save As",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_S},
[editor_manager]() {
if (editor_manager) {
// Use project-aware default filename when possible
std::string filename = editor_manager->GetCurrentRom()
? editor_manager->GetCurrentRom()->filename()
: "";
editor_manager->SaveRomAs(filename);
}
});
RegisterIfValid(shortcut_manager, "Close ROM", {ImGuiMod_Ctrl, ImGuiKey_W},
[editor_manager]() {
if (editor_manager && editor_manager->GetCurrentRom()) {
editor_manager->GetCurrentRom()->Close();
}
});
RegisterIfValid(shortcut_manager, "Quit", {ImGuiMod_Ctrl, ImGuiKey_Q},
[editor_manager]() {
if (editor_manager) {
editor_manager->Quit();
}
});
RegisterIfValid(shortcut_manager, "Undo", {ImGuiMod_Ctrl, ImGuiKey_Z},
[editor_manager]() {
if (editor_manager && editor_manager->GetCurrentEditor()) {
editor_manager->GetCurrentEditor()->Undo();
}
});
RegisterIfValid(shortcut_manager, "Redo",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_Z},
[editor_manager]() {
if (editor_manager && editor_manager->GetCurrentEditor()) {
editor_manager->GetCurrentEditor()->Redo();
}
});
RegisterIfValid(shortcut_manager, "Cut", {ImGuiMod_Ctrl, ImGuiKey_X},
[editor_manager]() {
if (editor_manager && editor_manager->GetCurrentEditor()) {
editor_manager->GetCurrentEditor()->Cut();
}
});
RegisterIfValid(shortcut_manager, "Copy", {ImGuiMod_Ctrl, ImGuiKey_C},
[editor_manager]() {
if (editor_manager && editor_manager->GetCurrentEditor()) {
editor_manager->GetCurrentEditor()->Copy();
}
});
RegisterIfValid(shortcut_manager, "Paste", {ImGuiMod_Ctrl, ImGuiKey_V},
[editor_manager]() {
if (editor_manager && editor_manager->GetCurrentEditor()) {
editor_manager->GetCurrentEditor()->Paste();
}
});
RegisterIfValid(shortcut_manager, "Find", {ImGuiMod_Ctrl, ImGuiKey_F},
[editor_manager]() {
if (editor_manager && editor_manager->GetCurrentEditor()) {
editor_manager->GetCurrentEditor()->Find();
}
});
RegisterIfValid(
shortcut_manager, "Command Palette",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_P},
[ui_coordinator]() {
if (ui_coordinator) {
ui_coordinator->ShowCommandPalette();
}
});
RegisterIfValid(
shortcut_manager, "Global Search",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_K},
[ui_coordinator]() {
if (ui_coordinator) {
ui_coordinator->ShowGlobalSearch();
}
});
RegisterIfValid(shortcut_manager, "Load Last ROM",
{ImGuiMod_Ctrl, ImGuiKey_R},
[editor_manager]() {
auto& recent = core::RecentFilesManager::GetInstance();
if (!recent.GetRecentFiles().empty() && editor_manager) {
editor_manager->OpenRomOrProject(
recent.GetRecentFiles().front());
}
});
RegisterIfValid(shortcut_manager, "Show About", ImGuiKey_F1,
[popup_manager]() {
if (popup_manager) {
popup_manager->Show("About");
}
});
auto register_editor_shortcut = [&](EditorType type, ImGuiKey key) {
RegisterIfValid(shortcut_manager,
absl::StrFormat("switch.%d", static_cast<int>(type)),
{ImGuiMod_Ctrl, key},
[editor_manager, type]() {
if (editor_manager) {
editor_manager->SwitchToEditor(type);
}
});
};
register_editor_shortcut(EditorType::kOverworld, ImGuiKey_1);
register_editor_shortcut(EditorType::kDungeon, ImGuiKey_2);
register_editor_shortcut(EditorType::kGraphics, ImGuiKey_3);
register_editor_shortcut(EditorType::kSprite, ImGuiKey_4);
register_editor_shortcut(EditorType::kMessage, ImGuiKey_5);
register_editor_shortcut(EditorType::kMusic, ImGuiKey_6);
register_editor_shortcut(EditorType::kPalette, ImGuiKey_7);
register_editor_shortcut(EditorType::kScreen, ImGuiKey_8);
register_editor_shortcut(EditorType::kAssembly, ImGuiKey_9);
register_editor_shortcut(EditorType::kSettings, ImGuiKey_0);
RegisterIfValid(shortcut_manager, "Editor Selection",
{ImGuiMod_Ctrl, ImGuiKey_E},
[ui_coordinator]() {
if (ui_coordinator) {
ui_coordinator->ShowEditorSelection();
}
});
RegisterIfValid(
shortcut_manager, "Card Browser",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_B},
[ui_coordinator]() {
if (ui_coordinator) {
ui_coordinator->ShowCardBrowser();
}
});
if (card_registry) {
RegisterIfValid(shortcut_manager, "Show Dungeon Cards",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_D},
[card_registry]() {
card_registry->ShowAllCardsInCategory("Dungeon");
});
RegisterIfValid(shortcut_manager, "Show Graphics Cards",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_G},
[card_registry]() {
card_registry->ShowAllCardsInCategory("Graphics");
});
RegisterIfValid(shortcut_manager, "Show Screen Cards",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_S},
[card_registry]() {
card_registry->ShowAllCardsInCategory("Screen");
});
}
#ifdef YAZE_WITH_GRPC
RegisterIfValid(shortcut_manager, "Agent Editor",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_A},
[editor_manager]() {
if (editor_manager) {
editor_manager->ShowAIAgent();
}
});
RegisterIfValid(shortcut_manager, "Agent Chat History",
{ImGuiMod_Ctrl, ImGuiKey_H},
[editor_manager]() {
if (editor_manager) {
editor_manager->ShowChatHistory();
}
});
RegisterIfValid(shortcut_manager, "Proposal Drawer",
{ImGuiMod_Ctrl, ImGuiKey_P},
[editor_manager]() {
if (editor_manager) {
editor_manager->ShowProposalDrawer();
}
});
#endif
}
void ConfigureMenuShortcuts(const ShortcutDependencies& deps,
ShortcutManager* shortcut_manager) {
if (!shortcut_manager) {
return;
}
auto* menu_orchestrator = deps.menu_orchestrator;
auto* session_coordinator = deps.session_coordinator;
auto* workspace_manager = deps.workspace_manager;
RegisterIfValid(shortcut_manager, "New Session",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_N},
[session_coordinator]() {
if (session_coordinator) {
session_coordinator->CreateNewSession();
}
});
RegisterIfValid(shortcut_manager, "Duplicate Session",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_D},
[session_coordinator]() {
if (session_coordinator) {
session_coordinator->DuplicateCurrentSession();
}
});
RegisterIfValid(shortcut_manager, "Close Session",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_W},
[session_coordinator]() {
if (session_coordinator) {
session_coordinator->CloseCurrentSession();
}
});
RegisterIfValid(shortcut_manager, "Session Switcher",
{ImGuiMod_Ctrl, ImGuiKey_Tab},
[session_coordinator]() {
if (session_coordinator) {
session_coordinator->ShowSessionSwitcher();
}
});
RegisterIfValid(shortcut_manager, "Save Layout",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_L},
[workspace_manager]() {
if (workspace_manager) {
workspace_manager->SaveWorkspaceLayout();
}
});
RegisterIfValid(shortcut_manager, "Load Layout",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_O},
[workspace_manager]() {
if (workspace_manager) {
workspace_manager->LoadWorkspaceLayout();
}
});
RegisterIfValid(shortcut_manager, "Reset Layout",
{ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_R},
[workspace_manager]() {
if (workspace_manager) {
workspace_manager->ResetWorkspaceLayout();
}
});
RegisterIfValid(shortcut_manager, "Maximize Window", ImGuiKey_F11,
[workspace_manager]() {
if (workspace_manager) {
workspace_manager->MaximizeCurrentWindow();
}
});
#ifdef YAZE_ENABLE_TESTING
RegisterIfValid(shortcut_manager, "Test Dashboard",
{ImGuiMod_Ctrl, ImGuiKey_T},
[menu_orchestrator]() {
if (menu_orchestrator) {
menu_orchestrator->OnShowTestDashboard();
}
});
#endif
}
} // namespace yaze::editor

View File

@@ -0,0 +1,48 @@
#ifndef YAZE_APP_EDITOR_SYSTEM_SHORTCUT_CONFIGURATOR_H_
#define YAZE_APP_EDITOR_SYSTEM_SHORTCUT_CONFIGURATOR_H_
#include <functional>
#include "app/editor/editor.h"
#include "app/editor/system/shortcut_manager.h"
namespace yaze {
namespace editor {
class EditorManager;
class EditorRegistry;
class MenuOrchestrator;
class RomFileManager;
class ProjectManager;
class SessionCoordinator;
class UICoordinator;
class WorkspaceManager;
class PopupManager;
class ToastManager;
class EditorCardRegistry;
struct ShortcutDependencies {
EditorManager* editor_manager = nullptr;
EditorRegistry* editor_registry = nullptr;
MenuOrchestrator* menu_orchestrator = nullptr;
RomFileManager* rom_file_manager = nullptr;
ProjectManager* project_manager = nullptr;
SessionCoordinator* session_coordinator = nullptr;
UICoordinator* ui_coordinator = nullptr;
WorkspaceManager* workspace_manager = nullptr;
PopupManager* popup_manager = nullptr;
ToastManager* toast_manager = nullptr;
EditorCardRegistry* card_registry = nullptr;
};
void ConfigureEditorShortcuts(const ShortcutDependencies& deps,
ShortcutManager* shortcut_manager);
void ConfigureMenuShortcuts(const ShortcutDependencies& deps,
ShortcutManager* shortcut_manager);
} // namespace editor
} // namespace yaze
#endif // YAZE_APP_EDITOR_SYSTEM_SHORTCUT_CONFIGURATOR_H_