92#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
94 ImGuiContext* ctx = ImGui::GetCurrentContext();
96 return R
"({"error": "ImGui context not available"})";
99 ImGuiIO& io = ImGui::GetIO();
106 ImGuiWindow* current = ImGui::GetCurrentWindow();
107 if (current && !current->Hidden) {
112 ImGuiID active_id = ImGui::GetActiveID();
113 if (active_id != 0) {
118 ImGuiID hovered_id = ImGui::GetHoveredID();
119 if (hovered_id != 0) {
124 for (ImGuiWindow* window : ctx->Windows) {
125 if (window && window->Active && !window->Hidden) {
131 for (
int i = 0; i < ctx->OpenPopupStack.Size; i++) {
132 ImGuiPopupData& popup = ctx->OpenPopupStack[i];
133 if (popup.Window && !popup.Window->Hidden) {
139 state.
nav_id = ctx->NavId;
143 for (
int i = 0; i < 5; i++) {
158 return "{\"warning\": \"Widget state capture unavailable (UI test engine disabled)\"}";
165#if defined(YAZE_WITH_JSON)
176 {
"nav_id", absl::StrFormat(
"0x%08X", state.
nav_id)},
179 nlohmann::json mouse_buttons;
180 for (
int i = 0; i < 5; ++i) {
185 {
"mouse_buttons", mouse_buttons},
198 json.append(
" \"frame_count\": ");
202 json.append(
" \"frame_rate\": ");
203 json.append(FormatFloatCompact(state.
frame_rate));
206 json.append(
" \"focused_window\": ");
210 json.append(
" \"focused_widget\": ");
214 json.append(
" \"hovered_widget\": ");
218 json.append(
" \"visible_windows\": [");
227 json.append(
" \"open_popups\": [");
228 for (
size_t i = 0; i < state.
open_popups.size(); ++i) {
232 json.append(EscapeJsonString(state.
open_popups[i]));
236 json.append(
" \"navigation\": {\n");
237 json.append(
" \"nav_id\": ");
238 json.append(EscapeJsonString(absl::StrFormat(
"0x%08X", state.
nav_id)));
240 json.append(
" \"nav_active\": ");
242 json.append(
"\n },\n");
244 json.append(
" \"input\": {\n");
245 json.append(
" \"mouse_buttons\": [");
246 for (
int i = 0; i < 5; ++i) {
254 json.append(
" \"mouse_pos\": [");
255 json.append(FormatFloatCompact(state.
mouse_pos_x));
257 json.append(FormatFloatCompact(state.
mouse_pos_y));
260 json.append(
" \"modifiers\": {\n");
261 json.append(
" \"ctrl\": ");
264 json.append(
" \"shift\": ");
267 json.append(
" \"alt\": ");
269 json.append(
"\n }\n");