From f69dc6f359015e992d181c60cd815cefd6c62aad Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 10 Jul 2022 00:21:09 +0200 Subject: Allow children of gui_container be resized anytime So far, their position inside the container was determined when initializing the interface. However, if a child were resized afterwards, the container would not adjust its elements accordingly. Moreover, the implementation for gui_container relied on hacking the children's X/Y coordinates, which could only be done once. Now, two additional members have been added to gui_common so that specific X/Y offset can be determined by the parent, additionally to the traditional rules followed by gui_coords. Despite the extra memory footprint, it now allows containers to set specific X/Y offsets for their children on every game cycle. --- src/menu/src/gamecfg_menu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/menu') diff --git a/src/menu/src/gamecfg_menu.c b/src/menu/src/gamecfg_menu.c index 31d105e..9fc3873 100644 --- a/src/menu/src/gamecfg_menu.c +++ b/src/menu/src/gamecfg_menu.c @@ -20,8 +20,11 @@ static int update(struct menu_common *const c, void *const arg) struct gamecfg_menu *const m = arg; m->bcnt.common.y = screen_h - 40; + m->r.w = screen_w / 2; + m->r.h = screen_h / 2; - if (gui_update(&m->bcnt.common, &c->p, &c->cam)) + if (gui_update(&m->cnt.common, &c->p, &c->cam) + || gui_update(&m->bcnt.common, &c->p, &c->cam)) return -1; return 0; @@ -48,8 +51,6 @@ int menu_gamecfg(struct menu_common *const c) m.cnt.common.vcentered = true; gui_rounded_rect_init(&m.r); - m.r.w = screen_w / 2; - m.r.h = screen_h / 2; gui_add_child(&m.cnt.common, &m.r.common); gui_container_init(&m.bcnt); -- cgit v1.2.3