Skip to contentSkip to conversation

expo: Improve positioning for cedit

PATCH New Simon Glass 1 participant 20 messages May 5, 2025 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

cover expo: Improve positioning for cedit

At present cedits look a little odd when they have both menus and textlines. This series tidies that up and improves the testing to cover this situation.

Expos now have 'requested' positions for each object, which are synced to the actual positions when scene_arrange() is called. This solves a problem where moving an object or changing and object puts expo into an inconsistent state briefly, until the scene is next rendered.

Simon Glass (19):
expo: Comment scene_obj fields which are for internal use
expo: Use a different logo for the second menu-item
expo: Create a function to arrange the current scene
expo: Avoid arranging the scene willy nilly
expo: Drop the extra parameter to scene_calc_dims()
expo: Separate out reading the theme from applying it
expo: Add extra checks for rendering
expo: Record the pointer position in the menu item
expo: Arrange cedit after setting dimensions
expo: Provide a few functions for working with dimensions
expo: Move menu dims calculations into scene_menu_arrange()
expo: Check dimensions before arranging a scene
expo: Simplify scene_textline dimension calculation
expo: Use a var to arrange horizonal positions in menu
expo: Allow the menu pointer to be wider
expo: Drop space from object name in test
expo: Separate requested bbox from actual
expo: Honour the textline edit_id when building
expo: Tidy up insets and improve tests

 arch/sandbox/dts/sandbox.dtsi |   4 +-
 arch/sandbox/dts/test.dts     |   1 +
 boot/bootflow_menu.c          |  16 +--
 boot/cedit.c                  |  16 ++-
 boot/expo.c                   |  67 +++++++----
 boot/expo_build.c             |   6 +-
 boot/scene.c                  | 205 ++++++++++++++++++++++++----------
 boot/scene_internal.h         |  52 ++++++---
 boot/scene_menu.c             | 110 +++++++++++-------
 boot/scene_textline.c         |  49 ++++----
 cmd/bootflow.c                |   3 +
 cmd/cedit.c                   |   2 +-
 doc/develop/expo.rst          |   4 +
 drivers/video/video-uclass.c  |   6 +-
 include/expo.h                |  64 ++++++++++-
 include/video.h               |   3 +-
 test/boot/bootflow.c          |   2 +-
 test/boot/cedit.c             | 152 ++++++++++++++++++++++---
 test/boot/expo.c              |  82 +++++++++-----
 19 files changed, 608 insertions(+), 236 deletions(-)
Signature · 4 lines
2.43.0

base-commit: a15813efc66b624cede0f3c6107ca77abbffe1f2
branch: sche
#1 lore raw

PATCH 1/19 expo: Comment scene_obj fields which are for internal use

A few fields should not be changed by the controller code. Add a comment so this is obvious.

---

 include/expo.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/expo.h +3 -2
index 4dee479e9a0..6b191815ded 100644
@@ -302,8 +302,9 @@ enum {
  * @id: ID number of the object
  * @type: Type of this object
  * @bbox: Bounding box for this object
- * @ofs: Offset from x0, y0 where the object is drawn
- * @dims: Dimensions of the text/image (may be smaller than bbox)
+ * @ofs: Offset from x0, y0 where the object is drawn (internal use only)
+ * @dims: Dimensions of the text/image; may be smaller than bbox
+ * (internal use only)
  * @horiz: Horizonal alignment
  * @vert: Vertical alignment
  * @flags: Flags for this object
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/19 expo: Use a different logo for the second menu-item

In reply to Simon Glass

When testing menu items it is easier to check that the correct preview is shown if the preview images are different. Make a copy of the image and modify the palette for the second menu item, so this is obvious.

---

 boot/bootflow_menu.c         |  2 +-
 drivers/video/video-uclass.c |  6 +++++-
 include/video.h              |  3 ++-
 test/boot/expo.c             | 29 ++++++++++++++++++++++-------
 4 files changed, 30 insertions(+), 10 deletions(-)
boot/bootflow_menu.c +1 -1
index 4a442e16850..5d77a0eaea8 100644
@@ -67,7 +67,7 @@ int bootflow_menu_new(struct expo **expp)
 				  SCENEOB_DISPLAY_MAX, 30);
 	ret |= scene_obj_set_halign(scn, OBJ_MENU_TITLE, SCENEOA_CENTRE);
 
