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;
81 if (ImGui::GetCurrentContext()) {
82 static const char kEmptyIni[] =
"\n";
83 ImGui::LoadIniSettingsFromMemory(kEmptyIni,
sizeof(kEmptyIni) - 1);
88 std::filesystem::remove(*ini_path, ec);
90 LOG_WARN(
"LayoutCoordinator",
"Failed to remove ImGui ini: %s",
91 ec.message().c_str());
99 ImGuiContext* imgui_ctx = ImGui::GetCurrentContext();
100 if (imgui_ctx && imgui_ctx->WithinFrameScope) {
101 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
106 LOG_INFO(
"LayoutCoordinator",
"Emulator layout reset complete");
111 LOG_INFO(
"LayoutCoordinator",
"Layout reset queued for next frame");
124 if (preset_name ==
"Minimal") {
126 }
else if (preset_name ==
"Developer") {
128 }
else if (preset_name ==
"Designer") {
130 }
else if (preset_name ==
"Modder") {
132 }
else if (preset_name ==
"Overworld Expert") {
134 }
else if (preset_name ==
"Dungeon Expert") {
136 }
else if (preset_name ==
"Testing") {
138 }
else if (preset_name ==
"Audio") {
141 LOG_WARN(
"LayoutCoordinator",
"Unknown layout preset: %s",
142 preset_name.c_str());
163 LOG_INFO(
"LayoutCoordinator",
"Applied layout preset: %s",
164 preset_name.c_str());
192 LOG_INFO(
"LayoutCoordinator",
"Reset editor layout to defaults for type %d",
193 static_cast<int>(editor_type));
204 bool is_emulator_visible) {
210 ImGuiContext* imgui_ctx = ImGui::GetCurrentContext();
211 if (!imgui_ctx || !imgui_ctx->WithinFrameScope) {
215 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
219 if (is_emulator_visible) {
222 rebuild_type = current_editor_type;
228 LOG_INFO(
"LayoutCoordinator",
"Layout rebuilt for editor type %d",
229 static_cast<int>(rebuild_type));
247 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
248 layout_manager_->InitializeEditorLayout(type, dockspace_id);
263 std::vector<std::function<void()>> actions_to_execute;
265 const int processed_count =
static_cast<int>(actions_to_execute.size());
267 for (
auto& action : actions_to_execute) {
271 if (processed_count > 0) {
273 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_
RightPanelManager * right_panel_manager_
void ProcessDeferredActions()
Process all queued deferred actions.
float GetBottomLayoutOffset() const
Get the bottom margin needed for status bar.
PanelManager * panel_manager_
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.
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 panels.
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)
bool ShowPanel(size_t session_id, const std::string &base_card_id)
bool IsPanelExpanded() const
void HideAll(size_t session_id)
static constexpr float GetSidebarWidth()
void ResetToDefaults(size_t session_id)
bool IsSidebarVisible() const
float GetActiveSidePanelWidth(float viewport_width) const
float GetPanelWidth() const
Get the width of the panel 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
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
All dependencies required by LayoutCoordinator.
PanelManager * panel_manager
ToastManager * toast_manager
UICoordinator * ui_coordinator
RightPanelManager * right_panel_manager
LayoutManager * layout_manager
Defines default panel visibility for an editor type.
std::vector< std::string > default_visible_panels