yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::LayoutManager Class Reference

Manages ImGui DockBuilder layouts for each editor type. More...

#include <layout_manager.h>

Collaboration diagram for yaze::editor::LayoutManager:

Classes

struct  LayoutIniState
 
struct  LazyDefaultDockState
 
struct  PendingDockTabSelection
 
struct  SessionSnapshot
 

Public Member Functions

 LayoutManager ()=default
 
 ~LayoutManager ()
 
void SetWindowManager (WorkspaceWindowManager *manager)
 Set the window manager for window title lookups.
 
WorkspaceWindowManager * window_manager () const
 Get the window manager.
 
void InitializeEditorLayout (EditorType type, ImGuiID dockspace_id)
 Initialize the default layout for a specific editor type.
 
void RebuildLayout (EditorType type, ImGuiID dockspace_id)
 Force rebuild of layout for a specific editor type.
 
bool DockDefaultPositionOnFirstOpen (size_t session_id, const std::string &panel_id)
 Dock a hidden-by-default panel at its preset position on first open.
 
bool DockPresetPositionOnPanelOpen (size_t session_id, const std::string &panel_id)
 Rebind any preset panel when a visibility event opens it.
 
void SaveCurrentLayout (const std::string &name, bool persist=true)
 Save the current layout with a custom name.
 
void LoadLayout (const std::string &name)
 Load a saved layout by name.
 
void CaptureTemporarySessionLayout (size_t session_id)
 Capture the current workspace as a temporary session layout.
 
bool RestoreTemporarySessionLayout (size_t session_id, bool clear_after_restore=false)
 Restore the temporary session layout if one has been captured.
 
bool HasTemporarySessionLayout () const
 Whether a temporary session layout is available.
 
void ClearTemporarySessionLayout ()
 Clear temporary session layout snapshot state.
 
bool SaveNamedSnapshot (const std::string &name, size_t session_id)
 Capture the current workspace under a named, session-scoped slot.
 
bool RestoreNamedSnapshot (const std::string &name, size_t session_id, bool remove_after_restore=false)
 Restore a named snapshot by name.
 
bool DeleteNamedSnapshot (const std::string &name)
 Delete a named snapshot. Returns true if an entry was removed.
 
std::vector< std::string > ListNamedSnapshots (size_t session_id) const
 List all named snapshots for the given session.
 
bool HasNamedSnapshot (const std::string &name) const
 Whether a named snapshot with the given name exists.
 
bool DeleteLayout (const std::string &name)
 Delete a saved layout by name.
 
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 > GetSavedLayoutNames () const
 Get list of all saved layout names.
 
bool HasLayout (const std::string &name) const
 Check if a layout exists.
 
void LoadLayoutsFromDisk ()
 Load layouts for the active scope (global + optional project)
 
void SetProjectLayoutKey (const std::string &key)
 Set the active project layout key (enables project scope)
 
void UseGlobalLayouts ()
 Clear project scope and return to global layouts only.
 
LayoutScope GetActiveScope () const
 Get the active layout scope.
 
void ResetToDefaultLayout (EditorType type)
 Reset the layout for an editor to its default.
 
bool IsLayoutInitialized (EditorType type) const
 Check if a layout has been initialized for an editor.
 
void MarkLayoutInitialized (EditorType type)
 Mark a layout as initialized.
 
void ClearInitializationFlags ()
 Clear all initialization flags (for testing)
 
void RequestRebuild ()
 Request a layout rebuild on next frame.
 
bool IsRebuildRequested () const
 Check if rebuild was requested.
 
void ClearRebuildRequest ()
 Clear rebuild request flag.
 
std::string GetWindowTitle (const std::string &card_id) const
 Get window title for a card ID from registry.
 
absl::Status ApplyDockTree (const layout_designer::DockTree &tree, ImGuiID dockspace_id)
 Apply a DockTree to the given dockspace.
 
void ProcessPendingDockTabSelections ()
 
void SetMainDockspaceId (ImGuiID id)
 Record the outer dockspace ID (OuterDockspaceId() in the app).
 
ImGuiID GetMainDockspaceId () const
 Get the cached main dockspace ID.
 
ImGuiID ActiveEditorDockspaceId () const
 Dockspace of the editor shown in the editor host, or 0 for kUnknown.
 
void SetActiveEditorType (EditorType type)
 
EditorType active_editor_type () const
 
void DrawEditorHost ()
 Draw the editor host window and enforce the pin node.
 
ImGuiID FindPinNode () const
 Pin node under the outer root, or 0 before the first split.
 
ImGuiDir pin_dir () const
 
float pin_size () const
 
void RegisterLayoutIniHandler ()
 Register the "YazeLayout" ImGui settings handler on the current context.
 
void ResetLayoutIniSettings ()
 
void ReadLayoutIniLine (const char *line)
 
void ApplyLayoutIniSettings ()
 
void WriteLayoutIniSettings (ImGuiTextBuffer *buf) const
 
void reset_startup_layout_consumed_for_test ()
 Test-only: reset the one-shot startup-reapply guard so a single test fixture can drive MaybeReapplyStartupLayout through multiple scenarios without standing up a fresh manager each time.
 
bool startup_layout_consumed_for_test () const
 
