Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BED6DC77B7A for ; Thu, 1 Jun 2023 16:32:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16C26865F4; Thu, 1 Jun 2023 18:26:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="AlLwwh/d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 68F09863A5; Thu, 1 Jun 2023 18:25:30 +0200 (CEST) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E9E0B863B8 for ; Thu, 1 Jun 2023 18:25:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-33b3f2f7989so3489175ab.0 for ; Thu, 01 Jun 2023 09:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636698; x=1688228698; 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=vfNzoxBLAO9R21kc4Sg0/fn1H5MqRFCw30Ikmz/eOVc=; b=AlLwwh/dw/r/XJzR+bn+oQKvwZY1s3J9Ywt7IdMPS/vaX6RuppfMPwutXoVxxcbxHy Gf8deieaNBJT3V04niHaEq0DpDLQlTzd60pEi9d/lS4hjam3uZVUPXKUbTObgNycwwQ5 HTYQNRKQbRCCLKlLFYOBpSjRqbn0uM8pbZ9yY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636698; x=1688228698; 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=vfNzoxBLAO9R21kc4Sg0/fn1H5MqRFCw30Ikmz/eOVc=; b=Sg0/DiazcCW3pLdzdA98FBRvaUSuo/pwtkFbm1Hi6YJeIaJNDTaS1OPL4SiNjssldN hMqI7sc19R/4EWGCaz5HozLiTM9aSQLa0IBxF92CyEt26zmhUx759gBsGFIefSVs9NjA n+WXuRD9cgasVEdbhvnzESD6V/nAZyx2bX8q/kruhzDay7UExCyalP9e398lgk+wP9e1 JU+NzMYhCGJwW89HwE78kg0Hm3bkF06NJWsRJG6la+VpMpd9n33aUn+NcBq83kObhCJ1 UjUcBLrplqmam+lzdXUMH2hJ3aVSj5U/mJIE+NIxLpwNzuQnm4Y1PspexFBcwjL/GsPW 4qiA== X-Gm-Message-State: AC+VfDyTVtFdv8ID5fgySTTKh+EvflDJf9dUt/HuQEia/pso5WiPEptT ksJ4xOqip2/ulfeEk7H5WDwXpA5XACe1BZO0/qw= X-Google-Smtp-Source: ACHHUZ5g4jKX1Y0ZYNLjm0eVr6dwgWAgJtHQSSBMggMwrGZQ0nznIvTVVCCR4lbyqRYxhaJc3Eg0UQ== X-Received: by 2002:a92:c990:0:b0:325:b96e:6701 with SMTP id y16-20020a92c990000000b00325b96e6701mr5209574iln.2.1685636698083; Thu, 01 Jun 2023 09:24:58 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id l1-20020a922901000000b0033a6e7ee4e3sm3862098ilg.1.2023.06.01.09.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:24:57 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH 36/40] expo: Add spacing around menus and items Date: Thu, 1 Jun 2023 10:23:00 -0600 Message-ID: <20230601162404.220488-35-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog In-Reply-To: <20230601162404.220488-1-sjg@chromium.org> References: <20230601162404.220488-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean It looks better if menus have a bit of an inset, rather than be drawn hard up against the background. Also, menu items look better if they have a bit of spacing between them. Add theme options for these and implement the required changes. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 2 ++ boot/expo.c | 2 ++ boot/scene.c | 6 ++++-- boot/scene_menu.c | 37 ++++++++++++++++++++++++------------- doc/develop/expo.rst | 6 ++++++ 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index ff9f9222e6f9..38d5739421f6 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -96,6 +96,8 @@ theme { font-size = <30>; + menu-inset = <3>; + menuitem-gap-y = <1>; }; /* diff --git a/boot/expo.c b/boot/expo.c index e99555163ca4..8c6fbc0e30bc 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -254,6 +254,8 @@ int expo_apply_theme(struct expo *exp, ofnode node) memset(theme, '\0', sizeof(struct expo_theme)); ofnode_read_u32(node, "font-size", &theme->font_size); + ofnode_read_u32(node, "menu-inset", &theme->menu_inset); + ofnode_read_u32(node, "menuitem-gap-y", &theme->menuitem_gap_y); list_for_each_entry(scn, &exp->scene_head, sibling) { ret = scene_apply_theme(scn, theme); diff --git a/boot/scene.c b/boot/scene.c index ea94b90584ee..6fbc1fc578c2 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -309,6 +309,7 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) { struct scene *scn = obj->scene; struct expo *exp = scn->expo; + const struct expo_theme *theme = &exp->theme; struct udevice *dev = exp->display; struct udevice *cons = text_mode ? NULL : exp->cons; int x, y, ret; @@ -363,8 +364,9 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) vid_priv = dev_get_uclass_priv(dev); if (obj->flags & SCENEOF_POINT) { vidconsole_push_colour(cons, fore, back, &old); - video_fill_part(dev, x, y, - x + obj->dim.w, y + obj->dim.h, + video_fill_part(dev, x - theme->menu_inset, y, + x + obj->dim.w, + y + obj->dim.h, vid_priv->colour_bg); } vidconsole_set_cursor_pos(cons, x, y); diff --git a/boot/scene_menu.c b/boot/scene_menu.c index dfe5692d6ce7..8a355f838cc8 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -98,7 +98,7 @@ static void menu_point_to_item(struct scene_obj_menu *menu, uint item_id) update_pointers(menu, item_id, true); } -static int scene_bbox_union(struct scene *scn, uint id, +static int scene_bbox_union(struct scene *scn, uint id, int inset, struct vidconsole_bbox *bbox) { struct scene_obj *obj; @@ -109,14 +109,14 @@ static int scene_bbox_union(struct scene *scn, uint id, if (!obj) return log_msg_ret("obj", -ENOENT); if (bbox->valid) { - bbox->x0 = min(bbox->x0, obj->dim.x); + bbox->x0 = min(bbox->x0, obj->dim.x - inset); bbox->y0 = min(bbox->y0, obj->dim.y); - bbox->x1 = max(bbox->x1, obj->dim.x + obj->dim.w); + bbox->x1 = max(bbox->x1, obj->dim.x + obj->dim.w + inset); bbox->y1 = max(bbox->y1, obj->dim.y + obj->dim.h); } else { - bbox->x0 = obj->dim.x; + bbox->x0 = obj->dim.x - inset; bbox->y0 = obj->dim.y; - bbox->x1 = obj->dim.x + obj->dim.w; + bbox->x1 = obj->dim.x + obj->dim.w + inset; bbox->y1 = obj->dim.y + obj->dim.h; bbox->valid = true; } @@ -135,22 +135,31 @@ static void scene_menu_calc_bbox(struct scene_obj_menu *menu, struct vidconsole_bbox *bbox, struct vidconsole_bbox *label_bbox) { + const struct expo_theme *theme = &menu->obj.scene->expo->theme; const struct scene_menitem *item; bbox->valid = false; - scene_bbox_union(menu->obj.scene, menu->title_id, bbox); + scene_bbox_union(menu->obj.scene, menu->title_id, 0, bbox); label_bbox->valid = false; list_for_each_entry(item, &menu->item_head, sibling) { - scene_bbox_union(menu->obj.scene, item->label_id, bbox); - scene_bbox_union(menu->obj.scene, item->key_id, bbox); - scene_bbox_union(menu->obj.scene, item->desc_id, bbox); - scene_bbox_union(menu->obj.scene, item->preview_id, bbox); + scene_bbox_union(menu->obj.scene, item->label_id, + theme->menu_inset, bbox); + scene_bbox_union(menu->obj.scene, item->key_id, 0, bbox); + scene_bbox_union(menu->obj.scene, item->desc_id, 0, bbox); + scene_bbox_union(menu->obj.scene, item->preview_id, 0, bbox); /* Get the bounding box of all labels */ - scene_bbox_union(menu->obj.scene, item->label_id, label_bbox); + scene_bbox_union(menu->obj.scene, item->label_id, + theme->menu_inset, label_bbox); } + + /* + * subtract the final menuitem's gap to keep the insert the same top + * and bottom + */ + label_bbox->y1 -= theme->menuitem_gap_y; } int scene_menu_calc_dims(struct scene_obj_menu *menu) @@ -182,6 +191,7 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) const bool open = menu->obj.flags & SCENEOF_OPEN; struct expo *exp = scn->expo; const bool stack = exp->popup; + const struct expo_theme *theme = &exp->theme; struct scene_menitem *item; uint sel_id; int x, y; @@ -233,7 +243,8 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) * 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, y); + ret = scene_obj_set_pos(scn, item->label_id, + x + theme->menu_inset, y); if (ret < 0) return log_msg_ret("nam", ret); scene_obj_set_hide(scn, item->label_id, @@ -269,7 +280,7 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) } if (!stack || open) - y += height; + y += height + theme->menuitem_gap_y; } if (sel_id) diff --git a/doc/develop/expo.rst b/doc/develop/expo.rst index 80e435c5e65e..bd593dc2b3f5 100644 --- a/doc/develop/expo.rst +++ b/doc/develop/expo.rst @@ -162,6 +162,12 @@ properties: font-size Font size to use for all text (type: u32) +menu-inset + Number of pixels to inset the menu on the sides and top (type: u32) + +menuitem-gap-y + Number of pixels between menu items + API documentation ----------------- -- 2.41.0.rc0.172.g3f132b7071-goog