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 50E99C77B7A for ; Thu, 1 Jun 2023 16:30:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8472B865CA; Thu, 1 Jun 2023 18:25:54 +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="apcCL4qe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B88E286386; Thu, 1 Jun 2023 18:25:20 +0200 (CEST) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 89C2D86385 for ; Thu, 1 Jun 2023 18:25:05 +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-x129.google.com with SMTP id e9e14a558f8ab-33d269dd56bso1806375ab.1 for ; Thu, 01 Jun 2023 09:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636688; x=1688228688; 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=7Ijlu/UfDmKYdpBquWHqt+UMo2fU1dXnUqfyVtt9OWw=; b=apcCL4qecU/oA/7o/cHbT5uI8nYWpCx/imv7XmPDpK2SY4jX0mST08cMjlyo5heQlU RPbCpesgXk1biEU/Xq+7ud2KXF+YZvQKFCi5pTzWPjHp1mQTR9AMPmfqWY/3NAA3e6xM YHWyUJPR5lbQtr5EX2w1HUuCAljVgH2qaQW14= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636688; x=1688228688; 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=7Ijlu/UfDmKYdpBquWHqt+UMo2fU1dXnUqfyVtt9OWw=; b=CpuKooFCXEnxeYr25CxSegFXj/quvHeJIaRT+wQNlBecndoYmX9mje6oZvqdOJdw+V h3RL8PxcguFyyTcSSzZltnfdCfP/CoGMdsc5h5IdJX42IsXWdF9wJHDxXYA9svCAIvn0 oYMccUG6Y1am6cZ2pclsqVzudeCdqgUc5QOdFz+B8Dvm/SlYChA7X41s9VNGqrJrbkfJ 2VhOIgzP5smubl3Dx/xIhvYw8XcVbePF97+AI6DVbbWA1LWzQkSs814exVwVIPOqspc6 viR+rn+L2mdGHNPfPa9tkP2hyQ1Tg3N6hXNld/cBGcQdNH8yUl9pr5/Kd9HnEV0nuB0q SRIg== X-Gm-Message-State: AC+VfDy+vYPsB8aC9bhQtYDZy/HVBG5SwMcP8mAbnBm/Jehh6M8NMipI M1MHgqkjdscNAhTIU6B3VdKzw+W9V/bgAFtEArk= X-Google-Smtp-Source: ACHHUZ5njrB4WJ38rWgk/wxSBSx/1RZByg7EiQr0YShRMAE65KSMCUt7WPHML06wpJAwzZLhrX7oWA== X-Received: by 2002:a92:cc43:0:b0:338:af0b:f2bd with SMTP id t3-20020a92cc43000000b00338af0bf2bdmr4818662ilq.5.1685636688087; Thu, 01 Jun 2023 09:24:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:24:47 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH 25/40] expo: Add width and height to objects Date: Thu, 1 Jun 2023 10:22:49 -0600 Message-ID: <20230601162404.220488-24-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 At present objects only have a position so it is not possible to determine the amount of space they take up on the display. Add width and height properties, using a struct to keep all the dimensions together. For now this is not used. Future work will set up these new properties. Signed-off-by: Simon Glass --- boot/scene.c | 8 ++++---- boot/scene_menu.c | 12 ++++++------ include/expo.h | 21 +++++++++++++++++---- test/boot/expo.c | 32 ++++++++++++++++---------------- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 2ac9bfcdbd52..8033d77fb266 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -201,8 +201,8 @@ int scene_obj_set_pos(struct scene *scn, uint id, int x, int y) obj = scene_obj_find(scn, id, SCENEOBJT_NONE); if (!obj) return log_msg_ret("find", -ENOENT); - obj->x = x; - obj->y = y; + obj->dim.x = x; + obj->dim.y = y; return 0; } @@ -272,8 +272,8 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) struct udevice *cons = text_mode ? NULL : exp->cons; int x, y, ret; - x = obj->x; - y = obj->y; + x = obj->dim.x; + y = obj->dim.y; switch (obj->type) { case SCENEOBJT_NONE: diff --git a/boot/scene_menu.c b/boot/scene_menu.c index 8b04d4403139..eed7565f6a61 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -49,9 +49,9 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) int y, cur_y; int ret; - y = menu->obj.y; + y = menu->obj.dim.y; if (menu->title_id) { - ret = scene_obj_set_pos(scn, menu->title_id, menu->obj.x, y); + ret = scene_obj_set_pos(scn, menu->title_id, menu->obj.dim.x, y); if (ret < 0) return log_msg_ret("tit", ret); @@ -89,18 +89,18 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) * pointer, then the key and the description */ if (item->label_id) { - ret = scene_obj_set_pos(scn, item->label_id, menu->obj.x, + ret = scene_obj_set_pos(scn, item->label_id, menu->obj.dim.x, y); if (ret < 0) return log_msg_ret("nam", ret); } - ret = scene_obj_set_pos(scn, item->key_id, menu->obj.x + 230, + ret = scene_obj_set_pos(scn, item->key_id, menu->obj.dim.x + 230, y); if (ret < 0) return log_msg_ret("key", ret); - ret = scene_obj_set_pos(scn, item->desc_id, menu->obj.x + 280, + ret = scene_obj_set_pos(scn, item->desc_id, menu->obj.dim.x + 280, y); if (ret < 0) return log_msg_ret("des", ret); @@ -134,7 +134,7 @@ int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu) * points to */ ret = scene_obj_set_pos(scn, menu->pointer_id, - menu->obj.x + 200, cur_y); + menu->obj.dim.x + 200, cur_y); if (ret < 0) return log_msg_ret("ptr", ret); } diff --git a/include/expo.h b/include/expo.h index b8f5327f2664..5135954ba139 100644 --- a/include/expo.h +++ b/include/expo.h @@ -122,6 +122,21 @@ enum scene_obj_t { SCENEOBJT_MENU, }; +/** + * struct scene_dim - Dimensions of an object + * + * @x: x position, in pixels from left side + * @y: y position, in pixels from top + * @w: width, in pixels + * @h: height, in pixels + */ +struct scene_dim { + int x; + int y; + int w; + int h; +}; + /** * struct scene_obj - information about an object in a scene * @@ -129,8 +144,7 @@ enum scene_obj_t { * @name: Name of the object (allocated) * @id: ID number of the object * @type: Type of this object - * @x: x position, in pixels from left side - * @y: y position, in pixels from top + * @dim: Dimensions for this object * @hide: true if the object should be hidden * @sibling: Node to link this object to its siblings */ @@ -139,8 +153,7 @@ struct scene_obj { char *name; uint id; enum scene_obj_t type; - int x; - int y; + struct scene_dim dim; bool hide; struct list_head sibling; }; diff --git a/test/boot/expo.c b/test/boot/expo.c index 70750d307ffa..10cb7b246f3f 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -250,8 +250,8 @@ static int expo_object_attr(struct unit_test_state *uts) ut_assert(id > 0); ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 123, 456)); - ut_asserteq(123, img->obj.x); - ut_asserteq(456, img->obj.y); + ut_asserteq(123, img->obj.dim.x); + ut_asserteq(456, img->obj.dim.y); ut_asserteq(-ENOENT, scene_obj_set_pos(scn, OBJ_TEXT2, 0, 0)); @@ -307,8 +307,8 @@ static int expo_object_menu(struct unit_test_state *uts) ut_asserteq(0, menu->pointer_id); ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400)); - ut_asserteq(50, menu->obj.x); - ut_asserteq(400, menu->obj.y); + ut_asserteq(50, menu->obj.dim.x); + ut_asserteq(400, menu->obj.dim.y); id = scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE, "Main Menu", &tit); @@ -354,24 +354,24 @@ static int expo_object_menu(struct unit_test_state *uts) ut_asserteq(id, menu->cur_item_id); /* the title should be at the top */ - ut_asserteq(menu->obj.x, tit->obj.x); - ut_asserteq(menu->obj.y, tit->obj.y); + ut_asserteq(menu->obj.dim.x, tit->obj.dim.x); + ut_asserteq(menu->obj.dim.y, tit->obj.dim.y); /* the first item should be next */ - ut_asserteq(menu->obj.x, name1->obj.x); - ut_asserteq(menu->obj.y + 32, name1->obj.y); + ut_asserteq(menu->obj.dim.x, name1->obj.dim.x); + ut_asserteq(menu->obj.dim.y + 32, name1->obj.dim.y); - ut_asserteq(menu->obj.x + 230, key1->obj.x); - ut_asserteq(menu->obj.y + 32, key1->obj.y); + ut_asserteq(menu->obj.dim.x + 230, key1->obj.dim.x); + ut_asserteq(menu->obj.dim.y + 32, key1->obj.dim.y); - ut_asserteq(menu->obj.x + 200, ptr->obj.x); - ut_asserteq(menu->obj.y + 32, ptr->obj.y); + ut_asserteq(menu->obj.dim.x + 200, ptr->obj.dim.x); + ut_asserteq(menu->obj.dim.y + 32, ptr->obj.dim.y); - ut_asserteq(menu->obj.x + 280, desc1->obj.x); - ut_asserteq(menu->obj.y + 32, desc1->obj.y); + ut_asserteq(menu->obj.dim.x + 280, desc1->obj.dim.x); + ut_asserteq(menu->obj.dim.y + 32, desc1->obj.dim.y); - ut_asserteq(-4, prev1->obj.x); - ut_asserteq(menu->obj.y + 32, prev1->obj.y); + ut_asserteq(-4, prev1->obj.dim.x); + ut_asserteq(menu->obj.dim.y + 32, prev1->obj.dim.y); ut_asserteq(false, prev1->obj.hide); expo_destroy(exp); -- 2.41.0.rc0.172.g3f132b7071-goog