bool startup_reapply_pending_protection_for_test () const
 
void set_current_editor_type_for_test (EditorType type)
 
void set_editor_host_size_for_test (ImVec2 size)
 
absl::Status MaybeReapplyStartupLayout (UserSettings *settings)
 One-shot startup hook that re-applies the user's last applied named layout, if any.
 
absl::StatusOr< layout_designer::DockTree > CaptureDockTree (ImGuiID dockspace_id) const
 Capture the current docking state into a DockTree.
 

Static Public Member Functions

static std::vector< LayoutProfile > GetBuiltInProfiles ()
 Get built-in layout profiles.
 
static ImGuiID OuterDockspaceId ()
 Outer dockspace hosted by DockSpaceWindow.
 
static ImGuiID EditorDockspaceId (EditorType type)
 Dockspace that holds one editor's panels.
 

Static Public Attributes

static constexpr int kLayoutIniRevision = 1
 Layout revision written to imgui.ini. A mismatch resets dock trees.
 

Private Member Functions

void BuildLayoutFromPreset (EditorType type, ImGuiID dockspace_id)
 
void DisableLazyDefaultDocking ()
 
void RefreshLazyDefaultDockingContext (EditorType type, ImGuiID dockspace_id)
 
void DockOpenPresetPanels (EditorType type)
 
bool DockPresetPositionOnFirstOpen (size_t session_id, const std::string &panel_id, bool include_default_visible, bool allow_redock=false)
 
void MarkLazyDefaultDockAttempted (const std::string &panel_id)
 
void StashLazyDefaultDockState ()
 
bool RestoreLazyDefaultDockState (EditorType type, ImGuiID dockspace_id)
 
ImGuiID EnsurePinNode ()
 
void RecordPinSpot ()
 
ImGuiID MovePinSpot (ImGuiDir dir, float size)
 
ImVec2 EditorDockspaceSize () const
 
void EnforcePinnedPanels (ImGuiID pin_node)
 
void ProtectRestoredLayoutFromDefaultInitialization ()
 
void LoadLayoutsFromDiskInternal (LayoutScope scope, bool merge)
 
void SaveLayoutsToDisk (LayoutScope scope) const
 

Private Attributes

std::unordered_map< EditorType, bool > layouts_initialized_
 
std::vector< PendingDockTabSelection > pending_dock_tab_selections_
 
WorkspaceWindowManager * window_manager_ = nullptr
 
bool rebuild_requested_ = false
 
ImGuiID last_dockspace_id_ = 0
 
ImGuiID main_dockspace_id_ = 0
 
bool startup_layout_consumed_ = false
 
bool startup_reapply_pending_protection_ = false
 
EditorType current_editor_type_ = EditorType::kUnknown
 
EditorType active_editor_type_ = EditorType::kUnknown
 
ImVec2 editor_host_size_ = ImVec2(0.0f, 0.0f)
 
LayoutIniState layout_ini_
 
bool layout_ini_backup_checked_ = false
 
ImGuiDir pin_dir_ = ImGuiDir_Right
 
float pin_size_ = 0.0f
 
std::unordered_set< std::string > pinned_last_frame_
 
LazyDefaultDockState lazy_default_dock_state_
 
std::unordered_map< EditorType, LazyDefaultDockState > lazy_states_by_type_
 
std::unordered_map< size_t, std::unordered_map< EditorType, std::unordered_set< std::string > > > lazy_default_dock_attempts_
 
std::unordered_map< std::string, std::unordered_map< std::string, bool > > saved_layouts_
 
bool has_temp_session_layout_ = false
 
size_t temp_session_id_ = 0
 
std::unordered_map< std::string, bool > temp_session_visibility_
 
std::unordered_map< std::string, bool > temp_session_pinned_
 
std::string temp_session_imgui_layout_
 
std::unordered_map< std::string, SessionSnapshot > named_snapshots_
 
std::unordered_map< std::string, std::string > saved_imgui_layouts_
 
std::unordered_map< std::string, std::unordered_map< std::string, bool > > saved_pinned_layouts_
 
std::unordered_map< std::string, LayoutScope > layout_scopes_
 
std::string project_layout_key_
 

Detailed Description

Manages ImGui DockBuilder layouts for each editor type.

Provides professional default layouts using ImGui's DockBuilder API, similar to VSCode's workspace layouts. Each editor type has a custom layout optimized for its workflow.

Features:

  • Per-editor default layouts (Overworld, Dungeon, Graphics, etc.)
  • Layout persistence and restoration
  • Workspace presets (Developer, Designer, Modder)
  • Dynamic layout initialization on first editor switch
  • Panel manager integration for window title lookups

Definition at line 54 of file layout_manager.h.

Constructor & Destructor Documentation

◆ LayoutManager()

yaze::editor::LayoutManager::LayoutManager ( )
default

◆ ~LayoutManager()

yaze::editor::LayoutManager::~LayoutManager ( )

Definition at line 772 of file layout_manager.cc.

Member Function Documentation

◆ SetWindowManager()

void yaze::editor::LayoutManager::SetWindowManager ( WorkspaceWindowManager * manager)
inline

Set the window manager for window title lookups.

Parameters
managerPointer to the WorkspaceWindowManager

