diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-04-27 11:07:55 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-04-27 11:07:55 -0400 |
| commit | dec2f0fe3ea9e3e95d6fc6abc421f1a81149c10c (patch) | |
| tree | a5af814c7b4249ccee710a8e455ac3195d2ad068 /widget.c | |
| parent | f45e9a8d37a384ccea33158a4d3062d633720c93 (diff) | |
| download | volute-dec2f0fe3ea9e3e95d6fc6abc421f1a81149c10c.zip | |
init compressor-select widget
Diffstat (limited to 'widget.c')
| -rw-r--r-- | widget.c | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -1,7 +1,11 @@ +#include <limits.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include "microui.h" +#include "unit.h" +#include "compressor.h" #include "widget.h" #include "util.h" @@ -106,6 +110,56 @@ w_select(mu_Context *ctx, w_Select *select) { return res; } +/* Returns non-zero on error. */ +int +w_init_select_compressor(w_Select_Compressor *select, int n, const Compressor *comps) { + int i; + size_t namesize; + + select->comps = comps; + select->n = n; + + select->filtered = malloc(n * sizeof(*select->filtered)); + if (select->filtered == NULL) { + return 1; + } + /* TODO: parallelize. */ + for (i = 0; i < n; i++) { + select->filtered[i] = i; + } + select->nfiltered = n; + + namesize = sizeof((*comps).brand) + sizeof((*comps).series) + sizeof((*comps).model) + 3; + select->names = malloc(n * namesize); + if (select->names == NULL) { + free(select->filtered); + return 1; + } + /* TODO: parallelize. */ + for (i = 0; i < n; i++) { + snprintf(select->names[i], namesize, "%s %s %s", + comps[i].brand, comps[i].series, comps[i].model); + } + + select->idx = 0; + select -> oldidx = 0; + + select->active = 0; + + return 0; +} + +void +w_free_select_compressor(w_Select_Compressor *select) { + free(select->filtered); + free(select->names); +} + +int +w_select_compressor(mu_Context *ctx, w_Select_Compressor *select) { + /* TODO */ +} + void w_init_number(w_Number num) { num[0] = '\0'; |