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 WorkspaceWindowManager;
16
21enum class LayoutType {
27 kScreen,
28 kMusic,
29 kSprite,
34};
35
41
46 std::string id; // Stable id (e.g. "code", "debug")
47 std::string label; // UI-facing label
48 std::string description; // Short profile summary
49 std::string preset_name; // Backing LayoutPresets name
50 bool open_agent_chat = false;
51};
52
69 public:
70 LayoutManager() = default;
71 ~LayoutManager() = default;
72
78 window_manager_ = manager;
79 }
80
86
92 void InitializeEditorLayout(EditorType type, ImGuiID dockspace_id);
93
102 void RebuildLayout(EditorType type, ImGuiID dockspace_id);
103
109 void SaveCurrentLayout(const std::string& name, bool persist = true);
110
115 void LoadLayout(const std::string& name);
116
122 void CaptureTemporarySessionLayout(size_t session_id);
123
128 bool RestoreTemporarySessionLayout(size_t session_id,
129 bool clear_after_restore = false);
130
135
140
148 bool SaveNamedSnapshot(const std::string& name, size_t session_id);
149
153 bool RestoreNamedSnapshot(const std::string& name, size_t session_id,
154 bool remove_after_restore = false);
155
159 bool DeleteNamedSnapshot(const std::string& name);
160
164 std::vector<std::string> ListNamedSnapshots(size_t session_id) const;
165
169 bool HasNamedSnapshot(const std::string& name) const;
170
176 bool DeleteLayout(const std::string& name);
177
181 static std::vector<LayoutProfile> GetBuiltInProfiles();
182
191 bool ApplyBuiltInProfile(const std::string& profile_id, size_t session_id,
192 EditorType editor_type,
193 LayoutProfile* out_profile = nullptr);
194
199 std::vector<std::string> GetSavedLayoutNames() const;
200
206 bool HasLayout(const std::string& name) const;
207
211 void LoadLayoutsFromDisk();
212
217 void SetProjectLayoutKey(const std::string& key);
218
222 void UseGlobalLayouts();
223
228
234
240 bool IsLayoutInitialized(EditorType type) const;
241
247
252
258
263
268
272 bool IsRebuildRequested() const { return rebuild_requested_; }
273
278
284 std::string GetWindowTitle(const std::string& card_id) const;
285
286 private:
287 // DockBuilder layout implementations for each editor type
288 void BuildLayoutFromPreset(EditorType type, ImGuiID dockspace_id);
289
290 void LoadLayoutsFromDiskInternal(LayoutScope scope, bool merge);
291 void SaveLayoutsToDisk(LayoutScope scope) const;
292
293 // Deprecated individual builders - kept for compatibility or as wrappers
294 void BuildOverworldLayout(ImGuiID dockspace_id);
295 void BuildDungeonLayout(ImGuiID dockspace_id);
296 void BuildGraphicsLayout(ImGuiID dockspace_id);
297 void BuildPaletteLayout(ImGuiID dockspace_id);
298 void BuildScreenLayout(ImGuiID dockspace_id);
299 void BuildMusicLayout(ImGuiID dockspace_id);
300 void BuildSpriteLayout(ImGuiID dockspace_id);
301 void BuildMessageLayout(ImGuiID dockspace_id);
302 void BuildAssemblyLayout(ImGuiID dockspace_id);
303 void BuildSettingsLayout(ImGuiID dockspace_id);
304 void BuildEmulatorLayout(ImGuiID dockspace_id);
305
306 // Track which layouts have been initialized
307 std::unordered_map<EditorType, bool> layouts_initialized_;
308
309 // Panel manager for window title lookups
311
312 // Current layout type
314
315 // Rebuild flag
316 bool rebuild_requested_ = false;
317
318 // Last used dockspace ID (for rebuild operations)
320
321 // Current editor type being displayed
323
324 // Saved layouts (panel visibility state)
325 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
327
328 // In-memory temporary session snapshot (never persisted).
331 std::unordered_map<std::string, bool> temp_session_visibility_;
332 std::unordered_map<std::string, bool> temp_session_pinned_;
334
335 // Multi-slot named session snapshots (in-memory only, never persisted).
336 // The user-supplied name is the stable key; duplicate saves overwrite.
338 size_t session_id = 0;
339 std::unordered_map<std::string, bool> visibility;
340 std::unordered_map<std::string, bool> pinned;
341 std::string imgui_layout;
342 };
343 std::unordered_map<std::string, SessionSnapshot> named_snapshots_;
344
345 // Saved ImGui docking layouts (INI data)
346 std::unordered_map<std::string, std::string> saved_imgui_layouts_;
347
348 // Saved pinned panel state for layouts
349 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
351
352 // Layout scope tracking
353 std::unordered_map<std::string, LayoutScope> layout_scopes_;
354
355 // Project storage key for project-scoped layouts
357};
358
359} // namespace editor
360} // namespace yaze
361
362#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.
bool RestoreNamedSnapshot(const std::string &name, size_t session_id, bool remove_after_restore=false)
Restore a named snapshot by name.
void BuildScreenLayout(ImGuiID dockspace_id)
void BuildPaletteLayout(ImGuiID dockspace_id)
WorkspaceWindowManager * window_manager() const
Get the window manager.
WorkspaceWindowManager * window_manager_
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)
bool DeleteNamedSnapshot(const std::string &name)
Delete a named snapshot. Returns true if an entry was removed.
bool SaveNamedSnapshot(const std::string &name, size_t session_id)
Capture the current workspace under a named, session-scoped slot.
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.
std::unordered_map< std::string, SessionSnapshot > named_snapshots_
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.
bool HasNamedSnapshot(const std::string &name) const
Whether a named snapshot with the given name exists.
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.
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.
void SetWindowManager(WorkspaceWindowManager *manager)
Set the window manager for window title lookups.
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::vector< std::string > ListNamedSnapshots(size_t session_id) const
List all named snapshots for the given session.
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.
std::unordered_map< std::string, bool > visibility
std::unordered_map< std::string, bool > pinned
Built-in workflow-oriented layout profiles.