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_UI_UI_COORDINATOR_H_
2#define YAZE_APP_EDITOR_UI_UI_COORDINATOR_H_
3
4#include <memory>
5#include <string>
6
7#include "absl/status/status.h"
8#include "app/editor/editor.h"
12#include "app/gui/core/icons.h"
13#include "app/startup_flags.h"
14
15namespace yaze {
16namespace editor {
17
26enum class StartupSurface {
27 kWelcome, // No ROM, showing onboarding
28 kDashboard, // ROM loaded, no active editor
29 kEditor, // Active editor/category
30};
31
32// Forward declarations to avoid circular dependencies
33class EditorManager;
34class RomFileManager;
35class ProjectManager;
36class EditorRegistry;
37class SessionCoordinator;
38class ToastManager;
39class WindowDelegate;
40class ShortcutManager;
41
58 public:
59 // Constructor takes references to the managers it coordinates with
60 UICoordinator(EditorManager* editor_manager, RomFileManager& rom_manager,
61 ProjectManager& project_manager,
62 EditorRegistry& editor_registry,
63 PanelManager& card_registry,
64 SessionCoordinator& session_coordinator,
65 WindowDelegate& window_delegate, ToastManager& toast_manager,
66 PopupManager& popup_manager, ShortcutManager& shortcut_manager);
67 ~UICoordinator() = default;
68
69 // Non-copyable due to reference members
70 UICoordinator(const UICoordinator&) = delete;
72
73 // Main UI drawing interface
74 void DrawBackground();
75 void DrawAllUI();
76 void DrawMenuBarExtras();
77 void DrawNotificationBell(bool show_dirty, bool has_dirty_rom,
78 bool show_session, bool has_multiple_sessions);
79 void DrawSessionButton();
80
81 // Core UI components (actual ImGui rendering moved from EditorManager)
82 void DrawCommandPalette();
83 void DrawPanelFinder();
84 void DrawGlobalSearch();
86
87 // Session UI components
91 void DrawLayoutPresets();
92
93 // Welcome screen and project UI
94 void DrawWelcomeScreen();
95 void DrawProjectHelp();
96
97 // Window management UI
99
100 // Popup and dialog management
101 void DrawAllPopups();
102 void ShowPopup(const std::string& popup_name);
103 void HidePopup(const std::string& popup_name);
104
105 // UI state management
107 void ShowDisplaySettings();
110 // Session switcher is now managed by SessionCoordinator
111 void ShowSessionSwitcher();
112 // Sidebar visibility delegates to PanelManager (single source of truth)
113 void TogglePanelSidebar();
118
123 void InitializeCommandPalette(size_t session_id);
124
129 void RefreshCommandPalette(size_t session_id);
130
131 // Menu bar visibility (for WASM/web app mode)
132 bool IsMenuBarVisible() const { return show_menu_bar_; }
133 void SetMenuBarVisible(bool visible) { show_menu_bar_ = visible; }
135
136 // Draw floating menu bar restore button (when menu bar is hidden)
138
139 // Window visibility management
140 void ShowAllWindows();
141 void HideAllWindows();
142
143 // UI state queries (EditorManager can check these)
146 // Session switcher visibility managed by SessionCoordinator
147 bool IsSessionSwitcherVisible() const;
158 // Sidebar visibility delegates to PanelManager (single source of truth)
159 bool IsPanelSidebarVisible() const;
160 bool IsImGuiDemoVisible() const { return show_imgui_demo_; }
162 // Emulator visibility delegates to PanelManager (single source of truth)
163 bool IsEmulatorVisible() const;
165 bool IsAsmEditorVisible() const { return show_asm_editor_; }
170 bool IsAIAgentVisible() const { return show_ai_agent_; }
173
174 // UI state setters (for programmatic control)
175 void SetEditorSelectionVisible(bool visible) {
176 show_editor_selection_ = visible;
177 }
178 void SetDisplaySettingsVisible(bool visible) {
179 show_display_settings_ = visible;
180 }
181 // Session switcher state managed by SessionCoordinator
182 void SetSessionSwitcherVisible(bool visible);
183 void SetWelcomeScreenVisible(bool visible) { show_welcome_screen_ = visible; }
188 void SetGlobalSearchVisible(bool visible) { show_global_search_ = visible; }
191 }
192 void SetPanelBrowserVisible(bool visible) { show_panel_browser_ = visible; }
193 void SetCommandPaletteVisible(bool visible) {
194 show_command_palette_ = visible;
195 }
196 // Sidebar visibility delegates to PanelManager (single source of truth)
197 void SetPanelSidebarVisible(bool visible);
198 void SetImGuiDemoVisible(bool visible) { show_imgui_demo_ = visible; }
199 void SetImGuiMetricsVisible(bool visible) { show_imgui_metrics_ = visible; }
200 // Emulator visibility delegates to PanelManager (single source of truth)
201 void SetEmulatorVisible(bool visible);
202 void SetMemoryEditorVisible(bool visible) { show_memory_editor_ = visible; }
203 void SetAsmEditorVisible(bool visible) { show_asm_editor_ = visible; }
204 void SetPaletteEditorVisible(bool visible) { show_palette_editor_ = visible; }
207 }
209 void SetAIAgentVisible(bool visible) { show_ai_agent_ = visible; }
210
211 // Startup surface management (single source of truth)
213 void SetStartupSurface(StartupSurface surface);
214 bool ShouldShowWelcome() const;
215 bool ShouldShowDashboard() const;
216 bool ShouldShowActivityBar() const;
217 void SetChatHistoryVisible(bool visible) { show_chat_history_ = visible; }
218 void SetProposalDrawerVisible(bool visible) { show_proposal_drawer_ = visible; }
219
220 // Note: Theme styling is handled by ThemeManager, not UICoordinator
221
222 private:
223 // References to coordinated managers
234
235 // UI state flags (UICoordinator owns all UI visibility state)
238 // show_session_switcher_ removed - managed by SessionCoordinator
243 bool show_imgui_demo_ = false;
247 bool show_panel_finder_ = false;
249 // show_emulator_ removed - now managed by PanelManager
250 // show_panel_sidebar_ removed - now managed by PanelManager
252 bool show_asm_editor_ = false;
255 bool show_ai_agent_ = false;
256 bool show_chat_history_ = false;
260 bool show_menu_bar_ = true; // Menu bar visible by default
263
264 // Single source of truth for startup surface state
266
267 // Command Palette state
272
273 // Panel Finder state
274 char panel_finder_query_[256] = {};
276
277 // Global Search state
278 char global_search_query_[256] = {};
279
280 // Welcome screen component
281 std::unique_ptr<WelcomeScreen> welcome_screen_;
282
283
284 // Menu bar icon button helper - provides consistent styling for all menubar buttons
285 // Returns true if button was clicked
286 bool DrawMenuBarIconButton(const char* icon, const char* tooltip,
287 bool is_active = false);
288
289 // Calculate width of a menubar icon button (icon + frame padding)
290 static float GetMenuBarIconButtonWidth();
291
292 // Material Design component helpers
293 void DrawMaterialButton(const std::string& text, const std::string& icon,
294 const ImVec4& color, std::function<void()> callback,
295 bool enabled = true);
296
297 // Mobile helpers
298 bool IsCompactLayout() const;
299
300 // Layout and positioning helpers
301 void CenterWindow(const std::string& window_name);
302 void PositionWindow(const std::string& window_name, float x, float y);
303 void SetWindowSize(const std::string& window_name, float width, float height);
304
305};
306
307} // namespace editor
308} // namespace yaze
309
310#endif // YAZE_APP_EDITOR_UI_UI_COORDINATOR_H_
The EditorManager controls the main editor window and manages the various editor classes.
Manages editor types, categories, and lifecycle.
Central registry for all editor cards with session awareness and dependency injection.
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 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)
UICoordinator(EditorManager *editor_manager, RomFileManager &rom_manager, ProjectManager &project_manager, EditorRegistry &editor_registry, PanelManager &card_registry, SessionCoordinator &session_coordinator, WindowDelegate &window_delegate, ToastManager &toast_manager, PopupManager &popup_manager, ShortcutManager &shortcut_manager)
void SetWelcomeScreenManuallyClosed(bool closed)
void SetMemoryEditorVisible(bool visible)
void SetResourceLabelManagerVisible(bool visible)
void SetEmulatorVisible(bool visible)
void SetPanelBrowserVisible(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_
StartupVisibility welcome_behavior_override_
UICoordinator & operator=(const UICoordinator &)=delete
bool IsResourceLabelManagerVisible() const
bool IsWelcomeScreenManuallyClosed() const
StartupVisibility dashboard_behavior_override_
StartupSurface current_startup_surface_
void PositionWindow(const std::string &window_name, float x, float y)
void SetWindowSize(const std::string &window_name, float width, float height)
UICoordinator(const UICoordinator &)=delete
void SetWelcomeScreenBehavior(StartupVisibility mode)
void SetImGuiDemoVisible(bool visible)
void SetChatHistoryVisible(bool visible)
void SetPaletteEditorVisible(bool visible)
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)
void SetProposalDrawerVisible(bool visible)
StartupSurface GetCurrentStartupSurface() const
EditorRegistry & editor_registry_
void CenterWindow(const std::string &window_name)
Low-level window operations with minimal dependencies.
StartupSurface
Represents the current startup surface state.
StartupVisibility
Tri-state toggle used for startup UI visibility controls.