Definition at line 63 of file layout_manager.h.

References window_manager_.

◆ window_manager()

WorkspaceWindowManager * yaze::editor::LayoutManager::window_manager ( ) const
inline

Get the window manager.

Returns
Pointer to the WorkspaceWindowManager

Definition at line 71 of file layout_manager.h.

References window_manager_.

◆ InitializeEditorLayout()

void yaze::editor::LayoutManager::InitializeEditorLayout ( EditorType type,
ImGuiID dockspace_id )

◆ RebuildLayout()

void yaze::editor::LayoutManager::RebuildLayout ( EditorType type,
ImGuiID dockspace_id )

Force rebuild of layout for a specific editor type.

Parameters
typeThe editor type to rebuild
dockspace_idThe ImGui dockspace ID to build the layout in

This method rebuilds the layout even if it was already initialized. Useful for resetting layouts to their default state.

Definition at line 262 of file layout_manager.cc.

References active_editor_type_, BuildLayoutFromPreset(), current_editor_type_, DockOpenPresetPanels(), EditorDockspaceSize(), last_dockspace_id_, layouts_initialized_, LOG_ERROR, LOG_INFO, MarkLayoutInitialized(), pending_dock_tab_selections_, and window_manager_.

Referenced by yaze::editor::LayoutCoordinator::ProcessLayoutRebuild(), and yaze::editor::LayoutCoordinator::ResetWorkspaceLayout().

Here is the call graph for this function:

◆ DockDefaultPositionOnFirstOpen()

bool yaze::editor::LayoutManager::DockDefaultPositionOnFirstOpen ( size_t session_id,
const std::string & panel_id )

Dock a hidden-by-default panel at its preset position on first open.

This is active only for default presets that intentionally build the startup dock tree from visible panels alone. Each panel is considered at most once per default-layout build, so closing and reopening a panel never overrides a position the user chose after its first open.

Returns
true when the panel was assigned to a default dock node.

Definition at line 1396 of file layout_manager.cc.

◆ DockPresetPositionOnPanelOpen()

bool yaze::editor::LayoutManager::DockPresetPositionOnPanelOpen ( size_t session_id,
const std::string & panel_id )

Rebind any preset panel when a visibility event opens it.

Unlike DockDefaultPositionOnFirstOpen(), this accepts both default-visible and optional panels. This matters after another editor replaces the shared dock tree while a default panel is hidden: its next open event must attach it to the new live tree instead of leaving it floating.

Returns
true when the panel was assigned to a preset dock node.

Definition at line 1402 of file layout_manager.cc.

◆ SaveCurrentLayout()

void yaze::editor::LayoutManager::SaveCurrentLayout ( const std::string & name,
bool persist = true )

Save the current layout with a custom name.

Parameters
nameThe name to save the layout under
persistWhether to write the layout to disk

Definition at line 1568 of file layout_manager.cc.

References LOG_INFO, and LOG_WARN.

Referenced by yaze::editor::LayoutCoordinator::ResetCurrentEditorLayout(), yaze::editor::WorkspaceManager::SaveWorkspaceLayout(), and yaze::editor::WorkspaceManager::SaveWorkspacePreset().

◆ LoadLayout()

void yaze::editor::LayoutManager::LoadLayout ( const std::string & name)

Load a saved layout by name.

Parameters
nameThe name of the layout to load

Definition at line 1603 of file layout_manager.cc.

References LOG_INFO, and LOG_WARN.

Referenced by yaze::editor::WorkspaceManager::LoadWorkspaceLayout(), yaze::editor::WorkspaceManager::LoadWorkspacePreset(), and yaze::editor::LayoutCoordinator::RestorePreviousEditorLayout().

◆ CaptureTemporarySessionLayout()

void yaze::editor::LayoutManager::CaptureTemporarySessionLayout ( size_t session_id)

Capture the current workspace as a temporary session layout.

Temporary layouts are held in memory only and are never persisted to disk.

Definition at line 1647 of file layout_manager.cc.

References LOG_INFO.

◆ RestoreTemporarySessionLayout()

bool yaze::editor::LayoutManager::RestoreTemporarySessionLayout ( size_t session_id,
bool clear_after_restore = false )

Restore the temporary session layout if one has been captured.

Returns
true when a captured layout was restored

Definition at line 1672 of file layout_manager.cc.

References LOG_INFO, and LOG_WARN.

◆ HasTemporarySessionLayout()

bool yaze::editor::LayoutManager::HasTemporarySessionLayout ( ) const
inline

Whether a temporary session layout is available.

Definition at line 146 of file layout_manager.h.

References has_temp_session_layout_.

◆ ClearTemporarySessionLayout()

void yaze::editor::LayoutManager::ClearTemporarySessionLayout ( )

Clear temporary session layout snapshot state.

Definition at line 1709 of file layout_manager.cc.

◆ SaveNamedSnapshot()

bool yaze::editor::LayoutManager::SaveNamedSnapshot ( const std::string & name,
size_t session_id )

Capture the current workspace under a named, session-scoped slot.

Named snapshots are held in memory only (never persisted) and identified by the caller-supplied name. Names are used as the stable lookup key; duplicate saves overwrite the existing entry.

Definition at line 1717 of file layout_manager.cc.

