From e3356fde2de41b29989b4e8884f04b2be763256f Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Tue, 20 Sep 2022 17:31:17 +0200 Subject: [PATCH] gui: Implement gui_deinit --- src/gui/inc/gui.h | 2 ++ src/gui/src/gui.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/gui/inc/gui.h b/src/gui/inc/gui.h index 9093572..72b2fb0 100644 --- a/src/gui/inc/gui.h +++ b/src/gui/inc/gui.h @@ -20,6 +20,7 @@ struct gui_common const struct camera *, struct input *); int (*render)(const struct gui_common *); void (*get_dim)(const struct gui_common *, short *w, short *h); + void (*deinit)(struct gui_common *, struct input *); } *cb; short x, y, xoff, yoff; @@ -32,6 +33,7 @@ void gui_add_sibling(struct gui_common *g, struct gui_common *sibling); int gui_update(struct gui_common *g, const union peripheral *p, const struct camera *c, struct input *in); int gui_render(const struct gui_common *g); +void gui_deinit(struct gui_common *g, struct input *in); #ifdef __cplusplus } diff --git a/src/gui/src/gui.c b/src/gui/src/gui.c index b99300b..e8bd4d7 100644 --- a/src/gui/src/gui.c +++ b/src/gui/src/gui.c @@ -182,3 +182,15 @@ int gui_render(const struct gui_common *const g) return 0; } + +void gui_deinit(struct gui_common *const g, struct input *const in) +{ + if (g->cb && g->cb->deinit) + g->cb->deinit(g, in); + + if (g->child) + gui_deinit(g->child, in); + + for (struct gui_common *s = g->sibling; s; s = s->sibling) + gui_deinit(s, in); +}