diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-07-10 00:21:09 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-07-10 00:26:48 +0200 |
| commit | e636accfd5b310165c0d7b5075f89a64583b5f1a (patch) | |
| tree | 0fd80ee1c9fad53f8193d5312b1d7f3c6721f39f /src/menu | |
| parent | 08951d4af59a8e8c6f760453bc84f59ee8fc157c (diff) | |
| download | rts-e636accfd5b310165c0d7b5075f89a64583b5f1a.tar.gz | |
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.
Diffstat (limited to 'src/menu')
| -rw-r--r-- | src/menu/src/gamecfg_menu.c | 7 |
1 files changed, 4 insertions, 3 deletions
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); |