References yaze::editor::LayoutManager::SessionSnapshot::imgui_layout, LOG_INFO, yaze::editor::LayoutManager::SessionSnapshot::pinned, yaze::editor::LayoutManager::SessionSnapshot::session_id, and yaze::editor::LayoutManager::SessionSnapshot::visibility.

◆ RestoreNamedSnapshot()

bool yaze::editor::LayoutManager::RestoreNamedSnapshot ( const std::string & name,
size_t session_id,
bool remove_after_restore = false )

◆ DeleteNamedSnapshot()

bool yaze::editor::LayoutManager::DeleteNamedSnapshot ( const std::string & name)

Delete a named snapshot. Returns true if an entry was removed.

Definition at line 1769 of file layout_manager.cc.

◆ ListNamedSnapshots()

std::vector< std::string > yaze::editor::LayoutManager::ListNamedSnapshots ( size_t session_id) const

List all named snapshots for the given session.

Definition at line 1778 of file layout_manager.cc.

◆ HasNamedSnapshot()

bool yaze::editor::LayoutManager::HasNamedSnapshot ( const std::string & name) const

Whether a named snapshot with the given name exists.

Definition at line 1791 of file layout_manager.cc.

◆ DeleteLayout()

bool yaze::editor::LayoutManager::DeleteLayout ( const std::string & name)

Delete a saved layout by name.

Parameters
nameThe name of the layout to delete
Returns
true if layout was deleted, false if not found

Definition at line 1795 of file layout_manager.cc.

References LOG_INFO, and LOG_WARN.

Referenced by yaze::editor::LayoutCoordinator::RestorePreviousEditorLayout().

◆ GetBuiltInProfiles()

std::vector< LayoutProfile > yaze::editor::LayoutManager::GetBuiltInProfiles ( )
static

Get built-in layout profiles.

Definition at line 1820 of file layout_manager.cc.

◆ ApplyBuiltInProfile()

bool yaze::editor::LayoutManager::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.

Parameters
profile_idStable profile id from GetBuiltInProfiles()
session_idActive session id
editor_typeCurrent editor type (for context-sensitive profiles)
out_profileOptional resolved profile metadata
Returns
true when a matching profile was applied

Definition at line 1845 of file layout_manager.cc.

References yaze::editor::PanelLayoutPreset::default_visible_panels, LOG_INFO, LOG_WARN, and yaze::editor::LayoutProfile::preset_name.

◆ GetSavedLayoutNames()

std::vector< std::string > yaze::editor::LayoutManager::GetSavedLayoutNames ( ) const

Get list of all saved layout names.

Returns
Vector of layout names

Definition at line 1905 of file layout_manager.cc.

◆ HasLayout()

bool yaze::editor::LayoutManager::HasLayout ( const std::string & name) const

◆ LoadLayoutsFromDisk()

void yaze::editor::LayoutManager::LoadLayoutsFromDisk ( )

Load layouts for the active scope (global + optional project)

Definition at line 1918 of file layout_manager.cc.

◆ SetProjectLayoutKey()

void yaze::editor::LayoutManager::SetProjectLayoutKey ( const std::string & key)

Set the active project layout key (enables project scope)

Parameters
keyStable project storage key (sanitized)

Definition at line 1930 of file layout_manager.cc.

◆ UseGlobalLayouts()

void yaze::editor::LayoutManager::UseGlobalLayouts ( )

Clear project scope and return to global layouts only.

Definition at line 1939 of file layout_manager.cc.

◆ GetActiveScope()

LayoutScope yaze::editor::LayoutManager::GetActiveScope ( ) const

Get the active layout scope.

Definition at line 1944 of file layout_manager.cc.

◆ ResetToDefaultLayout()

void yaze::editor::LayoutManager::ResetToDefaultLayout ( EditorType type)

Reset the layout for an editor to its default.

Parameters
typeThe editor type to reset

Definition at line 2068 of file layout_manager.cc.

References LOG_INFO.

Referenced by yaze::editor::LayoutCoordinator::ResetCurrentEditorLayout().

◆ IsLayoutInitialized()

bool yaze::editor::LayoutManager::IsLayoutInitialized ( EditorType type) const

Check if a layout has been initialized for an editor.

Parameters
typeThe editor type to check
Returns
True if layout is initialized

Definition at line 2075 of file layout_manager.cc.

Referenced by yaze::editor::EditorActivator::HandleNonEditorClassSwitch(), yaze::editor::LayoutCoordinator::InitializeEditorLayout(), yaze::editor::EditorActivator::InitializeEditorLayout(), and InitializeEditorLayout().

◆ MarkLayoutInitialized()

void yaze::editor::LayoutManager::MarkLayoutInitialized ( EditorType type)

Mark a layout as initialized.

Parameters
typeThe editor type to mark

Definition at line 2080 of file layout_manager.cc.

References LOG_INFO.

Referenced by InitializeEditorLayout(), ProtectRestoredLayoutFromDefaultInitialization(), and RebuildLayout().

◆ ClearInitializationFlags()

void yaze::editor::LayoutManager::ClearInitializationFlags ( )

Clear all initialization flags (for testing)

Definition at line 2086 of file layout_manager.cc.

References LOG_INFO.