-	logo = video_get_u_boot_logo();
+	logo = video_get_u_boot_logo(NULL);
 	if (logo) {
 		ret |= scene_img(scn, "ulogo", OBJ_U_BOOT_LOGO, logo, NULL);
 		ret |= scene_obj_set_pos(scn, OBJ_U_BOOT_LOGO, 1165, 100);
drivers/video/video-uclass.c +5 -1
index 780b2bc6125..c02fd9bb958 100644
@@ -582,11 +582,15 @@ int video_get_ysize(struct udevice *dev)
 	extern u8 __splash_ ## _name ## _end[]
 
 #define SPLASH_START(_name)	__splash_ ## _name ## _begin
+#define SPLASH_END(_name)	__splash_ ## _name ## _end
 
 SPLASH_DECL(u_boot_logo);
 
-void *video_get_u_boot_logo(void)
+void *video_get_u_boot_logo(int *sizep)
 {
+	if (sizep)
+		*sizep = SPLASH_END(u_boot_logo) - SPLASH_START(u_boot_logo);
+
 	return SPLASH_START(u_boot_logo);
 }
 
include/video.h +2 -1
index 9ea6b676463..2fbf8a9598a 100644
@@ -418,9 +418,10 @@ bool video_is_active(void);
 /**
  * video_get_u_boot_logo() - Get a pointer to the U-Boot logo
  *
+ * @sizep: If non-null, returns the size of the logic in bytes
  * Returns: Pointer to logo
  */
-void *video_get_u_boot_logo(void);
+void *video_get_u_boot_logo(int *sizep);
 
 /*
  * bmp_display() - Display BMP (bitmap) data located in memory
test/boot/expo.c +22 -7
index ddfb739f9cf..64b6c154b15 100644
@@ -463,13 +463,15 @@ BOOTSTD_TEST(expo_object_menu, UTF_DM | UTF_SCAN_FDT);
 static int expo_render_image(struct unit_test_state *uts)
 {
 	struct scene_obj_menu *menu;
+	struct abuf buf, logo_copy;
 	struct scene *scn, *scn2;
 	struct abuf orig, *text;
 	struct expo_action act;
 	struct scene_obj *obj;
 	struct udevice *dev;
 	struct expo *exp;
-	int id;
+	int id, size;
+	void *logo;
 
 	ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
 
@@ -478,7 +480,8 @@ static int expo_render_image(struct unit_test_state *uts)
 	ut_assert(id > 0);
 	ut_assertok(expo_set_display(exp, dev));
 
-	id = scene_img(scn, "logo", OBJ_LOGO, video_get_u_boot_logo(), NULL);
+	id = scene_img(scn, "logo", OBJ_LOGO, video_get_u_boot_logo(NULL),
+		       NULL);
 	ut_assert(id > 0);
 	ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 50, 20));
 
@@ -526,8 +529,18 @@ static int expo_render_image(struct unit_test_state *uts)
 	id = scene_txt_str(scn, "item1-key", ITEM1_KEY, STR_ITEM1_KEY, "1",
 			   NULL);
 	ut_assert(id > 0);
-	id = scene_img(scn, "item1-preview", ITEM1_PREVIEW,
-		       video_get_u_boot_logo(), NULL);
+
+	/*
+	 * hack the logo to change the palette and use that for item2 so we can
+	 * tell them apart
+	 */
+	logo = video_get_u_boot_logo(&size);
+	abuf_init_const(&buf, logo, size);
+	ut_assert(abuf_copy(&buf, &logo_copy));
+	memset(logo_copy.data + 0x70, '\x45', 0x20);
+
+	id = scene_img(scn, "item1-preview", ITEM1_PREVIEW, logo_copy.data,
+		       NULL);
 	id = scene_menuitem(scn, OBJ_MENU, "item1", ITEM1, ITEM1_KEY,
 			    ITEM1_LABEL, ITEM1_DESC, ITEM1_PREVIEW, 0, NULL);
 	ut_assert(id > 0);
@@ -542,7 +555,7 @@ static int expo_render_image(struct unit_test_state *uts)
 			   NULL);
 	ut_assert(id > 0);
 	id = scene_img(scn, "item2-preview", ITEM2_PREVIEW,
-		       video_get_u_boot_logo(), NULL);
+		       video_get_u_boot_logo(NULL), NULL);
 	ut_assert(id > 0);
 
 	id = scene_menuitem(scn, OBJ_MENU, "item2", ITEM2, ITEM2_KEY,
@@ -670,8 +683,7 @@ static int expo_render_image(struct unit_test_state *uts)
 	ut_assertok(scene_arrange(scn));
 	ut_asserteq(OBJ_MENU, scn->highlight_id);
 	ut_assertok(expo_render(exp));
-
-	ut_asserteq(19704, video_compress_fb(uts, dev, false));
+	ut_asserteq(20433, video_compress_fb(uts, dev, false));
 
 	/* move down */
 	ut_assertok(expo_send_key(exp, BKEY_DOWN));
@@ -762,6 +774,9 @@ static int expo_render_image(struct unit_test_state *uts)
 
 	ut_assert_console_end();
 
+	abuf_uninit(&buf);
+	abuf_uninit(&logo_copy);
+
 	expo_destroy(exp);
 
 	return 0;
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/19 expo: Create a function to arrange the current scene

In reply to Simon Glass

Provide a convenient function which arranges the current scene in an expo. Make use of this in bootflow_menu

---

 boot/bootflow_menu.c | 12 +-----------
 boot/expo.c          | 19 +++++++++++++++++++
 include/expo.h       | 11 +++++++++++
 3 files changed, 31 insertions(+), 11 deletions(-)
boot/bootflow_menu.c +1 -11
index 5d77a0eaea8..934165d2855 100644
@@ -249,9 +249,7 @@ int bootflow_menu_setup(struct bootstd_priv *std, bool text_mode,
 int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
 			struct expo **expp)
 {
-	struct scene *scn;
 	struct expo *exp;
-	uint scene_id;
 	int ret;
 
 	ret = bootflow_menu_setup(std, text_mode, &exp);
@@ -272,15 +270,7 @@ int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
 	if (ret)
 		return log_msg_ret("bmd", ret);
 
-	ret = expo_first_scene_id(exp);
-	if (ret < 0)
-		return log_msg_ret("scn", ret);
-	scene_id = ret;
-	scn = expo_lookup_scene_id(exp, scene_id);
-
-	scene_set_highlight_id(scn, OBJ_MENU);
-
-	ret = scene_arrange(scn);
+	ret = expo_arrange(exp);
 	if (ret)
 		return log_msg_ret("arr", ret);
 
boot/expo.c +19 -0
index 94413acd381..3e79cbca04b 100644
@@ -211,6 +211,25 @@ int expo_first_scene_id(struct expo *exp)
 	return scn->id;
 }
 
+int expo_arrange(struct expo *exp)
+{
+	struct scene *scn;
+	int ret;
+
+	if (!exp->scene_id)
+		return 0;
+
+	scn = expo_lookup_scene_id(exp, exp->scene_id);
+	if (!scn)
+		return log_msg_ret("scn", -ENOENT);
+
+	ret = scene_arrange(scn);
+	if (ret)
+		return log_msg_ret("ear", ret);
+
+	return 0;
+}
+
 int expo_render(struct expo *exp)
 {
 	struct udevice *dev = exp->display;
include/expo.h +11 -0
index 6b191815ded..75ff1df3cfc 100644
@@ -620,6 +620,17 @@ int expo_first_scene_id(struct expo *exp);
  */
 int expo_render(struct expo *exp);
 
+/**
+ * expo_arrange() - Arrange the current scene to deal with object sizes
+ *
+ * Updates any menus in the current scene so that their objects are in the right
+ * place. Does nothing if there is no scene
+ *
+ * @exp: Expo to arrange
+ * Returns: 0 if OK, -ve on error
+ */
+int expo_arrange(struct expo *exp);
+
 /**
  * expo_set_text_mode() - Controls whether the expo renders in text mode
  *
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/19 expo: Avoid arranging the scene willy nilly

In reply to Simon Glass

Moving from one scene to another should not result in the scene being re-arranged. Drop this, so that tests can have more control of when scenes are arranged.

Also drop the scene_arrange() call when applying a theme, for the same reason.

Add the now-required scene_arrange() to cedit and bootmenu

---

 boot/cedit.c   | 3 +++
 boot/expo.c    | 4 ----
 boot/scene.c   | 5 -----
 cmd/bootflow.c | 3 +++
 4 files changed, 6 insertions(+), 9 deletions(-)
boot/cedit.c +3 -0
index 56dc7c6af15..b7c2d37e3a2 100644
@@ -98,6 +98,9 @@ int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
 			break;
 		}
 	}
+	ret = scene_arrange(scn);
+	if (ret)
+		return log_msg_ret("cac", ret);
 
 	return 0;
 }
boot/expo.c +0 -4
index 3e79cbca04b..d09cc1861da 100644
@@ -185,14 +185,10 @@ struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id)
 int expo_set_scene_id(struct expo *exp, uint scene_id)
 {
 	struct scene *scn;
-	int ret;
 
 	scn = expo_lookup_scene_id(exp, scene_id);
 	if (!scn)
 		return log_msg_ret("id", -ENOENT);
-	ret = scene_arrange(scn);
-	if (ret)
-		return log_msg_ret("arr", ret);
 
 	exp->scene_id = scene_id;
 
boot/scene.c +0 -5
index fa8f540bfb0..2ca82236300 100644
@@ -1062,7 +1062,6 @@ int scene_calc_dims(struct scene *scn, bool do_menus)
 int scene_apply_theme(struct scene *scn, struct expo_theme *theme)
 {
 	struct scene_obj *obj;
-	int ret;
 
 	/* Avoid error-checking optional items */
 	scene_txt_set_font(scn, scn->title_id, NULL, theme->font_size);
@@ -1086,10 +1085,6 @@ int scene_apply_theme(struct scene *scn, struct expo_theme *theme)
 		}
 	}
 
-	ret = scene_arrange(scn);
-	if (ret)
-		return log_msg_ret("arr", ret);
-
 	return 0;
 }
 
cmd/bootflow.c +3 -0
index 6ffb1bd33e1..9d449f430c9 100644
@@ -118,6 +118,9 @@ __maybe_unused static int bootflow_handle_menu(struct bootstd_priv *std,
 	ret = -ERESTART;
 	do {
 		if (ret == -ERESTART) {
+			ret = expo_arrange(exp);
+			if (ret)
+				return log_msg_ret("bha", ret);
 			ret = expo_render(exp);
 			if (ret)
 				return log_msg_ret("bhr", ret);
Signature · 1 line
2.43.0
#5 lore raw

PATCH 5/19 expo: Drop the extra parameter to scene_calc_dims()

In reply to Simon Glass

We always call this with false first, then true. Drop the parameter and handle this within the function itself.

---

 boot/expo.c           |  9 +----
 boot/scene.c          | 93 ++++++++++++++++++++++++-------------------
 boot/scene_internal.h |  3 +-
 3 files changed, 55 insertions(+), 50 deletions(-)
boot/expo.c +1 -8
index d09cc1861da..64d3febacdb 100644
@@ -150,14 +150,7 @@ int expo_calc_dims(struct expo *exp)
 		return log_msg_ret("dim", -ENOTSUPP);
 
 	list_for_each_entry(scn, &exp->scene_head, sibling) {
-		/*
-		 * Do the menus last so that all the menus' text objects
-		 * are dimensioned
-		 */
-		ret = scene_calc_dims(scn, false);
-		if (ret)
-			return log_msg_ret("scn", ret);
-		ret = scene_calc_dims(scn, true);
+		ret = scene_calc_dims(scn);
 		if (ret)
 			return log_msg_ret("scn", ret);
 	}
boot/scene.c +53 -40

109 lines not on this page · raw message

boot/scene_internal.h +1 -2
index 95927472875..04218b4b911 100644
@@ -117,10 +117,9 @@ int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
  * Updates the width and height of all objects based on their contents
  *
  * @scn: Scene to update
- * @do_menus: true to calculate only menus, false to calculate everything else
  * Returns 0 if OK, -ENOTSUPP if there is no graphical console
  */
-int scene_calc_dims(struct scene *scn, bool do_menus);
+int scene_calc_dims(struct scene *scn);
 
 /**
  * scene_menu_arrange() - Set the position of things in the menu
Signature · 1 line
2.43.0
#6 lore raw

PATCH 6/19 expo: Separate out reading the theme from applying it

In reply to Simon Glass

Rename the existing expo_apply_theme() to expo_setup_theme() and adjust the former so that it applies a theme which has already been read into the struct. This will make it easier for tests to check theme adjustments, since they won't have to put them in a node.

Add the white-on-black property into the theme struct while we are.

---

 boot/bootflow_menu.c |  2 +-
 boot/expo.c          | 33 +++++++++++++++++++++++----------
 cmd/cedit.c          |  2 +-
 include/expo.h       | 18 ++++++++++++++++--
 test/boot/bootflow.c |  2 +-
 test/boot/expo.c     |  2 +-
 6 files changed, 43 insertions(+), 16 deletions(-)
boot/bootflow_menu.c +1 -1
index 934165d2855..a0437177364 100644
@@ -261,7 +261,7 @@ int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
 		return log_msg_ret("bma", ret);
 
 	if (ofnode_valid(std->theme)) {
-		ret = expo_apply_theme(exp, std->theme);
+		ret = expo_setup_theme(exp, std->theme);
 		if (ret)
 			return log_msg_ret("thm", ret);
 	}
boot/expo.c +23 -10
index 64d3febacdb..a218ea0e4e9 100644
@@ -281,11 +281,28 @@ int expo_action_get(struct expo *exp, struct expo_action *act)
 	return act->type == EXPOACT_NONE ? -EAGAIN : 0;
 }
 
-int expo_apply_theme(struct expo *exp, ofnode node)
+int expo_apply_theme(struct expo *exp)
 {
+	struct expo_theme *theme = &exp->theme;
 	struct scene *scn;
+
+	if (exp->display)
+		video_set_white_on_black(exp->display, theme->white_on_black);
+
+	list_for_each_entry(scn, &exp->scene_head, sibling) {
+		int ret;
+
+		ret = scene_apply_theme(scn, theme);
+		if (ret)
+			return log_msg_ret("asn", ret);
+	}
+
+	return 0;
+}
+
+int expo_setup_theme(struct expo *exp, ofnode node)
+{
 	struct expo_theme *theme = &exp->theme;
-	bool white_on_black;
 	int ret;
 
 	log_debug("Applying theme %s\n", ofnode_get_name(node));
@@ -296,15 +313,11 @@ int expo_apply_theme(struct expo *exp, ofnode node)
 	ofnode_read_u32(node, "menuitem-gap-y", &theme->menuitem_gap_y);
 	ofnode_read_u32(node, "menu-title-margin-x",
 			&theme->menu_title_margin_x);
-	white_on_black = ofnode_read_bool(node, "white-on-black");
-	if (exp->display)
-		video_set_white_on_black(exp->display, white_on_black);
+	theme->white_on_black = ofnode_read_bool(node, "white-on-black");
 
-	list_for_each_entry(scn, &exp->scene_head, sibling) {
-		ret = scene_apply_theme(scn, theme);
-		if (ret)
-			return log_msg_ret("app", ret);
-	}
+	ret = expo_apply_theme(exp);
+	if (ret)
+		return log_msg_ret("asn", ret);
 
 	return 0;
 }
cmd/cedit.c +1 -1
index 2e15b063462..9c492d45171 100644
@@ -274,7 +274,7 @@ static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	node = ofnode_path("/bootstd/cedit-theme");
 	if (ofnode_valid(node)) {
-		ret = expo_apply_theme(cur_exp, node);
+		ret = expo_setup_theme(cur_exp, node);
 		if (ret)
 			return CMD_RET_FAILURE;
 	} else {
include/expo.h +16 -2
index 75ff1df3cfc..0b25a9d8b41 100644
@@ -83,12 +83,15 @@ struct expo_action {
  * @menuitem_gap_y: Gap between menu items in pixels
  * @menu_title_margin_x: Gap between right side of menu title and left size of
  *	menu label
+ * @white_on_black: True to use white-on-black for the expo, false for
+ *	black-on-white
  */
 struct expo_theme {
 	u32 font_size;
 	u32 menu_inset;
 	u32 menuitem_gap_y;
 	u32 menu_title_margin_x;
+	bool white_on_black;
 };
 
 /**
@@ -994,12 +997,23 @@ int expo_send_key(struct expo *exp, int key);
 int expo_action_get(struct expo *exp, struct expo_action *act);
 
 /**
- * expo_apply_theme() - Apply a theme to an expo
+ * expo_setup_theme() - Read a theme from a node and apply it to an expo
  *
  * @exp: Expo to update
  * @node: Node containing the theme
+ * Returns: 0 if OK, -ve on error
+ */
+int expo_setup_theme(struct expo *exp, ofnode node);
+
+/**
+ * expo_apply_theme() - Apply an expo's theme
+ *
+ * The theme to be applied must be set up exp->theme
+ *
+ * @exp: Expo to update
+ * Returns: 0 if OK, -ve on error
  */
-int expo_apply_theme(struct expo *exp, ofnode node);
+int expo_apply_theme(struct expo *exp);
 
 /**
  * expo_build() - Build an expo from an FDT description
test/boot/bootflow.c +1 -1
index 670e73c265b..0dd8fa71261 100644
@@ -884,7 +884,7 @@ static int bootflow_menu_theme(struct unit_test_state *uts)
 	ut_assertok(bootflow_menu_add_all(exp));
 	node = ofnode_path("/bootstd/theme");
 	ut_assert(ofnode_valid(node));
-	ut_assertok(expo_apply_theme(exp, node));
+	ut_assertok(expo_setup_theme(exp, node));
 
 	scn = expo_lookup_scene_id(exp, MAIN);
 	ut_assertnonnull(scn);
test/boot/expo.c +1 -1
index 64b6c154b15..824ef023c1c 100644
@@ -302,7 +302,7 @@ static int expo_object_attr(struct unit_test_state *uts)
 
 	node = ofnode_path("/bootstd/theme");
 	ut_assert(ofnode_valid(node));
-	ut_assertok(expo_apply_theme(exp, node));
+	ut_assertok(expo_setup_theme(exp, node));
 	ut_asserteq(30, txt->gen.font_size);
 
 	expo_destroy(exp);
Signature · 1 line
2.43.0
#7 lore raw

PATCH 7/19 expo: Add extra checks for rendering

In reply to Simon Glass

Check the framebuffer immediately after the first render, to make sure it doesn't change when the scene is arranged a second time.

Check that the logic around menu-item highlight is correct.

---

 test/boot/expo.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
test/boot/expo.c +18 -0
index 824ef023c1c..135e177cbbd 100644
@@ -671,17 +671,35 @@ static int expo_render_image(struct unit_test_state *uts)
 	/* reset back to normal */
 	scene_obj_set_bbox(scn, OBJ_MENU, 50, 400, 50 + 160, 400 + 160);
 
+	/* make sure the preview for the first item is not shown */
+	obj = scene_obj_find(scn, ITEM1_PREVIEW, SCENEOBJT_NONE);
+	ut_assertnonnull(obj);
+	ut_assert(obj->flags & SCENEOF_HIDE);
+
 	/* render it */
 	expo_set_scene_id(exp, SCENE1);
 	ut_assertok(expo_render(exp));
+	ut_asserteq(18786, video_compress_fb(uts, dev, false));
 
 	ut_asserteq(0, scn->highlight_id);
 	ut_assertok(scene_arrange(scn));
 	ut_asserteq(0, scn->highlight_id);
+	ut_assertok(expo_render(exp));
+	ut_asserteq(20433, video_compress_fb(uts, dev, false));
+
+	ut_assertok(scene_arrange(scn));
+	ut_assertok(expo_render(exp));
+	ut_asserteq(20433, video_compress_fb(uts, dev, false));
 
 	scene_set_highlight_id(scn, OBJ_MENU);
+	ut_asserteq(OBJ_MENU, scn->highlight_id);
+	ut_assertok(scene_menu_select_item(scn, OBJ_MENU, ITEM1));
 	ut_assertok(scene_arrange(scn));
 	ut_asserteq(OBJ_MENU, scn->highlight_id);
+
+	/* make sure the preview for the first item is now shown */
+	ut_assert(!(obj->flags & SCENEOF_HIDE));
+
 	ut_assertok(expo_render(exp));
 	ut_asserteq(20433, video_compress_fb(uts, dev, false));
 
Signature · 1 line
2.43.0
#8 lore raw

PATCH 8/19 expo: Record the pointer position in the menu item

In reply to Simon Glass

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()

---

 boot/scene_menu.c | 7 ++++++-
 include/expo.h    | 2 ++
 test/boot/expo.c  | 6 +++---
 3 files changed, 11 insertions(+), 4 deletions(-)
boot/scene_menu.c +6 -1
index 8db6a2b2f4d..3f988657e00 100644
@@ -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)
include/expo.h +2 -0
index 0b25a9d8b41..4a07a72cf7e 100644
@@ -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;
 };
 
test/boot/expo.c +3 -3
index 135e177cbbd..bf18199caab 100644
@@ -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);
 
Signature · 1 line
2.43.0
#9 lore raw

PATCH 9/19 expo: Arrange cedit after setting dimensions

In reply to Simon Glass

Switch the order of these two calls since dims for each object should be figured out before moving to arranging things.

---

 boot/cedit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
