diff options
| author | Simon Glass <[email protected]> | 2025-05-02 08:46:50 -0600 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2025-05-30 09:49:32 +0100 |
| commit | 0dc8c7740c8f5a7155259f0e55618f8006c0d7af (patch) | |
| tree | 55113e06998142b60e31126d5e735154ed4a33ad /boot | |
| parent | 86acc21d854cbd881d1612c6b8528de0a577b91e (diff) | |
expo: Support highlighting menu items
Expo normally uses a pointer to show the current item. Add support for
highlighting as well, since this makes it easier for the user to see the
current item.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/cedit.c | 1 | ||||
| -rw-r--r-- | boot/scene.c | 31 | ||||
| -rw-r--r-- | boot/scene_menu.c | 14 |
3 files changed, 33 insertions, 13 deletions
diff --git a/boot/cedit.c b/boot/cedit.c index 54810257fb9..8faf230a9e2 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -126,6 +126,7 @@ int cedit_prepare(struct expo *exp, struct udevice *vid_dev, return log_msg_ret("sid", ret); exp->popup = true; + exp->show_highlight = true; /* This is not supported for now */ if (0) diff --git a/boot/scene.c b/boot/scene.c index c8dc1716f1d..237f2bccc00 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -466,8 +466,10 @@ int scene_obj_get_hw(struct scene *scn, uint id, int *widthp) * @obj: Object to render * @box_only: true to show a box around the object, but keep the normal * background colour inside + * @cur_item: true to render the background only for the current menu item */ -static void scene_render_background(struct scene_obj *obj, bool box_only) +static void scene_render_background(struct scene_obj *obj, bool box_only, + bool cur_item) { struct vidconsole_bbox bbox[SCENEBB_count], *sel; struct expo *exp = obj->scene->expo; @@ -493,7 +495,7 @@ static void scene_render_background(struct scene_obj *obj, bool box_only) if (scene_obj_calc_bbox(obj, bbox)) return; - sel = &bbox[SCENEBB_label]; + sel = cur_item ? &bbox[SCENEBB_curitem] : &bbox[SCENEBB_label]; if (!sel->valid) return; @@ -547,9 +549,13 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, } if (obj->flags & SCENEOF_POINT) { + int inset; + + inset = exp->popup ? menu_inset : 0; vidconsole_push_colour(cons, fore, back, &old); - video_fill_part(dev, x - menu_inset, y, obj->bbox.x1, - obj->bbox.y1, vid_priv->colour_bg); + video_fill_part(dev, x - inset, y, + obj->bbox.x1, obj->bbox.y1, + vid_priv->colour_bg); } mline = alist_get(&gen->lines, 0, typeof(*mline)); @@ -632,13 +638,18 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) case SCENEOBJT_MENU: { struct scene_obj_menu *menu = (struct scene_obj_menu *)obj; - if (exp->popup && (obj->flags & SCENEOF_OPEN)) { - if (!cons) - return -ENOTSUPP; + if (exp->popup) { + if (obj->flags & SCENEOF_OPEN) { + if (!cons) + return -ENOTSUPP; - /* draw a background behind the menu items */ - scene_render_background(obj, false); + /* draw a background behind the menu items */ + scene_render_background(obj, false, false); + } + } else if (exp->show_highlight) { + /* do nothing */ } + /* * With a vidconsole, the text and item pointer are rendered as * normal objects so we don't need to do anything here. The menu @@ -655,7 +666,7 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) } case SCENEOBJT_TEXTLINE: if (obj->flags & SCENEOF_OPEN) - scene_render_background(obj, true); + scene_render_background(obj, true, false); break; case SCENEOBJT_BOX: { struct scene_obj_box *box = (struct scene_obj_box *)obj; diff --git a/boot/scene_menu.c b/boot/scene_menu.c index de433ece6ee..8db6a2b2f4d 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -87,7 +87,7 @@ struct scene_menitem *scene_menuitem_find_val(const struct scene_obj_menu *menu, static int update_pointers(struct scene_obj_menu *menu, uint id, bool point) { struct scene *scn = menu->obj.scene; - const bool stack = scn->expo->popup; + const bool stack = scn->expo->show_highlight; const struct scene_menitem *item; int ret; @@ -108,9 +108,17 @@ static int update_pointers(struct scene_obj_menu *menu, uint id, bool point) } if (stack) { + uint id; + int val; + point &= scn->highlight_id == menu->obj.id; - scene_obj_flag_clrset(scn, item->label_id, SCENEOF_POINT, - point ? SCENEOF_POINT : 0); + val = point ? SCENEOF_POINT : 0; + id = item->desc_id; + if (!id) + id = item->label_id; + if (!id) + id = item->key_id; + scene_obj_flag_clrset(scn, id, SCENEOF_POINT, val); } return 0; |