Referenced by yaze::editor::LayoutCoordinator::ResetWorkspaceLayout().

◆ RequestRebuild()

void yaze::editor::LayoutManager::RequestRebuild ( )
inline

◆ IsRebuildRequested()

bool yaze::editor::LayoutManager::IsRebuildRequested ( ) const
inline

Check if rebuild was requested.

Definition at line 273 of file layout_manager.h.

References rebuild_requested_.

Referenced by yaze::editor::LayoutCoordinator::ProcessLayoutRebuild().

◆ ClearRebuildRequest()

void yaze::editor::LayoutManager::ClearRebuildRequest ( )
inline

◆ GetWindowTitle()

std::string yaze::editor::LayoutManager::GetWindowTitle ( const std::string & card_id) const

Get window title for a card ID from registry.

Parameters
card_idThe card ID to look up
Returns
Window title or empty string if not found

Definition at line 2093 of file layout_manager.cc.

◆ ApplyDockTree()

absl::Status yaze::editor::LayoutManager::ApplyDockTree ( const layout_designer::DockTree & tree,
ImGuiID dockspace_id )

Apply a DockTree to the given dockspace.

Removes and rebuilds dockspace_id from scratch, walking the tree and calling DockBuilder{SplitNode,DockWindow,Finish}.

Side effects beyond DockBuilder, added in Phase 8 review (2026-04-24):

  • Calls WorkspaceWindowManager::OpenWindow(panel_id) for every panel referenced in the tree, so the user actually sees the panels they docked rather than empty slots.
  • Marks the active editor's layout initialized. If no editor is active, protects the next editor's first initialization instead. Other editors can still initialize their own defaults.

Panels in the tree whose panel_id is not registered against the bound WorkspaceWindowManager are skipped with a best-effort fallback that reconstructs the window title from the PanelEntry's cached icon + display_name + id.

Parameters
treeTree to apply. Must pass Validate().
dockspace_idImGui dockspace to rebuild.
Returns
FailedPrecondition when no WorkspaceWindowManager is bound; InvalidArgument when the tree fails validation; OK otherwise.

Definition at line 2273 of file layout_manager.cc.

References yaze::editor::layout_designer::DockTree::root, and yaze::editor::layout_designer::DockTree::Validate().

Referenced by yaze::editor::layout_designer::LayoutDesignerPanel::ApplyCurrentTreeToLiveDockspace(), and yaze::editor::SettingsPanel::ApplyNamedLayoutToDockspace().

Here is the call graph for this function:

◆ ProcessPendingDockTabSelections()

void yaze::editor::LayoutManager::ProcessPendingDockTabSelections ( )

◆ SetMainDockspaceId()

void yaze::editor::LayoutManager::SetMainDockspaceId ( ImGuiID id)
inline

Record the outer dockspace ID (OuterDockspaceId() in the app).

GetMainDockspaceId() returns the active editor's dockspace when one is set and falls back to this ID. Tests that drive a single dockspace set it directly.

Definition at line 328 of file layout_manager.h.

References main_dockspace_id_.

◆ GetMainDockspaceId()

ImGuiID yaze::editor::LayoutManager::GetMainDockspaceId ( ) const

Get the cached main dockspace ID.

Returns
The ID cached by SetMainDockspaceId, or 0 before the first frame of the DockSpaceWindow has rendered.

Definition at line 800 of file layout_manager.cc.

Referenced by yaze::editor::layout_designer::LayoutDesignerPanel::ApplyCurrentTreeToLiveDockspace(), yaze::editor::SettingsPanel::ApplyNamedLayoutToDockspace(), and yaze::editor::WorkspaceManager::MaximizeCurrentWindow().

◆ OuterDockspaceId()

ImGuiID yaze::editor::LayoutManager::OuterDockspaceId ( )
static

Outer dockspace hosted by DockSpaceWindow.

Hashed with a fixed seed, so the value does not depend on the calling window's ID stack. The outer root holds the shared pin node and the central node that hosts the editor host window.

Definition at line 783 of file layout_manager.cc.

Referenced by yaze::Controller::OnLoad().

◆ EditorDockspaceId()

ImGuiID yaze::editor::LayoutManager::EditorDockspaceId ( EditorType type)
static

Dockspace that holds one editor's panels.

Each editor keeps its own dock tree. Switching editors submits a different dockspace instead of rebuilding a shared one, so closed and moved panels survive a round trip.

Definition at line 787 of file layout_manager.cc.

References yaze::editor::EditorTypeIndex(), and yaze::editor::kEditorNames.

Referenced by yaze::editor::EditorActivator::HandleNonEditorClassSwitch(), yaze::editor::EditorActivator::InitializeEditorLayout(), yaze::editor::LayoutCoordinator::ProcessLayoutRebuild(), and yaze::editor::LayoutCoordinator::ResetWorkspaceLayout().

Here is the call graph for this function:

◆ ActiveEditorDockspaceId()

ImGuiID yaze::editor::LayoutManager::ActiveEditorDockspaceId ( ) const

Dockspace of the editor shown in the editor host, or 0 for kUnknown.

Definition at line 793 of file layout_manager.cc.

◆ SetActiveEditorType()

void yaze::editor::LayoutManager::SetActiveEditorType ( EditorType type)
inline

