[Concept,05/16] expo: Avoid setting SCENEOF_SIZE_VALID with menu items

Message ID 20251014111301.1059317-6-sjg@chromium.org
State New
Headers
Series boot: Separate out the boot-menu style |

Commit Message

Simon Glass Oct. 14, 2025, 11:12 a.m. UTC
  The font size of menu items might change, thus requiring the size to
be updated. So it is not correct to mark the items as fixed size.

Drop this code.

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

 boot/scene.c      |  9 +++++++--
 boot/scene_menu.c | 13 +++++++------
 include/expo.h    | 14 ++++++++++++++
 3 files changed, 28 insertions(+), 8 deletions(-)
  

Patch

diff --git a/boot/scene.c b/boot/scene.c
index 04a5e8a03e2..c2d106738f5 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -316,7 +316,7 @@  int scene_obj_set_size(struct scene *scn, uint id, int w, int h)
 	return 0;
 }
 
-int scene_obj_set_width(struct scene *scn, uint id, int w)
+int scene_obj_set_width_flags(struct scene *scn, uint id, int w, uint flags)
 {
 	struct scene_obj *obj;
 
@@ -324,11 +324,16 @@  int scene_obj_set_width(struct scene *scn, uint id, int w)
 	if (!obj)
 		return log_msg_ret("find", -ENOENT);
 	obj->req_bbox.x1 = obj->req_bbox.x0 + w;
-	obj->flags |= SCENEOF_SYNC_WIDTH;
+	obj->flags |= flags;
 
 	return 0;
 }
 
+int scene_obj_set_width(struct scene *scn, uint id, int w)
+{
+	return scene_obj_set_width_flags(scn, id, w, SCENEOF_SYNC_WIDTH);
+}
+
 int scene_obj_set_bbox(struct scene *scn, uint id, int x0, int y0, int x1,
 		       int y1)
 {
diff --git a/boot/scene_menu.c b/boot/scene_menu.c
index f52d561094b..6aa217ecfab 100644
--- a/boot/scene_menu.c
+++ b/boot/scene_menu.c
@@ -359,13 +359,14 @@  int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 			y += height + theme->menuitem_gap_y;
 	}
 
+	/* line up the right size of each set of items */
 	list_for_each_entry(item, &menu->item_head, sibling) {
-		scene_obj_set_width(menu->obj.scene, item->label_id,
-				    dims[SCENEBB_label].x);
-		scene_obj_set_width(menu->obj.scene, item->key_id,
-				    dims[SCENEBB_key].x);
-		scene_obj_set_width(menu->obj.scene, item->desc_id,
-				    dims[SCENEBB_desc].x);
+		scene_obj_set_width_flags(menu->obj.scene, item->label_id,
+					  dims[SCENEBB_label].x, 0);
+		scene_obj_set_width_flags(menu->obj.scene, item->key_id,
+					  dims[SCENEBB_key].x, 0);
+		scene_obj_set_width_flags(menu->obj.scene, item->desc_id,
+					  dims[SCENEBB_desc].x, 0);
 	}
 
 	if (sel_id)
diff --git a/include/expo.h b/include/expo.h
index aa8e41af176..7307c3aef98 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -943,6 +943,20 @@  int scene_obj_set_pos(struct scene *scn, uint id, int x, int y);
  */
 int scene_obj_set_size(struct scene *scn, uint id, int w, int h);
 
+/**
+ * scene_obj_set_width_flags() - Set the width of an object, with flags
+ *
+ * The given width is marked as 'requested' and will be applied when the scene
+ * is next arranged. The object flags are ORed with @flags
+ *
+ * @scn: Scene to update
+ * @id: ID of object to update
+ * @w: width in pixels
+ * @flags: Flags to OR with the current flags
+ * Returns: 0 if OK, -ENOENT if @id is invalid
+ */
+int scene_obj_set_width_flags(struct scene *scn, uint id, int w, uint flags);
+
 /**
  * scene_obj_set_width() - Set the width of an object
  *