expo: Separate dimensions from the bounding box

At present each object has a width and height and the bounding box is
implicit in that.

This is not flexible enough to handle objects which are larger than
their contents might need. For example, when centring a text object we
might want to have it stretch across the whole width of the display even
if the text itself does not need that much space.

Create a new 'dimensions' field and convert the existing width/height
into x1/y1 coordinates.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-05-02 08:46:33 -06:00
parent bc6c19c87b
commit 8d4237592a
5 changed files with 74 additions and 33 deletions

View File

@@ -61,7 +61,8 @@ void scene_textline_calc_bbox(struct scene_obj_textline *tline,
int scene_textline_calc_dims(struct scene_obj_textline *tline)
{
struct scene *scn = tline->obj.scene;
struct scene_obj *obj = &tline->obj;
struct scene *scn = obj->scene;
struct vidconsole_bbox bbox;
struct scene_obj_txt *txt;
int ret;
@@ -76,11 +77,16 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline)
return log_msg_ret("nom", ret);
if (bbox.valid) {
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.bbox.w,
tline->obj.bbox.h);
obj->dims.x = bbox.x1 - bbox.x0;
obj->dims.y = bbox.y1 - bbox.y0;
if (!(obj->flags & SCENEOF_SIZE_VALID)) {
obj->bbox.x1 = obj->bbox.x0 + obj->dims.x;
obj->bbox.y1 = obj->bbox.y0 + obj->dims.y;
obj->flags |= SCENEOF_SIZE_VALID;
}
scene_obj_set_size(scn, tline->edit_id,
obj->bbox.x1 - obj->bbox.x0,
obj->bbox.y1 - obj->bbox.y0);
}
return 0;