mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-16 20:05:29 +00:00
u/var: Add u_var_curves
This commit is contained in:
parent
0324fbae6c
commit
789111daf8
|
@ -140,6 +140,16 @@ struct u_var_curve
|
|||
const char *ylabel; //!< Label of the Y axis
|
||||
};
|
||||
|
||||
struct u_var_curves
|
||||
{
|
||||
struct u_var_curve curves[16];
|
||||
int curve_count;
|
||||
|
||||
// These override individual curve axis labels
|
||||
const char *xlabel; //!< Label of the X axis
|
||||
const char *ylabel; //!< Label of the Y axis
|
||||
};
|
||||
|
||||
/*!
|
||||
* What kind of variable is this tracking.
|
||||
*/
|
||||
|
@ -181,6 +191,7 @@ enum u_var_kind
|
|||
U_VAR_KIND_HISTOGRAM_F32,
|
||||
U_VAR_KIND_DRAGGABLE_U16,
|
||||
U_VAR_KIND_CURVE,
|
||||
U_VAR_KIND_CURVES,
|
||||
};
|
||||
|
||||
#define U_VAR_NAME_STRING_SIZE 256
|
||||
|
@ -290,7 +301,8 @@ u_var_force_on(void);
|
|||
ADD_FUNC(draggable_f32, struct u_var_draggable_f32, DRAGGABLE_F32) \
|
||||
ADD_FUNC(draggable_u16, struct u_var_draggable_u16, DRAGGABLE_U16) \
|
||||
ADD_FUNC(histogram_f32, struct u_var_histogram_f32, HISTOGRAM_F32) \
|
||||
ADD_FUNC(curve, struct u_var_curve, CURVE)
|
||||
ADD_FUNC(curve, struct u_var_curve, CURVE) \
|
||||
ADD_FUNC(curves, struct u_var_curves, CURVES)
|
||||
|
||||
#define ADD_FUNC(SUFFIX, TYPE, ENUM) void u_var_add_##SUFFIX(void *, TYPE *, const char *);
|
||||
|
||||
|
|
|
@ -270,6 +270,24 @@ on_curve_var(const char *name, void *ptr)
|
|||
ImPlot_EndPlot();
|
||||
}
|
||||
|
||||
static void
|
||||
on_curves_var(const char *name, void *ptr)
|
||||
{
|
||||
struct u_var_curves *cs = (struct u_var_curves *)ptr;
|
||||
ImVec2 size = {igGetWindowContentRegionWidth(), 256};
|
||||
|
||||
bool shown = ImPlot_BeginPlot(name, cs->xlabel, cs->ylabel, size, 0, 0, 0, 0, 0);
|
||||
if (!shown) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cs->curve_count; i++) {
|
||||
struct u_var_curve *c = &cs->curves[i];
|
||||
ImPlot_PlotLineG(c->label, curve_var_implot_getter, c, c->count, 0);
|
||||
}
|
||||
ImPlot_EndPlot();
|
||||
}
|
||||
|
||||
static void
|
||||
on_draggable_f32_var(const char *name, void *ptr)
|
||||
{
|
||||
|
@ -420,6 +438,7 @@ on_elem(struct u_var_info *info, void *priv)
|
|||
case U_VAR_KIND_DRAGGABLE_U16: on_draggable_u16_var(name, ptr); break;
|
||||
case U_VAR_KIND_HISTOGRAM_F32: on_histogram_f32_var(name, ptr); break;
|
||||
case U_VAR_KIND_CURVE: on_curve_var(name, ptr); break;
|
||||
case U_VAR_KIND_CURVES: on_curves_var(name, ptr); break;
|
||||
default: igLabelText(name, "Unknown tag '%i'", kind); break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue