[PATCH 08/19] expo: Record the pointer position in the menu item

Simon Glass sjg at chromium.org
Mon May 5 17:42:46 CEST 2025


Rather than drawing the poointer with a hard-coded position elsewhere in
the code, add a field to hold this value.

Move the check for the pointer position up so that the ordering of the
tests matches the order that the fields are dealt with in
scene_menu_arrange()

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 boot/scene_menu.c | 7 ++++++-
 include/expo.h    | 2 ++
 test/boot/expo.c  | 6 +++---
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/boot/scene_menu.c b/boot/scene_menu.c
index 8db6a2b2f4d..3f988657e00 100644
--- a/boot/scene_menu.c
+++ b/boot/scene_menu.c
@@ -102,7 +102,8 @@ 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.bbox.x0 + 200, label->bbox.y0);
+					menu->obj.bbox.x0 + menu->pointer_xofs,
+					label->bbox.y0);
 		if (ret < 0)
 			return log_msg_ret("ptr", ret);
 	}
@@ -293,6 +294,10 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 		scene_obj_set_hide(scn, item->label_id,
 				   stack && !open && !selected);
 
+		/* space for the pointer */
+		if (menu->pointer_id)
+			menu->pointer_xofs = 200;
+
 		if (item->key_id) {
 			ret = scene_obj_set_pos(scn, item->key_id, x + 230, y);
 			if (ret < 0)
diff --git a/include/expo.h b/include/expo.h
index 0b25a9d8b41..4a07a72cf7e 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -395,6 +395,7 @@ struct scene_obj_txt {
  * @title_id: ID of the title text, or 0 if none
  * @cur_item_id: ID of the current menu item, or 0 if none
  * @pointer_id: ID of the object pointing to the current selection
+ * @pointer_xofs: x position of pointer relative to the left side of the menu
  * @item_head: List of items in the menu
  */
 struct scene_obj_menu {
@@ -402,6 +403,7 @@ struct scene_obj_menu {
 	uint title_id;
 	uint cur_item_id;
 	uint pointer_id;
+	int pointer_xofs;
 	struct list_head item_head;
 };
 
diff --git a/test/boot/expo.c b/test/boot/expo.c
index 135e177cbbd..bf18199caab 100644
--- a/test/boot/expo.c
+++ b/test/boot/expo.c
@@ -421,12 +421,12 @@ static int expo_object_menu(struct unit_test_state *uts)
 	ut_asserteq(menu->obj.bbox.x0, name1->obj.bbox.x0);
 	ut_asserteq(menu->obj.bbox.y0 + 32, name1->obj.bbox.y0);
 
-	ut_asserteq(menu->obj.bbox.x0 + 230, key1->obj.bbox.x0);
-	ut_asserteq(menu->obj.bbox.y0 + 32, key1->obj.bbox.y0);
-
 	ut_asserteq(menu->obj.bbox.x0 + 200, ptr->obj.bbox.x0);
 	ut_asserteq(menu->obj.bbox.y0 + 32, ptr->obj.bbox.y0);
 
+	ut_asserteq(menu->obj.bbox.x0 + 230, key1->obj.bbox.x0);
+	ut_asserteq(menu->obj.bbox.y0 + 32, key1->obj.bbox.y0);
+
 	ut_asserteq(menu->obj.bbox.x0 + 280, desc1->obj.bbox.x0);
 	ut_asserteq(menu->obj.bbox.y0 + 32, desc1->obj.bbox.y0);
 
-- 
2.43.0



More information about the U-Boot mailing list