aboutsummaryrefslogtreecommitdiff
path: root/src/gui/inc
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-02 04:08:31 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-02 04:08:35 +0200
commit85e11e8f9859738abbc53d2c96f4731869d09802 (patch)
tree9476e571115dab61f766d734e741a5a32d1aeea3 /src/gui/inc
parentf4357485e6febf90be34524824b15f771b6cd310 (diff)
downloadjancity-85e11e8f9859738abbc53d2c96f4731869d09802.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.h14
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;