diff options
author | Simon Glass <sjg@chromium.org> | 2023-06-01 10:22:52 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-07-14 12:54:51 -0400 |
commit | 699b0acb522fd808b67b745b541bacf18c275d15 (patch) | |
tree | adaa46800aadebb241d88974aaebde13512a5885 /boot/scene.c | |
parent | 50f02037594563dbc8da67f65959499bc1f5a46a (diff) |
expo: Set up the width and height of objects
Provide a way to set the full dimensions of objects, i.e. including the
width and height.
For menus, calculate the bounding box of all objects in the menu. Set all
labels to be the same size, so that highlighting works correct, once
implemented.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/scene.c')
-rw-r--r-- | boot/scene.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/boot/scene.c b/boot/scene.c index 981a18b3ba..6d5e3c1f03 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -207,6 +207,19 @@ int scene_obj_set_pos(struct scene *scn, uint id, int x, int y) return 0; } +int scene_obj_set_size(struct scene *scn, uint id, int w, int h) +{ + struct scene_obj *obj; + + obj = scene_obj_find(scn, id, SCENEOBJT_NONE); + if (!obj) + return log_msg_ret("find", -ENOENT); + obj->dim.w = w; + obj->dim.h = h; + + return 0; +} + int scene_obj_set_hide(struct scene *scn, uint id, bool hide) { int ret; @@ -414,3 +427,42 @@ int scene_send_key(struct scene *scn, int key, struct expo_action *event) return 0; } + +int scene_calc_dims(struct scene *scn, bool do_menus) +{ + struct scene_obj *obj; + int ret; + + list_for_each_entry(obj, &scn->obj_head, sibling) { + switch (obj->type) { + case SCENEOBJT_NONE: + case SCENEOBJT_TEXT: + case SCENEOBJT_IMAGE: { + int width; + + if (!do_menus) { + ret = scene_obj_get_hw(scn, obj->id, &width); + if (ret < 0) + return log_msg_ret("get", ret); + obj->dim.w = width; + obj->dim.h = ret; + } + break; + } + case SCENEOBJT_MENU: { + struct scene_obj_menu *menu; + + if (do_menus) { + menu = (struct scene_obj_menu *)obj; + + ret = scene_menu_calc_dims(menu); + if (ret) + return log_msg_ret("men", ret); + } + break; + } + } + } + + return 0; +} |