aboutsummaryrefslogtreecommitdiffstats
path: root/widget.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-03-01 12:27:50 -0500
committerSam Anthony <sam@samanthony.xyz>2025-03-01 12:27:50 -0500
commit8cd4a9079a3a4343c2e2fa34d41901569541ec98 (patch)
treeb5c94d79823c73eab85e86bc16ae8940b6b51145 /widget.c
parent89fd08ec37e6b3d5191d20c2e3d219579255d934 (diff)
downloadvolute-8cd4a9079a3a4343c2e2fa34d41901569541ec98.zip
reformat displacement when unit changes
Diffstat (limited to 'widget.c')
-rw-r--r--widget.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/widget.c b/widget.c
index cc9d894..46c7b07 100644
--- a/widget.c
+++ b/widget.c
@@ -33,10 +33,17 @@ w_field(mu_Context *ctx, w_Field *f) {
}
void
+w_set_field(w_Field *f, double val) {
+ f->value = val;
+ snprintf(f->buf, sizeof(f->buf), "%lf", val);
+}
+
+void
w_init_select(w_Select *select, int nopts, const char *const opts[]) {
select->nopts = nopts;
select->opts = opts;
select->idx = 0;
+ select->oldidx = 0;
select ->active = 0;
}
@@ -65,6 +72,7 @@ w_select(mu_Context *ctx, w_Select *select) {
res = MU_RES_ACTIVE;
for (i = 0; i < select->nopts; i++) {
if (mu_button(ctx, select->opts[i])) {
+ select->oldidx = select->idx;
select->idx = i;
res |= MU_RES_CHANGE;
select->active = 0;