◆ active_editor_type()

EditorType yaze::editor::LayoutManager::active_editor_type ( ) const
inline

Definition at line 363 of file layout_manager.h.

References active_editor_type_.

◆ DrawEditorHost()

void yaze::editor::LayoutManager::DrawEditorHost ( )

Draw the editor host window and enforce the pin node.

Call once per frame after the DockSpaceWindow ends and before editor panels are drawn. Splits the outer root into the pin node and central node on first use, docks the host into the central node, submits the active editor dockspace and keeps every other editor dockspace alive.

Definition at line 960 of file layout_manager.cc.

References yaze::editor::kEditorTypeCount.

Referenced by yaze::Controller::OnLoad().

◆ FindPinNode()

ImGuiID yaze::editor::LayoutManager::FindPinNode ( ) const

Pin node under the outer root, or 0 before the first split.

Definition at line 807 of file layout_manager.cc.

◆ pin_dir()

ImGuiDir yaze::editor::LayoutManager::pin_dir ( ) const
inline

Side and size (pixels along the split axis) the pin node is rebuilt with. Follows the last pin node drawn; size 0 means the default share.

Definition at line 380 of file layout_manager.h.

References pin_dir_.

◆ pin_size()

float yaze::editor::LayoutManager::pin_size ( ) const
inline

Definition at line 381 of file layout_manager.h.

References pin_size_.

◆ RegisterLayoutIniHandler()

void yaze::editor::LayoutManager::RegisterLayoutIniHandler ( )

Register the "YazeLayout" ImGui settings handler on the current context.

Definition at line 1091 of file layout_manager.cc.

◆ ResetLayoutIniSettings()

void yaze::editor::LayoutManager::ResetLayoutIniSettings ( )

Definition at line 1113 of file layout_manager.cc.

◆ ReadLayoutIniLine()

void yaze::editor::LayoutManager::ReadLayoutIniLine ( const char * line)

◆ ApplyLayoutIniSettings()

void yaze::editor::LayoutManager::ApplyLayoutIniSettings ( )

Definition at line 1155 of file layout_manager.cc.

References LOG_INFO.

◆ WriteLayoutIniSettings()

void yaze::editor::LayoutManager::WriteLayoutIniSettings ( ImGuiTextBuffer * buf) const

◆ reset_startup_layout_consumed_for_test()

void yaze::editor::LayoutManager::reset_startup_layout_consumed_for_test ( )
inline

Test-only: reset the one-shot startup-reapply guard so a single test fixture can drive MaybeReapplyStartupLayout through multiple scenarios without standing up a fresh manager each time.

Definition at line 404 of file layout_manager.h.

References startup_layout_consumed_.

◆ startup_layout_consumed_for_test()

bool yaze::editor::LayoutManager::startup_layout_consumed_for_test ( ) const
inline

Definition at line 407 of file layout_manager.h.

References startup_layout_consumed_.

◆ startup_reapply_pending_protection_for_test()

bool yaze::editor::LayoutManager::startup_reapply_pending_protection_for_test ( ) const
inline

Definition at line 410 of file layout_manager.h.

References startup_reapply_pending_protection_.

◆ set_current_editor_type_for_test()

void yaze::editor::LayoutManager::set_current_editor_type_for_test ( EditorType type)
inline

Definition at line 413 of file layout_manager.h.

References current_editor_type_.

◆ set_editor_host_size_for_test()

void yaze::editor::LayoutManager::set_editor_host_size_for_test ( ImVec2 size)
inline

Definition at line 416 of file layout_manager.h.

References editor_host_size_.

◆ MaybeReapplyStartupLayout()

absl::Status yaze::editor::LayoutManager::MaybeReapplyStartupLayout ( UserSettings * settings)

One-shot startup hook that re-applies the user's last applied named layout, if any.

Drives idempotently from UserSettings::last_applied_layout_name

  • named_layouts. The first frame this is called with a valid main_dockspace_id_ (i.e. after the controller has rendered at least one DockSpaceWindow), the matching layout is parsed, validated, and applied to the live dockspace; subsequent calls are no-ops.

Failure modes are absorbed (logged, internally consumed) rather than propagated, because there is no useful caller-side recovery for "the layout the user picked yesterday no longer parses": the editor falls through to whatever default layout the workspace shell already built. The Status return is for observability and tests.

Skipped paths (return OK, leave the consumed flag clear so the caller can retry next frame):

  • main_dockspace_id_ == 0 (dockspace not bound yet).

Skipped paths (return OK, set consumed):

  • settings == nullptr.
  • last_applied_layout_name is empty.

Failure paths (return error status, set consumed):

  • The named layout is missing from named_layouts.
  • Its body fails to parse / validate.
  • ApplyDockTree returns non-OK.
Parameters
settingsUserSettings to read named_layouts and last_applied_layout_name from. May be null.
Returns
OK on legitimate skip or successful apply; the underlying error otherwise.

Definition at line 2420 of file layout_manager.cc.

References yaze::editor::UserSettings::Preferences::last_applied_layout_name, yaze::editor::UserSettings::Preferences::named_layouts, and yaze::editor::UserSettings::prefs().

Here is the call graph for this function:

