yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
layout_manager.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_LAYOUT_LAYOUT_MANAGER_H_
2#define YAZE_APP_EDITOR_LAYOUT_LAYOUT_MANAGER_H_
3
4#include <string>
5#include <unordered_map>
6#include <vector>
7
8#include "app/editor/editor.h"
9#include "imgui/imgui.h"
10
11namespace yaze {
12namespace editor {
13
14// Forward declaration
15class PanelManager;
16
21enum class LayoutType {
27 kScreen,
28 kMusic,
29 kSprite,
34};
35
40enum class LayoutScope {
41 kGlobal,
43};
44
49 std::string id; // Stable id (e.g. "code", "debug")
50 std::string label; // UI-facing label
51 std::string description; // Short profile summary
52 std::string preset_name; // Backing LayoutPresets name
53 bool open_agent_chat = false;
54};
55
72 public:
73 LayoutManager() = default;
74 ~LayoutManager() = default;
75
81 panel_manager_ = manager;
82 }
83
89
95 void InitializeEditorLayout(EditorType type, ImGuiID dockspace_id);
96
105 void RebuildLayout(EditorType type, ImGuiID dockspace_id);
106
112 void SaveCurrentLayout(const std::string& name, bool persist = true);
113
118 void LoadLayout(const std::string& name);
119
125 void CaptureTemporarySessionLayout(size_t session_id);
126
131 bool RestoreTemporarySessionLayout(size_t session_id,
132 bool clear_after_restore = false);
133
138
143
149 bool DeleteLayout(const std::string& name);
150
154 static std::vector<LayoutProfile> GetBuiltInProfiles();
155
164 bool ApplyBuiltInProfile(const std::string& profile_id, size_t session_id,
165 EditorType editor_type,
166 LayoutProfile* out_profile = nullptr);
167
172 std::vector<std::string> GetSavedLayoutNames() const;
173
179 bool HasLayout(const std::string& name) const;
180
184 void LoadLayoutsFromDisk();
185
190 void SetProjectLayoutKey(const std::string& key);
191
195 void UseGlobalLayouts();
196
201
207
213 bool IsLayoutInitialized(EditorType type) const;
214
220
225
231
236
241
245 bool IsRebuildRequested() const { return rebuild_requested_; }
246
251
257 std::string GetWindowTitle(const std::string& card_id) const;
258
259 private:
260 // DockBuilder layout implementations for each editor type
261 void BuildLayoutFromPreset(EditorType type, ImGuiID dockspace_id);
262
263 void LoadLayoutsFromDiskInternal(LayoutScope scope, bool merge);
264 void SaveLayoutsToDisk(LayoutScope scope) const;
265
266 // Deprecated individual builders - kept for compatibility or as wrappers
267 void BuildOverworldLayout(ImGuiID dockspace_id);
268 void BuildDungeonLayout(ImGuiID dockspace_id);
269 void BuildGraphicsLayout(ImGuiID dockspace_id);
270 void BuildPaletteLayout(ImGuiID dockspace_id);
271 void BuildScreenLayout(ImGuiID dockspace_id);
272 void BuildMusicLayout(ImGuiID dockspace_id);
273 void BuildSpriteLayout(ImGuiID dockspace_id);
274 void BuildMessageLayout(ImGuiID dockspace_id);
275 void BuildAssemblyLayout(ImGuiID dockspace_id);
276 void BuildSettingsLayout(ImGuiID dockspace_id);
277 void BuildEmulatorLayout(ImGuiID dockspace_id);
278
279 // Track which layouts have been initialized
280 std::unordered_map<EditorType, bool> layouts_initialized_;
281
282 // Panel manager for window title lookups
284
285 // Current layout type
287
288 // Rebuild flag
289 bool rebuild_requested_ = false;
290
291 // Last used dockspace ID (for rebuild operations)
293
294 // Current editor type being displayed
296
297 // Saved layouts (panel visibility state)
298 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
300
301 // In-memory temporary session snapshot (never persisted).
304 std::unordered_map<std::string, bool> temp_session_visibility_;
305 std::unordered_map<std::string, bool> temp_session_pinned_;
307
308 // Saved ImGui docking layouts (INI data)
309 std::unordered_map<std::string, std::string> saved_imgui_layouts_;
310
311 // Saved pinned panel state for layouts
312 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
314
315 // Layout scope tracking
316 std::unordered_map<std::string, LayoutScope> layout_scopes_;
317
318 // Project storage key for project-scoped layouts
320};
321
322} // namespace editor
323} // namespace yaze
324
325#endif // YAZE_APP_EDITOR_LAYOUT_LAYOUT_MANAGER_H_
Manages ImGui DockBuilder layouts for each editor type.
void SetLayoutType(LayoutType type)
Set the current layout type for rebuild.
void LoadLayout(const std::string &name)
Load a saved layout by name.
std::string GetWindowTitle(const std::string &card_id) const
Get window title for a card ID from registry.
void BuildScreenLayout(ImGuiID dockspace_id)
void BuildPaletteLayout(ImGuiID dockspace_id)
void BuildDungeonLayout(ImGuiID dockspace_id)
void CaptureTemporarySessionLayout(size_t session_id)
Capture the current workspace as a temporary session layout.
void SetProjectLayoutKey(const std::string &key)
Set the active project layout key (enables project scope)
void SetPanelManager(PanelManager *manager)
Set the panel manager for window title lookups.
std::unordered_map< std::string, std::unordered_map< std::string, bool > > saved_layouts_
void SaveLayoutsToDisk(LayoutScope scope) const
void BuildGraphicsLayout(ImGuiID dockspace_id)
void RebuildLayout(EditorType type, ImGuiID dockspace_id)
Force rebuild of layout for a specific editor type.
void BuildEmulatorLayout(ImGuiID dockspace_id)
void LoadLayoutsFromDisk()
Load layouts for the active scope (global + optional project)
void UseGlobalLayouts()
Clear project scope and return to global layouts only.
void BuildAssemblyLayout(ImGuiID dockspace_id)
void ClearInitializationFlags()
Clear all initialization flags (for testing)
bool HasTemporarySessionLayout() const
Whether a temporary session layout is available.
void BuildMessageLayout(ImGuiID dockspace_id)
bool DeleteLayout(const std::string &name)
Delete a saved layout by name.
std::unordered_map< std::string, std::string > saved_imgui_layouts_
std::vector< std::string > GetSavedLayoutNames() const
Get list of all saved layout names.
std::unordered_map< EditorType, bool > layouts_initialized_
void LoadLayoutsFromDiskInternal(LayoutScope scope, bool merge)
bool IsLayoutInitialized(EditorType type) const
Check if a layout has been initialized for an editor.
LayoutType GetLayoutType() const
Get the current layout type.
bool RestoreTemporarySessionLayout(size_t session_id, bool clear_after_restore=false)
Restore the temporary session layout if one has been captured.
void BuildSettingsLayout(ImGuiID dockspace_id)
std::unordered_map< std::string, std::unordered_map< std::string, bool > > saved_pinned_layouts_
void ResetToDefaultLayout(EditorType type)
Reset the layout for an editor to its default.
LayoutScope GetActiveScope() const
Get the active layout scope.
void BuildOverworldLayout(ImGuiID dockspace_id)
void ClearRebuildRequest()
Clear rebuild request flag.
void ClearTemporarySessionLayout()
Clear temporary session layout snapshot state.
PanelManager * panel_manager() const
Get the panel manager.
void MarkLayoutInitialized(EditorType type)
Mark a layout as initialized.
void SaveCurrentLayout(const std::string &name, bool persist=true)
Save the current layout with a custom name.
void RequestRebuild()
Request a layout rebuild on next frame.
static std::vector< LayoutProfile > GetBuiltInProfiles()
Get built-in layout profiles.
void InitializeEditorLayout(EditorType type, ImGuiID dockspace_id)
Initialize the default layout for a specific editor type.
bool IsRebuildRequested() const
Check if rebuild was requested.
bool HasLayout(const std::string &name) const
Check if a layout exists.
std::unordered_map< std::string, LayoutScope > layout_scopes_
void BuildLayoutFromPreset(EditorType type, ImGuiID dockspace_id)
void BuildSpriteLayout(ImGuiID dockspace_id)
bool ApplyBuiltInProfile(const std::string &profile_id, size_t session_id, EditorType editor_type, LayoutProfile *out_profile=nullptr)
Apply a built-in layout profile by profile ID.
std::unordered_map< std::string, bool > temp_session_pinned_
void BuildMusicLayout(ImGuiID dockspace_id)
std::unordered_map< std::string, bool > temp_session_visibility_
Central registry for all editor cards with session awareness and dependency injection.
LayoutScope
Storage scope for saved layouts.
LayoutType
Predefined layout types for different editor workflows.
Built-in workflow-oriented layout profiles.