From patchwork Mon Jan 19 20:41:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1656 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855432; bh=NJwvBj9R2lceYqAU9qoD1Dova8OJ1EWzk1ZF466g7YY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Rp5QwYMGJEEM2gV8KmehiT65KyxrvqXO+GN8v2LVRlx67trj71Hq5ZbJxAHzK1c/9 DkUO79bMEAF/DqM1IYQWXiXiyN+jTSLvqU+NY1SC/LGI+suHOyDhZKtWPJ6MJYXO4I cAYInqpsvnAo+U6irtAkllAyYQGW4sHVQozx5L9jI74Rt5o0Jw0OAF11X8Rf2Ednaf gOMspuAoFvRjeOT3V+kXoD/ZhrIcvwYtO8kM7mBYdGOOevSD4WhFtZybIBCeTioE0g aQz2GNGUDbwuVwPgKjE4QXRQU9peFnlXXjACXre3TBvQwy0jn5+INGV2k9+6uOyRkQ kyLo6tBHn56jw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D692F69525 for ; Mon, 19 Jan 2026 13:43:52 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id IBR5LeMjCjoE for ; Mon, 19 Jan 2026 13:43:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855432; bh=NJwvBj9R2lceYqAU9qoD1Dova8OJ1EWzk1ZF466g7YY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Rp5QwYMGJEEM2gV8KmehiT65KyxrvqXO+GN8v2LVRlx67trj71Hq5ZbJxAHzK1c/9 DkUO79bMEAF/DqM1IYQWXiXiyN+jTSLvqU+NY1SC/LGI+suHOyDhZKtWPJ6MJYXO4I cAYInqpsvnAo+U6irtAkllAyYQGW4sHVQozx5L9jI74Rt5o0Jw0OAF11X8Rf2Ednaf gOMspuAoFvRjeOT3V+kXoD/ZhrIcvwYtO8kM7mBYdGOOevSD4WhFtZybIBCeTioE0g aQz2GNGUDbwuVwPgKjE4QXRQU9peFnlXXjACXre3TBvQwy0jn5+INGV2k9+6uOyRkQ kyLo6tBHn56jw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C5C8869504 for ; Mon, 19 Jan 2026 13:43:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855430; bh=i4BoX1cpwPh1tz8cofiGK1SEEYh1TcHHAYMBbNk+rqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lhN1furuw3ShoZjgZ6L9asvIXDXjaFDqgJZTtenqAeqqzZWHsgVF8D35vm1kCp6Gf JRWVkL+6tJp4bet8omOJjtDMbtRwmIBp9IcR1scvp4Ut4hwSiof5Xe0kQqXYLXRTyY ZpHyBZ+RSRqKB3CMmj74u3c3RUmVfW0C/q7nnDHMWV9WHe3kgN4zSzk5rE5rzs4wUg YcCltAjYar3xmz3JnEKLfylKWt4ir3p/rj6YqPlKicWSPYNdFQ+54+CESqVgxNCFZx 1JKW/7GqjsBLSYxqdx0VFa7/Dgkm5OTsisBmMAvR2ELMP8rR+peitKW27puNGu3xI6 kp5dMpf79VJMg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B59C9693BA; Mon, 19 Jan 2026 13:43:50 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 7DntH9mBrtvY; Mon, 19 Jan 2026 13:43:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855426; bh=y4QwV2cSvXTFAEXyd93dF2XL/blOzQN7l9wRMyk+7KA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IQ+4Ho7nOcq/KckypxXEx4Y8Mb0+m3H2xkcYzyaAC3hLLPFTHOFGfoaQOvlTkDnBb GPRZpe1I4gMXwAEWo0YDrc1FwY+ZKEHVLzF1iEkir/uK5/j0HG0WHfRHVSCrDz1L/V kbDeZ6EJl/o3giD0e9RwjeZ03G2jHaGdtnoi3yOn9lj38469V80XpRVgYbNpH3kdr5 zmg8P7TW50Nx0AgVbJ6/dvL4JWXuHABCwowhe+jGuNA/emsZ3ErppYZoopqOzLukKp GSuQdstR6xYszx188rDdtLrD4hHIujEzhCMHfg4enJMeyR/VppozbDOu9yYs+oHHUS SJ85QDud44c5A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 64E3E693E3; Mon, 19 Jan 2026 13:43:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 19 Jan 2026 13:41:19 -0700 Message-ID: <20260119204130.3972647-27-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119204130.3972647-1-sjg@u-boot.org> References: <20260119204130.3972647-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UKEIW2H6P7QPZYGEJUJNM7DTE2ARR6TR X-Message-ID-Hash: UKEIW2H6P7QPZYGEJUJNM7DTE2ARR6TR X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 26/27] expo: Fix textedit height calculation List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The scene_txted_arrange() function sets the textedit's height to zero, which causes problems when highlighting since the bounding box has no height. Fix this by calculating the height from the edit text's dimensions, similar to how scene_textline_arrange() does it. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_textedit.c | 44 ++++++++++++++++++++++++++++++++++--------- test/boot/expo.c | 2 +- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index 2075cfbd417..d6ef725db3e 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -54,21 +54,31 @@ int scene_txted_set_font(struct scene *scn, uint id, const char *font_name, int scene_txted_calc_dims(struct scene_obj_txtedit *ted, struct udevice *cons) { + const struct expo_theme *theme = &ted->obj.scene->expo->theme; struct scene *scn = ted->obj.scene; struct scene_obj_txt *txt; - int ret; + int x0, ret; txt = scene_obj_find(scn, ted->tin.edit_id, SCENEOBJT_NONE); if (!txt) return log_msg_ret("txt", -ENOENT); /* - * Set the edit text's bbox to match the textedit's bbox. This ensures - * SCENEOF_SIZE_VALID is set so vidconsole_measure() applies the width - * limit for word-wrapping/clipping. + * Set the edit text's bbox to fit within the textedit's bbox, after + * the label. This ensures SCENEOF_SIZE_VALID is set so + * vidconsole_measure() applies the width limit for word-wrapping. */ + x0 = ted->obj.req_bbox.x0; + if (ted->tin.label_id) { + int width; + + ret = scene_obj_get_hw(scn, ted->tin.label_id, &width); + if (ret < 0) + return log_msg_ret("lab", ret); + x0 += width + theme->textline_label_margin_x; + } ret = scene_obj_set_bbox(scn, ted->tin.edit_id, - ted->obj.req_bbox.x0, ted->obj.req_bbox.y0, + x0, ted->obj.req_bbox.y0, ted->obj.req_bbox.x1, ted->obj.req_bbox.y1); if (ret < 0) return log_msg_ret("sbb", ret); @@ -84,7 +94,8 @@ int scene_txted_calc_dims(struct scene_obj_txtedit *ted, struct udevice *cons) int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, struct scene_obj_txtedit *ted) { - int x; + struct scene_obj *edit; + int x, y; int ret; x = scene_txtin_arrange(scn, arr, &ted->obj, &ted->tin); @@ -92,14 +103,29 @@ int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, return log_msg_ret("arr", x); /* constrain the edit text to fit within the textedit bbox */ - ret = scene_obj_set_bbox(scn, ted->tin.edit_id, x, ted->obj.req_bbox.y0, + y = ted->obj.req_bbox.y0; + ret = scene_obj_set_bbox(scn, ted->tin.edit_id, x, y, ted->obj.req_bbox.x1, ted->obj.req_bbox.y1); if (ret < 0) return log_msg_ret("edi", ret); + /* Re-measure text with the correct limit (bbox may have changed) */ + ret = scene_obj_get_hw(scn, ted->tin.edit_id, NULL); + if (ret < 0) + return log_msg_ret("hw", ret); + + edit = scene_obj_find(scn, ted->tin.edit_id, SCENEOBJT_NONE); + if (!edit) + return log_msg_ret("fnd", -ENOENT); + x += edit->dims.x; + y += edit->dims.y; + + /* + * Set dims based on content size, but don't call scene_obj_set_size() + * as that would overwrite the user-specified req_bbox + */ ted->obj.dims.x = x - ted->obj.req_bbox.x0; - ted->obj.dims.y = 0; - scene_obj_set_size(scn, ted->obj.id, ted->obj.dims.x, ted->obj.dims.y); + ted->obj.dims.y = y - ted->obj.req_bbox.y0; return 0; } diff --git a/test/boot/expo.c b/test/boot/expo.c index c8c97057d54..79e77b83b0a 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1570,7 +1570,7 @@ static int expo_render_textedit(struct unit_test_state *uts) expo_set_scene_id(exp, SCENE1); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(19860, video_compress_fb(uts, dev, false)); + ut_asserteq(19841, video_compress_fb(uts, dev, false)); abuf_uninit(&buf); abuf_uninit(&logo_copy);