At present labels are lined up vertically. Do the same with keys and
descriptions, since it looks nicer.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 boot/scene_menu.c | 22 ++++++++++++++--------
 test/boot/expo.c  | 30 ++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/boot/scene_menu.c b/boot/scene_menu.c
index 6d945cfa62d..8aa77924b33 100644
--- a/boot/scene_menu.c
+++ b/boot/scene_menu.c
@@ -182,14 +182,20 @@ int scene_menu_calc_dims(struct scene_obj_menu *menu)
 
        scene_menu_calc_bbox(menu, bbox);
 
-       /* Make all labels the same size */
-       cur = &bbox[SCENEBB_label];
-       if (cur->valid) {
-               list_for_each_entry(item, &menu->item_head, sibling) {
-                       scene_obj_set_size(menu->obj.scene, item->label_id,
-                                          cur->x1 - cur->x0,
-                                          cur->y1 - cur->y0);
-               }
+       /* Make all field types the same width */
+       list_for_each_entry(item, &menu->item_head, sibling) {
+               cur = &bbox[SCENEBB_label];
+               if (cur->valid)
+                       scene_obj_set_width(menu->obj.scene, item->label_id,
+                                           cur->x1 - cur->x0);
+               cur = &bbox[SCENEBB_key];
+               if (cur->valid)
+                       scene_obj_set_width(menu->obj.scene, item->key_id,
+                                           cur->x1 - cur->x0);
+               cur = &bbox[SCENEBB_desc];
+               if (cur->valid)
+                       scene_obj_set_width(menu->obj.scene, item->desc_id,
+                                           cur->x1 - cur->x0);
        }
 
        cur = &bbox[SCENEBB_all];
diff --git a/test/boot/expo.c b/test/boot/expo.c
index 2a430d3d482..70db33d48b1 100644
--- a/test/boot/expo.c
+++ b/test/boot/expo.c
@@ -576,6 +576,36 @@ static int expo_render_image(struct unit_test_state *uts)
        ut_asserteq(50 + 29, obj->bbox.x1);
        ut_asserteq(454 + 18, obj->bbox.y1);
 
+       /* same for the key */
+       obj = scene_obj_find(scn, ITEM1_KEY, SCENEOBJT_NONE);
+       ut_assertnonnull(obj);
+       ut_asserteq(280, obj->bbox.x0);
+       ut_asserteq(436, obj->bbox.y0);
+       ut_asserteq(280 + 9, obj->bbox.x1);
+       ut_asserteq(436 + 18, obj->bbox.y1);
+
+       obj = scene_obj_find(scn, ITEM2_KEY, SCENEOBJT_NONE);
+       ut_assertnonnull(obj);
+       ut_asserteq(280, obj->bbox.x0);
+       ut_asserteq(454, obj->bbox.y0);
+       ut_asserteq(280 + 9, obj->bbox.x1);
+       ut_asserteq(454 + 18, obj->bbox.y1);
+
+       /* and the description */
+       obj = scene_obj_find(scn, ITEM1_DESC, SCENEOBJT_NONE);
+       ut_assertnonnull(obj);
+       ut_asserteq(330, obj->bbox.x0);
+       ut_asserteq(436, obj->bbox.y0);
+       ut_asserteq(330 + 89, obj->bbox.x1);
+       ut_asserteq(436 + 18, obj->bbox.y1);
+
+       obj = scene_obj_find(scn, ITEM2_DESC, SCENEOBJT_NONE);
+       ut_assertnonnull(obj);
+       ut_asserteq(330, obj->bbox.x0);
+       ut_asserteq(454, obj->bbox.y0);
+       ut_asserteq(330 + 89, obj->bbox.x1);
+       ut_asserteq(454 + 18, obj->bbox.y1);
+
        /* check dimensions of menu */
        obj = scene_obj_find(scn, OBJ_MENU, SCENEOBJT_NONE);
        ut_assertnonnull(obj);
-- 
2.43.0

Reply via email to