5#include "absl/strings/str_format.h"
11#include "imgui/imgui.h"
12#include "imgui/imgui_internal.h"
53 float viewport_width = 0.0f;
54 if (ImGui::GetCurrentContext()) {
55 const ImGuiViewport* viewport = ImGui::GetMainViewport();
56 viewport_width = viewport ? viewport->WorkSize.x : 0.0f;
82 if (ImGui::GetCurrentContext()) {
83 static const char kEmptyIni[] =
"\n";
84 ImGui::LoadIniSettingsFromMemory(kEmptyIni,
sizeof(kEmptyIni) - 1);
89 std::filesystem::remove(*ini_path, ec);
91 LOG_WARN(
"LayoutCoordinator",
"Failed to remove ImGui ini: %s",
92 ec.message().c_str());
100 ImGuiContext* imgui_ctx = ImGui::GetCurrentContext();
101 if (imgui_ctx && imgui_ctx->WithinFrameScope) {
102 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
107 LOG_INFO(
"LayoutCoordinator",
"Emulator layout reset complete");
112 LOG_INFO(
"LayoutCoordinator",
"Layout reset queued for next frame");
125 if (preset_name ==
"Minimal") {
127 }
else if (preset_name ==
"Developer") {
129 }
else if (preset_name ==
"Designer") {
131 }
else if (preset_name ==
"Modder") {
133 }
else if (preset_name ==
"Overworld Expert") {
135 }
else if (preset_name ==
"Dungeon Expert") {
137 }
else if (preset_name ==
"Testing") {
139 }
else if (preset_name ==
"Audio") {
142 LOG_WARN(
"LayoutCoordinator",
"Unknown layout preset: %s",
143 preset_name.c_str());
164 LOG_INFO(
"LayoutCoordinator",
"Applied layout preset: %s",
165 preset_name.c_str());
193 LOG_INFO(
"LayoutCoordinator",
"Reset editor layout to defaults for type %d",
194 static_cast<int>(editor_type));
205 bool is_emulator_visible) {
211 ImGuiContext* imgui_ctx = ImGui::GetCurrentContext();
212 if (!imgui_ctx || !imgui_ctx->WithinFrameScope) {
216 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
220 if (is_emulator_visible) {
223 rebuild_type = current_editor_type;
229 LOG_INFO(
"LayoutCoordinator",
"Layout rebuilt for editor type %d",
230 static_cast<int>(rebuild_type));
248 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
249 layout_manager_->InitializeEditorLayout(type, dockspace_id);
264 std::vector<std::function<void()>> actions_to_execute;
266 const int processed_count =
static_cast<int>(actions_to_execute.size());
268 for (
auto& action : actions_to_execute) {
272 if (processed_count > 0) {
274 processed_count, std::memory_order_relaxed) -
std::vector< std::function< void()> > deferred_actions_
void QueueDeferredAction(std::function< void()> action)
Queue an action to be executed on the next frame.
LayoutManager * layout_manager_
void ProcessDeferredActions()
Process all queued deferred actions.
float GetBottomLayoutOffset() const
Get the bottom margin needed for status bar.
UICoordinator * ui_coordinator_
void ResetWorkspaceLayout()
Reset the workspace layout to defaults.
void ProcessLayoutRebuild(EditorType current_editor_type, bool is_emulator_visible)
Process pending layout rebuild requests.
RightDrawerManager * right_drawer_manager_
WorkspaceWindowManager * window_manager_
ToastManager * toast_manager_
std::atomic< int > pending_deferred_actions_
void InitializeEditorLayout(EditorType type)
Initialize layout for an editor type on first activation.
float GetRightLayoutOffset() const
Get the right margin needed for drawers.
void ResetCurrentEditorLayout(EditorType editor_type, size_t session_id)
Reset current editor layout to its default configuration.
void ApplyLayoutPreset(const std::string &preset_name, size_t session_id)
Apply a named layout preset.
void Initialize(const Dependencies &deps)
Initialize with all dependencies.
float GetLeftLayoutOffset() const
Get the left margin needed for sidebar (Activity Bar + Side Panel)
void RebuildLayout(EditorType type, ImGuiID dockspace_id)
Force rebuild of layout for a specific editor type.
void ClearInitializationFlags()
Clear all initialization flags (for testing)
bool IsLayoutInitialized(EditorType type) const
Check if a layout has been initialized for an editor.
void ResetToDefaultLayout(EditorType type)
Reset the layout for an editor to its default.
void ClearRebuildRequest()
Clear rebuild request flag.
void RequestRebuild()
Request a layout rebuild on next frame.
bool IsRebuildRequested() const
Check if rebuild was requested.
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 GetDesignerPreset()
Get the "designer" workspace preset (visual-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 GetModderPreset()
Get the "modder" workspace preset (full-featured)
static PanelLayoutPreset GetMinimalPreset()
Get the "minimal" workspace preset (minimal cards)
static PanelLayoutPreset GetDeveloperPreset()
Get the "developer" workspace preset (debug-focused)
float GetDrawerWidth() const
Get the width of the drawer when expanded.
float GetHeight() const
Get the height of the status bar.
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f)
bool IsEmulatorVisible() const
bool ShouldShowActivityBar() const
bool IsPanelSidebarVisible() const
void ResetToDefaults(size_t session_id)
void HideAll(size_t session_id)
bool IsSidebarExpanded() const
float GetActiveSidePanelWidth(float viewport_width) const
static constexpr float GetSidebarWidth()
bool OpenWindow(size_t session_id, const std::string &base_window_id)
bool IsSidebarVisible() const
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
All dependencies required by LayoutCoordinator.
ToastManager * toast_manager
UICoordinator * ui_coordinator
LayoutManager * layout_manager
WorkspaceWindowManager * window_manager
RightDrawerManager * right_drawer_manager
Defines default panel visibility for an editor type.
std::vector< std::string > default_visible_panels