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:

Public Member Functions

 LayoutManager ()=default
 
 ~LayoutManager ()=default
 
void SetPanelManager (PanelManager *manager)
 Set the panel manager for window title lookups.
 
PanelManagerpanel_manager () const
 Get the panel 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.
 
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 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 SetLayoutType (LayoutType type)
 Set the current layout type for rebuild.
 
LayoutType GetLayoutType () const
 Get the current layout type.
 
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.
 

Static Public Member Functions

static std::vector< LayoutProfileGetBuiltInProfiles ()
 Get built-in layout profiles.
 

Private Member Functions

void BuildLayoutFromPreset (EditorType type, ImGuiID dockspace_id)
 
void LoadLayoutsFromDiskInternal (LayoutScope scope, bool merge)
 
void SaveLayoutsToDisk (LayoutScope scope) const
 
void BuildOverworldLayout (ImGuiID dockspace_id)
 
void BuildDungeonLayout (ImGuiID dockspace_id)
 
void BuildGraphicsLayout (ImGuiID dockspace_id)
 
void BuildPaletteLayout (ImGuiID dockspace_id)
 
void BuildScreenLayout (ImGuiID dockspace_id)
 
void BuildMusicLayout (ImGuiID dockspace_id)
 
void BuildSpriteLayout (ImGuiID dockspace_id)
 
void BuildMessageLayout (ImGuiID dockspace_id)
 
void BuildAssemblyLayout (ImGuiID dockspace_id)
 
void BuildSettingsLayout (ImGuiID dockspace_id)
 
void BuildEmulatorLayout (ImGuiID dockspace_id)
 

Private Attributes

std::unordered_map< EditorType, bool > layouts_initialized_
 
PanelManagerpanel_manager_ = nullptr
 
LayoutType current_layout_type_ = LayoutType::kDefault
 
bool rebuild_requested_ = false
 
ImGuiID last_dockspace_id_ = 0
 
EditorType current_editor_type_ = EditorType::kUnknown
 
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, std::string > saved_imgui_layouts_
 
std::unordered_map< std::string, std::unordered_map< std::string, bool > > saved_pinned_layouts_
 
std::unordered_map< std::string, LayoutScopelayout_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 71 of file layout_manager.h.

Constructor & Destructor Documentation

◆ LayoutManager()

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

◆ ~LayoutManager()

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

Member Function Documentation

◆ SetPanelManager()

void yaze::editor::LayoutManager::SetPanelManager ( PanelManager * manager)
inline

Set the panel manager for window title lookups.

Parameters
registryPointer to the PanelManager

Definition at line 80 of file layout_manager.h.

References panel_manager_.

Referenced by main().

◆ panel_manager()

PanelManager * yaze::editor::LayoutManager::panel_manager ( ) const
inline

Get the panel manager.

Returns
Pointer to the PanelManager

Definition at line 88 of file layout_manager.h.

References panel_manager_.

◆ InitializeEditorLayout()

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

Initialize the default layout for a specific editor type.

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

Definition at line 143 of file layout_manager.cc.

References BuildLayoutFromPreset(), current_editor_type_, yaze::gui::DockSpaceRenderer::GetLastDockspaceSize(), IsLayoutInitialized(), last_dockspace_id_, LOG_INFO, MarkLayoutInitialized(), and panel_manager_.

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

Here is the call graph for this function:

◆ 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 188 of file layout_manager.cc.

References BuildLayoutFromPreset(), current_editor_type_, yaze::gui::DockSpaceRenderer::GetLastDockspaceSize(), last_dockspace_id_, layouts_initialized_, LOG_ERROR, LOG_INFO, MarkLayoutInitialized(), and panel_manager_.

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

Here is the call graph for this function:

◆ SaveCurrentLayout()

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

◆ LoadLayout()

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

◆ 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 602 of file layout_manager.cc.

References has_temp_session_layout_, LOG_INFO, panel_manager_, yaze::editor::PanelManager::SerializePinnedState(), yaze::editor::PanelManager::SerializeVisibilityState(), temp_session_id_, temp_session_imgui_layout_, temp_session_pinned_, and temp_session_visibility_.

Here is the call graph for this function:

◆ 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 625 of file layout_manager.cc.

