yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
layout_orchestrator.cc
Go to the documentation of this file.
2
3#include "absl/strings/str_format.h"
4
5namespace yaze {
6namespace editor {
7
9 PanelManager* panel_manager)
10 : layout_manager_(layout_manager), panel_manager_(panel_manager) {}
11
17
18void LayoutOrchestrator::ApplyPreset(EditorType type, size_t session_id) {
19 if (!IsInitialized()) {
20 return;
21 }
22
23 // Get the default preset for this editor type
24 auto preset = LayoutPresets::GetDefaultPreset(type);
25
26 // Show default panels
27 ShowPresetPanels(preset, session_id, type);
28
29 // Hide optional panels
30 HideOptionalPanels(type, session_id);
31
32 // Apply DockBuilder layout
33 ApplyDockLayout(type);
34}
35
36void LayoutOrchestrator::ApplyNamedPreset(const std::string& preset_name,
37 size_t session_id) {
38 if (!IsInitialized()) {
39 return;
40 }
41
42 PanelLayoutPreset preset;
43 if (preset_name == "Minimal") {
45 } else if (preset_name == "Logic Debugger") {
47 } else if (preset_name == "Overworld Artist") {
49 } else if (preset_name == "Dungeon Master") {
51 } else if (preset_name == "Audio Engineer") {
53 } else {
54 // Unknown preset, use minimal
56 }
57
58 ShowPresetPanels(preset, session_id, EditorType::kUnknown);
60}
61
62void LayoutOrchestrator::ResetToDefault(EditorType type, size_t session_id) {
63 ApplyPreset(type, session_id);
65}
66
67std::string LayoutOrchestrator::GetWindowTitle(const std::string& card_id,
68 size_t session_id) const {
69 if (!panel_manager_) {
70 return "";
71 }
72 return panel_manager_->GetPanelWindowName(session_id, card_id);
73}
74
75std::vector<std::string> LayoutOrchestrator::GetVisiblePanels(
76 size_t session_id) const {
77 // Return empty since this requires more complex session handling
78 // This can be implemented later when session-aware panel visibility is needed
79 return {};
80}
81
83 size_t session_id,
84 EditorType editor_type) {
85 if (!panel_manager_) {
86 return;
87 }
88
89 for (const auto& panel_id : preset.default_visible_panels) {
90 panel_manager_->ShowPanel(session_id, panel_id);
91 }
92}
93
95 size_t session_id) {
96 if (!panel_manager_) {
97 return;
98 }
99
100 auto preset = LayoutPresets::GetDefaultPreset(type);
101 for (const auto& panel_id : preset.optional_panels) {
102 panel_manager_->HidePanel(session_id, panel_id);
103 }
104}
105
112
114 if (!layout_manager_) {
115 return;
116 }
117
118 // Map EditorType to LayoutType
119 LayoutType layout_type = LayoutType::kDefault;
120 switch (type) {
122 layout_type = LayoutType::kOverworld;
123 break;
125 layout_type = LayoutType::kDungeon;
126 break;
128 layout_type = LayoutType::kGraphics;
129 break;
131 layout_type = LayoutType::kPalette;
132 break;
134 layout_type = LayoutType::kSprite;
135 break;
137 layout_type = LayoutType::kScreen;
138 break;
140 layout_type = LayoutType::kMusic;
141 break;
143 layout_type = LayoutType::kMessage;
144 break;
146 layout_type = LayoutType::kAssembly;
147 break;
149 layout_type = LayoutType::kSettings;
150 break;
152 layout_type = LayoutType::kEmulator;
153 break;
154 default:
155 layout_type = LayoutType::kDefault;
156 break;
157 }
158
159 layout_manager_->SetLayoutType(layout_type);
161}
162
163std::string LayoutOrchestrator::GetPrefixedPanelId(const std::string& card_id,
164 size_t session_id) const {
165 if (panel_manager_) {
166 return panel_manager_->MakePanelId(session_id, card_id);
167 }
168 if (session_id == 0) {
169 return card_id;
170 }
171 return absl::StrFormat("s%zu.%s", session_id, card_id);
172}
173
174} // namespace editor
175} // namespace yaze
Manages ImGui DockBuilder layouts for each editor type.
void SetLayoutType(LayoutType type)
Set the current layout type for rebuild.
void RequestRebuild()
Request a layout rebuild on next frame.
std::vector< std::string > GetVisiblePanels(size_t session_id) const
Get all visible panels for a session.
void ResetToDefault(EditorType type, size_t session_id=0)
Reset to default layout for an editor type.
bool IsInitialized() const
Check if orchestrator is properly initialized.
PanelManager * panel_manager()
Get the card registry.
void ApplyDockLayout(EditorType type)
Apply DockBuilder layout for an editor type.
void RequestLayoutRebuild()
Request layout rebuild on next frame.
std::string GetPrefixedPanelId(const std::string &card_id, size_t session_id) const
Get prefixed card ID for a session.
void ApplyPreset(EditorType type, size_t session_id=0)
Apply the default layout preset for an editor type.
void HideOptionalPanels(EditorType type, size_t session_id=0)
Hide all optional panels for an editor type.
void ApplyNamedPreset(const std::string &preset_name, size_t session_id=0)
Apply a named workspace preset (Developer, Designer, Modder)
LayoutManager * layout_manager()
Get the layout manager.
void Initialize(LayoutManager *layout_manager, PanelManager *panel_manager)
Initialize with dependencies.
std::string GetWindowTitle(const std::string &card_id, size_t session_id=0) const
Get window title for a card from the registry.
void ShowPresetPanels(const PanelLayoutPreset &preset, size_t session_id, EditorType editor_type)
Show panels specified in a preset.
static PanelLayoutPreset GetLogicDebuggerPreset()
Get the "logic debugger" workspace preset (QA and debug focused)
static PanelLayoutPreset GetDungeonMasterPreset()
Get the "dungeon master" workspace preset.
static PanelLayoutPreset GetAudioEngineerPreset()
Get the "audio engineer" workspace preset (music focused)
static PanelLayoutPreset GetOverworldArtistPreset()
Get the "overworld artist" workspace preset.
static PanelLayoutPreset GetDefaultPreset(EditorType type)
Get the default layout preset for an editor type.
static PanelLayoutPreset GetMinimalPreset()
Get the "minimal" workspace preset (minimal cards)
Central registry for all editor cards with session awareness and dependency injection.
bool ShowPanel(size_t session_id, const std::string &base_card_id)
std::string MakePanelId(size_t session_id, const std::string &base_id) const
std::string GetPanelWindowName(size_t session_id, const std::string &base_card_id) const
Resolve the exact ImGui window name for a panel by base ID.
bool HidePanel(size_t session_id, const std::string &base_card_id)
LayoutType
Predefined layout types for different editor workflows.
Defines default panel visibility for an editor type.
std::vector< std::string > default_visible_panels