From 3e8a070e93f267a3ace25a645850bf6c21a53ce2 Mon Sep 17 00:00:00 2001 From: Mateo de Mayo Date: Mon, 13 Dec 2021 09:33:59 -0300 Subject: [PATCH] u/var: Add u_var_combo --- src/xrt/auxiliary/util/u_var.h | 14 ++++++++++++++ src/xrt/state_trackers/gui/gui_scene_debug.c | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/src/xrt/auxiliary/util/u_var.h b/src/xrt/auxiliary/util/u_var.h index 501678ea1..5c1087398 100644 --- a/src/xrt/auxiliary/util/u_var.h +++ b/src/xrt/auxiliary/util/u_var.h @@ -81,6 +81,18 @@ struct u_var_button bool disabled; }; +struct u_var_combo +{ + //! Number of options. + int count; + + //! List of `count` option names separated by \0. + const char *options; + + //! Pointer to the option value. + int *value; +}; + struct u_var_draggable_f32 { float val; @@ -125,6 +137,7 @@ enum u_var_kind U_VAR_KIND_RO_FF_VEC3_F32, U_VAR_KIND_GUI_HEADER, U_VAR_KIND_BUTTON, + U_VAR_KIND_COMBO, }; #define U_VAR_NAME_STRING_SIZE 256 @@ -231,6 +244,7 @@ u_var_force_on(void); ADD_FUNC(ro_ff_vec3_f32, struct m_ff_vec3_f32, RO_FF_VEC3_F32) \ ADD_FUNC(gui_header, bool, GUI_HEADER) \ ADD_FUNC(button, struct u_var_button, BUTTON) \ + ADD_FUNC(combo, struct u_var_combo, COMBO) \ ADD_FUNC(draggable_f32, struct u_var_draggable_f32, DRAGGABLE_F32) #define ADD_FUNC(SUFFIX, TYPE, ENUM) void u_var_add_##SUFFIX(void *, TYPE *, const char *); diff --git a/src/xrt/state_trackers/gui/gui_scene_debug.c b/src/xrt/state_trackers/gui/gui_scene_debug.c index 8554ff3ee..e94fe9842 100644 --- a/src/xrt/state_trackers/gui/gui_scene_debug.c +++ b/src/xrt/state_trackers/gui/gui_scene_debug.c @@ -229,6 +229,12 @@ on_button_var(const char *name, void *ptr) igPopStyleVar(1); } } +static void +on_combo_var(const char *name, void *ptr) +{ + struct u_var_combo *combo = (struct u_var_combo *)ptr; + igComboStr(name, combo->value, combo->options, combo->count); +} static void on_draggable_f32_var(const char *name, void *ptr) @@ -368,6 +374,7 @@ on_elem(struct u_var_info *info, void *priv) case U_VAR_KIND_SINK_DEBUG: on_sink_debug_var(name, ptr, state->p, state->ds); break; case U_VAR_KIND_DRAGGABLE_F32: on_draggable_f32_var(name, ptr); break; case U_VAR_KIND_BUTTON: on_button_var(name, ptr); break; + case U_VAR_KIND_COMBO: on_combo_var(name, ptr); break; default: igLabelText(name, "Unknown tag '%i'", kind); break; } }