From patchwork Sun Jan 18 20:42:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1603 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=1768769053; bh=mR5W+VrruBESXjoTi5ghP3KVpJOgFDVlVelcckcdAAU=; 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=Wwmoh67E/1rBr4/P+xQzLZtNWV6zCmTNSlxgP029QyiW0XEZtS8GiXS9ZtdWj6fmP 1lcleosbrYUGns5r23nWRWDUyzYFBnSlW2bRqu3TjGt9HQba85rgp7eluvU/3wf+AA 1IKJRhaYMNmm1mDhnyvwSrGJQXzB13QVWU4F6wW84v1BeNSZ7Uryhxy480IIafEIun bzzgIi+etCp8OGt9VFQW6uj5RLo4IDOX/h3YHGThRhG5tFk2EPLT7c6uEqLFqHgoyT JdNgz//rock6bR4F4qUL8F2pnSIMW+9aTZ5xkNKxfySbvPGuCcXSbwyg+r58N+h9qY izxH00PmjjjcQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 03D7A6949D for ; Sun, 18 Jan 2026 13:44:13 -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 aIEECBj-cgHL for ; Sun, 18 Jan 2026 13:44:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769052; bh=mR5W+VrruBESXjoTi5ghP3KVpJOgFDVlVelcckcdAAU=; 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=vgTsQuLCo/jh20BDepwhsDOq2NdXhA1MALpzNjwzPsYiczclqlk0W3PyLHO8Lgrkt AMuOdCBARZ/B5LFOiDX5gbQ1iFkEPYgZpcKH1RR3qfmDSVlcPEHh+cSVfM3Z9aWcrl erGx5ho0kW58kFc5LTyF//v02VyBsIkKxroxQ1jWKlyfUGv6yXLU4g874AgsMNMrJU gbAyRx9cc7kaqOQUN+lCDpDjf746yoIZwkI22epoERcTQtS2i5nFijm6ohNCKv3I4P AnB5FgxkS3BPbCi2rBNhIrdMrPVrVhF9jfzFp7Q0aV1z6U7ClNPVYtf1hs0LmlFopx b045tzah2LszA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E6D8469491 for ; Sun, 18 Jan 2026 13:44:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769051; bh=ce+U43F6BASqS/xG+9n8Vfg/f3mZKJ2cPCpLZSVkIjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KLILVpTtqDPN4bXgHVbqR2ZJj+ESu73AUIr9YvUwFfkfae//8BUl74piWob2qkT2v LnEDoJ5dqjy23oSYFI8x8Yr+zg9LgYZs+uTWPE+NiT0V0ErlWrZ1ZBoM3SvQdvozl5 N0+BiywbJJdkDAO65YM3/LmKaR15QFWWhA+dgNiQMq2j7nVQ7Ar3smn0HSit1p4Dab RSkLwxIk5rGNezLFI6XgeMWpOEYPnLhzbFlP5dLi+AbZI7sWK24nQUM6RY6KF8XmzL Q4ifmt8cDIC0dF/jayTba1VBg2N9IRbQ8xSPRqb2gk6HxGB9cyvd5JcJPzag67nW2d W12W8yswRFjbg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B4BF86948C; Sun, 18 Jan 2026 13:44:11 -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 xPEgRN8dfTCw; Sun, 18 Jan 2026 13:44:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769047; bh=lJC2kHbc+Tv6XB1juV/te+J3ns8xD/Yz5nv1x0cKeaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btbHCIn9blbPv+I95JAxSPQzQjtxkCpZbLkfmHqcbFx+0L24fVBvNjgb7/T97yoT0 k2foTL7JkShYneEKWhn1iM7uqGqnDAqDis93qFjSIgcVyOBNRV806raGPq0Xaquioj 1vqfp2/kB6pEBJb8DDM0ifI75hxIg2D0sUn+VUtBtlcZmQrAe+4808xa4WzN4TThcs udCzc407vV8K+sTtsSsbAHw2c59LC1VAln9D5PkT1KDvpIMOINxIqH9/O32JpAB2Hw GqoGz7WToJCCVKDMef9I53pZe11l/h2SzHGzcxGZP2jtnWfqE2x39pEwqBx4e+hghL kRjnYB+HBv2SQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 656A26946A; Sun, 18 Jan 2026 13:44:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:51 -0700 Message-ID: <20260118204303.1982533-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260118204303.1982533-1-sjg@u-boot.org> References: <20260118204303.1982533-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5TTH3LK4XYV6VWT6WL4CFG3HYI3H5BFR X-Message-ID-Hash: 5TTH3LK4XYV6VWT6WL4CFG3HYI3H5BFR 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 12/16] expo: Factor out common calc_bbox code into scene_txtin.c 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 Create a new file scene_txtin.c containing common code for text-input scene objects (textline, textedit). Move the calc_bbox logic into scene_txtin_calc_bbox() which is called directly from scene_obj_calc_bbox() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/Makefile | 2 +- boot/scene.c | 13 ++++++++++--- boot/scene_internal.h | 15 ++++++++------- boot/scene_textedit.c | 24 ++++++++++++++++++++++++ boot/scene_textline.c | 16 ---------------- boot/scene_txtin.c | 30 ++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 boot/scene_txtin.c diff --git a/boot/Makefile b/boot/Makefile index 39069014310..b9129a174c7 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -61,7 +61,7 @@ obj-$(CONFIG_$(PHASE_)LOAD_FIT) += common_fit.o obj-$(CONFIG_$(PHASE_)EXPO) += expo.o scene.o expo_build.o obj-$(CONFIG_$(PHASE_)EXPO_DUMP) += expo_dump.o -obj-$(CONFIG_$(PHASE_)EXPO) += scene_menu.o scene_textline.o scene_textedit.o +obj-$(CONFIG_$(PHASE_)EXPO) += scene_menu.o scene_textline.o scene_textedit.o scene_txtin.o obj-$(CONFIG_$(PHASE_)EXPO_TEST) += expo_test.o ifdef CONFIG_COREBOOT_SYSINFO obj-$(CONFIG_$(PHASE_)EXPO) += expo_build_cb.o diff --git a/boot/scene.c b/boot/scene.c index 9c02c9b36be..220fbf26b44 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1440,7 +1440,6 @@ int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox bbox[]) case SCENEOBJT_IMAGE: case SCENEOBJT_TEXT: case SCENEOBJT_BOX: - case SCENEOBJT_TEXTEDIT: return -ENOSYS; case SCENEOBJT_MENU: { struct scene_obj_menu *menu = (struct scene_obj_menu *)obj; @@ -1452,8 +1451,16 @@ int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox bbox[]) struct scene_obj_textline *tline; tline = (struct scene_obj_textline *)obj; - scene_textline_calc_bbox(tline, &bbox[SCENEBB_all], - &bbox[SCENEBB_label]); + scene_txtin_calc_bbox(obj, &tline->tin, &bbox[SCENEBB_all], + &bbox[SCENEBB_label]); + break; + } + case SCENEOBJT_TEXTEDIT: { + struct scene_obj_txtedit *ted; + + ted = (struct scene_obj_txtedit *)obj; + scene_txtin_calc_bbox(obj, &ted->tin, &bbox[SCENEBB_all], + &bbox[SCENEBB_label]); break; } } diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 1e5bd3d2a28..a3eb720c385 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -20,6 +20,7 @@ struct scene_obj_dims; struct scene_obj_menu; struct scene_obj_textline; struct scene_obj_txtedit; +struct scene_txtin; struct scene_txt_generic; struct udevice; struct vidconsole_bbox; @@ -497,16 +498,16 @@ void scene_menu_calc_bbox(struct scene_obj_menu *menu, struct vidconsole_bbox *bbox); /** - * scene_textline_calc_bbox() - Calculate bounding box for the textline + * scene_txtin_calc_bbox() - Calculate bounding box for a text-input object * - * @textline: Menu to process - * @bbox: Returns bounding box of textline including prompt + * @obj: Object to process + * @tin: Text-input object info + * @bbox: Returns bounding box of object including label * @edit_bbox: Returns bounding box of editable part - * Return: 0 if OK, -ve on error */ -void scene_textline_calc_bbox(struct scene_obj_textline *menu, - struct vidconsole_bbox *bbox, - struct vidconsole_bbox *label_bbox); +void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, + struct vidconsole_bbox *bbox, + struct vidconsole_bbox *edit_bbox); /** * scene_obj_calc_bbox() - Calculate bounding boxes for an object diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index de985c6f6e1..37138fc7542 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -56,6 +56,30 @@ int scene_txted_set_font(struct scene *scn, uint id, const char *font_name, return scene_txt_set_font(scn, ted->tin.edit_id, font_name, font_size); } +int scene_txted_calc_dims(struct scene_obj_txtedit *ted, struct udevice *cons) +{ + struct scene *scn = ted->obj.scene; + struct scene_obj_txt *txt; + int 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. + */ + ret = scene_obj_set_bbox(scn, ted->tin.edit_id, + ted->obj.req_bbox.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); + + return 0; +} + int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, struct scene_obj_txtedit *ted) { diff --git a/boot/scene_textline.c b/boot/scene_textline.c index c0492896888..0f542dd590f 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -44,22 +44,6 @@ int scene_textline(struct scene *scn, const char *name, uint id, return tline->obj.id; } -void scene_textline_calc_bbox(struct scene_obj_textline *tline, - struct vidconsole_bbox *bbox, - 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->tin.label_id, inset, bbox); - scene_bbox_union(tline->obj.scene, tline->tin.edit_id, inset, bbox); - - edit_bbox->valid = false; - scene_bbox_union(tline->obj.scene, tline->tin.edit_id, inset, - edit_bbox); -} - int scene_textline_calc_dims(struct scene_obj_textline *tline, struct udevice *cons) { diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c new file mode 100644 index 00000000000..b2d8d0ad49e --- /dev/null +++ b/boot/scene_txtin.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Common code for text-input scene objects (textline, textedit) + * + * Copyright 2026 Canonical Ltd + * Written by Simon Glass + */ + +#define LOG_CATEGORY LOGC_EXPO + +#include +#include +#include +#include "scene_internal.h" + +void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, + struct vidconsole_bbox *bbox, + struct vidconsole_bbox *edit_bbox) +{ + struct scene *scn = obj->scene; + const struct expo_theme *theme = &scn->expo->theme; + int inset = theme->menu_inset; + + bbox->valid = false; + scene_bbox_union(scn, tin->label_id, inset, bbox); + scene_bbox_union(scn, tin->edit_id, inset, bbox); + + edit_bbox->valid = false; + scene_bbox_union(scn, tin->edit_id, inset, edit_bbox); +}