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>
diff --git a/boot/scene_textline.c b/boot/scene_textline.c
index a513d55..f1d6ff7 100644
--- a/boot/scene_textline.c
+++ b/boot/scene_textline.c
@@ -61,7 +61,8 @@
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 @@
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;