diff options
author | Simon Glass <sjg@chromium.org> | 2025-05-02 08:46:30 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2025-05-30 09:49:32 +0100 |
commit | 85a2954c29cf8631ccd0fb2c2c348711f8b5260e (patch) | |
tree | 6ee8832b6caea9ed48fd44eaa709ce5ab45ce1bf /boot | |
parent | a4ede5e0aced904efb17f3a3d5fb2c7f3c622133 (diff) |
expo: Rename scene_dim to scene_obj_bbox
At present we assume that each object is a simple box and that it fills
the whole box.
This is quite limiting for text objects, which we may want to centre
within the box. We need a position within the box where drawing starts.
Rename the scene_dim struct to indicate that it is a bounding box.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot')
-rw-r--r-- | boot/scene.c | 36 | ||||
-rw-r--r-- | boot/scene_menu.c | 12 | ||||
-rw-r--r-- | boot/scene_textline.c | 22 |
3 files changed, 35 insertions, 35 deletions
diff --git a/boot/scene.c b/boot/scene.c index 90b4ccf4766..a0060c6a97d 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -210,8 +210,8 @@ int scene_obj_set_pos(struct scene *scn, uint id, int x, int y) obj = scene_obj_find(scn, id, SCENEOBJT_NONE); if (!obj) return log_msg_ret("find", -ENOENT); - obj->dim.x = x; - obj->dim.y = y; + obj->bbox.x = x; + obj->bbox.y = y; return 0; } @@ -223,8 +223,8 @@ int scene_obj_set_size(struct scene *scn, uint id, int w, int h) obj = scene_obj_find(scn, id, SCENEOBJT_NONE); if (!obj) return log_msg_ret("find", -ENOENT); - obj->dim.w = w; - obj->dim.h = h; + obj->bbox.w = w; + obj->bbox.h = h; return 0; } @@ -368,8 +368,8 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) struct udevice *cons = text_mode ? NULL : exp->cons; int x, y, ret; - x = obj->dim.x; - y = obj->dim.y; + x = obj->bbox.x; + y = obj->bbox.y; switch (obj->type) { case SCENEOBJT_NONE: @@ -419,8 +419,8 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) if (obj->flags & SCENEOF_POINT) { vidconsole_push_colour(cons, fore, back, &old); video_fill_part(dev, x - theme->menu_inset, y, - x + obj->dim.w, - y + obj->dim.h, + x + obj->bbox.w, + y + obj->bbox.h, vid_priv->colour_bg); } vidconsole_set_cursor_pos(cons, x, y); @@ -765,8 +765,8 @@ int scene_calc_dims(struct scene *scn, bool 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; + obj->bbox.w = width; + obj->bbox.h = ret; } break; } @@ -915,15 +915,15 @@ int scene_bbox_union(struct scene *scn, uint id, int inset, if (!obj) return log_msg_ret("obj", -ENOENT); if (bbox->valid) { - bbox->x0 = min(bbox->x0, obj->dim.x - inset); - bbox->y0 = min(bbox->y0, obj->dim.y); - bbox->x1 = max(bbox->x1, obj->dim.x + obj->dim.w + inset); - bbox->y1 = max(bbox->y1, obj->dim.y + obj->dim.h); + bbox->x0 = min(bbox->x0, obj->bbox.x - inset); + bbox->y0 = min(bbox->y0, obj->bbox.y); + bbox->x1 = max(bbox->x1, obj->bbox.x + obj->bbox.w + inset); + bbox->y1 = max(bbox->y1, obj->bbox.y + obj->bbox.h); } else { - bbox->x0 = obj->dim.x - inset; - bbox->y0 = obj->dim.y; - bbox->x1 = obj->dim.x + obj->dim.w + inset; - bbox->y1 = obj->dim.y + obj->dim.h; + bbox->x0 = obj->bbox.x - inset; + bbox->y0 = obj->bbox.y; + bbox->x1 = obj->bbox.x + obj->bbox.w + inset; + bbox->y1 = obj->bbox.y + obj->bbox.h; bbox->valid = true; } diff --git a/boot/scene_menu.c b/boot/scene_menu.c index 6a2f5b6b93f..20a6a6b6a01 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -102,7 +102,7 @@ static int update_pointers(struct scene_obj_menu *menu, uint id, bool point) label = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE); ret = scene_obj_set_pos(scn, menu->pointer_id, - menu->obj.dim.x + 200, label->dim.y); + menu->obj.bbox.x + 200, label->bbox.y); if (ret < 0) return log_msg_ret("ptr", ret); } @@ -186,8 +186,8 @@ int scene_menu_calc_dims(struct scene_obj_menu *menu) } if (bbox.valid) { - menu->obj.dim.w = bbox.x1 - bbox.x0; - menu->obj.dim.h = bbox.y1 - bbox.y0; + menu->obj.bbox.w = bbox.x1 - bbox.x0; + menu->obj.bbox.h = bbox.y1 - bbox.y0; } return 0; @@ -205,12 +205,12 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr, int x, y; int ret; - x = menu->obj.dim.x; - y = menu->obj.dim.y; + x = menu->obj.bbox.x; + y = menu->obj.bbox.y; if (menu->title_id) { int width; - ret = scene_obj_set_pos(scn, menu->title_id, menu->obj.dim.x, y); + ret = scene_obj_set_pos(scn, menu->title_id, menu->obj.bbox.x, y); if (ret < 0) return log_msg_ret("tit", ret); diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 90642a3f03d..5b4e21e6360 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -76,11 +76,11 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline) return log_msg_ret("nom", ret); if (bbox.valid) { - tline->obj.dim.w = bbox.x1 - bbox.x0; - tline->obj.dim.h = bbox.y1 - bbox.y0; + tline->obj.bbox.w = bbox.x1 - bbox.x0; + tline->obj.bbox.h = bbox.y1 - bbox.y0; - scene_obj_set_size(scn, tline->edit_id, tline->obj.dim.w, - tline->obj.dim.h); + scene_obj_set_size(scn, tline->edit_id, tline->obj.bbox.w, + tline->obj.bbox.h); } return 0; @@ -94,16 +94,16 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, int x, y; int ret; - x = tline->obj.dim.x; - y = tline->obj.dim.y; + x = tline->obj.bbox.x; + y = tline->obj.bbox.y; if (tline->label_id) { - ret = scene_obj_set_pos(scn, tline->label_id, tline->obj.dim.x, + ret = scene_obj_set_pos(scn, tline->label_id, tline->obj.bbox.x, y); if (ret < 0) return log_msg_ret("tit", ret); ret = scene_obj_set_pos(scn, tline->edit_id, - tline->obj.dim.x + 200, y); + tline->obj.bbox.x + 200, y); if (ret < 0) return log_msg_ret("tit", ret); @@ -197,8 +197,8 @@ int scene_textline_render_deps(struct scene *scn, if (ret) return log_msg_ret("sav", ret); - vidconsole_set_cursor_visible(cons, true, txt->obj.dim.x, - txt->obj.dim.y, scn->cls.num); + vidconsole_set_cursor_visible(cons, true, txt->obj.bbox.x, + txt->obj.bbox.y, scn->cls.num); } return 0; @@ -219,7 +219,7 @@ int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline) if (!txt) return log_msg_ret("cur", -ENOENT); - vidconsole_set_cursor_pos(cons, txt->obj.dim.x, txt->obj.dim.y); + vidconsole_set_cursor_pos(cons, txt->obj.bbox.x, txt->obj.bbox.y); vidconsole_entry_start(cons); cli_cread_init(&scn->cls, abuf_data(&tline->buf), tline->max_chars); scn->cls.insert = true; |