◆ CaptureDockTree()

absl::StatusOr< layout_designer::DockTree > yaze::editor::LayoutManager::CaptureDockTree ( ImGuiID dockspace_id) const

Capture the current docking state into a DockTree.

Walks ImGui's internal dock node tree rooted at dockspace_id and samples splits + leaf windows. Unknown windows (those not registered against the bound WorkspaceWindowManager) are dropped. Split ratios are recovered from measured node sizes; X-axis splits always emit SplitDirection::kLeft and Y-axis splits emit kUp (direction is lossy, since a 0.4 right-placed split is visually identical to a 0.4 left-placed split).

Parameters
dockspace_idImGui dockspace to sample.
Returns
FailedPrecondition when no WorkspaceWindowManager is bound; NotFound when no node exists at dockspace_id; the captured tree otherwise.

Definition at line 2496 of file layout_manager.cc.

References yaze::editor::layout_designer::DockTree::root.

◆ BuildLayoutFromPreset()

void yaze::editor::LayoutManager::BuildLayoutFromPreset ( EditorType type,
ImGuiID dockspace_id )
private

Definition at line 1221 of file layout_manager.cc.

References LOG_WARN.

Referenced by InitializeEditorLayout(), and RebuildLayout().

◆ DisableLazyDefaultDocking()

void yaze::editor::LayoutManager::DisableLazyDefaultDocking ( )
private

Definition at line 132 of file layout_manager.cc.

References lazy_default_dock_state_.

Referenced by InitializeEditorLayout().

◆ RefreshLazyDefaultDockingContext()

◆ DockOpenPresetPanels()

◆ DockPresetPositionOnFirstOpen()

bool yaze::editor::LayoutManager::DockPresetPositionOnFirstOpen ( size_t session_id,
const std::string & panel_id,
bool include_default_visible,
bool allow_redock = false )
private

◆ MarkLazyDefaultDockAttempted()

void yaze::editor::LayoutManager::MarkLazyDefaultDockAttempted ( const std::string & panel_id)
private

◆ StashLazyDefaultDockState()

void yaze::editor::LayoutManager::StashLazyDefaultDockState ( )
private

Definition at line 910 of file layout_manager.cc.

◆ RestoreLazyDefaultDockState()

bool yaze::editor::LayoutManager::RestoreLazyDefaultDockState ( EditorType type,
ImGuiID dockspace_id )
private

◆ EnsurePinNode()

ImGuiID yaze::editor::LayoutManager::EnsurePinNode ( )
private

Definition at line 820 of file layout_manager.cc.

◆ RecordPinSpot()

void yaze::editor::LayoutManager::RecordPinSpot ( )
private

Definition at line 855 of file layout_manager.cc.

◆ MovePinSpot()

ImGuiID yaze::editor::LayoutManager::MovePinSpot ( ImGuiDir dir,
float size )
private

Definition at line 869 of file layout_manager.cc.

◆ EditorDockspaceSize()

ImVec2 yaze::editor::LayoutManager::EditorDockspaceSize ( ) const
private

Definition at line 895 of file layout_manager.cc.

References yaze::gui::DockSpaceRenderer::GetLastDockspaceSize().

Referenced by InitializeEditorLayout(), and RebuildLayout().

Here is the call graph for this function:

◆ EnforcePinnedPanels()

void yaze::editor::LayoutManager::EnforcePinnedPanels ( ImGuiID pin_node)
private

Definition at line 1014 of file layout_manager.cc.

◆ ProtectRestoredLayoutFromDefaultInitialization()

void yaze::editor::LayoutManager::ProtectRestoredLayoutFromDefaultInitialization ( )
private

Definition at line 186 of file layout_manager.cc.

References current_editor_type_, yaze::editor::kUnknown, MarkLayoutInitialized(), and startup_reapply_pending_protection_.

Here is the call graph for this function:

◆ LoadLayoutsFromDiskInternal()

void yaze::editor::LayoutManager::LoadLayoutsFromDiskInternal ( LayoutScope scope,
bool merge )
private

Definition at line 1949 of file layout_manager.cc.

References yaze::Json::contains(), yaze::Json::is_object(), yaze::Json::items(), LOG_INFO, and LOG_WARN.

Here is the call graph for this function:

◆ SaveLayoutsToDisk()

void yaze::editor::LayoutManager::SaveLayoutsToDisk ( LayoutScope scope) const
private

Definition at line 2012 of file layout_manager.cc.

References yaze::Json::dump(), yaze::util::PlatformPaths::EnsureDirectoryExists(), LOG_WARN, and yaze::Json::object().

Here is the call graph for this function:

Member Data Documentation

◆ kLayoutIniRevision

constexpr int yaze::editor::LayoutManager::kLayoutIniRevision = 1
staticconstexpr

Layout revision written to imgui.ini. A mismatch resets dock trees.

Definition at line 388 of file layout_manager.h.

◆ layouts_initialized_

std::unordered_map<EditorType, bool> yaze::editor::LayoutManager::layouts_initialized_
private

Definition at line 501 of file layout_manager.h.

Referenced by RebuildLayout().

◆ pending_dock_tab_selections_

std::vector<PendingDockTabSelection> yaze::editor::LayoutManager::pending_dock_tab_selections_
private

