94#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
96 ImGuiContext* ctx = ImGui::GetCurrentContext();
98 return R
"({"error": "ImGui context not available"})";
101 ImGuiIO& io = ImGui::GetIO();
108 ImGuiWindow* current = ImGui::GetCurrentWindow();
109 if (current && !current->Hidden) {
114 ImGuiID active_id = ImGui::GetActiveID();
115 if (active_id != 0) {
120 ImGuiID hovered_id = ImGui::GetHoveredID();
121 if (hovered_id != 0) {
126 for (ImGuiWindow* window : ctx->Windows) {
127 if (window && window->Active && !window->Hidden) {
133 for (
int i = 0; i < ctx->OpenPopupStack.Size; i++) {
134 ImGuiPopupData& popup = ctx->OpenPopupStack[i];
135 if (popup.Window && !popup.Window->Hidden) {
141 state.
nav_id = ctx->NavId;
145 for (
int i = 0; i < 5; i++) {
160 return "{\"warning\": \"Widget state capture unavailable (UI test engine "
168#if defined(YAZE_WITH_JSON)
178 j[
"navigation"] = {{
"nav_id", absl::StrFormat(
"0x%08X", state.
nav_id)},
181 nlohmann::json mouse_buttons;
182 for (
int i = 0; i < 5; ++i) {
186 j[
"input"] = {{
"mouse_buttons", mouse_buttons},
199 json.append(
" \"frame_count\": ");
203 json.append(
" \"frame_rate\": ");
204 json.append(FormatFloatCompact(state.
frame_rate));
207 json.append(
" \"focused_window\": ");
211 json.append(
" \"focused_widget\": ");
215 json.append(
" \"hovered_widget\": ");
219 json.append(
" \"visible_windows\": [");
228 json.append(
" \"open_popups\": [");
229 for (
size_t i = 0; i < state.
open_popups.size(); ++i) {
233 json.append(EscapeJsonString(state.
open_popups[i]));
237 json.append(
" \"navigation\": {\n");
238 json.append(
" \"nav_id\": ");
239 json.append(EscapeJsonString(absl::StrFormat(
"0x%08X", state.
nav_id)));
241 json.append(
" \"nav_active\": ");
243 json.append(
"\n },\n");
245 json.append(
" \"input\": {\n");
246 json.append(
" \"mouse_buttons\": [");
247 for (
int i = 0; i < 5; ++i) {
255 json.append(
" \"mouse_pos\": [");
256 json.append(FormatFloatCompact(state.
mouse_pos_x));
258 json.append(FormatFloatCompact(state.
mouse_pos_y));
261 json.append(
" \"modifiers\": {\n");
262 json.append(
" \"ctrl\": ");
265 json.append(
" \"shift\": ");
268 json.append(
" \"alt\": ");
270 json.append(
"\n }\n");