boot/cedit.c +1 -2
index b7c2d37e3a2..c560be4d9c4 100644
@@ -140,11 +140,10 @@ int cedit_prepare(struct expo *exp, struct udevice *vid_dev,
 	scn = expo_lookup_scene_id(exp, scene_id);
 	scene_highlight_first(scn);
 
-	cedit_arange(exp, vid_priv, scene_id);
-
 	ret = expo_calc_dims(exp);
 	if (ret)
 		return log_msg_ret("dim", ret);
+	cedit_arange(exp, vid_priv, scene_id);
 
 	*scnp = scn;
 
Signature · 1 line
2.43.0
#10 lore raw

PATCH 10/19 expo: Provide a few functions for working with dimensions

In reply to Simon Glass

Allow expanding dimensions using the dimensions of an object or another dimensions struct.

---

 boot/scene.c          | 20 ++++++++++++++++++++
 boot/scene_internal.h | 29 ++++++++++++++++++++++++++---
 2 files changed, 46 insertions(+), 3 deletions(-)
boot/scene.c +20 -0
index 2ea8e30ad83..258161f27ce 100644
@@ -1219,3 +1219,23 @@ int scene_bbox_union(struct scene *scn, uint id, int inset,
 
 	return 0;
 }
+
+void scene_dims_join(struct scene_obj_dims *src, struct scene_obj_dims *dst)
+{
+	dst->x = max(dst->x, src->x);
+	dst->y = max(dst->y, src->y);
+}
+
+int scene_dims_union(struct scene *scn, uint id, struct scene_obj_dims *dims)
+{
+	struct scene_obj *obj;
+
+	if (!id)
+		return 0;
+	obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
+	if (!obj)
+		return log_msg_ret("obj", -ENOENT);
+	scene_dims_join(&obj->dims, dims);
+
+	return 0;
+}
boot/scene_internal.h +26 -3
index 04218b4b911..f9b30caa208 100644
@@ -16,6 +16,7 @@ struct expo_action;
 struct expo_arrange_info;
 struct expo_theme;
 struct scene_obj;
+struct scene_obj_dims;
 struct scene_obj_menu;
 struct scene_obj_textline;
 struct scene_obj_txtedit;
@@ -325,7 +326,7 @@ struct scene_menitem *scene_menuitem_find_val(const struct scene_obj_menu *menu,
 					      int val);
 
 /**
- * scene_bbox_join() - update bouding box with a given src box
+ * scene_bbox_join() - update bounding box with a given src bbox
  *
  * Updates @dst so that it encompasses the bounding box @src
  *
@@ -338,11 +339,11 @@ int scene_bbox_join(const struct vidconsole_bbox *src, int inset,
 		    struct vidconsole_bbox *dst);
 
 /**
- * scene_bbox_union() - update bouding box with the demensions of an object
+ * scene_bbox_union() - update bounding box with the bbox of an object
  *
  * Updates @bbox so that it encompasses the bounding box of object @id
  *
- * @snd: Scene containing object
+ * @scn: Scene containing object
  * @id: Object id
  * @inset: Amount of inset to use for width
  * @bbox: Bounding box to update
@@ -351,6 +352,28 @@ int scene_bbox_join(const struct vidconsole_bbox *src, int inset,
 int scene_bbox_union(struct scene *scn, uint id, int inset,
 		     struct vidconsole_bbox *bbox);
 
+/**
+ * scene_bbox_join() - update dimensions with a given src dimensions
+ *
+ * Updates @dst so that it encompasses the dimensions of @src
+ *
+ * @src: Input dimensions
+ * @dst: Dimensions to update
+ */
+void scene_dims_join(struct scene_obj_dims *src, struct scene_obj_dims *dst);
+
+/**
+ * scene_dims_union() - update dimensions with the dimensions of an object
+ *
+ * Updates @dims so that it encompasses the dimensions of object @id
+ *
+ * @scn: Scene containing object
+ * @id: Object id
+ * @dims: Dimensions to update
+ * Return: 0 if OK, -ve on error
+ */
+int scene_dims_union(struct scene *scn, uint id, struct scene_obj_dims *dims);
+
 /**
  * scene_textline_calc_dims() - Calculate the dimensions of a textline
  *
Signature · 1 line
2.43.0
#11 lore raw

PATCH 11/19 expo: Move menu dims calculations into scene_menu_arrange()

In reply to Simon Glass

A menu's dimensions are currently only used for positioning the component parts of the menu, i.e. the label, key, description and preview.

Move the logic for this entirely into the scene_menu file and drop the logic at the top level.

---

 boot/scene.c          | 12 +-------
 boot/scene_internal.h | 10 -------
 boot/scene_menu.c     | 65 ++++++++++++++++++++++++-------------------
 3 files changed, 38 insertions(+), 49 deletions(-)
boot/scene.c +1 -11
index 258161f27ce..9c1eae3d52b 100644
@@ -1043,18 +1043,8 @@ int scene_calc_dims(struct scene *scn)
 				}
 				break;
 			}
-			case SCENEOBJT_MENU: {
-				struct scene_obj_menu *menu;
-
-				if (do_menus) {
-					menu = (struct scene_obj_menu *)obj;
-
-					ret = scene_menu_calc_dims(menu);
-					if (ret)
-						return log_msg_ret("men", ret);
-				}
+			case SCENEOBJT_MENU:
 				break;
-			}
 			case SCENEOBJT_TEXTLINE: {
 				struct scene_obj_textline *tline;
 
boot/scene_internal.h +0 -10
index f9b30caa208..cca7c18e9f5 100644
@@ -259,16 +259,6 @@ int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu);
 int scene_textline_render_deps(struct scene *scn,
 			       struct scene_obj_textline *tline);
 
-/**
- * scene_menu_calc_dims() - Calculate the dimensions of a menu
- *
- * Updates the width and height of the menu based on its contents
- *
- * @menu: Menu to update
- * Returns 0 if OK, -ENOTSUPP if there is no graphical console
- */
-int scene_menu_calc_dims(struct scene_obj_menu *menu);
-
 /**
  * scene_iter_objs() - Iterate through all scene objects
  *
boot/scene_menu.c +37 -28

100 lines not on this page · raw message

Signature · 1 line
2.43.0
#12 lore raw

PATCH 12/19 expo: Check dimensions before arranging a scene

In reply to Simon Glass

It is possible that positions, styling or even text have changed since the scene was initially arranged, so recalculate the dimensions of all objects before arranging the scene.

---

 boot/scene.c     | 39 +++++++++++++++++++++++++++++++--------
 test/boot/expo.c |  1 -
 2 files changed, 31 insertions(+), 9 deletions(-)
boot/scene.c +31 -8
index 9c1eae3d52b..0d8599f955c 100644
@@ -737,6 +737,31 @@ int scene_calc_arrange(struct scene *scn, struct expo_arrange_info *arr)
 	return 0;
 }
 
+/**
+ * scene_set_default_bbox() - Set a default for each object's size
+ *
+ * If there is not already a size, use the dims property to set one
+ */
+static int scene_set_default_bbox(struct scene *scn)
+{
+	struct scene_obj *obj;
+
+	list_for_each_entry(obj, &scn->obj_head, sibling) {
+		switch (obj->type) {
+		case SCENEOBJT_IMAGE:
+		case SCENEOBJT_TEXT:
+			if (!(obj->flags & SCENEOF_SIZE_VALID)) {
+				scene_obj_set_size(scn, obj->id, obj->dims.x,
+						   obj->dims.y);
+			}
+		default:
+			break;
+		}
+	}
+
+	return 0;
+}
+
 int scene_arrange(struct scene *scn)
 {
 	struct expo_arrange_info arr;
@@ -753,6 +778,12 @@ int scene_arrange(struct scene *scn)
 		ysize = priv->ysize;
 	}
 
+	ret = scene_calc_dims(scn);
+	if (ret)
+		return log_msg_ret("scd", ret);
+	ret = scene_set_default_bbox(scn);
+	if (ret)
+		return log_msg_ret("sce", ret);
 	ret = scene_calc_arrange(scn, &arr);
 	if (ret < 0)
 		return log_msg_ret("arr", ret);
@@ -1032,14 +1063,6 @@ int scene_calc_dims(struct scene *scn)
 						return log_msg_ret("get", ret);
 					obj->dims.x = width;
 					obj->dims.y = ret;
-					if (!(obj->flags & SCENEOF_SIZE_VALID)) {
-						obj->bbox.x1 = obj->bbox.x0 +
-							width;
-						obj->bbox.y1 = obj->bbox.y0 +
-							ret;
-						obj->flags |=
-							SCENEOF_SIZE_VALID;
-					}
 				}
 				break;
 			}
test/boot/expo.c +0 -1
index bf18199caab..0289350df9c 100644
@@ -588,7 +588,6 @@ static int expo_render_image(struct unit_test_state *uts)
 	/* render without a scene */
 	ut_asserteq(-ECHILD, expo_render(exp));
 
-	ut_assertok(expo_calc_dims(exp));
 	ut_assertok(scene_arrange(scn));
 
 	/* check dimensions of text */
Signature · 1 line
2.43.0
#13 lore raw

PATCH 13/19 expo: Simplify scene_textline dimension calculation

In reply to Simon Glass

The goal here is to obtain the dimensions of the edit field, which does not change.

Since scene_arrange() now handles setting the bounding-box size based on the dimensions there is no need to do it here.

