The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/var: Add nested headers

+42 -6
+4
src/xrt/auxiliary/util/u_var.h
··· 187 187 U_VAR_KIND_RO_FF_F64, 188 188 U_VAR_KIND_RO_FF_VEC3_F32, 189 189 U_VAR_KIND_GUI_HEADER, 190 + U_VAR_KIND_GUI_HEADER_BEGIN, 191 + U_VAR_KIND_GUI_HEADER_END, 190 192 U_VAR_KIND_BUTTON, 191 193 U_VAR_KIND_COMBO, 192 194 U_VAR_KIND_HISTOGRAM_F32, ··· 298 300 ADD_FUNC(ro_ff_f64, struct m_ff_f64, RO_FF_F64) \ 299 301 ADD_FUNC(ro_ff_vec3_f32, struct m_ff_vec3_f32, RO_FF_VEC3_F32) \ 300 302 ADD_FUNC(gui_header, bool, GUI_HEADER) \ 303 + ADD_FUNC(gui_header_begin, bool, GUI_HEADER_BEGIN) \ 304 + ADD_FUNC(gui_header_end, bool, GUI_HEADER_END) \ 301 305 ADD_FUNC(button, struct u_var_button, BUTTON) \ 302 306 ADD_FUNC(combo, struct u_var_combo, COMBO) \ 303 307 ADD_FUNC(draggable_f32, struct u_var_draggable_f32, DRAGGABLE_F32) \
+38 -6
src/xrt/state_trackers/gui/gui_scene_debug.c
··· 111 111 math_quat_normalize(q); 112 112 } 113 113 114 + #define MAX_HEADER_NESTING 256 114 115 struct draw_state 115 116 { 116 117 struct gui_program *p; 117 118 struct debug_scene *ds; 118 - bool hidden; 119 + bool vis_stack[MAX_HEADER_NESTING]; //!< Visibility stack for nested headers 120 + int vis_i; 119 121 }; 120 122 121 123 struct plot_state ··· 306 308 on_root_enter(const char *name, void *priv) 307 309 { 308 310 struct draw_state *state = (struct draw_state *)priv; 309 - state->hidden = false; 311 + state->vis_i = 0; 312 + state->vis_stack[0] = true; 310 313 311 314 igBegin(name, NULL, 0); 312 315 } ··· 326 329 enum u_var_kind kind = info->kind; 327 330 328 331 struct draw_state *state = (struct draw_state *)priv; 329 - if (state->hidden && kind != U_VAR_KIND_GUI_HEADER) { 332 + 333 + bool visible = state->vis_stack[state->vis_i]; 334 + 335 + if (kind == U_VAR_KIND_GUI_HEADER_BEGIN) { 336 + state->vis_i++; 337 + state->vis_stack[state->vis_i] = visible; 338 + } else if (kind == U_VAR_KIND_GUI_HEADER_END) { 339 + state->vis_i--; 340 + } 341 + 342 + // Check balanced GUI_HEADER_BEGIN/END pairs 343 + assert(state->vis_i >= 0 && state->vis_i < MAX_HEADER_NESTING); 344 + 345 + if (!visible && kind != U_VAR_KIND_GUI_HEADER) { 330 346 return; 331 347 } 332 348 ··· 429 445 case U_VAR_KIND_RO_QUAT_F32: igInputFloat4(name, (float *)ptr, "%+f", ro_i_flags); break; 430 446 case U_VAR_KIND_RO_FF_VEC3_F32: on_ff_vec3_var(info, state->p); break; 431 447 case U_VAR_KIND_GUI_HEADER: { 432 - state->hidden = !igCollapsingHeaderBoolPtr(name, NULL, 0); 448 + assert(state->vis_i == 0 && "Do not mix GUI_HEADER with GUI_HEADER_BEGIN/END"); 449 + state->vis_stack[state->vis_i] = igCollapsingHeaderBoolPtr(name, NULL, 0); 450 + break; 451 + } 452 + case U_VAR_KIND_GUI_HEADER_BEGIN: { 453 + bool is_open = igCollapsingHeaderBoolPtr(name, NULL, 0); 454 + state->vis_stack[state->vis_i] = is_open; 455 + if (is_open) { 456 + igIndent(8.0f); 457 + } 458 + break; 459 + } 460 + case U_VAR_KIND_GUI_HEADER_END: { 461 + igDummy((ImVec2){0, 8.0f}); 462 + igUnindent(8.0f); 433 463 break; 434 464 } 435 465 case U_VAR_KIND_SINK_DEBUG: on_sink_debug_var(name, ptr, state->p, state->ds); break; ··· 448 478 on_root_exit(const char *name, void *priv) 449 479 { 450 480 struct draw_state *state = (struct draw_state *)priv; 451 - state->hidden = false; 481 + assert(state->vis_i == 0 && "Unbalanced GUI_HEADER_BEGIN/END pairs"); 482 + state->vis_i = 0; 483 + state->vis_stack[0] = false; 452 484 453 485 igEnd(); 454 486 } ··· 513 545 scene_render(struct gui_scene *scene, struct gui_program *p) 514 546 { 515 547 struct debug_scene *ds = (struct debug_scene *)scene; 516 - struct draw_state state = {p, ds, false}; 548 + struct draw_state state = {p, ds, {0}, 0}; 517 549 518 550 u_var_visit(on_root_enter, on_root_exit, on_elem, &state); 519 551 }