1#ifndef YAZE_APP_EDITOR_LAYOUT_LAYOUT_MANAGER_H_
2#define YAZE_APP_EDITOR_LAYOUT_LAYOUT_MANAGER_H_
5#include <unordered_map>
6#include <unordered_set>
9#include "absl/status/status.h"
10#include "absl/status/statusor.h"
13#include "imgui/imgui.h"
19class WorkspaceWindowManager;
101 const std::string& panel_id);
114 const std::string& panel_id);
141 bool clear_after_restore =
false);
166 bool remove_after_restore =
false);
218 bool HasLayout(
const std::string& name)
const;
316 ImGuiID dockspace_id);
473 ImGuiID dockspace_id)
const;
482 const std::string& panel_id,
483 bool include_default_visible,
484 bool allow_redock =
false);
600 size_t, std::unordered_map<EditorType, std::unordered_set<std::string>>>
604 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
619 std::unordered_map<std::string, bool>
pinned;
628 std::unordered_map<std::string, std::unordered_map<std::string, bool>>
Manages ImGui DockBuilder layouts for each editor type.
void DrawEditorHost()
Draw the editor host window and enforce the pin node.
void DockOpenPresetPanels(EditorType type)
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.
EditorType current_editor_type_
void DisableLazyDefaultDocking()
std::unordered_set< std::string > pinned_last_frame_
bool RestoreNamedSnapshot(const std::string &name, size_t session_id, bool remove_after_restore=false)
Restore a named snapshot by name.
std::vector< PendingDockTabSelection > pending_dock_tab_selections_
ImGuiID last_dockspace_id_
bool DockPresetPositionOnPanelOpen(size_t session_id, const std::string &panel_id)
Rebind any preset panel when a visibility event opens it.
WorkspaceWindowManager * window_manager() const
Get the window manager.
WorkspaceWindowManager * window_manager_
void ProtectRestoredLayoutFromDefaultInitialization()
ImGuiID FindPinNode() const
Pin node under the outer root, or 0 before the first split.
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.
void ProcessPendingDockTabSelections()
void ResetLayoutIniSettings()
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_
std::unordered_map< size_t, std::unordered_map< EditorType, std::unordered_set< std::string > > > lazy_default_dock_attempts_
void SaveLayoutsToDisk(LayoutScope scope) const
bool startup_reapply_pending_protection_
absl::Status ApplyDockTree(const layout_designer::DockTree &tree, ImGuiID dockspace_id)
Apply a DockTree to the given dockspace.
void RebuildLayout(EditorType type, ImGuiID dockspace_id)
Force rebuild of layout for a specific editor type.
std::unordered_map< std::string, SessionSnapshot > named_snapshots_
bool startup_layout_consumed_
void ApplyLayoutIniSettings()
void LoadLayoutsFromDisk()
Load layouts for the active scope (global + optional project)
static ImGuiID EditorDockspaceId(EditorType type)
Dockspace that holds one editor's panels.
void UseGlobalLayouts()
Clear project scope and return to global layouts only.
LazyDefaultDockState lazy_default_dock_state_
void ClearInitializationFlags()
Clear all initialization flags (for testing)
bool DockPresetPositionOnFirstOpen(size_t session_id, const std::string &panel_id, bool include_default_visible, bool allow_redock=false)
bool HasTemporarySessionLayout() const
Whether a temporary session layout is available.
bool startup_reapply_pending_protection_for_test() const
void StashLazyDefaultDockState()
void set_current_editor_type_for_test(EditorType type)
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.
absl::StatusOr< layout_designer::DockTree > CaptureDockTree(ImGuiID dockspace_id) const
Capture the current docking state into a DockTree.
std::unordered_map< std::string, std::string > saved_imgui_layouts_
void reset_startup_layout_consumed_for_test()
Test-only: reset the one-shot startup-reapply guard so a single test fixture can drive MaybeReapplySt...
std::vector< std::string > GetSavedLayoutNames() const
Get list of all saved layout names.
EditorType active_editor_type_
std::unordered_map< EditorType, bool > layouts_initialized_
static ImGuiID OuterDockspaceId()
Outer dockspace hosted by DockSpaceWindow.
void RefreshLazyDefaultDockingContext(EditorType type, ImGuiID dockspace_id)
void LoadLayoutsFromDiskInternal(LayoutScope scope, bool merge)
bool IsLayoutInitialized(EditorType type) const
Check if a layout has been initialized for an editor.
LayoutIniState layout_ini_
ImGuiID MovePinSpot(ImGuiDir dir, float size)
bool RestoreTemporarySessionLayout(size_t session_id, bool clear_after_restore=false)
Restore the temporary session layout if one has been captured.
EditorType active_editor_type() const
std::string temp_session_imgui_layout_
void EnforcePinnedPanels(ImGuiID pin_node)
std::unordered_map< EditorType, LazyDefaultDockState > lazy_states_by_type_
std::unordered_map< std::string, std::unordered_map< std::string, bool > > saved_pinned_layouts_
bool RestoreLazyDefaultDockState(EditorType type, ImGuiID dockspace_id)
void ResetToDefaultLayout(EditorType type)
Reset the layout for an editor to its default.
void SetMainDockspaceId(ImGuiID id)
Record the outer dockspace ID (OuterDockspaceId() in the app).
void set_editor_host_size_for_test(ImVec2 size)
LayoutScope GetActiveScope() const
Get the active layout scope.
void WriteLayoutIniSettings(ImGuiTextBuffer *buf) const
void ClearRebuildRequest()
Clear rebuild request flag.
static constexpr int kLayoutIniRevision
Layout revision written to imgui.ini. A mismatch resets dock trees.
ImGuiID main_dockspace_id_
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.
ImGuiID ActiveEditorDockspaceId() const
Dockspace of the editor shown in the editor host, or 0 for kUnknown.
static std::vector< LayoutProfile > GetBuiltInProfiles()
Get built-in layout profiles.
bool DockDefaultPositionOnFirstOpen(size_t session_id, const std::string &panel_id)
Dock a hidden-by-default panel at its preset position on first open.
void ReadLayoutIniLine(const char *line)
void InitializeEditorLayout(EditorType type, ImGuiID dockspace_id)
Initialize the default layout for a specific editor type.
void SetActiveEditorType(EditorType type)
void RegisterLayoutIniHandler()
Register the "YazeLayout" ImGui settings handler on the current context.
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)
bool layout_ini_backup_checked_
bool startup_layout_consumed_for_test() const
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_
ImVec2 EditorDockspaceSize() const
std::string project_layout_key_
absl::Status MaybeReapplyStartupLayout(UserSettings *settings)
One-shot startup hook that re-applies the user's last applied named layout, if any.
bool has_temp_session_layout_
void MarkLazyDefaultDockAttempted(const std::string &panel_id)
ImGuiID GetMainDockspaceId() const
Get the cached main dockspace ID.
std::unordered_map< std::string, bool > temp_session_visibility_
Manages user preferences and settings persistence.
Central registry for all editor cards with session awareness and dependency injection.
LayoutScope
Storage scope for saved layouts.
std::vector< EditorType > initialized
std::unordered_set< std::string > attempted_panels
ImGuiID selected_window_id
std::vector< ImGuiID > tab_ids
std::unordered_map< std::string, bool > visibility
std::unordered_map< std::string, bool > pinned
Built-in workflow-oriented layout profiles.