Adjust the code to simply set up the dimensions.

---

 boot/scene_textline.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
boot/scene_textline.c +3 -10
index 7bc35a997dc..07711d147c3 100644
@@ -61,8 +61,7 @@ void scene_textline_calc_bbox(struct scene_obj_textline *tline,
 
 int scene_textline_calc_dims(struct scene_obj_textline *tline)
 {
-	struct scene_obj *obj = &tline->obj;
-	struct scene *scn = obj->scene;
+	struct scene *scn = tline->obj.scene;
 	struct vidconsole_bbox bbox;
 	struct scene_obj_txt *txt;
 	int ret;
@@ -77,16 +76,10 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline)
 		return log_msg_ret("nom", ret);
 
 	if (bbox.valid) {
+		struct scene_obj *obj = &txt->obj;
+
 		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;
Signature · 1 line
2.43.0
#14 lore raw

PATCH 14/19 expo: Use a var to arrange horizonal positions in menu

In reply to Simon Glass

At present the components of each menu item are set at fixed positions. Use an 'x' variable instead, so that we can eventually move to taking account of the actual dimensions of the items.

---

 boot/scene_menu.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
boot/scene_menu.c +13 -8
index c2abf1e3926..094489e2a40 100644
@@ -228,7 +228,7 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	const struct expo_theme *theme = &exp->theme;
 	struct scene_menitem *item;
 	uint sel_id;
-	int x, y;
+	int startx, x, y;
 	int ret;
 
 	menu->obj.dims.x = 0;
@@ -237,12 +237,12 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	memset(dims, '\0', sizeof(dims));
 	scene_menu_calc_dims(scn, menu, dims);
 
-	x = menu->obj.bbox.x0;
+	startx = menu->obj.bbox.x0;
 	y = menu->obj.bbox.y0;
 	if (menu->title_id) {
 		int width;
 
-		ret = scene_obj_set_pos(scn, menu->title_id, menu->obj.bbox.x0, y);
+		ret = scene_obj_set_pos(scn, menu->title_id, startx, y);
 		if (ret < 0)
 			return log_msg_ret("tit", ret);
 
@@ -251,7 +251,7 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 			return log_msg_ret("hei", ret);
 
 		if (stack)
-			x += arr->label_width + theme->menu_title_margin_x;
+			startx += arr->label_width + theme->menu_title_margin_x;
 		else
 			y += ret * 2;
 	}
@@ -267,6 +267,7 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 		bool selected;
 		int height;
 
+		x = startx;
 		ret = scene_obj_get_hw(scn, item->label_id, NULL);
 		if (ret < 0)
 			return log_msg_ret("get", ret);
@@ -291,19 +292,23 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 			return log_msg_ret("nam", ret);
 		scene_obj_set_hide(scn, item->label_id,
 				   stack && !open && !selected);
+		x += 200;
 
 		/* space for the pointer */
-		if (menu->pointer_id)
-			menu->pointer_xofs = 200;
+		if (menu->pointer_id) {
+			menu->pointer_xofs = x - startx;
+			x += 30;
+		}
 
 		if (item->key_id) {
-			ret = scene_obj_set_pos(scn, item->key_id, x + 230, y);
+			ret = scene_obj_set_pos(scn, item->key_id, x, y);
 			if (ret < 0)
 				return log_msg_ret("key", ret);
+			x += 50;
 		}
 
 		if (item->desc_id) {
-			ret = scene_obj_set_pos(scn, item->desc_id, x + 280, y);
+			ret = scene_obj_set_pos(scn, item->desc_id, x, y);
 			if (ret < 0)
 				return log_msg_ret("des", ret);
 		}
Signature · 1 line
2.43.0
#15 lore raw

PATCH 15/19 expo: Allow the menu pointer to be wider

In reply to Simon Glass

Rather than hard-coding the distance between the labels and the key, measure the width of the pointer to determine the space needed.

Tweak a few tests according. It isn't possible to get the same result when the font-size differs.

---

 boot/scene_menu.c | 17 ++++++++++++++---
 test/boot/expo.c  |  4 ++--
 2 files changed, 16 insertions(+), 5 deletions(-)
boot/scene_menu.c +14 -3
index 094489e2a40..b33e0a7d3b4 100644
@@ -222,7 +222,7 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 		       struct scene_obj_menu *menu)
 {
 	const bool open = menu->obj.flags & SCENEOF_OPEN;
-	struct scene_obj_dims dims[SCENEBB_count];
+	struct scene_obj_dims dims[SCENEBB_count], pointer_dims;
 	struct expo *exp = scn->expo;
 	const bool stack = exp->popup;
 	const struct expo_theme *theme = &exp->theme;
@@ -231,6 +231,7 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	int startx, x, y;
 	int ret;
 
+	memset(&pointer_dims, '\0', sizeof(pointer_dims));
 	menu->obj.dims.x = 0;
 	menu->obj.dims.y = 0;
 
@@ -256,6 +257,16 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 			y += ret * 2;
 	}
 
+	if (menu->pointer_id) {
+		const struct scene_obj *obj;
+
+		obj = scene_obj_find(scn, menu->pointer_id, SCENEOBJT_NONE);
+		if (!obj)
+			return log_msg_ret("obj", -ENOENT);
+
+		pointer_dims = obj->dims;
+	}
+
 	/*
 	 * Currently everything is hard-coded to particular columns so this
 	 * won't work on small displays and looks strange if the font size is
@@ -295,9 +306,9 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 		x += 200;
 
 		/* space for the pointer */
-		if (menu->pointer_id) {
+		if (pointer_dims.x) {
 			menu->pointer_xofs = x - startx;
-			x += 30;
+			x += 12 + pointer_dims.x + 9;
 		}
 
 		if (item->key_id) {
test/boot/expo.c +2 -2
index 0289350df9c..b05e57b4f5a 100644
@@ -424,10 +424,10 @@ static int expo_object_menu(struct unit_test_state *uts)
 	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.x0 + 229, 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.x0 + 279, desc1->obj.bbox.x0);
 	ut_asserteq(menu->obj.bbox.y0 + 32, desc1->obj.bbox.y0);
 
 	ut_asserteq(-4, prev1->obj.bbox.x0);
Signature · 1 line
2.43.0
#16 lore raw

PATCH 16/19 expo: Drop space from object name in test

In reply to Simon Glass

Two of the objects have a space in their name. Change it to a hyphen to match the other objects.

---

 test/boot/expo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/boot/expo.c +2 -2
index b05e57b4f5a..517fb09d767 100644
@@ -523,7 +523,7 @@ static int expo_render_image(struct unit_test_state *uts)
 	id = scene_txt_str(scn, "label1", ITEM1_LABEL, STR_ITEM1_LABEL, "Play",
 			   NULL);
 	ut_assert(id > 0);
-	id = scene_txt_str(scn, "item1 txt", ITEM1_DESC, STR_ITEM1_DESC,
+	id = scene_txt_str(scn, "item1-txt", ITEM1_DESC, STR_ITEM1_DESC,
 			   "Lord Melchett", NULL);
 	ut_assert(id > 0);
 	id = scene_txt_str(scn, "item1-key", ITEM1_KEY, STR_ITEM1_KEY, "1",
@@ -548,7 +548,7 @@ static int expo_render_image(struct unit_test_state *uts)
 	id = scene_txt_str(scn, "label2", ITEM2_LABEL, STR_ITEM2_LABEL, "Now",
 			   NULL);
 	ut_assert(id > 0);
-	id = scene_txt_str(scn, "item2 txt", ITEM2_DESC, STR_ITEM2_DESC,
+	id = scene_txt_str(scn, "item2-txt", ITEM2_DESC, STR_ITEM2_DESC,
 			   "Lord Percy", NULL);
 	ut_assert(id > 0);
 	id = scene_txt_str(scn, "item2-key", ITEM2_KEY, STR_ITEM2_KEY, "2",
Signature · 1 line
2.43.0
#17 lore raw

PATCH 17/19 expo: Separate requested bbox from actual

In reply to Simon Glass

With fixed coordinates it is difficult to create scenes that can work on any display size. Add a separate 'requested' bounding box for each object and sync it when required.

With future work, this will allow scaling the nominal coordinates so that an expo can be rendered correctly on a wider range of displays.

---

 boot/scene.c          | 74 +++++++++++++++++++++++++++++++++----------
 boot/scene_internal.h | 10 ++++++
 boot/scene_menu.c     | 13 ++++----
 boot/scene_textline.c | 10 +++---
 include/expo.h        | 25 ++++++++++++++-
 test/boot/expo.c      | 18 +++++------
 6 files changed, 111 insertions(+), 39 deletions(-)
boot/scene.c +58 -16
index 0d8599f955c..40ef3e0138c 100644
@@ -253,12 +253,13 @@ int scene_obj_set_pos(struct scene *scn, uint id, int x, int y)
 	obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
 	if (!obj)
 		return log_msg_ret("find", -ENOENT);
-	w = obj->bbox.x1 - obj->bbox.x0;
-	h = obj->bbox.y1 - obj->bbox.y0;
-	obj->bbox.x0 = x;
-	obj->bbox.y0 = y;
-	obj->bbox.x1 = obj->bbox.x0 + w;
-	obj->bbox.y1 = obj->bbox.y0 + h;
+	w = obj->req_bbox.x1 - obj->req_bbox.x0;
+	h = obj->req_bbox.y1 - obj->req_bbox.y0;
+	obj->req_bbox.x0 = x;
+	obj->req_bbox.y0 = y;
+	obj->req_bbox.x1 = obj->req_bbox.x0 + w;
+	obj->req_bbox.y1 = obj->req_bbox.y0 + h;
+	obj->flags |= SCENEOF_SYNC_POS;
 
 	return 0;
 }
@@ -270,9 +271,10 @@ int scene_obj_set_size(struct scene *scn, uint id, int w, int h)
 	obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
 	if (!obj)
 		return log_msg_ret("find", -ENOENT);
-	obj->bbox.x1 = obj->bbox.x0 + w;
-	obj->bbox.y1 = obj->bbox.y0 + h;
-	obj->flags |= SCENEOF_SIZE_VALID;
+	log_debug("obj %s w %d h %d\n", obj->name, w, h);
+	obj->req_bbox.x1 = obj->req_bbox.x0 + w;
+	obj->req_bbox.y1 = obj->req_bbox.y0 + h;
+	obj->flags |= SCENEOF_SIZE_VALID | SCENEOF_SYNC_SIZE;
 
 	return 0;
 }
@@ -284,7 +286,8 @@ int scene_obj_set_width(struct scene *scn, uint id, int w)
 	obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
 	if (!obj)
 		return log_msg_ret("find", -ENOENT);
-	obj->bbox.x1 = obj->bbox.x0 + w;
+	obj->req_bbox.x1 = obj->req_bbox.x0 + w;
+	obj->flags |= SCENEOF_SYNC_WIDTH;
 
 	return 0;
 }
@@ -297,11 +300,11 @@ int scene_obj_set_bbox(struct scene *scn, uint id, int x0, int y0, int x1,
 	obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
 	if (!obj)
 		return log_msg_ret("find", -ENOENT);
-	obj->bbox.x0 = x0;
-	obj->bbox.y0 = y0;
-	obj->bbox.x1 = x1;
-	obj->bbox.y1 = y1;
-	obj->flags |= SCENEOF_SIZE_VALID;
+	obj->req_bbox.x0 = x0;
+	obj->req_bbox.y0 = y0;
+	obj->req_bbox.x1 = x1;
+	obj->req_bbox.y1 = y1;
+	obj->flags |= SCENEOF_SIZE_VALID | SCENEOF_SYNC_BBOX;
 
 	return 0;
 }
@@ -448,7 +451,8 @@ int scene_obj_get_hw(struct scene *scn, uint id, int *widthp)
 		}
 
 		limit = obj->flags & SCENEOF_SIZE_VALID ?
-			obj->bbox.x1 - obj->bbox.x0 : -1;
+			obj->req_bbox.x1 - obj->req_bbox.x0 : -1;
+		log_debug("obj %s limit %d\n", obj->name, limit);
 
 		ret = vidconsole_measure(scn->expo->cons, gen->font_name,
 					 gen->font_size, str, limit, &bbox,
@@ -819,6 +823,9 @@ int scene_arrange(struct scene *scn)
 		}
 		}
 	}