References ClearTemporarySessionLayout(), has_temp_session_layout_, LOG_INFO, LOG_WARN, panel_manager_, yaze::editor::PanelManager::RestorePinnedState(), yaze::editor::PanelManager::RestoreVisibilityState(), temp_session_id_, temp_session_imgui_layout_, temp_session_pinned_, and temp_session_visibility_.

Here is the call graph for this function:

◆ HasTemporarySessionLayout()

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

Whether a temporary session layout is available.

Definition at line 137 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 656 of file layout_manager.cc.

References has_temp_session_layout_, temp_session_id_, temp_session_imgui_layout_, temp_session_pinned_, and temp_session_visibility_.

Referenced by RestoreTemporarySessionLayout().

◆ 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 664 of file layout_manager.cc.

References GetActiveScope(), layout_scopes_, LOG_INFO, LOG_WARN, saved_imgui_layouts_, saved_layouts_, saved_pinned_layouts_, and SaveLayoutsToDisk().

Here is the call graph for this function:

◆ GetBuiltInProfiles()

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

Get built-in layout profiles.

Definition at line 689 of file layout_manager.cc.

Referenced by ApplyBuiltInProfile().

◆ 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 714 of file layout_manager.cc.

References yaze::editor::PanelLayoutPreset::default_visible_panels, GetBuiltInProfiles(), yaze::editor::PanelManager::HideAllPanelsInSession(), LOG_INFO, LOG_WARN, panel_manager_, yaze::editor::LayoutProfile::preset_name, RequestRebuild(), and yaze::editor::PanelManager::ShowPanel().

Here is the call graph for this function:

◆ 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 770 of file layout_manager.cc.

References saved_layouts_.

◆ HasLayout()

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

Check if a layout exists.

Parameters
nameThe layout name to check
Returns
true if layout exists

Definition at line 779 of file layout_manager.cc.

References saved_layouts_.

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

◆ LoadLayoutsFromDisk()

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

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

Definition at line 783 of file layout_manager.cc.

References yaze::editor::kGlobal, yaze::editor::kProject, layout_scopes_, LoadLayoutsFromDiskInternal(), project_layout_key_, saved_imgui_layouts_, saved_layouts_, and saved_pinned_layouts_.

Referenced by SetProjectLayoutKey(), and UseGlobalLayouts().

Here is the call graph for this function:

◆ 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 795 of file layout_manager.cc.

References LoadLayoutsFromDisk(), project_layout_key_, and UseGlobalLayouts().

Here is the call graph for this function:

◆ UseGlobalLayouts()

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

Clear project scope and return to global layouts only.

Definition at line 804 of file layout_manager.cc.

References LoadLayoutsFromDisk(), and project_layout_key_.

Referenced by SetProjectLayoutKey().

Here is the call graph for this function:

◆ GetActiveScope()

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

Get the active layout scope.

Definition at line 809 of file layout_manager.cc.

References yaze::editor::kGlobal, yaze::editor::kProject, and project_layout_key_.

Referenced by DeleteLayout(), and SaveCurrentLayout().

◆ 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 935 of file layout_manager.cc.

References layouts_initialized_, and LOG_INFO.

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

◆ 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 941 of file layout_manager.cc.

References layouts_initialized_.

Referenced by yaze::editor::EditorActivator::ActivatePanelBasedEditor(), 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 946 of file layout_manager.cc.

References layouts_initialized_, and LOG_INFO.

Referenced by InitializeEditorLayout(), and RebuildLayout().

◆ ClearInitializationFlags()

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

Clear all initialization flags (for testing)

Definition at line 952 of file layout_manager.cc.

References layouts_initialized_, and LOG_INFO.

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

◆ SetLayoutType()

void yaze::editor::LayoutManager::SetLayoutType ( LayoutType type)
inline

Set the current layout type for rebuild.

Parameters
typeThe layout type to set

Definition at line 230 of file layout_manager.h.

References current_layout_type_.

Referenced by yaze::editor::LayoutOrchestrator::ApplyDockLayout().

◆ GetLayoutType()

LayoutType yaze::editor::LayoutManager::GetLayoutType ( ) const
inline

Get the current layout type.

Definition at line 235 of file layout_manager.h.

