aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-05-02 20:54:00 -0230
committerSam Anthony <sam@samanthony.xyz>2025-05-02 20:54:00 -0230
commite977059a478178101eda2e6771d52f21b135248c (patch)
treecfc1d592479cd4bc030041dcf106a224a65fa91c
parent08ddaa509e254c335a13417b157d4da23ea9314b (diff)
downloadvolute-e977059a478178101eda2e6771d52f21b135248c.zip
select compressor map
-rw-r--r--main.c9
-rw-r--r--widget.c7
-rw-r--r--widget.h1
3 files changed, 16 insertions, 1 deletions
diff --git a/main.c b/main.c
index cc1620f..220abe6 100644
--- a/main.c
+++ b/main.c
@@ -12,6 +12,7 @@
#include "engine.h"
#include "ui.h"
#include "color.h"
+#include "eprintf.h"
/* Macros. */
@@ -386,8 +387,14 @@ mass_flow_rate_corrected_row(mu_Context *ctx, UI *ui) {
static void
comp_select(mu_Context *ctx, UI *ui) {
+ const Compressor *comp;
+
if (w_select_compressor(ctx, &ui->comp_select) & MU_RES_CHANGE) {
- /* TODO */
+ comp = &ui->comps[ui->comp_select.idx];
+ if (w_canvas_set_bg(&ui->comp_img, comp->imgfile) != 0) {
+ weprintf("failed to set compressor image: %s", comp->imgfile);
+ }
+ compute_all(ui);
}
}
diff --git a/widget.c b/widget.c
index cca3415..613d834 100644
--- a/widget.c
+++ b/widget.c
@@ -396,3 +396,10 @@ w_clear_canvas(w_Canvas *canvas) {
r_clear_canvas(canvas->id);
canvas->dirty = 1;
}
+
+/* Set the background image of the canvas. Returns non-zero on error. */
+int
+w_canvas_set_bg(w_Canvas *canvas, const char *path) {
+ r_remove_canvas(canvas->id);
+ return w_init_canvas(canvas, path);
+}
diff --git a/widget.h b/widget.h
index 98f592c..802e8ba 100644
--- a/widget.h
+++ b/widget.h
@@ -87,3 +87,4 @@ void w_free_canvas(w_Canvas *c);
void w_canvas(mu_Context *ctx, w_Canvas *canvas);
void w_canvas_draw_circle(w_Canvas *canvas, int x, int y, int r, mu_Color color);
void w_clear_canvas(w_Canvas *canvas);
+int w_canvas_set_bg(w_Canvas *canvas, const char *path);