diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-07-02 04:08:31 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-07-02 04:08:35 +0200 |
| commit | b0eb562b9b78d37493d28b413aca45542e8cd0ba (patch) | |
| tree | 1e3470a5b7dc71a7831ed91ee1493a6dab0ac45c /src/gui/inc | |
| parent | a71ce379297384df42e720641d39a4d2ade6bbd9 (diff) | |
| download | rts-b0eb562b9b78d37493d28b413aca45542e8cd0ba.tar.gz | |
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.
Diffstat (limited to 'src/gui/inc')
| -rw-r--r-- | src/gui/inc/gui.h | 14 |
1 files changed, 9 insertions, 5 deletions
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; |
