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 <cstdint>
5#include <functional>
6#include <memory>
7#include <string>
8#include <vector>
9
10#include "absl/status/status.h"
11#include "app/editor/editor.h"
16#include "app/gui/core/icons.h"
17#include "app/startup_flags.h"
18
19namespace yaze {
20namespace editor {
21
30enum class StartupSurface {
31 kWelcome, // No ROM, showing onboarding
32 kDashboard, // ROM loaded, no active editor
33 kEditor, // Active editor/category
34};
35
36// Forward declarations to avoid circular dependencies
37class EditorManager;
38class RomFileManager;
39class ProjectManager;
40class EditorRegistry;
41class SessionCoordinator;
42class ToastManager;
43class WindowDelegate;
44class ShortcutManager;
45class WorkspaceWindowManager;
46
63 public:
64 // Constructor takes references to the managers it coordinates with
65 UICoordinator(EditorManager* editor_manager, RomFileManager& rom_manager,
66 ProjectManager& project_manager,
67 EditorRegistry& editor_registry,
68 WorkspaceWindowManager& card_registry,
69 SessionCoordinator& session_coordinator,
70 WindowDelegate& window_delegate, ToastManager& toast_manager,
71 PopupManager& popup_manager, ShortcutManager& shortcut_manager);
72 ~UICoordinator() = default;
73
74 // Non-copyable due to reference members
75 UICoordinator(const UICoordinator&) = delete;
77
78 // Main UI drawing interface
79 void DrawBackground();
80 void DrawAllUI();
81 void DrawMenuBarExtras();
82 // Shared styling for menu-bar icon buttons (hamburger, bell, session, WASM).
83 bool DrawMenuBarIconButton(const char* icon, const char* tooltip,
84 bool is_active = false);
85 void DrawNotificationBell(bool show_dirty, bool has_dirty_rom,
86 bool show_session, bool has_multiple_sessions);
87 void DrawSessionButton();
88
89 // Core UI components (actual ImGui rendering moved from EditorManager)
90 void DrawCommandPalette();
91 void DrawPanelFinder();
93 void DrawGlobalSearch();
95
96 // Session UI components
100 void DrawLayoutPresets();
101
102 // Welcome screen and project UI
103 void DrawWelcomeScreen();
104 void DrawProjectHelp();
106 const std::string& initial_template = "Vanilla ROM Hack") {
107 new_project_dialog_.Open(initial_template);
108 }
110
111 // Window management UI
113
114 // Popup and dialog management
115 void DrawAllPopups();
116 void ShowPopup(const std::string& popup_name);
117 void HidePopup(const std::string& popup_name);
118
119 // UI state management
121 void ShowDisplaySettings();
124 // Session switcher is now managed by SessionCoordinator
125 void ShowSessionSwitcher();
126 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
127 void TogglePanelSidebar();
129 void ShowCommandPalette(const char* initial_query = nullptr);
132 void ShowPanelFinder();
136
141 void InitializeCommandPalette(size_t session_id);
143
148 void RefreshCommandPalette(size_t session_id);
150
153 void ExecutePaletteCommand(const std::string& name,
154 std::function<void()> callback);
155
156 // Menu bar visibility (for WASM/web app mode)
157 bool IsMenuBarVisible() const { return show_menu_bar_; }
158 void SetMenuBarVisible(bool visible) { show_menu_bar_ = visible; }
160
161 // Draw floating menu bar restore button (when menu bar is hidden)
163
164 // Window visibility management
165 void ShowAllWindows();
166 void HideAllWindows();
167
168 // UI state queries (EditorManager can check these)
171 // Session switcher visibility managed by SessionCoordinator
172 bool IsSessionSwitcherVisible() const;
183 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
184 bool IsPanelSidebarVisible() const;
185 bool IsImGuiDemoVisible() const { return show_imgui_demo_; }
187 // Emulator + Assembly visibility delegate to WorkspaceWindowManager (single
188 // source of truth). Assembly follows the same category-backed pattern as the
189 // emulator; there is no per-editor boolean that can drift.
190 bool IsEmulatorVisible() const;
191 bool IsAsmEditorVisible() const;
195 bool IsAIAgentVisible() const { return show_ai_agent_; }
198
199 // UI state setters (for programmatic control)
200 // Automatic entry into the dashboard (ROM load, project load, ROM-options
201 // apply). `--startup_dashboard=hide` suppresses exactly this path.
202 // Ctrl+E goes through ShowEditorSelection() and is deliberately unaffected:
203 // the flag governs startup, not the shortcut.
204 void SetEditorSelectionVisible(bool visible) {
205 if (visible && !ShouldShowDashboard()) {
206 return;
207 }
208 show_editor_selection_ = visible;
209 }
210 void SetDisplaySettingsVisible(bool visible) {
211 show_display_settings_ = visible;
212 }
213 // Session switcher state managed by SessionCoordinator
214 void SetSessionSwitcherVisible(bool visible);
215 void SetWelcomeScreenVisible(bool visible) { show_welcome_screen_ = visible; }
220 void SetGlobalSearchVisible(bool visible) { show_global_search_ = visible; }
223 }
224 void SetWindowBrowserVisible(bool visible) { show_panel_browser_ = visible; }
225 void SetCommandPaletteVisible(bool visible);
226 // Sidebar visibility delegates to WorkspaceWindowManager (single source of truth)
227 void SetPanelSidebarVisible(bool visible);
228 void SetImGuiDemoVisible(bool visible) { show_imgui_demo_ = visible; }
229 void SetImGuiMetricsVisible(bool visible) { show_imgui_metrics_ = visible; }
230 // Emulator + Assembly visibility delegate to WorkspaceWindowManager.
231 void SetEmulatorVisible(bool visible);
232 void SetAsmEditorVisible(bool visible);
235 }
237 void SetAIAgentVisible(bool visible) { show_ai_agent_ = visible; }
238
239 // Startup surface management (single source of truth)
243 void SetStartupSurface(StartupSurface surface);
244 bool ShouldShowWelcome() const;
245 bool ShouldShowDashboard() const;
246 bool ShouldShowActivityBar() const;
247 void SetChatHistoryVisible(bool visible) { show_chat_history_ = visible; }
248 void SetProposalDrawerVisible(bool visible) {
249 show_proposal_drawer_ = visible;
250 }
251
252 // Note: Theme styling is handled by ThemeManager, not UICoordinator
253
254 private:
255 // References to coordinated managers
266
267 // UI state flags (UICoordinator owns all UI visibility state)
270 // show_session_switcher_ removed - managed by SessionCoordinator
275 bool show_imgui_demo_ = false;
279 bool show_panel_finder_ = false;
282 // show_emulator_ removed - now managed by WorkspaceWindowManager
283 // show_panel_sidebar_ removed - now managed by WorkspaceWindowManager
284 // show_memory_editor_ / show_palette_editor_ removed - dead state, their
285 // editors register panels with WorkspaceWindowManager directly.
286 // show_asm_editor_ removed - now delegates via GetWindowsInCategory("Assembly")
288 bool show_ai_agent_ = false;
289 bool show_chat_history_ = false;
293 bool show_menu_bar_ = true; // Menu bar visible by default
296
297 // Single source of truth for startup surface state
299
300 // Command Palette state
308 // Search() cache: recomputed only when the query or palette changes.
310 uint64_t command_palette_cached_generation_ = ~uint64_t{0};
311 std::vector<CommandMatch> command_palette_cached_matches_;
312
314
315 // Window Finder state (legacy modal; ShowPanelFinder now seeds the palette)
316 char panel_finder_query_[256] = {};
318
319 // Shortcuts browser state
321
322 // Global Search state
323 char global_search_query_[256] = {};
324
325 // Welcome screen component
326 std::unique_ptr<WelcomeScreen> welcome_screen_;
327
328 // "New Project" guided dialog. Owned here so it survives welcome-screen
329 // visibility transitions during startup.
331
332 // Calculate width of a menubar icon button (icon + frame padding)
333 static float GetMenuBarIconButtonWidth();
334
335 // Material Design component helpers
336 void DrawMaterialButton(const std::string& text, const std::string& icon,
337 const ImVec4& color, std::function<void()> callback,
338 bool enabled = true);
339
340 // Mobile helpers
341 bool IsCompactLayout() const;
342
343 // Layout and positioning helpers
344 void CenterWindow(const std::string& window_name);
345 void PositionWindow(const std::string& window_name, float x, float y);
346 void SetWindowSize(const std::string& window_name, float width, float height);
347};
348
349} // namespace editor
350} // namespace yaze
351
352#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)
std::string command_palette_cached_query_
void ShowPopup(const std::string &popup_name)
ProjectManager & project_manager_
std::vector< CommandMatch > command_palette_cached_matches_
CommandPalette * command_palette()
StartupVisibility welcome_behavior_override_
UICoordinator & operator=(const UICoordinator &)=delete
bool IsResourceLabelManagerVisible() const
void ExecutePaletteCommand(const std::string &name, std::function< void()> callback)
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.