yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
ui_coordinator.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SHELL_COORDINATOR_UI_COORDINATOR_H_
2#define YAZE_APP_EDITOR_SHELL_COORDINATOR_UI_COORDINATOR_H_
3
4#include <memory>
5#include <string>
6
7#include "absl/status/status.h"
8#include "app/editor/editor.h"
13#include "app/gui/core/icons.h"
14#include "app/startup_flags.h"
15
16namespace yaze {
17namespace editor {
18
27enum class StartupSurface {
28 kWelcome, // No ROM, showing onboarding
29 kDashboard, // ROM loaded, no active editor
30 kEditor, // Active editor/category
31};
32
33// Forward declarations to avoid circular dependencies
34class EditorManager;
35class RomFileManager;
36class ProjectManager;
37class EditorRegistry;
38class SessionCoordinator;
39class ToastManager;
40class WindowDelegate;
41class ShortcutManager;
42class WorkspaceWindowManager;
43
60 public:
61 // Constructor takes references to the managers it coordinates with
62 UICoordinator(EditorManager* editor_manager, RomFileManager& rom_manager,
63 ProjectManager& project_manager,
64 EditorRegistry& editor_registry,
65 WorkspaceWindowManager& card_registry,
66 SessionCoordinator& session_coordinator,
67 WindowDelegate& window_delegate, ToastManager& toast_manager,
68 PopupManager& popup_manager, ShortcutManager& shortcut_manager);
69 ~UICoordinator() = default;
70
71 // Non-copyable due to reference members
72 UICoordinator(const UICoordinator&) = delete;
74
75 // Main UI drawing interface
76 void DrawBackground();
77 void DrawAllUI();
78 void DrawMenuBarExtras();
79 // Shared styling for menu-bar icon buttons (hamburger, bell, session, WASM).
80 bool DrawMenuBarIconButton(const char* icon, const char* tooltip,
81 bool is_active = false);
82 void DrawNotificationBell(bool show_dirty, bool has_dirty_rom,
83 bool show_session, bool has_multiple_sessions);
84 void DrawSessionButton();
85
86 // Core UI components (actual ImGui rendering moved from EditorManager)
87 void DrawCommandPalette();
88 void DrawPanelFinder();
90 void DrawGlobalSearch();
92
93 // Session UI components
97 void DrawLayoutPresets();
98
99 // Welcome screen and project UI
100 void DrawWelcomeScreen();
101 void DrawProjectHelp();
103 const std::string& initial_template = "Vanilla ROM Hack") {
104 new_project_dialog_.Open(initial_template);
105 }
107
108 // Window management UI
110
111 // Popup and dialog management
112 void DrawAllPopups();
113 void ShowPopup(const std::string& popup_name);
114 void HidePopup(const std::string& popup_name);
115
116 // UI state management
118 void ShowDisplaySettings();
121 // Session switcher is now managed by SessionCoordinator
122 void ShowSessionSwitcher();
123 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
124 void TogglePanelSidebar();
126 void ShowCommandPalette(const char* initial_query = nullptr);
129 void ShowPanelFinder();
133
138 void InitializeCommandPalette(size_t session_id);
140
145 void RefreshCommandPalette(size_t session_id);
147
148 // Menu bar visibility (for WASM/web app mode)
149 bool IsMenuBarVisible() const { return show_menu_bar_; }
150 void SetMenuBarVisible(bool visible) { show_menu_bar_ = visible; }
152
153 // Draw floating menu bar restore button (when menu bar is hidden)
155
156 // Window visibility management
157 void ShowAllWindows();
158 void HideAllWindows();
159
160 // UI state queries (EditorManager can check these)
163 // Session switcher visibility managed by SessionCoordinator
164 bool IsSessionSwitcherVisible() const;
175 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
176 bool IsPanelSidebarVisible() const;
177 bool IsImGuiDemoVisible() const { return show_imgui_demo_; }
179 // Emulator + Assembly visibility delegate to WorkspaceWindowManager (single
180 // source of truth). Assembly follows the same category-backed pattern as the
181 // emulator; there is no per-editor boolean that can drift.
182 bool IsEmulatorVisible() const;
183 bool IsAsmEditorVisible() const;
187 bool IsAIAgentVisible() const { return show_ai_agent_; }
190
191 // UI state setters (for programmatic control)
192 // Automatic entry into the dashboard (ROM load, project load, ROM-options
193 // apply). `--startup_dashboard=hide` suppresses exactly this path.
194 // Ctrl+E goes through ShowEditorSelection() and is deliberately unaffected:
195 // the flag governs startup, not the shortcut.
196 void SetEditorSelectionVisible(bool visible) {
197 if (visible && !ShouldShowDashboard()) {
198 return;
199 }
200 show_editor_selection_ = visible;
201 }
202 void SetDisplaySettingsVisible(bool visible) {
203 show_display_settings_ = visible;
204 }
205 // Session switcher state managed by SessionCoordinator
206 void SetSessionSwitcherVisible(bool visible);
207 void SetWelcomeScreenVisible(bool visible) { show_welcome_screen_ = visible; }
212 void SetGlobalSearchVisible(bool visible) { show_global_search_ = visible; }
215 }
216 void SetWindowBrowserVisible(bool visible) { show_panel_browser_ = visible; }
217 void SetCommandPaletteVisible(bool visible);
218 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
219 void SetPanelSidebarVisible(bool visible);
220 void SetImGuiDemoVisible(bool visible) { show_imgui_demo_ = visible; }
221 void SetImGuiMetricsVisible(bool visible) { show_imgui_metrics_ = visible; }
222 // Emulator + Assembly visibility delegate to WorkspaceWindowManager.
223 void SetEmulatorVisible(bool visible);
224 void SetAsmEditorVisible(bool visible);
227 }
229 void SetAIAgentVisible(bool visible) { show_ai_agent_ = visible; }
230
231 // Startup surface management (single source of truth)
235 void SetStartupSurface(StartupSurface surface);
236 bool ShouldShowWelcome() const;
237 bool ShouldShowDashboard() const;
238 bool ShouldShowActivityBar() const;
239 void SetChatHistoryVisible(bool visible) { show_chat_history_ = visible; }
240 void SetProposalDrawerVisible(bool visible) {
241 show_proposal_drawer_ = visible;
242 }
243
244 // Note: Theme styling is handled by ThemeManager, not UICoordinator
245
246 private:
247 // References to coordinated managers
258
259 // UI state flags (UICoordinator owns all UI visibility state)
262 // show_session_switcher_ removed - managed by SessionCoordinator
267 bool show_imgui_demo_ = false;
271 bool show_panel_finder_ = false;
274 // show_emulator_ removed - now managed by WorkspaceWindowManager
275 // show_panel_sidebar_ removed - now managed by WorkspaceWindowManager
276 // show_memory_editor_ / show_palette_editor_ removed - dead state, their
277 // editors register panels with WorkspaceWindowManager directly.
278 // show_asm_editor_ removed - now delegates via GetWindowsInCategory("Assembly")
280 bool show_ai_agent_ = false;
281 bool show_chat_history_ = false;
285 bool show_menu_bar_ = true; // Menu bar visible by default
288
289 // Single source of truth for startup surface state
291
292 // Command Palette state
297
298 // Window Finder state (legacy modal; ShowPanelFinder now seeds the palette)
299 char panel_finder_query_[256] = {};
301
302 // Shortcuts browser state
304
305 // Global Search state
306 char global_search_query_[256] = {};
307
308 // Welcome screen component
309 std::unique_ptr<WelcomeScreen> welcome_screen_;
310
311 // "New Project" guided dialog. Owned here so it survives welcome-screen
312 // visibility transitions during startup.
314
315 // Calculate width of a menubar icon button (icon + frame padding)
316 static float GetMenuBarIconButtonWidth();
317
318 // Material Design component helpers
319 void DrawMaterialButton(const std::string& text, const std::string& icon,
320 const ImVec4& color, std::function<void()> callback,
321 bool enabled = true);
322
323 // Mobile helpers
324 bool IsCompactLayout() const;
325
326 // Layout and positioning helpers
327 void CenterWindow(const std::string& window_name);
328 void PositionWindow(const std::string& window_name, float x, float y);
329 void SetWindowSize(const std::string& window_name, float width, float height);
330};
331
332} // namespace editor
333} // namespace yaze
334
335#endif // YAZE_APP_EDITOR_SHELL_COORDINATOR_UI_COORDINATOR_H_
The EditorManager controls the main editor window and manages the various editor classes.
Manages editor types, categories, and lifecycle.
void Open(const std::string &initial_template="")
Handles all project file operations with ROM-first workflow.
Handles all ROM file I/O operations.
High-level orchestrator for multi-session UI.
Handles all UI drawing operations and state management.
ShortcutManager & shortcut_manager_
void DrawMaterialButton(const std::string &text, const std::string &icon, const ImVec4 &color, std::function< void()> callback, bool enabled=true)
void SetPanelSidebarVisible(bool visible)
void SetWindowBrowserVisible(bool visible)
void SetPerformanceDashboardVisible(bool visible)
void SetSessionSwitcherVisible(bool visible)
void SetGlobalSearchVisible(bool visible)
void HidePopup(const std::string &popup_name)
void SetStartupSurface(StartupSurface surface)
bool IsPerformanceDashboardVisible() const
SessionCoordinator & session_coordinator_
void InitializeCommandPalette(size_t session_id)
Initialize command palette with all discoverable commands.
void RefreshCommandPalette(size_t session_id)
Refresh command palette commands (call after session switch)
void SetWelcomeScreenManuallyClosed(bool closed)
void SetResourceLabelManagerVisible(bool visible)
void SetEmulatorVisible(bool visible)
void ShowCommandPalette(const char *initial_query=nullptr)
void DrawNotificationBell(bool show_dirty, bool has_dirty_rom, bool show_session, bool has_multiple_sessions)
void SetAsmEditorVisible(bool visible)
void SetWelcomeScreenVisible(bool visible)
WindowDelegate & window_delegate_
bool DrawMenuBarIconButton(const char *icon, const char *tooltip, bool is_active=false)
void ShowPopup(const std::string &popup_name)
ProjectManager & project_manager_
CommandPalette * command_palette()
StartupVisibility welcome_behavior_override_
UICoordinator & operator=(const UICoordinator &)=delete
bool IsResourceLabelManagerVisible() const
bool IsWelcomeScreenManuallyClosed() const
StartupVisibility dashboard_behavior_override_
StartupSurface current_startup_surface_
void ShowShortcutsBrowser()
Searchable shortcut map grouped by menu IA (File / View / Drawers / …).
void OpenNewProjectDialog(const std::string &initial_template="Vanilla ROM Hack")
void PositionWindow(const std::string &window_name, float x, float y)
void SetWindowSize(const std::string &window_name, float width, float height)
NewProjectDialog new_project_dialog_
UICoordinator(const UICoordinator &)=delete
void SetWelcomeScreenBehavior(StartupVisibility mode)
void SetImGuiDemoVisible(bool visible)
void SetChatHistoryVisible(bool visible)
WorkspaceWindowManager & window_manager_
void SetDisplaySettingsVisible(bool visible)
void SetDashboardBehavior(StartupVisibility mode)
void SetCommandPaletteVisible(bool visible)
void SetMenuBarVisible(bool visible)
void SetAIAgentVisible(bool visible)
std::unique_ptr< WelcomeScreen > welcome_screen_
void SetImGuiMetricsVisible(bool visible)
static float GetMenuBarIconButtonWidth()
void SetEditorSelectionVisible(bool visible)
UICoordinator(EditorManager *editor_manager, RomFileManager &rom_manager, ProjectManager &project_manager, EditorRegistry &editor_registry, WorkspaceWindowManager &card_registry, SessionCoordinator &session_coordinator, WindowDelegate &window_delegate, ToastManager &toast_manager, PopupManager &popup_manager, ShortcutManager &shortcut_manager)
void SetProposalDrawerVisible(bool visible)
StartupSurface GetCurrentStartupSurface() const
EditorRegistry & editor_registry_
void CenterWindow(const std::string &window_name)
Low-level window operations with minimal dependencies.
Central registry for all editor cards with session awareness and dependency injection.
StartupSurface
Represents the current startup surface state.
StartupVisibility
Tri-state toggle used for startup UI visibility controls.