+	ret = scene_sync_bbox(scn);
+	if (ret)
+		return log_msg_ret("saf", ret);
 
 	return 0;
 }
@@ -1034,6 +1041,41 @@ int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox bbox[])
 	return 0;
 }
 
+int scene_sync_bbox(struct scene *scn)
+{
+	struct scene_obj *obj;
+
+	list_for_each_entry(obj, &scn->obj_head, sibling) {
+		int req_width = obj->req_bbox.x1 - obj->req_bbox.x0;
+		int req_height = obj->req_bbox.y1 - obj->req_bbox.y0;
+
+		if (obj->flags & SCENEOF_SYNC_POS) {
+			if (obj->flags & SCENEOF_SIZE_VALID) {
+				int width = obj->bbox.x1 - obj->bbox.x0;
+				int height = obj->bbox.y1 - obj->bbox.y0;
+
+				obj->bbox.x1 = obj->req_bbox.x0 + width;
+				obj->bbox.y1 = obj->req_bbox.y0 + height;
+			}
+			obj->bbox.x0 = obj->req_bbox.x0;
+			obj->bbox.y0 = obj->req_bbox.y0;
+		}
+
+		if (obj->flags & SCENEOF_SYNC_SIZE) {
+			obj->bbox.x1 = obj->bbox.x0 + req_width;
+			obj->bbox.y1 = obj->bbox.y0 + req_height;
+		}
+		if (obj->flags & SCENEOF_SYNC_WIDTH)
+			obj->bbox.x1 = obj->bbox.x0 + req_width;
+		if (obj->flags & SCENEOF_SYNC_BBOX)
+			obj->bbox = obj->req_bbox;
+		obj->flags &= ~(SCENEOF_SYNC_POS | SCENEOF_SYNC_SIZE |
+				SCENEOF_SYNC_WIDTH | SCENEOF_SYNC_BBOX);
+	}
+
+	return 0;
+}
+
 int scene_calc_dims(struct scene *scn)
 {
 	struct scene_obj *obj;
boot/scene_internal.h +10 -0
index cca7c18e9f5..ba05e05d99a 100644
@@ -112,6 +112,16 @@ int scene_obj_add(struct scene *scn, const char *name, uint id,
  */
 int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
 
+/**
+ * scene_sync_bbox() - Apply any requested changes to object positions
+ *
+ * Updates each object's bbox to match the req_bbox using the SCENEOF_SYNC_...
+ * flags
+ *
+ * @scn: Scene to update
+ */
+int scene_sync_bbox(struct scene *scn);
+
 /**
  * scene_calc_dims() - Calculate the dimensions of the scene objects
  *
boot/scene_menu.c +6 -7
index b33e0a7d3b4..54c20d3e137 100644
@@ -102,8 +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 + menu->pointer_xofs,
-					label->bbox.y0);
+					menu->obj.req_bbox.x0 +
+					menu->pointer_xofs, label->req_bbox.y0);
 		if (ret < 0)
 			return log_msg_ret("ptr", ret);
 	}
@@ -238,8 +238,8 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	memset(dims, '\0', sizeof(dims));
 	scene_menu_calc_dims(scn, menu, dims);
 
-	startx = menu->obj.bbox.x0;
-	y = menu->obj.bbox.y0;
+	startx = menu->obj.req_bbox.x0;
+	y = menu->obj.req_bbox.y0;
 	if (menu->title_id) {
 		int width;
 
@@ -358,9 +358,8 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	if (sel_id)
 		menu_point_to_item(menu, sel_id);
 	menu->obj.dims.y = dims[SCENEBB_all].y;
-	menu->obj.bbox.x1 = menu->obj.bbox.x0 + menu->obj.dims.x;
-	menu->obj.bbox.y1 = menu->obj.bbox.y0 + menu->obj.dims.y;
-	menu->obj.flags |= SCENEOF_SIZE_VALID;
+	scene_obj_set_size(scn, menu->obj.id, menu->obj.dims.x,
+			   menu->obj.dims.y);
 
 	return 0;
 }
boot/scene_textline.c +4 -6
index 07711d147c3..e55db98ec30 100644
@@ -93,16 +93,14 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	int x, y;
 	int ret;
 
-	x = tline->obj.bbox.x0;
-	y = tline->obj.bbox.y0;
+	x = tline->obj.req_bbox.x0;
+	y = tline->obj.req_bbox.y0;
 	if (tline->label_id) {
-		ret = scene_obj_set_pos(scn, tline->label_id,
-					tline->obj.bbox.x0, y);
+		ret = scene_obj_set_pos(scn, tline->label_id, x, y);
 		if (ret < 0)
 			return log_msg_ret("tit", ret);
 
-		ret = scene_obj_set_pos(scn, tline->edit_id,
-					tline->obj.bbox.x0 + 200, y);
+		ret = scene_obj_set_pos(scn, tline->edit_id, x + 200, y);
 		if (ret < 0)
 			return log_msg_ret("tit", ret);
 
include/expo.h +24 -1
index 4a07a72cf7e..b67eb53b0c9 100644
@@ -284,12 +284,20 @@ enum scene_obj_align {
  * can be selected)
  * @SCENEOF_SIZE_VALID: object's size (width/height) is valid, so any adjustment
  * to x0/y0 should maintain the width/height of the object
+ * @SCENEOF_SYNC_POS: object's position has changed
+ * @SCENEOF_SYNC_SIZE: object's size (width/height) has changed
+ * @SCENEOF_SYNC_WIDTH: object's widget has changed
+ * @SCENEOF_SYNC_BBOX: object's bounding box has changed
  */
 enum scene_obj_flags_t {
 	SCENEOF_HIDE	= 1 << 0,
 	SCENEOF_POINT	= 1 << 1,
 	SCENEOF_OPEN	= 1 << 2,
 	SCENEOF_SIZE_VALID	= BIT(3),
+	SCENEOF_SYNC_POS		= BIT(4),
+	SCENEOF_SYNC_SIZE	= BIT(5),
+	SCENEOF_SYNC_WIDTH	= BIT(6),
+	SCENEOF_SYNC_BBOX	= BIT(7),
 };
 
 enum {
@@ -304,7 +312,9 @@ enum {
  * @name: Name of the object (allocated)
  * @id: ID number of the object
  * @type: Type of this object
- * @bbox: Bounding box for this object
+ * @req_bbox: Requested bounding box for this object, synced to @bbox when scene is
+ * arranged
+ * @bbox: Bounding box for this object (internal use only)
  * @ofs: Offset from x0, y0 where the object is drawn (internal use only)
  * @dims: Dimensions of the text/image; may be smaller than bbox
  * (internal use only)
@@ -320,6 +330,7 @@ struct scene_obj {
 	char *name;
 	uint id;
 	enum scene_obj_t type;
+	struct scene_obj_bbox req_bbox;
 	struct scene_obj_bbox bbox;
 	struct scene_obj_offset ofs;
 	struct scene_obj_dims dims;
@@ -821,6 +832,9 @@ int scene_txted_set_font(struct scene *scn, uint id, const char *font_name,
 /**
  * scene_obj_set_pos() - Set the postion of an object
  *
+ * The given position is marked as 'requested' and will be applied when the
+ * scene is next arranged
+ *
  * @scn: Scene to update
  * @id: ID of object to update
  * @x: x position, in pixels from left side
@@ -832,6 +846,9 @@ int scene_obj_set_pos(struct scene *scn, uint id, int x, int y);
 /**
  * scene_obj_set_size() - Set the size of an object
  *
+ * The given size is marked as 'requested' and will be applied when the scene
+ * is next arranged
+ *
  * @scn: Scene to update
  * @id: ID of object to update
  * @w: width in pixels
@@ -843,6 +860,9 @@ int scene_obj_set_size(struct scene *scn, uint id, int w, int h);
 /**
  * scene_obj_set_width() - Set the width of an object
  *
+ * The given width is marked as 'requested' and will be applied when the scene
+ * is next arranged
+ *
  * @scn: Scene to update
  * @id: ID of object to update
  * @w: width in pixels
@@ -853,6 +873,9 @@ int scene_obj_set_width(struct scene *scn, uint id, int w);
 /**
  * scene_obj_set_bbox() - Set the bounding box of an object
  *
+ * The given bounding box is marked as 'requested' and will be applied when the
+ * scene is next arranged
+ *
  * @scn: Scene to update
  * @id: ID of object to update
  * @x0: x position, in pixels from left side
test/boot/expo.c +9 -9
index 517fb09d767..b97a04e1102 100644
@@ -277,8 +277,8 @@ static int expo_object_attr(struct unit_test_state *uts)
 	ut_assert(id > 0);
 
 	ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 123, 456));
-	ut_asserteq(123, img->obj.bbox.x0);
-	ut_asserteq(456, img->obj.bbox.y0);
+	ut_asserteq(123, img->obj.req_bbox.x0);
+	ut_asserteq(456, img->obj.req_bbox.y0);
 
 	ut_asserteq(-ENOENT, scene_obj_set_pos(scn, OBJ_TEXT2, 0, 0));
 
@@ -367,8 +367,8 @@ static int expo_object_menu(struct unit_test_state *uts)
 	ut_asserteq(0, menu->pointer_id);
 
 	ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400));
-	ut_asserteq(50, menu->obj.bbox.x0);
-	ut_asserteq(400, menu->obj.bbox.y0);
+	ut_asserteq(50, menu->obj.req_bbox.x0);
+	ut_asserteq(400, menu->obj.req_bbox.y0);
 
 	id = scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
 			   "Main Menu", &tit);
@@ -660,12 +660,12 @@ static int expo_render_image(struct unit_test_state *uts)
 	ut_asserteq(400 + 160, obj->bbox.y1);
 
 	scene_obj_set_width(scn, OBJ_MENU, 170);
-	ut_asserteq(50 + 170, obj->bbox.x1);
+	ut_asserteq(50 + 170, obj->req_bbox.x1);
 	scene_obj_set_bbox(scn, OBJ_MENU, 60, 410, 50 + 160, 400 + 160);
-	ut_asserteq(60, obj->bbox.x0);
-	ut_asserteq(410, obj->bbox.y0);
-	ut_asserteq(50 + 160, obj->bbox.x1);
-	ut_asserteq(400 + 160, obj->bbox.y1);
+	ut_asserteq(60, obj->req_bbox.x0);
+	ut_asserteq(410, obj->req_bbox.y0);
+	ut_asserteq(50 + 160, obj->req_bbox.x1);
+	ut_asserteq(400 + 160, obj->req_bbox.y1);
 
 	/* reset back to normal */
 	scene_obj_set_bbox(scn, OBJ_MENU, 50, 400, 50 + 160, 400 + 160);
Signature · 1 line
2.43.0
#18 lore raw

PATCH 18/19 expo: Honour the textline edit_id when building

In reply to Simon Glass

There is no need to create a new ID and it makes it harder for tests to locate objects. Use the ID provided in the file, if any.

---

 boot/expo_build.c | 6 ++----
 test/boot/expo.c  | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
boot/expo_build.c +2 -4
index d97347e1725..9a99a21e5e0 100644
@@ -286,7 +286,7 @@ static int textline_build(struct build_info *info, ofnode node,
 			  struct scene *scn, uint id, struct scene_obj **objp)
 {
 	struct scene_obj_textline *ted;
-	uint ted_id, edit_id;
+	uint edit_id;
 	const char *name;
 	u32 max_chars;
 	int ret;
@@ -301,7 +301,6 @@ static int textline_build(struct build_info *info, ofnode node,
 	ret = scene_textline(scn, name, id, max_chars, &ted);
 	if (ret < 0)
 		return log_msg_ret("ted", ret);
-	ted_id = ret;
 
 	/* Set the title */
 	ret = add_txt_str(info, node, scn, "title", 0);
@@ -311,10 +310,9 @@ static int textline_build(struct build_info *info, ofnode node,
 
 	/* Setup the editor */
 	info->err_prop = "edit-id";
-	ret = ofnode_read_u32(node, "edit-id", &id);
+	ret = ofnode_read_u32(node, "edit-id", &edit_id);
 	if (ret)
 		return log_msg_ret("id", -ENOENT);
-	edit_id = ret;
 
 	ret = scene_txt_str(scn, "edit", edit_id, 0, abuf_data(&ted->buf),
 			    NULL);
test/boot/expo.c +1 -1
index b97a04e1102..b025e48469f 100644
@@ -819,7 +819,7 @@ static int expo_test_build(struct unit_test_state *uts)
 
 	ut_asserteq_str("name", exp->name);
 	ut_asserteq(0, exp->scene_id);
-	ut_asserteq(ID_DYNAMIC_START + 24, exp->next_id);
+	ut_asserteq(ID_DYNAMIC_START + 23, exp->next_id);
 	ut_asserteq(false, exp->popup);
 
 	/* check the scene */
Signature · 1 line
2.43.0
#19 lore raw

PATCH 19/19 expo: Tidy up insets and improve tests

In reply to Simon Glass

Insets are handled inconsistently at present, since menus use them to offset the label text, whereas textlines don't. This is done because menus need the margin to be visible when opened. However this causes an alignment issue when menus and textlines appear in the same cedit.

Remove the offsets from menus and compensate by adjusting the bounding boxes used for highlighting and the opened menu.

Line up menu items and textlines vertically and add a style option for textlines to control how much padding is added.

Add a test to check the positions of objects in a cedit, since this is more direct than the rendering tests. Add style information so that the impact can be seen.

---

 arch/sandbox/dts/sandbox.dtsi |   4 +-
 arch/sandbox/dts/test.dts     |   1 +
 boot/cedit.c                  |  10 ++-
 boot/expo.c                   |   2 +
 boot/scene.c                  |   2 +-
 boot/scene_menu.c             |   9 +-
 boot/scene_textline.c         |  30 ++++---
 doc/develop/expo.rst          |   4 +
 include/expo.h                |   3 +
 test/boot/cedit.c             | 152 ++++++++++++++++++++++++++++++----
 10 files changed, 181 insertions(+), 36 deletions(-)
arch/sandbox/dts/sandbox.dtsi +3 -1
index 8a115c503dc..dd18bd26352 100644
@@ -46,7 +46,9 @@
 		cedit-theme {
 			font-size = <30>;
 			menu-inset = <3>;
-			menuitem-gap-y = <1>;
+			menuitem-gap-y = <0>;
+			menu-title-margin-x = <10>;
+			textline-label-margin-x = <10>;
 		};
 	};
 
arch/sandbox/dts/test.dts +1 -0
index 2087c91285c..3e8db5c09c6 100644
@@ -137,6 +137,7 @@
 			font-size = <30>;
 			menu-inset = <3>;
 			menuitem-gap-y = <1>;
+			textline-label-margin-x = <10>;
 		};
 
 		/*
boot/cedit.c +8 -2
index c560be4d9c4..cc60e757649 100644
@@ -52,6 +52,7 @@ struct cedit_iter_priv {
 
 int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
 {
+	struct expo_theme *theme = &exp->theme;
 	struct expo_arrange_info arr;
 	struct scene_obj_txt *txt;
 	struct scene_obj *obj;
@@ -77,26 +78,31 @@ int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
 
 	y = 100;
 	list_for_each_entry(obj, &scn->obj_head, sibling) {
+		bool add_gap = true;
+
 		switch (obj->type) {
 		case SCENEOBJT_NONE:
 		case SCENEOBJT_IMAGE:
 		case SCENEOBJT_TEXT:
 		case SCENEOBJT_BOX:
 		case SCENEOBJT_TEXTEDIT:
+			add_gap = false;
 			break;
 		case SCENEOBJT_MENU:
 			scene_obj_set_pos(scn, obj->id, 50, y);
 			scene_menu_arrange(scn, &arr,
 					   (struct scene_obj_menu *)obj);
-			y += 50;
+			y += obj->dims.y;
 			break;
 		case SCENEOBJT_TEXTLINE:
 			scene_obj_set_pos(scn, obj->id, 50, y);
 			scene_textline_arrange(scn, &arr,
 					(struct scene_obj_textline *)obj);
-			y += 50;
+			y += obj->dims.y;
 			break;
 		}
+		if (add_gap)
+			y += theme->menuitem_gap_y;
 	}
 	ret = scene_arrange(scn);
 	if (ret)
boot/expo.c +2 -0
index a218ea0e4e9..035c3de5a0a 100644
@@ -313,6 +313,8 @@ int expo_setup_theme(struct expo *exp, ofnode node)
 	ofnode_read_u32(node, "menuitem-gap-y", &theme->menuitem_gap_y);
 	ofnode_read_u32(node, "menu-title-margin-x",
 			&theme->menu_title_margin_x);
+	ofnode_read_u32(node, "textline-label-margin-x",
+			&theme->textline_label_margin_x);
 	theme->white_on_black = ofnode_read_bool(node, "white-on-black");
 
 	ret = expo_apply_theme(exp);
boot/scene.c +1 -1
index 40ef3e0138c..61b943e2b52 100644
@@ -563,7 +563,7 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev,
 		inset = exp->popup ? menu_inset : 0;
 		vidconsole_push_colour(cons, fore, back, &old);
 		video_fill_part(dev, x - inset, y,
-				obj->bbox.x1, obj->bbox.y1,
+				obj->bbox.x1 + inset, obj->bbox.y1,
 				vid_priv->colour_bg);
 	}
 
boot/scene_menu.c +4 -5
index 54c20d3e137..fd16cad6521 100644
@@ -297,8 +297,7 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 		 * Put the label on the left, then leave a space for the
 		 * pointer, then the key and the description
 		 */
-		ret = scene_obj_set_pos(scn, item->label_id,
-					x + theme->menu_inset, y);
+		ret = scene_obj_set_pos(scn, item->label_id, x, y);
 		if (ret < 0)
 			return log_msg_ret("nam", ret);
 		scene_obj_set_hide(scn, item->label_id,
@@ -348,11 +347,11 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr,
 
 	list_for_each_entry(item, &menu->item_head, sibling) {
 		scene_obj_set_width(menu->obj.scene, item->label_id,
-				    dims[SCENEBB_label].x + theme->menu_inset);
+				    dims[SCENEBB_label].x);
 		scene_obj_set_width(menu->obj.scene, item->key_id,
-				    dims[SCENEBB_key].x + theme->menu_inset);
+				    dims[SCENEBB_key].x);
 		scene_obj_set_width(menu->obj.scene, item->desc_id,
-				    dims[SCENEBB_desc].x + theme->menu_inset);
+				    dims[SCENEBB_desc].x);
 	}
 
 	if (sel_id)
boot/scene_textline.c +20 -10
index e55db98ec30..acaf3d91bbc 100644
@@ -49,13 +49,14 @@ void scene_textline_calc_bbox(struct scene_obj_textline *tline,
 			      struct vidconsole_bbox *edit_bbox)
 {
 	const struct expo_theme *theme = &tline->obj.scene->expo->theme;
+	int inset = theme->menu_inset;
 
 	bbox->valid = false;
-	scene_bbox_union(tline->obj.scene, tline->label_id, 0, bbox);
-	scene_bbox_union(tline->obj.scene, tline->edit_id, 0, bbox);
+	scene_bbox_union(tline->obj.scene, tline->label_id, inset, bbox);
+	scene_bbox_union(tline->obj.scene, tline->edit_id, inset, bbox);
 
 	edit_bbox->valid = false;
-	scene_bbox_union(tline->obj.scene, tline->edit_id, theme->menu_inset,
+	scene_bbox_union(tline->obj.scene, tline->edit_id, inset,
 			 edit_bbox);
 }
 
@@ -89,6 +90,7 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr,
 			   struct scene_obj_textline *tline)
 {
 	const bool open = tline->obj.flags & SCENEOF_OPEN;
+	const struct expo_theme *theme = &scn->expo->theme;
 	bool point;
 	int x, y;
 	int ret;
@@ -96,19 +98,22 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	x = tline->obj.req_bbox.x0;
 	y = tline->obj.req_bbox.y0;
 	if (tline->label_id) {
-		ret = scene_obj_set_pos(scn, tline->label_id, x, y);
-		if (ret < 0)
-			return log_msg_ret("tit", ret);
+		struct scene_obj *edit;
 
-		ret = scene_obj_set_pos(scn, tline->edit_id, x + 200, y);
+		ret = scene_obj_set_pos(scn, tline->label_id, x, y);
 		if (ret < 0)
 			return log_msg_ret("tit", ret);
 
-		ret = scene_obj_get_hw(scn, tline->label_id, NULL);
+		x += arr->label_width + theme->textline_label_margin_x;
+		ret = scene_obj_set_pos(scn, tline->edit_id, x, y);
 		if (ret < 0)
-			return log_msg_ret("hei", ret);
+			return log_msg_ret("til", ret);
 
-		y += ret * 2;
+		edit = scene_obj_find(scn, tline->edit_id, SCENEOBJT_NONE);
+		if (!edit)
+			return log_msg_ret("tie", -ENOENT);
+		x += edit->dims.x;
+		y += edit->dims.y;
 	}
 
 	point = scn->highlight_id == tline->obj.id;
@@ -116,6 +121,11 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	scene_obj_flag_clrset(scn, tline->edit_id, SCENEOF_POINT,
 			      point ? SCENEOF_POINT : 0);
 
+	tline->obj.dims.x = x - tline->obj.req_bbox.x0;
+	tline->obj.dims.y = y - tline->obj.req_bbox.y0;
+	scene_obj_set_size(scn, tline->obj.id, tline->obj.dims.x,
+			   tline->obj.dims.y);
+
 	return 0;
 }
 
doc/develop/expo.rst +4 -0
index b94340e9a8d..5bdaffb14bb 100644
@@ -218,6 +218,10 @@ menu-title-margin-x
     Number of pixels between right side of menu title to the left size of the
     menu labels
 
+textline-label-margin-x
+    Number of pixels between right side of textline label to the left size of
+    the editor
+
 Pop-up mode
 -----------
 
include/expo.h +3 -0
index b67eb53b0c9..e383872b307 100644
@@ -83,6 +83,8 @@ struct expo_action {
  * @menuitem_gap_y: Gap between menu items in pixels
  * @menu_title_margin_x: Gap between right side of menu title and left size of
  *	menu label
+ * @textline_label_margin_x: Gap between right side of textline prompt and left
+ *	side of editable text
  * @white_on_black: True to use white-on-black for the expo, false for
  *	black-on-white
  */
@@ -91,6 +93,7 @@ struct expo_theme {
 	u32 menu_inset;
 	u32 menuitem_gap_y;
 	u32 menu_title_margin_x;
+	u32 textline_label_margin_x;
 	bool white_on_black;
 };
 
test/boot/cedit.c +135 -17

261 lines not on this page · raw message

Signature · 1 line
2.43.0