From patchwork Mon Sep 15 12:28:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 327 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=1757939406; bh=jUR48FDjVhj1k4gAOOAWZcUYINVy7OWxtwPVVE3Q03U=; 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=wicdgQC+JB3FF67afiyQuWBVl6xTsvLZLpHu0dbMRgSCwwCYOyLLoK0K2qra5ctaD TreUgRVeXDWOBKN0t0yuLDvRL40+wi+vrfXOKmib1KE7ZFSB+0PXSGQfL/sOYUzIU6 izXR0AKlh0mXjauY1WG+tJV7BDq5R6qBqV0sVoLWtQX26BoBdHfklFWtZdquXIpk5Y 5/Gt5jXlIyCripP+WGl6Lc3a6jC2HEXu85Z4ElFDD97h7n4Jt8S//ld1mmcILYpCPx 7eu1OClxlrUlUW35Oj5qjvPAoJhqzP5dIu5TSkAQrAlLDEGdHQBK3YT+AR6Noi3vlj nuqIOGxrRfyDg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A4F467BC8 for ; Mon, 15 Sep 2025 06:30:06 -0600 (MDT) 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 NYsxJ0thmuIk for ; Mon, 15 Sep 2025 06:30:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939406; bh=jUR48FDjVhj1k4gAOOAWZcUYINVy7OWxtwPVVE3Q03U=; 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=wicdgQC+JB3FF67afiyQuWBVl6xTsvLZLpHu0dbMRgSCwwCYOyLLoK0K2qra5ctaD TreUgRVeXDWOBKN0t0yuLDvRL40+wi+vrfXOKmib1KE7ZFSB+0PXSGQfL/sOYUzIU6 izXR0AKlh0mXjauY1WG+tJV7BDq5R6qBqV0sVoLWtQX26BoBdHfklFWtZdquXIpk5Y 5/Gt5jXlIyCripP+WGl6Lc3a6jC2HEXu85Z4ElFDD97h7n4Jt8S//ld1mmcILYpCPx 7eu1OClxlrUlUW35Oj5qjvPAoJhqzP5dIu5TSkAQrAlLDEGdHQBK3YT+AR6Noi3vlj nuqIOGxrRfyDg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 722E867BCA for ; Mon, 15 Sep 2025 06:30:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939404; bh=DP5lM3oPZ/YX6ejxg+hGIVGQ8EOkx5GCGmYU5qTCyIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PXhNGE4uHTG/03vhiFaiizLU8wDBVQKCtgU9/RKJB3s5I6flGWfZNoTM8LGTjiuhz 7acG7FNxDwatAFWiEW0Q7/7Tmmj2NDgb69nmET/ZGfmiSp9GdR5TxrJ+R8hlBs4wt4 U+KEaJ5CxmV+8afMMkOTAUqfaEabbtqahbMCT+eg2oFeKidIagWx5xeVXQpE7Frg4W mKX41wVb7HgypBbPirRhf8TWPB0OqbYJHBsWbYzHvpN56VMXsia3OcN2GFxlr4RoOU xFFoHYoMFjQcGuuFRGn3VOFfnY7v0WpgohvwICo24aDp9oaWhz4p8K/KRfQaxTbeHH WPxyUO00rikbw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 82C5267B44; Mon, 15 Sep 2025 06:30:04 -0600 (MDT) 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 yb_CXqg9qjQM; Mon, 15 Sep 2025 06:30:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939399; bh=epHrxTN3HES7P05c0H25J8LX0lS31DnyF519Yn+Ru/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYnb4fFZ4zfVWNFmeImAxC4wV+iL3qTnX0QlZAMf4YACewAmjvWfIaDW5ELemF6Yf JXJ41UZ+VkgVwsOyi3ge88yYgg6OWE/k8syEm7UX3TEOtLp0siL49PMnY33pBMYHf/ 5oCBta5TveqMDpzauBaSoTonrRIOV5PwCS62QrKNHL34KOKNkDOgbZx8ATLiIa6wq+ EoDXtnQBHEl0gMXG/M+q7FuvfCMbIOK1yno5wb8EaVhWdDdkijy834UAOu8Iw5vHFo h1qMsVPHdsZle8NWwPPTPJpdnHzY1+MA2RA3QUqqRsxzivMw3Wkbhfw6pDL/+iXEnN 1n597Td+WFOTA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A518D67BCB; Mon, 15 Sep 2025 06:29:59 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 06:28:45 -0600 Message-ID: <20250915122905.1217249-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915122905.1217249-1-sjg@u-boot.org> References: <20250915122905.1217249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2DMIEUKJO74LF5A4YMZ7ZHMNS6ADEV2S X-Message-ID-Hash: 2DMIEUKJO74LF5A4YMZ7ZHMNS6ADEV2S 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/23] expo: Allow checking if a position is within a textline 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 For a textline it is possible to click into the edit field. Provide a function to check whether a position is within this field. Signed-off-by: Simon Glass --- boot/scene.c | 33 +++++++++++++++++++++++++++++++++ boot/scene_internal.h | 12 ++++++++++++ boot/scene_textline.c | 6 ++++++ test/boot/expo.c | 24 +++++++++++++++++++++--- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 98716ef2337..e25596366cc 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1045,6 +1045,39 @@ bool scene_within(const struct scene *scn, uint id, int x, int y) y >= obj->bbox.y0 && y <= obj->bbox.y1); } +bool scene_obj_within(const struct scene *scn, struct scene_obj *obj, int x, + int y) +{ + bool within = false; + + switch (obj->type) { + case SCENEOBJT_NONE: + case SCENEOBJT_IMAGE: + case SCENEOBJT_TEXT: + case SCENEOBJT_BOX: + break; + case SCENEOBJT_MENU: { + struct scene_obj_menu *menu; + + menu = (struct scene_obj_menu *)obj, + within = scene_menu_within(scn, menu, x, y); + break; + } + case SCENEOBJT_TEXTLINE: { + struct scene_obj_textline *tline; + + tline = (struct scene_obj_textline *)obj, + within = scene_textline_within(scn, tline, x, y); + break; + } + case SCENEOBJT_TEXTEDIT: + /* TODO(sjg@chromium.org): Implement this */ + break; + } + + return within; +} + int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox bbox[]) { switch (obj->type) { diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 15a96b1e31e..03bc925edfe 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -265,6 +265,18 @@ struct scene_menitem *scene_menu_within(const struct scene *scn, struct scene_obj_menu *menu, int x, int y); +/** + * scene_textline_within() - check if a point is considered within a textline + * + * @scn: Scene to check + * @tline: Txtline to check + * @x: X coordinate of the point + * @y: Y coordinate of the point + * Return: true if the point is considered within the object, false if not + */ +bool scene_textline_within(const struct scene *scn, + struct scene_obj_textline *tline, int x, int y); + /** * scene_render_deps() - Render an object and its dependencies * diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 4a77cc652a8..b595d3477e4 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -175,6 +175,12 @@ int scene_textline_send_key(struct scene *scn, struct scene_obj_textline *tline, return 0; } +bool scene_textline_within(const struct scene *scn, + struct scene_obj_textline *tline, int x, int y) +{ + return scene_within(scn, tline->edit_id, x, y); +} + int scene_textline_render_deps(struct scene *scn, struct scene_obj_textline *tline) { diff --git a/test/boot/expo.c b/test/boot/expo.c index 99c28cc77f6..e8674d359d7 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -962,9 +962,10 @@ static int expo_test_build(struct unit_test_state *uts) } BOOTSTD_TEST(expo_test_build, UTF_DM); -/* test scene_menu_within() function */ -static int expo_menu_within(struct unit_test_state *uts) +/* test scene object within functions */ +static int expo_within_funcs(struct unit_test_state *uts) { + struct scene_obj_textline *tline; struct scene_obj_menu *menu; struct scene_menitem *item; struct scene_obj *obj; @@ -980,6 +981,7 @@ static int expo_menu_within(struct unit_test_state *uts) scn = expo_lookup_scene_id(exp, ID_SCENE1); ut_assertnonnull(scn); + /* test scene_menu_within() */ menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_NONE); ut_assertnonnull(menu); @@ -1005,11 +1007,27 @@ static int expo_menu_within(struct unit_test_state *uts) /* test point far outside menu bounds */ ut_assertnull(scene_menu_within(scn, menu, 9999, 9999)); + /* test scene_textline_within() */ + tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_NONE); + ut_assertnonnull(tline); + obj = scene_obj_find(scn, tline->edit_id, SCENEOBJT_NONE); + ut_assertnonnull(obj); + + /* positive test: point within textline bounds */ + ut_assert(scene_textline_within(scn, tline, obj->bbox.x0 + 1, + obj->bbox.y0 + 1)); + + /* test point outside textline bounds */ + ut_assert(!scene_textline_within(scn, tline, -1, -1)); + + /* test point far outside textline bounds */ + ut_assert(!scene_textline_within(scn, tline, 9999, 9999)); + expo_destroy(exp); return 0; } -BOOTSTD_TEST(expo_menu_within, UTF_DM | UTF_SCAN_FDT); +BOOTSTD_TEST(expo_within_funcs, UTF_DM | UTF_SCAN_FDT); /* test expo_set_mouse_enable() */ static int expo_mouse_enable(struct unit_test_state *uts)