From patchwork Tue Oct 14 11:12:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 594 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org Authentication-Results: mail.u-boot.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dKU6OiFs; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 27A0568103 for ; Tue, 14 Oct 2025 05:13:53 -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 Va37tDDxgLZv for ; Tue, 14 Oct 2025 05:13:53 -0600 (MDT) Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A164868146 for ; Tue, 14 Oct 2025 05:13:52 -0600 (MDT) Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CFB026813F for ; Tue, 14 Oct 2025 05:13:45 -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 eDJSwwt7DMbn for ; Tue, 14 Oct 2025 05:13:45 -0600 (MDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.166.175; helo=mail-il1-f175.google.com; envelope-from=sjg@chromium.org; receiver=u-boot.org Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by mail.u-boot.org (Postfix) with ESMTPS id 33F2D67C83 for ; Tue, 14 Oct 2025 05:13:42 -0600 (MDT) Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-430a4322b12so3534415ab.0 for ; Tue, 14 Oct 2025 04:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1760440421; x=1761045221; darn=u-boot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AmUTsPbuwWe+aouQ3TjCHFby58DsvGmUuGo/npHRlZs=; b=dKU6OiFsh13PGoo7Ev0tnR5EDAcIKd4Mc1uHZ30KOVbXPmv49B5XRgEnvhrhrIrzOi TCpca3HAiPWVys7b6OAw3XPAq7R3Z1A75QJy8/MYZSAZbpSUHs4BQy4lYjFehr+85CU9 xaX+2NCQ64E5XgtyXH5ArwH9845ZHAsTFKYRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760440421; x=1761045221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AmUTsPbuwWe+aouQ3TjCHFby58DsvGmUuGo/npHRlZs=; b=RdIvjB/ZFgImfp/TFbUrVs6ew6F00c2fK77Dnaxmbc1uh4EOI+5vnaJeDvEO3smYd8 bQQ6m77yf5EmWy4g1ArExjKVr+Xd+hCwkPvZ8Ebt+zX4+yxo9yNgdU+2aY1MW0xxe6t0 fk0d/ej8IDOVlTYM899OTtbYGJ6XVjuPZnQ4fAyM8N3v1fDqHXriEIphrd4z3JIzCfF7 i2uxkpqBYpKEB2arxN1Q1mdth4tr9qIPsb1XZl/YlzBW3WziEQ5VBbmELOGvHJhsnb+L 2ejykUApYxesqU7STFiJGZiIJIT4Ypz6DVowZCU/ieV32Mbj3vFnNFNbilRp6YgUY3rj lOVg== X-Gm-Message-State: AOJu0YwToM36cPSA/Lq1yTiAMr2MaFEqiO3jf4SDffR5Taev4oZRliAC EYlEnkkO/eVOEmiQ09JeNO2cL1MSDnpZ26sqNrZq28gB37yKhk0nGvXeiLOXdnoH2EIAcjm2P8c kgLPfDaA2fXA= X-Gm-Gg: ASbGncvtNPFK2rQpJbXsPRMSlmO66qx6eIOAiKbx8izSQ6Cw9H1HB3+Ho/si/vIyg6o YY3uwYh8ml+nAyX0X1D+Poul5pMp7ImjyOo/7hdqS+y/sGRcGW9CvHxJPzvQtP3UZ9Ba6ph/01o LgDo+PKF7bcsA+KCWIG6Aqw6yUxXlz14ojfEkzT9NoZrTvYQtXl4obsEfhd8QCtODfkHwsp4cWC 1uBNrAXdklefjnhk+TPlVD8HGUGxZsElW5HC0+64lkjOe/lvC4Im2e7V0PC8f667+8peunNtQlH 6mcKU3W2Kqkb7VgL36GPsxy9cMTXrQWJbmlBQtVBoZOZoIJ7KHQ5YXImrXEz9h8hrQhPxZ96+0o 1vYl3DJrGJiPSqQi/GPhSXqDH1c5ySKp0BHeGzVj/Y7jl3Q== X-Google-Smtp-Source: AGHT+IFuTP6V14oDGF8JpnBIiXOuCwER+p/9KusX5aqnFkKazgEeiyd5rGlKZVm4qIl57RScfVkiJw== X-Received: by 2002:a05:6e02:3c04:b0:42e:712c:b15 with SMTP id e9e14a558f8ab-42f87351fefmr250281565ab.1.1760440420796; Tue, 14 Oct 2025 04:13:40 -0700 (PDT) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-430a3869174sm4608785ab.15.2025.10.14.04.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 04:13:39 -0700 (PDT) From: Simon Glass To: U-Boot Concept Date: Tue, 14 Oct 2025 05:12:46 -0600 Message-ID: <20251014111301.1059317-10-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014111301.1059317-1-sjg@chromium.org> References: <20251014111301.1059317-1-sjg@chromium.org> MIME-Version: 1.0 Message-ID-Hash: B3FQOSJO3DDHTFYTMIGMCPNMLYWZ7CBA X-Message-ID-Hash: B3FQOSJO3DDHTFYTMIGMCPNMLYWZ7CBA X-MailFrom: sjg@chromium.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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/16] boot: Split out setting menu properties from menu creation List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The existing menu is functional but basic. It would be useful to be able to create the objects but apply a different layout or style for them. The bootflow_menu_new() function is quite long in any case. Split out the parts which adjust the position, alignment, etc. of the objects into a separate function. We can (later) call this from elsewhere to apply the basic styling. Signed-off-by: Simon Glass --- boot/bootflow_menu.c | 75 +++++++++++++++++++++++++++----------------- include/bootflow.h | 12 +++++++ 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c index 1f24215f392..b66ab2d3b73 100644 --- a/boot/bootflow_menu.c +++ b/boot/bootflow_menu.c @@ -32,13 +32,54 @@ struct menu_priv { struct udevice *last_bootdev; }; +int bootflow_menu_set_props(struct expo *exp, struct scene *scn, bool has_logo) +{ + int ret = 0; + bool use_font; + + ret |= scene_obj_set_bbox(scn, OBJ_BOX, 30, 90, 1366 - 30, 720); + ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100); + ret |= scene_obj_set_bbox(scn, OBJ_MENU_TITLE, 0, 32, + 1366, 60); + ret |= scene_obj_set_halign(scn, OBJ_MENU_TITLE, SCENEOA_CENTRE); + + if (has_logo) + ret |= scene_obj_set_pos(scn, OBJ_U_BOOT_LOGO, 1165, 100); + + ret |= scene_obj_set_bbox(scn, OBJ_PROMPT1A, 0, 590, + 1366, 590 + 40); + ret |= scene_obj_set_bbox(scn, OBJ_PROMPT1B, 0, 620, + 1366, 620 + 40); + ret |= scene_obj_set_bbox(scn, OBJ_PROMPT2, 100, 650, + 1366 - 100, 700); + ret |= scene_obj_set_bbox(scn, OBJ_AUTOBOOT, 0, 720, + 1366, 750); + ret |= scene_obj_set_halign(scn, OBJ_PROMPT1A, SCENEOA_CENTRE); + ret |= scene_obj_set_halign(scn, OBJ_PROMPT1B, SCENEOA_CENTRE); + ret |= scene_obj_set_halign(scn, OBJ_PROMPT2, SCENEOA_CENTRE); + ret |= scene_obj_set_valign(scn, OBJ_PROMPT2, SCENEOA_CENTRE); + ret |= scene_obj_set_halign(scn, OBJ_AUTOBOOT, SCENEOA_CENTRE); + ret |= scene_menu_set_pointer(scn, OBJ_MENU, OBJ_POINTER); + + if (ret) + return log_msg_ret("msp", ret); + + use_font = IS_ENABLED(CONFIG_CONSOLE_TRUETYPE); + scene_obj_set_hide(scn, OBJ_PROMPT1A, use_font); + scene_obj_set_hide(scn, OBJ_PROMPT1B, !use_font); + scene_obj_set_hide(scn, OBJ_AUTOBOOT, use_font); + + exp->show_highlight = true; + + return 0; +} + int bootflow_menu_new(struct expo **expp) { struct scene_obj_menu *menu; struct menu_priv *priv; struct scene *scn; struct expo *exp; - bool use_font; void *logo; int ret; @@ -60,21 +101,14 @@ int bootflow_menu_new(struct expo **expp) ret = scene_box(scn, "box", OBJ_BOX, 2, false, NULL); if (ret < 0) return log_msg_ret("bmb", ret); - ret |= scene_obj_set_bbox(scn, OBJ_BOX, 30, 90, 1366 - 30, 720); ret = scene_menu(scn, "main", OBJ_MENU, &menu); - ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100); ret |= scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE, "U-Boot - Boot Menu", NULL); - ret |= scene_obj_set_bbox(scn, OBJ_MENU_TITLE, 0, 32, - 1366, 60); - ret |= scene_obj_set_halign(scn, OBJ_MENU_TITLE, SCENEOA_CENTRE); logo = video_get_u_boot_logo(NULL); - if (logo) { + 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); - } ret |= scene_txt_str(scn, "prompt1a", OBJ_PROMPT1A, STR_PROMPT1A, "Use the \x18 and \x19 keys to select which entry is highlighted.", @@ -89,32 +123,15 @@ int bootflow_menu_new(struct expo **expp) ret |= scene_txt_str(scn, "autoboot", OBJ_AUTOBOOT, STR_AUTOBOOT, "The highlighted entry will be executed automatically in %ds.", NULL); - ret |= scene_obj_set_bbox(scn, OBJ_PROMPT1A, 0, 590, - 1366, 590 + 40); - ret |= scene_obj_set_bbox(scn, OBJ_PROMPT1B, 0, 620, - 1366, 620 + 40); - ret |= scene_obj_set_bbox(scn, OBJ_PROMPT2, 100, 650, - 1366 - 100, 700); - ret |= scene_obj_set_bbox(scn, OBJ_AUTOBOOT, 0, 720, - 1366, 750); - ret |= scene_obj_set_halign(scn, OBJ_PROMPT1A, SCENEOA_CENTRE); - ret |= scene_obj_set_halign(scn, OBJ_PROMPT1B, SCENEOA_CENTRE); - ret |= scene_obj_set_halign(scn, OBJ_PROMPT2, SCENEOA_CENTRE); - ret |= scene_obj_set_valign(scn, OBJ_PROMPT2, SCENEOA_CENTRE); - ret |= scene_obj_set_halign(scn, OBJ_AUTOBOOT, SCENEOA_CENTRE); - - use_font = IS_ENABLED(CONFIG_CONSOLE_TRUETYPE); - scene_obj_set_hide(scn, OBJ_PROMPT1A, use_font); - scene_obj_set_hide(scn, OBJ_PROMPT1B, !use_font); - scene_obj_set_hide(scn, OBJ_AUTOBOOT, use_font); ret |= scene_txt_str(scn, "cur_item", OBJ_POINTER, STR_POINTER, ">", NULL); - ret |= scene_menu_set_pointer(scn, OBJ_MENU, OBJ_POINTER); if (ret < 0) return log_msg_ret("new", -EINVAL); - exp->show_highlight = true; + ret = bootflow_menu_set_props(exp, scn, logo); + if (ret < 0) + return log_msg_ret("nep", -EINVAL); *expp = exp; diff --git a/include/bootflow.h b/include/bootflow.h index 17ecc80c2eb..9ee11b33dbf 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -560,6 +560,18 @@ int bootflow_menu_add(struct expo *exp, struct bootflow *bflow, int seq, */ int bootflow_menu_apply_theme(struct expo *exp, ofnode node); +/** + * bootflow_menu_set_props() - Apply properties for the menu + * + * This sets up the positions of the objects in the basic menu. It also + * enables show_highlight + * + * @exp: Expo to update + * @scn: Scene to update + * @has_logo: true if a logo should be visible + */ +int bootflow_menu_set_props(struct expo *exp, struct scene *scn, bool has_logo); + #define BOOTFLOWCL_EMPTY ((void *)1) /**