From 5ac5c25c299b3c1d390c68c3d04ae979e787def0 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Wed, 30 Apr 2025 11:37:49 -0400 Subject: canvas widget --- widget.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'widget.c') 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; +} -- cgit v1.2.3