From b0eb562b9b78d37493d28b413aca45542e8cd0ba Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sat, 2 Jul 2022 04:08:31 +0200 Subject: gui: reuse callback data There is no need to allocate memory for these callbacks for each single GUI element. Instead, a single, statically-allocated instance can be shared among all GUI elements of a given type. --- src/gui/inc/gui.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/gui/inc') diff --git a/src/gui/inc/gui.h b/src/gui/inc/gui.h index 7198af0..18ed37b 100644 --- a/src/gui/inc/gui.h +++ b/src/gui/inc/gui.h @@ -12,11 +12,15 @@ extern "C" struct gui_common { - void (*add_child)(struct gui_common *parent, struct gui_common *child); - int (*update)(struct gui_common *, const union peripheral *, - const struct camera *); - int (*render)(const struct gui_common *); - void (*get_dim)(const struct gui_common *, short *w, short *h); + const struct gui_common_cb + { + void (*add_child)(struct gui_common *parent, struct gui_common *child); + int (*update)(struct gui_common *, const union peripheral *, + const struct camera *); + int (*render)(const struct gui_common *); + void (*get_dim)(const struct gui_common *, short *w, short *h); + } *cb; + short x, y; bool hcentered, vcentered; struct gui_common *parent, *child, *sibling; -- cgit v1.2.3