mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
u/var: Add u_var_combo
This commit is contained in:
parent
7ee8d1ac5d
commit
3e8a070e93
|
@ -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 *);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue