aboutsummaryrefslogtreecommitdiffstats
path: root/widget.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-04-30 11:37:49 -0400
committerSam Anthony <sam@samanthony.xyz>2025-04-30 11:37:49 -0400
commit5ac5c25c299b3c1d390c68c3d04ae979e787def0 (patch)
treebf0a222e5075be9ead50c05f942768b484435572 /widget.c
parent550dee49514fe3528c43541f062c1ae5590313ae (diff)
downloadvolute-5ac5c25c299b3c1d390c68c3d04ae979e787def0.zip
canvas widget
Diffstat (limited to 'widget.c')
-rw-r--r--widget.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/widget.c b/widget.c
index 721055b..8f864c3 100644
--- a/widget.c
+++ b/widget.c
@@ -333,3 +333,20 @@ update_active(mu_Context *ctx, mu_Id id, mu_Rect r, int *active) {
mu_update_control(ctx, id, r, 0);
*active ^= (ctx->mouse_pressed == MU_MOUSE_LEFT && ctx->focus == id);
}
+
+/* Create a canvas with the background loaded from an image file. Returns non-zero on error. */
+int
+w_init_canvas(w_Canvas *c, const char *bg_img_path) {
+ c->id = r_add_canvas(bg_img_path);
+ if (c->id < 0) {
+ weprintf("failed to create canvas widget");
+ return 1;
+ }
+ return 0;
+}
+
+void
+w_free_canvas(w_Canvas *c) {
+ r_remove_canvas(c->id);
+ c->id = -1;
+}