7#include "absl/strings/str_format.h"
8#include "imgui/imgui.h"
16 printf(
"[WindowDelegate] ShowAllWindows() - %zu windows registered\n",
23 printf(
"[WindowDelegate] HideAllWindows() - %zu windows registered\n",
29 printf(
"[WindowDelegate] ShowWindow: %s\n", window_id.c_str());
36 printf(
"[WindowDelegate] HideWindow: %s\n", window_id.c_str());
43 printf(
"[WindowDelegate] ToggleWindow: %s\n", window_id.c_str());
58 printf(
"[WindowDelegate] FocusWindow: %s\n", window_id.c_str());
65 printf(
"[WindowDelegate] MaximizeWindow: %s\n", window_id.c_str());
72 printf(
"[WindowDelegate] RestoreWindow: %s\n", window_id.c_str());
79 printf(
"[WindowDelegate] CenterWindow: %s\n", window_id.c_str());
86 printf(
"[WindowDelegate] DockWindow: %s to direction %d\n",
87 window_id.c_str(),
static_cast<int>(dock_direction));
94 printf(
"[WindowDelegate] UndockWindow: %s\n", window_id.c_str());
100 printf(
"[WindowDelegate] SetDockSpace: %s (%.1f x %.1f)\n",
101 dock_space_id.c_str(), size.x, size.y);
106 if (preset_name.empty()) {
107 return absl::InvalidArgumentError(
"Layout preset name cannot be empty");
114 std::filesystem::path dir = std::filesystem::path(file_path).parent_path();
115 if (!std::filesystem::exists(dir)) {
116 std::filesystem::create_directories(dir);
120 std::ofstream file(file_path);
121 if (!file.is_open()) {
122 return absl::InternalError(absl::StrFormat(
"Failed to open layout file: %s", file_path));
125 file <<
"# YAZE Layout Preset: " << preset_name <<
"\n";
126 file <<
"# Generated by WindowDelegate\n";
127 file <<
"# TODO: Implement actual layout serialization\n";
131 printf(
"[WindowDelegate] Saved layout: %s\n", preset_name.c_str());
132 return absl::OkStatus();
134 }
catch (
const std::exception& e) {
135 return absl::InternalError(absl::StrFormat(
"Failed to save layout: %s", e.what()));
140 if (preset_name.empty()) {
141 return absl::InvalidArgumentError(
"Layout preset name cannot be empty");
147 if (!std::filesystem::exists(file_path)) {
148 return absl::NotFoundError(absl::StrFormat(
"Layout file not found: %s", file_path));
151 std::ifstream file(file_path);
152 if (!file.is_open()) {
153 return absl::InternalError(absl::StrFormat(
"Failed to open layout file: %s", file_path));
158 while (std::getline(file, line)) {
164 printf(
"[WindowDelegate] Loaded layout: %s\n", preset_name.c_str());
165 return absl::OkStatus();
167 }
catch (
const std::exception& e) {
168 return absl::InternalError(absl::StrFormat(
"Failed to load layout: %s", e.what()));
173 printf(
"[WindowDelegate] ResetLayout()\n");
175 ImGui::LoadIniSettingsFromMemory(
nullptr);
176 return absl::OkStatus();
180 std::vector<std::string> layouts;
184 std::string config_dir =
"config/layouts";
185 if (std::filesystem::exists(config_dir)) {
186 for (
const auto& entry : std::filesystem::directory_iterator(config_dir)) {
187 if (entry.is_regular_file() && entry.path().extension() ==
".ini") {
188 layouts.push_back(entry.path().stem().string());
192 }
catch (
const std::exception& e) {
193 printf(
"[WindowDelegate] Error scanning layouts: %s\n", e.what());
200 std::vector<std::string> visible;
206 std::vector<std::string> hidden;
216 return ImVec2(400, 300);
224 return ImVec2(100, 100);
228 printf(
"[WindowDelegate] ShowWindowsInCategory: %s\n", category.c_str());
233 printf(
"[WindowDelegate] HideWindowsInCategory: %s\n", category.c_str());
238 printf(
"[WindowDelegate] ShowOnlyWindow: %s\n", window_id.c_str());
249 printf(
"[WindowDelegate] Registered window: %s (category: %s)\n",
250 window_id.c_str(), category.c_str());
257 printf(
"[WindowDelegate] Unregistered window: %s\n", window_id.c_str());
262 printf(
"[WindowDelegate] LoadDeveloperLayout()\n");
267 printf(
"[WindowDelegate] LoadDesignerLayout()\n");
272 printf(
"[WindowDelegate] LoadModderLayout()\n");
277 printf(
"[WindowDelegate] LoadMinimalLayout()\n");
288 return absl::StrFormat(
"config/layouts/%s.ini", preset_name);
293 printf(
"[WindowDelegate] ApplyLayoutToWindow: %s\n", window_id.c_str());
299 ImGui::SaveIniSettingsToDisk(
"yaze_workspace.ini");
300 printf(
"[WindowDelegate] Workspace layout saved to yaze_workspace.ini\n");
304 ImGui::LoadIniSettingsFromDisk(
"yaze_workspace.ini");
305 printf(
"[WindowDelegate] Workspace layout loaded from yaze_workspace.ini\n");
310 ImGui::LoadIniSettingsFromMemory(
nullptr);
311 printf(
"[WindowDelegate] Workspace layout reset to default\n");
void LoadDesignerLayout()
void LoadWorkspaceLayout()
void SaveWorkspaceLayout()
std::vector< std::string > GetVisibleWindows() const
void SetDockSpace(const std::string &dock_space_id, const ImVec2 &size=ImVec2(0, 0))
absl::Status ResetLayout()
bool IsWindowVisible(const std::string &window_id) const
void UnregisterWindow(const std::string &window_id)
void RegisterWindow(const std::string &window_id, const std::string &category="")
std::unordered_map< std::string, WindowInfo > registered_windows_
void RestoreWindow(const std::string &window_id)
void MaximizeWindow(const std::string &window_id)
std::string GetLayoutFilePath(const std::string &preset_name) const
void ShowWindow(const std::string &window_id)
void HideWindow(const std::string &window_id)
std::vector< std::string > GetAvailableLayouts() const
ImVec2 GetWindowSize(const std::string &window_id) const
void ToggleWindow(const std::string &window_id)
void UndockWindow(const std::string &window_id)
absl::Status SaveLayout(const std::string &preset_name)
void ShowOnlyWindow(const std::string &window_id)
void ShowWindowsInCategory(const std::string &category)
bool IsWindowRegistered(const std::string &window_id) const
void HideWindowsInCategory(const std::string &category)
void CenterWindow(const std::string &window_id)
void ResetWorkspaceLayout()
ImVec2 GetWindowPosition(const std::string &window_id) const
void ApplyLayoutToWindow(const std::string &window_id, const std::string &layout_data)
absl::Status LoadLayout(const std::string &preset_name)
void DockWindow(const std::string &window_id, ImGuiDir dock_direction)
std::vector< std::string > GetHiddenWindows() const
void FocusWindow(const std::string &window_id)
void LoadDeveloperLayout()
Main namespace for the application.