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 void DrawNotificationBell(bool show_dirty, bool has_dirty_rom,
80 bool show_session, bool has_multiple_sessions);
81 void DrawSessionButton();
82
83 // Core UI components (actual ImGui rendering moved from EditorManager)
84 void DrawCommandPalette();
85 void DrawPanelFinder();
86 void DrawGlobalSearch();
88
89 // Session UI components
93 void DrawLayoutPresets();
94
95 // Welcome screen and project UI
96 void DrawWelcomeScreen();
97 void DrawProjectHelp();
99 const std::string& initial_template = "Vanilla ROM Hack") {
100 new_project_dialog_.Open(initial_template);
101 }
103
104 // Window management UI
106
107 // Popup and dialog management
108 void DrawAllPopups();
109 void ShowPopup(const std::string& popup_name);
110 void HidePopup(const std::string& popup_name);
111
112 // UI state management
114 void ShowDisplaySettings();
117 // Session switcher is now managed by SessionCoordinator
118 void ShowSessionSwitcher();
119 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
120 void TogglePanelSidebar();
122 void ShowCommandPalette();
125
130 void InitializeCommandPalette(size_t session_id);
132
137 void RefreshCommandPalette(size_t session_id);
139
140 // Menu bar visibility (for WASM/web app mode)
141 bool IsMenuBarVisible() const { return show_menu_bar_; }
142 void SetMenuBarVisible(bool visible) { show_menu_bar_ = visible; }
144
145 // Draw floating menu bar restore button (when menu bar is hidden)
147
148 // Window visibility management
149 void ShowAllWindows();
150 void HideAllWindows();
151
152 // UI state queries (EditorManager can check these)
155 // Session switcher visibility managed by SessionCoordinator
156 bool IsSessionSwitcherVisible() const;
167 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
168 bool IsPanelSidebarVisible() const;
169 bool IsImGuiDemoVisible() const { return show_imgui_demo_; }
171 // Emulator + Assembly visibility delegate to WorkspaceWindowManager (single
172 // source of truth). Assembly follows the same category-backed pattern as the
173 // emulator; there is no per-editor boolean that can drift.
174 bool IsEmulatorVisible() const;
175 bool IsAsmEditorVisible() const;
179 bool IsAIAgentVisible() const { return show_ai_agent_; }
182
183 // UI state setters (for programmatic control)
184 void SetEditorSelectionVisible(bool visible) {
185 show_editor_selection_ = visible;
186 }
187 void SetDisplaySettingsVisible(bool visible) {
188 show_display_settings_ = visible;
189 }
190 // Session switcher state managed by SessionCoordinator
191 void SetSessionSwitcherVisible(bool visible);
192 void SetWelcomeScreenVisible(bool visible) { show_welcome_screen_ = visible; }
197 void SetGlobalSearchVisible(bool visible) { show_global_search_ = visible; }
200 }
201 void SetWindowBrowserVisible(bool visible) { show_panel_browser_ = visible; }
202 void SetCommandPaletteVisible(bool visible);
203 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
204 void SetPanelSidebarVisible(bool visible);
205 void SetImGuiDemoVisible(bool visible) { show_imgui_demo_ = visible; }
206 void SetImGuiMetricsVisible(bool visible) { show_imgui_metrics_ = visible; }
207 // Emulator + Assembly visibility delegate to WorkspaceWindowManager.
208 void SetEmulatorVisible(bool visible);
209 void SetAsmEditorVisible(bool visible);
212 }
214 void SetAIAgentVisible(bool visible) { show_ai_agent_ = visible; }
215
216 // Startup surface management (single source of truth)
220 void SetStartupSurface(StartupSurface surface);
221 bool ShouldShowWelcome() const;
222 bool ShouldShowDashboard() const;
223 bool ShouldShowActivityBar() const;
224 void SetChatHistoryVisible(bool visible) { show_chat_history_ = visible; }
225 void SetProposalDrawerVisible(bool visible) {
226 show_proposal_drawer_ = visible;
227 }
228
229 // Note: Theme styling is handled by ThemeManager, not UICoordinator
230
231 private:
232 // References to coordinated managers
243
244 // UI state flags (UICoordinator owns all UI visibility state)
247 // show_session_switcher_ removed - managed by SessionCoordinator
252 bool show_imgui_demo_ = false;
256 bool show_panel_finder_ = false;
258 // show_emulator_ removed - now managed by WorkspaceWindowManager
259 // show_panel_sidebar_ removed - now managed by WorkspaceWindowManager
260 // show_memory_editor_ / show_palette_editor_ removed - dead state, their
261 // editors register panels with WorkspaceWindowManager directly.
262 // show_asm_editor_ removed - now delegates via GetWindowsInCategory("Assembly")
264 bool show_ai_agent_ = false;
265 bool show_chat_history_ = false;
269 bool show_menu_bar_ = true; // Menu bar visible by default
272
273 // Single source of truth for startup surface state
275
276 // Command Palette state
281
282 // Window Finder state
283 char panel_finder_query_[256] = {};
285
286 // Global Search state
287 char global_search_query_[256] = {};
288
289 // Welcome screen component
290 std::unique_ptr<WelcomeScreen> welcome_screen_;
291
292 // "New Project" guided dialog. Opened when the welcome screen dispatches a
293 // template-creation request; owned here so it survives welcome-screen
294 // visibility transitions during startup.
296
297 // Menu bar icon button helper - provides consistent styling for all menubar buttons
298 // Returns true if button was clicked
299 bool DrawMenuBarIconButton(const char* icon, const char* tooltip,
300 bool is_active = false);
301
302 // Calculate width of a menubar icon button (icon + frame padding)
303 static float GetMenuBarIconButtonWidth();
304
305 // Material Design component helpers
306 void DrawMaterialButton(const std::string& text, const std::string& icon,
307 const ImVec4& color, std::function<void()> callback,
308 bool enabled = true);
309
310 // Mobile helpers
311 bool IsCompactLayout() const;
312
313 // Layout and positioning helpers
314 void CenterWindow(const std::string& window_name);
315 void PositionWindow(const std::string& window_name, float x, float y);
316 void SetWindowSize(const std::string& window_name, float width, float height);
317};
318
319} // namespace editor
320} // namespace yaze
321
322#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 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 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.