Definition at line 511 of file layout_manager.h.

Referenced by InitializeEditorLayout(), and RebuildLayout().

◆ window_manager_

WorkspaceWindowManager* yaze::editor::LayoutManager::window_manager_ = nullptr
private

◆ rebuild_requested_

bool yaze::editor::LayoutManager::rebuild_requested_ = false
private

Definition at line 517 of file layout_manager.h.

Referenced by ClearRebuildRequest(), IsRebuildRequested(), and RequestRebuild().

◆ last_dockspace_id_

ImGuiID yaze::editor::LayoutManager::last_dockspace_id_ = 0
private

Definition at line 520 of file layout_manager.h.

Referenced by InitializeEditorLayout(), and RebuildLayout().

◆ main_dockspace_id_

ImGuiID yaze::editor::LayoutManager::main_dockspace_id_ = 0
private

Definition at line 525 of file layout_manager.h.

Referenced by SetMainDockspaceId().

◆ startup_layout_consumed_

bool yaze::editor::LayoutManager::startup_layout_consumed_ = false
private

◆ startup_reapply_pending_protection_

bool yaze::editor::LayoutManager::startup_reapply_pending_protection_ = false
private

◆ current_editor_type_

EditorType yaze::editor::LayoutManager::current_editor_type_ = EditorType::kUnknown
private

◆ active_editor_type_

EditorType yaze::editor::LayoutManager::active_editor_type_ = EditorType::kUnknown
private

◆ editor_host_size_

ImVec2 yaze::editor::LayoutManager::editor_host_size_ = ImVec2(0.0f, 0.0f)
private

Definition at line 550 of file layout_manager.h.

Referenced by set_editor_host_size_for_test().

◆ layout_ini_

LayoutIniState yaze::editor::LayoutManager::layout_ini_
private

Definition at line 560 of file layout_manager.h.

◆ layout_ini_backup_checked_

bool yaze::editor::LayoutManager::layout_ini_backup_checked_ = false
private

Definition at line 561 of file layout_manager.h.

◆ pin_dir_

ImGuiDir yaze::editor::LayoutManager::pin_dir_ = ImGuiDir_Right
private

Definition at line 565 of file layout_manager.h.

Referenced by pin_dir().

◆ pin_size_

float yaze::editor::LayoutManager::pin_size_ = 0.0f
private

Definition at line 566 of file layout_manager.h.

Referenced by pin_size().

◆ pinned_last_frame_

std::unordered_set<std::string> yaze::editor::LayoutManager::pinned_last_frame_
private

Definition at line 570 of file layout_manager.h.

◆ lazy_default_dock_state_

LazyDefaultDockState yaze::editor::LayoutManager::lazy_default_dock_state_
private

◆ lazy_states_by_type_

std::unordered_map<EditorType, LazyDefaultDockState> yaze::editor::LayoutManager::lazy_states_by_type_
private

Definition at line 598 of file layout_manager.h.

◆ lazy_default_dock_attempts_

std::unordered_map< size_t, std::unordered_map<EditorType, std::unordered_set<std::string> > > yaze::editor::LayoutManager::lazy_default_dock_attempts_
private

◆ saved_layouts_

std::unordered_map<std::string, std::unordered_map<std::string, bool> > yaze::editor::LayoutManager::saved_layouts_
private

Definition at line 605 of file layout_manager.h.

◆ has_temp_session_layout_

bool yaze::editor::LayoutManager::has_temp_session_layout_ = false
private

Definition at line 608 of file layout_manager.h.

Referenced by HasTemporarySessionLayout().

◆ temp_session_id_

size_t yaze::editor::LayoutManager::temp_session_id_ = 0
private

Definition at line 609 of file layout_manager.h.

◆ temp_session_visibility_

std::unordered_map<std::string, bool> yaze::editor::LayoutManager::temp_session_visibility_
private

Definition at line 610 of file layout_manager.h.

◆ temp_session_pinned_

std::unordered_map<std::string, bool> yaze::editor::LayoutManager::temp_session_pinned_
private

Definition at line 611 of file layout_manager.h.

◆ temp_session_imgui_layout_

std::string yaze::editor::LayoutManager::temp_session_imgui_layout_
private

Definition at line 612 of file layout_manager.h.

◆ named_snapshots_

std::unordered_map<std::string, SessionSnapshot> yaze::editor::LayoutManager::named_snapshots_
private

Definition at line 622 of file layout_manager.h.

◆ saved_imgui_layouts_

std::unordered_map<std::string, std::string> yaze::editor::LayoutManager::saved_imgui_layouts_
private

Definition at line 625 of file layout_manager.h.

◆ saved_pinned_layouts_

std::unordered_map<std::string, std::unordered_map<std::string, bool> > yaze::editor::LayoutManager::saved_pinned_layouts_
private

Definition at line 629 of file layout_manager.h.

◆ layout_scopes_

std::unordered_map<std::string, LayoutScope> yaze::editor::LayoutManager::layout_scopes_
private

Definition at line 632 of file layout_manager.h.

◆ project_layout_key_

std::string yaze::editor::LayoutManager::project_layout_key_
private

Definition at line 635 of file layout_manager.h.


The documentation for this class was generated from the following files: