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());
85 ImGuiDir dock_direction) {
87 printf(
"[WindowDelegate] DockWindow: %s to direction %d\n",
88 window_id.c_str(),
static_cast<int>(dock_direction));
95 printf(
"[WindowDelegate] UndockWindow: %s\n", window_id.c_str());
101 const ImVec2& size) {
102 printf(
"[WindowDelegate] SetDockSpace: %s (%.1f x %.1f)\n",
103 dock_space_id.c_str(), size.x, size.y);
108 if (preset_name.empty()) {
109 return absl::InvalidArgumentError(
"Layout preset name cannot be empty");
116 std::filesystem::path dir = std::filesystem::path(file_path).parent_path();
117 if (!std::filesystem::exists(dir)) {
118 std::filesystem::create_directories(dir);
122 std::ofstream file(file_path);
123 if (!file.is_open()) {
124 return absl::InternalError(
125 absl::StrFormat(
"Failed to open layout file: %s", file_path));
128 file <<
"# YAZE Layout Preset: " << preset_name <<
"\n";
129 file <<
"# Generated by WindowDelegate\n";
130 file <<
"# TODO: Implement actual layout serialization\n";
134 printf(
"[WindowDelegate] Saved layout: %s\n", preset_name.c_str());
135 return absl::OkStatus();
137 }
catch (
const std::exception& e) {
138 return absl::InternalError(
139 absl::StrFormat(
"Failed to save layout: %s", e.what()));
144 if (preset_name.empty()) {
145 return absl::InvalidArgumentError(
"Layout preset name cannot be empty");
151 if (!std::filesystem::exists(file_path)) {
152 return absl::NotFoundError(
153 absl::StrFormat(
"Layout file not found: %s", file_path));
156 std::ifstream file(file_path);
157 if (!file.is_open()) {
158 return absl::InternalError(
159 absl::StrFormat(
"Failed to open layout file: %s", file_path));
164 while (std::getline(file, line)) {
170 printf(
"[WindowDelegate] Loaded layout: %s\n", preset_name.c_str());
171 return absl::OkStatus();
173 }
catch (
const std::exception& e) {
174 return absl::InternalError(
175 absl::StrFormat(
"Failed to load layout: %s", e.what()));
180 printf(
"[WindowDelegate] ResetLayout()\n");
182 ImGui::LoadIniSettingsFromMemory(
nullptr);
183 return absl::OkStatus();
187 std::vector<std::string> layouts;
191 std::string config_dir =
"config/layouts";
192 if (std::filesystem::exists(config_dir)) {
193 for (
const auto& entry :
194 std::filesystem::directory_iterator(config_dir)) {
195 if (entry.is_regular_file() && entry.path().extension() ==
".ini") {
196 layouts.push_back(entry.path().stem().string());
200 }
catch (
const std::exception& e) {
201 printf(
"[WindowDelegate] Error scanning layouts: %s\n", e.what());
208 std::vector<std::string> visible;
214 std::vector<std::string> hidden;
224 return ImVec2(400, 300);
232 return ImVec2(100, 100);
236 printf(
"[WindowDelegate] ShowWindowsInCategory: %s\n", category.c_str());
241 printf(
"[WindowDelegate] HideWindowsInCategory: %s\n", category.c_str());
246 printf(
"[WindowDelegate] ShowOnlyWindow: %s\n", window_id.c_str());
251 const std::string& category) {
258 printf(
"[WindowDelegate] Registered window: %s (category: %s)\n",
259 window_id.c_str(), category.c_str());
266 printf(
"[WindowDelegate] Unregistered window: %s\n", window_id.c_str());
271 printf(
"[WindowDelegate] LoadDeveloperLayout()\n");
276 printf(
"[WindowDelegate] LoadDesignerLayout()\n");
281 printf(
"[WindowDelegate] LoadModderLayout()\n");
286 printf(
"[WindowDelegate] LoadMinimalLayout()\n");
296 const std::string& preset_name)
const {
298 return absl::StrFormat(
"config/layouts/%s.ini", preset_name);
302 const std::string& layout_data) {
304 printf(
"[WindowDelegate] ApplyLayoutToWindow: %s\n", window_id.c_str());
310 ImGui::SaveIniSettingsToDisk(
"yaze_workspace.ini");
311 printf(
"[WindowDelegate] Workspace layout saved to yaze_workspace.ini\n");
315 ImGui::LoadIniSettingsFromDisk(
"yaze_workspace.ini");
316 printf(
"[WindowDelegate] Workspace layout loaded from yaze_workspace.ini\n");
322 printf(
"[WindowDelegate] Workspace layout reset requested\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()