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)
|
// UICoordinator: Coordinates all UI drawing (dialogs, popups, welcome screen)
|
||||||
ui_coordinator_ = std::make_unique<UICoordinator>(
|
ui_coordinator_ = std::make_unique<UICoordinator>(
|
||||||
this, rom_file_manager_, project_manager_, editor_registry_,
|
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;
|
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() {
|
void EditorManager::DrawMenuBar() {
|
||||||
static bool show_display_settings = false;
|
static bool show_display_settings = false;
|
||||||
static bool save_as_menu = 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()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
// Delegate to MenuOrchestrator for clean separation of concerns
|
// Delegate menu building to MenuOrchestrator
|
||||||
if (menu_orchestrator_) {
|
if (menu_orchestrator_) {
|
||||||
menu_orchestrator_->BuildMainMenu();
|
menu_orchestrator_->BuildMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inline ROM selector and status
|
// Inline ROM selector (requires direct session access)
|
||||||
status_ = DrawRomSelector();
|
status_ = DrawRomSelector();
|
||||||
|
|
||||||
// Delegate to UICoordinator for clean separation of concerns
|
// Delegate menu bar extras to UICoordinator (session indicator, version display)
|
||||||
if (ui_coordinator_) {
|
if (ui_coordinator_) {
|
||||||
ui_coordinator_->DrawMenuBarExtras();
|
ui_coordinator_->DrawMenuBarExtras();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version display on far right
|
|
||||||
ImGui::SameLine(ImGui::GetWindowWidth() - version_width - 10);
|
|
||||||
ImGui::Text("%s", version_text.c_str());
|
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -343,11 +343,6 @@ void MenuOrchestrator::AddHelpMenuItems() {
|
|||||||
menu_builder_
|
menu_builder_
|
||||||
.Item("Getting Started", ICON_MD_PLAY_ARROW,
|
.Item("Getting Started", ICON_MD_PLAY_ARROW,
|
||||||
[this]() { OnShowGettingStarted(); })
|
[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,
|
.Item("Asar Integration", ICON_MD_CODE,
|
||||||
[this]() { OnShowAsarIntegration(); })
|
[this]() { OnShowAsarIntegration(); })
|
||||||
.Item("Build Instructions", ICON_MD_BUILD,
|
.Item("Build Instructions", ICON_MD_BUILD,
|
||||||
@@ -548,8 +543,7 @@ void MenuOrchestrator::OnSwitchToEditor(EditorType editor_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuOrchestrator::OnShowEditorSelection() {
|
void MenuOrchestrator::OnShowEditorSelection() {
|
||||||
// Delegate to EditorManager
|
// Delegate to UICoordinator for editor selection dialog display
|
||||||
// TODO: Draw editor selection via UICoordinator
|
|
||||||
if (editor_manager_) {
|
if (editor_manager_) {
|
||||||
if (auto* ui = editor_manager_->ui_coordinator()) {
|
if (auto* ui = editor_manager_->ui_coordinator()) {
|
||||||
ui->ShowEditorSelection();
|
ui->ShowEditorSelection();
|
||||||
@@ -558,8 +552,7 @@ void MenuOrchestrator::OnShowEditorSelection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuOrchestrator::OnShowDisplaySettings() {
|
void MenuOrchestrator::OnShowDisplaySettings() {
|
||||||
// Delegate to EditorManager
|
// Delegate to UICoordinator for display settings popup
|
||||||
// TODO: Draw display settings via UICoordinator
|
|
||||||
if (editor_manager_) {
|
if (editor_manager_) {
|
||||||
if (auto* ui = editor_manager_->ui_coordinator()) {
|
if (auto* ui = editor_manager_->ui_coordinator()) {
|
||||||
ui->ShowDisplaySettings();
|
ui->ShowDisplaySettings();
|
||||||
@@ -630,7 +623,7 @@ void MenuOrchestrator::OnSwitchToSession(size_t session_index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuOrchestrator::OnShowSessionSwitcher() {
|
void MenuOrchestrator::OnShowSessionSwitcher() {
|
||||||
// TODO: Draw session switcher via UICoordinator
|
// Delegate to UICoordinator for session switcher UI
|
||||||
if (editor_manager_) {
|
if (editor_manager_) {
|
||||||
if (auto* ui = editor_manager_->ui_coordinator()) {
|
if (auto* ui = editor_manager_->ui_coordinator()) {
|
||||||
ui->ShowSessionSwitcher();
|
ui->ShowSessionSwitcher();
|
||||||
@@ -795,14 +788,6 @@ void MenuOrchestrator::OnShowAbout() {
|
|||||||
popup_manager_.Show("About");
|
popup_manager_.Show("About");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuOrchestrator::OnShowKeyboardShortcuts() {
|
|
||||||
popup_manager_.Show("Keyboard Shortcuts");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuOrchestrator::OnShowUserGuide() {
|
|
||||||
popup_manager_.Show("User Guide");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuOrchestrator::OnShowGettingStarted() {
|
void MenuOrchestrator::OnShowGettingStarted() {
|
||||||
popup_manager_.Show("Getting Started");
|
popup_manager_.Show("Getting Started");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ UICoordinator::UICoordinator(
|
|||||||
SessionCoordinator& session_coordinator,
|
SessionCoordinator& session_coordinator,
|
||||||
WindowDelegate& window_delegate,
|
WindowDelegate& window_delegate,
|
||||||
ToastManager& toast_manager,
|
ToastManager& toast_manager,
|
||||||
PopupManager& popup_manager)
|
PopupManager& popup_manager,
|
||||||
|
ShortcutManager& shortcut_manager)
|
||||||
: editor_manager_(editor_manager),
|
: editor_manager_(editor_manager),
|
||||||
rom_manager_(rom_manager),
|
rom_manager_(rom_manager),
|
||||||
project_manager_(project_manager),
|
project_manager_(project_manager),
|
||||||
@@ -39,7 +40,8 @@ UICoordinator::UICoordinator(
|
|||||||
session_coordinator_(session_coordinator),
|
session_coordinator_(session_coordinator),
|
||||||
window_delegate_(window_delegate),
|
window_delegate_(window_delegate),
|
||||||
toast_manager_(toast_manager),
|
toast_manager_(toast_manager),
|
||||||
popup_manager_(popup_manager) {
|
popup_manager_(popup_manager),
|
||||||
|
shortcut_manager_(shortcut_manager) {
|
||||||
|
|
||||||
// Initialize welcome screen with proper callbacks
|
// Initialize welcome screen with proper callbacks
|
||||||
welcome_screen_ = std::make_unique<WelcomeScreen>();
|
welcome_screen_ = std::make_unique<WelcomeScreen>();
|
||||||
@@ -92,8 +94,7 @@ UICoordinator::UICoordinator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UICoordinator::DrawAllUI() {
|
void UICoordinator::DrawAllUI() {
|
||||||
// Apply Material Design styling
|
// Note: Theme styling is applied by ThemeManager, not here
|
||||||
ApplyMaterialDesignStyling();
|
|
||||||
|
|
||||||
// Draw all UI components in order
|
// Draw all UI components in order
|
||||||
DrawMenuBarExtras();
|
DrawMenuBarExtras();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class EditorRegistry;
|
|||||||
class SessionCoordinator;
|
class SessionCoordinator;
|
||||||
class ToastManager;
|
class ToastManager;
|
||||||
class WindowDelegate;
|
class WindowDelegate;
|
||||||
|
class ShortcutManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class UICoordinator
|
* @class UICoordinator
|
||||||
@@ -47,7 +48,8 @@ class UICoordinator {
|
|||||||
SessionCoordinator& session_coordinator,
|
SessionCoordinator& session_coordinator,
|
||||||
WindowDelegate& window_delegate,
|
WindowDelegate& window_delegate,
|
||||||
ToastManager& toast_manager,
|
ToastManager& toast_manager,
|
||||||
PopupManager& popup_manager);
|
PopupManager& popup_manager,
|
||||||
|
ShortcutManager& shortcut_manager);
|
||||||
~UICoordinator() = default;
|
~UICoordinator() = default;
|
||||||
|
|
||||||
// Non-copyable due to reference members
|
// Non-copyable due to reference members
|
||||||
@@ -59,6 +61,10 @@ class UICoordinator {
|
|||||||
void DrawMenuBarExtras();
|
void DrawMenuBarExtras();
|
||||||
void DrawContextSensitiveCardControl();
|
void DrawContextSensitiveCardControl();
|
||||||
|
|
||||||
|
// Core UI components (actual ImGui rendering moved from EditorManager)
|
||||||
|
void DrawCommandPalette();
|
||||||
|
void DrawGlobalSearch();
|
||||||
|
|
||||||
// Session UI components
|
// Session UI components
|
||||||
void DrawSessionSwitcher();
|
void DrawSessionSwitcher();
|
||||||
void DrawSessionManager();
|
void DrawSessionManager();
|
||||||
@@ -117,10 +123,7 @@ class UICoordinator {
|
|||||||
void SetImGuiDemoVisible(bool visible) { show_imgui_demo_ = visible; }
|
void SetImGuiDemoVisible(bool visible) { show_imgui_demo_ = visible; }
|
||||||
void SetImGuiMetricsVisible(bool visible) { show_imgui_metrics_ = visible; }
|
void SetImGuiMetricsVisible(bool visible) { show_imgui_metrics_ = visible; }
|
||||||
|
|
||||||
// Theme and styling helpers
|
// Note: Theme styling is handled by ThemeManager, not UICoordinator
|
||||||
void ApplyMaterialDesignStyling();
|
|
||||||
void UpdateThemeElements();
|
|
||||||
void DrawThemePreview();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// References to coordinated managers
|
// References to coordinated managers
|
||||||
@@ -132,6 +135,7 @@ class UICoordinator {
|
|||||||
WindowDelegate& window_delegate_;
|
WindowDelegate& window_delegate_;
|
||||||
ToastManager& toast_manager_;
|
ToastManager& toast_manager_;
|
||||||
PopupManager& popup_manager_;
|
PopupManager& popup_manager_;
|
||||||
|
ShortcutManager& shortcut_manager_;
|
||||||
|
|
||||||
// UI state flags (UICoordinator owns all UI visibility state)
|
// UI state flags (UICoordinator owns all UI visibility state)
|
||||||
bool show_editor_selection_ = false;
|
bool show_editor_selection_ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user