refactor(editor): enhance UI coordination and menu management
- Updated EditorManager to include ShortcutManager in the UICoordinator initialization, improving UI responsiveness. - Refactored menu handling in MenuOrchestrator to delegate more responsibilities to UICoordinator, streamlining the UI flow. - Removed unused menu items and comments, clarifying the code structure and enhancing maintainability. Benefits: - Improves the organization of UI components, leading to a more efficient user experience. - Enhances clarity in the codebase by reducing clutter and focusing on essential functionalities.
This commit is contained in:
@@ -164,7 +164,8 @@ EditorManager::EditorManager()
|
||||
// UICoordinator: Coordinates all UI drawing (dialogs, popups, welcome screen)
|
||||
ui_coordinator_ = std::make_unique<UICoordinator>(
|
||||
this, rom_file_manager_, project_manager_, editor_registry_,
|
||||
*session_coordinator_, window_delegate_, toast_manager_, *popup_manager_);
|
||||
*session_coordinator_, window_delegate_, toast_manager_, *popup_manager_,
|
||||
shortcut_manager_);
|
||||
}
|
||||
|
||||
EditorManager::~EditorManager() = default;
|
||||
@@ -936,29 +937,35 @@ void EditorManager::DrawContextSensitiveCardControl() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draw the main menu bar
|
||||
*
|
||||
* DELEGATION:
|
||||
* - Menu items: MenuOrchestrator::BuildMainMenu()
|
||||
* - ROM selector: EditorManager::DrawRomSelector() (inline, needs current_rom_ access)
|
||||
* - Menu bar extras: UICoordinator::DrawMenuBarExtras() (session indicator, version)
|
||||
*
|
||||
* Note: ROM selector stays in EditorManager because it needs direct access to sessions_
|
||||
* and current_rom_ for the combo box. Could be extracted to SessionCoordinator in future.
|
||||
*/
|
||||
void EditorManager::DrawMenuBar() {
|
||||
static bool show_display_settings = false;
|
||||
static bool save_as_menu = false;
|
||||
std::string version_text = absl::StrFormat("v%s", version_.c_str());
|
||||
float version_width = ImGui::CalcTextSize(version_text.c_str()).x;
|
||||
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
// Delegate to MenuOrchestrator for clean separation of concerns
|
||||
// Delegate menu building to MenuOrchestrator
|
||||
if (menu_orchestrator_) {
|
||||
menu_orchestrator_->BuildMainMenu();
|
||||
}
|
||||
|
||||
// Inline ROM selector and status
|
||||
// Inline ROM selector (requires direct session access)
|
||||
status_ = DrawRomSelector();
|
||||
|
||||
// Delegate to UICoordinator for clean separation of concerns
|
||||
// Delegate menu bar extras to UICoordinator (session indicator, version display)
|
||||
if (ui_coordinator_) {
|
||||
ui_coordinator_->DrawMenuBarExtras();
|
||||
}
|
||||
|
||||
// Version display on far right
|
||||
ImGui::SameLine(ImGui::GetWindowWidth() - version_width - 10);
|
||||
ImGui::Text("%s", version_text.c_str());
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
|
||||
@@ -343,11 +343,6 @@ void MenuOrchestrator::AddHelpMenuItems() {
|
||||
menu_builder_
|
||||
.Item("Getting Started", ICON_MD_PLAY_ARROW,
|
||||
[this]() { OnShowGettingStarted(); })
|
||||
.Item("User Guide", ICON_MD_HELP,
|
||||
[this]() { OnShowUserGuide(); })
|
||||
.Item("Keyboard Shortcuts", ICON_MD_KEYBOARD,
|
||||
[this]() { OnShowKeyboardShortcuts(); })
|
||||
.Separator()
|
||||
.Item("Asar Integration", ICON_MD_CODE,
|
||||
[this]() { OnShowAsarIntegration(); })
|
||||
.Item("Build Instructions", ICON_MD_BUILD,
|
||||
@@ -548,8 +543,7 @@ void MenuOrchestrator::OnSwitchToEditor(EditorType editor_type) {
|
||||
}
|
||||
|
||||
void MenuOrchestrator::OnShowEditorSelection() {
|
||||
// Delegate to EditorManager
|
||||
// TODO: Draw editor selection via UICoordinator
|
||||
// Delegate to UICoordinator for editor selection dialog display
|
||||
if (editor_manager_) {
|
||||
if (auto* ui = editor_manager_->ui_coordinator()) {
|
||||
ui->ShowEditorSelection();
|
||||
@@ -558,8 +552,7 @@ void MenuOrchestrator::OnShowEditorSelection() {
|
||||
}
|
||||
|
||||
void MenuOrchestrator::OnShowDisplaySettings() {
|
||||
// Delegate to EditorManager
|
||||
// TODO: Draw display settings via UICoordinator
|
||||
// Delegate to UICoordinator for display settings popup
|
||||
if (editor_manager_) {
|
||||
if (auto* ui = editor_manager_->ui_coordinator()) {
|
||||
ui->ShowDisplaySettings();
|
||||
@@ -630,7 +623,7 @@ void MenuOrchestrator::OnSwitchToSession(size_t session_index) {
|
||||
}
|
||||
|
||||
void MenuOrchestrator::OnShowSessionSwitcher() {
|
||||
// TODO: Draw session switcher via UICoordinator
|
||||
// Delegate to UICoordinator for session switcher UI
|
||||
if (editor_manager_) {
|
||||
if (auto* ui = editor_manager_->ui_coordinator()) {
|
||||
ui->ShowSessionSwitcher();
|
||||
@@ -795,14 +788,6 @@ void MenuOrchestrator::OnShowAbout() {
|
||||
popup_manager_.Show("About");
|
||||
}
|
||||
|
||||
void MenuOrchestrator::OnShowKeyboardShortcuts() {
|
||||
popup_manager_.Show("Keyboard Shortcuts");
|
||||
}
|
||||
|
||||
void MenuOrchestrator::OnShowUserGuide() {
|
||||
popup_manager_.Show("User Guide");
|
||||
}
|
||||
|
||||
void MenuOrchestrator::OnShowGettingStarted() {
|
||||
popup_manager_.Show("Getting Started");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ UICoordinator::UICoordinator(
|
||||
SessionCoordinator& session_coordinator,
|
||||
WindowDelegate& window_delegate,
|
||||
ToastManager& toast_manager,
|
||||
PopupManager& popup_manager)
|
||||
PopupManager& popup_manager,
|
||||
ShortcutManager& shortcut_manager)
|
||||
: editor_manager_(editor_manager),
|
||||
rom_manager_(rom_manager),
|
||||
project_manager_(project_manager),
|
||||
@@ -39,7 +40,8 @@ UICoordinator::UICoordinator(
|
||||
session_coordinator_(session_coordinator),
|
||||
window_delegate_(window_delegate),
|
||||
toast_manager_(toast_manager),
|
||||
popup_manager_(popup_manager) {
|
||||
popup_manager_(popup_manager),
|
||||
shortcut_manager_(shortcut_manager) {
|
||||
|
||||
// Initialize welcome screen with proper callbacks
|
||||
welcome_screen_ = std::make_unique<WelcomeScreen>();
|
||||
@@ -92,8 +94,7 @@ UICoordinator::UICoordinator(
|
||||
}
|
||||
|
||||
void UICoordinator::DrawAllUI() {
|
||||
// Apply Material Design styling
|
||||
ApplyMaterialDesignStyling();
|
||||
// Note: Theme styling is applied by ThemeManager, not here
|
||||
|
||||
// Draw all UI components in order
|
||||
DrawMenuBarExtras();
|
||||
|
||||
@@ -21,6 +21,7 @@ class EditorRegistry;
|
||||
class SessionCoordinator;
|
||||
class ToastManager;
|
||||
class WindowDelegate;
|
||||
class ShortcutManager;
|
||||
|
||||
/**
|
||||
* @class UICoordinator
|
||||
@@ -47,7 +48,8 @@ class UICoordinator {
|
||||
SessionCoordinator& session_coordinator,
|
||||
WindowDelegate& window_delegate,
|
||||
ToastManager& toast_manager,
|
||||
PopupManager& popup_manager);
|
||||
PopupManager& popup_manager,
|
||||
ShortcutManager& shortcut_manager);
|
||||
~UICoordinator() = default;
|
||||
|
||||
// Non-copyable due to reference members
|
||||
@@ -59,6 +61,10 @@ class UICoordinator {
|
||||
void DrawMenuBarExtras();
|
||||
void DrawContextSensitiveCardControl();
|
||||
|
||||
// Core UI components (actual ImGui rendering moved from EditorManager)
|
||||
void DrawCommandPalette();
|
||||
void DrawGlobalSearch();
|
||||
|
||||
// Session UI components
|
||||
void DrawSessionSwitcher();
|
||||
void DrawSessionManager();
|
||||
@@ -117,10 +123,7 @@ class UICoordinator {
|
||||
void SetImGuiDemoVisible(bool visible) { show_imgui_demo_ = visible; }
|
||||
void SetImGuiMetricsVisible(bool visible) { show_imgui_metrics_ = visible; }
|
||||
|
||||
// Theme and styling helpers
|
||||
void ApplyMaterialDesignStyling();
|
||||
void UpdateThemeElements();
|
||||
void DrawThemePreview();
|
||||
// Note: Theme styling is handled by ThemeManager, not UICoordinator
|
||||
|
||||
private:
|
||||
// References to coordinated managers
|
||||
@@ -132,6 +135,7 @@ class UICoordinator {
|
||||
WindowDelegate& window_delegate_;
|
||||
ToastManager& toast_manager_;
|
||||
PopupManager& popup_manager_;
|
||||
ShortcutManager& shortcut_manager_;
|
||||
|
||||
// UI state flags (UICoordinator owns all UI visibility state)
|
||||
bool show_editor_selection_ = false;
|
||||
|
||||
Reference in New Issue
Block a user