References current_layout_type_.

◆ RequestRebuild()

◆ IsRebuildRequested()

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

Check if rebuild was requested.

Definition at line 245 of file layout_manager.h.

References rebuild_requested_.

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

◆ ClearRebuildRequest()

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

Clear rebuild request flag.

Definition at line 250 of file layout_manager.h.

References rebuild_requested_.

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

◆ 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 957 of file layout_manager.cc.

References yaze::editor::PanelManager::GetActiveSessionId(), yaze::editor::PanelManager::GetPanelWindowName(), and panel_manager_.

Here is the call graph for this function:

◆ BuildLayoutFromPreset()

◆ LoadLayoutsFromDiskInternal()

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

◆ SaveLayoutsToDisk()

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

◆ BuildOverworldLayout()

void yaze::editor::LayoutManager::BuildOverworldLayout ( ImGuiID dockspace_id)
private

Definition at line 520 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kOverworld.

Here is the call graph for this function:

◆ BuildDungeonLayout()

void yaze::editor::LayoutManager::BuildDungeonLayout ( ImGuiID dockspace_id)
private

Definition at line 521 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kDungeon.

Here is the call graph for this function:

◆ BuildGraphicsLayout()

void yaze::editor::LayoutManager::BuildGraphicsLayout ( ImGuiID dockspace_id)
private

Definition at line 522 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kGraphics.

Here is the call graph for this function:

◆ BuildPaletteLayout()

void yaze::editor::LayoutManager::BuildPaletteLayout ( ImGuiID dockspace_id)
private

Definition at line 523 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kPalette.

Here is the call graph for this function:

◆ BuildScreenLayout()

void yaze::editor::LayoutManager::BuildScreenLayout ( ImGuiID dockspace_id)
private

Definition at line 524 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kScreen.

Here is the call graph for this function:

◆ BuildMusicLayout()

void yaze::editor::LayoutManager::BuildMusicLayout ( ImGuiID dockspace_id)
private

Definition at line 525 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kMusic.

Here is the call graph for this function:

◆ BuildSpriteLayout()

void yaze::editor::LayoutManager::BuildSpriteLayout ( ImGuiID dockspace_id)
private

Definition at line 526 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kSprite.

Here is the call graph for this function:

◆ BuildMessageLayout()

void yaze::editor::LayoutManager::BuildMessageLayout ( ImGuiID dockspace_id)
private

Definition at line 527 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kMessage.

Here is the call graph for this function:

◆ BuildAssemblyLayout()

void yaze::editor::LayoutManager::BuildAssemblyLayout ( ImGuiID dockspace_id)
private

Definition at line 528 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kAssembly.

Here is the call graph for this function:

◆ BuildSettingsLayout()

void yaze::editor::LayoutManager::BuildSettingsLayout ( ImGuiID dockspace_id)
private

Definition at line 529 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kSettings.

Here is the call graph for this function:

◆ BuildEmulatorLayout()

void yaze::editor::LayoutManager::BuildEmulatorLayout ( ImGuiID dockspace_id)
private

Definition at line 530 of file layout_manager.cc.

References BuildLayoutFromPreset(), and yaze::editor::kEmulator.

Here is the call graph for this function:

Member Data Documentation

◆ layouts_initialized_

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

◆ panel_manager_

◆ current_layout_type_

LayoutType yaze::editor::LayoutManager::current_layout_type_ = LayoutType::kDefault
private

Definition at line 286 of file layout_manager.h.

Referenced by GetLayoutType(), and SetLayoutType().

◆ rebuild_requested_

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

Definition at line 289 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 292 of file layout_manager.h.

Referenced by InitializeEditorLayout(), and RebuildLayout().

◆ current_editor_type_

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

Definition at line 295 of file layout_manager.h.

Referenced by InitializeEditorLayout(), and RebuildLayout().

◆ saved_layouts_

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

◆ has_temp_session_layout_

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

◆ temp_session_id_

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

◆ temp_session_visibility_

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

◆ temp_session_pinned_

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

◆ temp_session_imgui_layout_

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

◆ saved_imgui_layouts_

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

◆ saved_pinned_layouts_

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

◆ layout_scopes_

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

◆ project_layout_key_

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

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