78 Commits

Author SHA1 Message Date
Simon Glass
9b0bd72935 expo: Add prompt_id to struct scene
Add a prompt_id field to struct scene to track the prompt text object.
Update cedit_arange() to use title_id and prompt_id directly instead
of looking up objects by name, which is more robust.

Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 11:53:55 -07:00
Simon Glass
6926f89a20 expo: Support hiding password entry
Some fields may have sensitive information. Allow it to be obscured
during entry, in case someone is watching the display nearby.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-14 12:00:31 -07:00
Simon Glass
5e892b5ea2 expo: Clarify that text objects are not string IDs
Add a reminder in the struct comments that a text ID is not a string ID.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-14 10:57:31 +01:00
Simon Glass
2575f78957 expo: Allow applying the theme to just the display
In some cases it is useful to apply the display-related theme elements
without touching the objects. Add an argument to expo_apply_theme() to
support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-14 10:57:31 +01:00
Simon Glass
bea3b16617 expo: Avoid setting SCENEOF_SIZE_VALID with menu items
The font size of menu items might change, thus requiring the size to
be updated. So it is not correct to mark the items as fixed size.

Drop this code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-14 10:57:31 +01:00
Simon Glass
e94de63e6c expo: Add a way to select settings
In some cases it is useful to provide a settings scene, or perhaps just
a button to change the layout. Add support for this.
2025-10-10 03:11:26 +01:00
Simon Glass
47e05ed19e expo: Support clicking on any type of object
It is sometimes useful to be able to click on an image (sometimes called
an icon). Allow this within expo and return new click action.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 03:11:18 +01:00
Simon Glass
7d91a4b457 expo: Provide a way to dump an expo
For debugging it is sometimes helpful to dump an expo. Add an
implementation of this, writing to a membuf.

Add a MAINTAINERS entry for expo, including this next file.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 02:24:07 +01:00
Simon Glass
a5c5b3b2fb expo: Speed up polling the keyboard
The current algorithm spends 10ms or more looking for keyboard input.
Since we expect the frame rate to be 50 or more, it should be OK to only
check once.

Handle the timeout by recording the timestamp of the last key and timing
out the CLI entry after 10ms. This allows an 'Escape' key to work,
rather than it just waiting forever for a terminal sequence that starts
with escape.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
f95a85e1a6 expo: Track the number of render calls
Keep track of the frame count, i.e. the number of times that
expo_render() has been called since expo_enter_mode() was invoked.

Allow test mode to be enabled (if compiled in) by setting the 'expotest'
environment variable to 1.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
10f0e9f4ca expo: Support drawing only the dirty portion of an expo
To optimise drawing on the display, provide a new function which draws
only the part of the display which is marked as dirty.

Series-to: concept
Cover-letter:
expo: Continue development of expo with mouse
This series integrates mouse support into expo and starts to build the
infrastructure for drawing the mouse pointer more efficiently (i.e.
without re-rendering the entire scene).

It also adds a few more structs to video_defs.h for position and size.

This is part D.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 10:11:05 -06:00
Simon Glass
f2909a4cde expo: Set dirty flag when an object bbox changes
Add a flag to indicate that am object must be redrawn. Set this flag
when an object's bounding box changes.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 10:11:04 -06:00
Simon Glass
cec177e67b expo: Add damage tracking
As a few step towards making rendering more efficient, add support for
tracking video damage within an expo.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 10:04:36 -06:00
Simon Glass
3e8147c8e4 expo: Drop struct scene_obj_bbox in favour of vid_bbox
Replace the scene_obj_bbox with the common vid_bbox structure to avoid
having the same structs with different names.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 10:04:36 -06:00
Simon Glass
c4e7c60e97 expo: Show the mouse when enabled
When the mouse is enabled, show it at its new position each time the
expo is rendered.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 10:04:35 -06:00
Simon Glass
ef117db9c3 expo: Store mouse pointer and size in expo
Store the mouse pointer image and its dimensions in the expo structure
when mouse support is enabled. This avoids repeatedly looking up the
image and calculating its size.

Use struct vid_size to store the mouse pointer dimensions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 10:03:29 -06:00
Simon Glass
0efc5f0ffc expo: Allow manual positioning of menu items
Sometimes we want to position items individually rather than relying on
the automatic scene layout. Provide a flag for this, expanding the type
to cope.

Also add an assertion that the flags fit in the available space.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-25 09:47:09 -06:00
Simon Glass
a6fd275924 expo: Support sending a click to an expo
Implement clicking on an expo, which simply passes it onto the scene.
For now, there are no callers for this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:13 -06:00
Simon Glass
92a2b06a3b expo: Add three new actions for mouse events
Popup menus have particular behaviour which needs to be modelled in
the expoact_type enum:

- clicking on a menu item should select it and close the menu
- clicking on a menu should highlight it and open the menu
- clicking on a menu while another menu is open should select the item,
  close the menu, then open the other menu

Add actions associated with each of these. These are modelled as
combined actions for simplicity.

Implement the actions in cedit. The general expo support will come
later.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
1c6269576a expo: Tidy up comments for enum expoact_type
Some of the comments in this enum and the struct which uses it are
out-of-date. Fix this up.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
d738ddf73f expo: Provide a way to enable the mouse
In some cases it is useful to use expo with a mouse (or touchpad). Add
a way to tell expo to find and record a mouse device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
9f3b86c8f6 expo: Support boxes fully
At present boxes are not supported in the expo_build format. Also, it is
now possible to draw filled boxes, a recently added feature to the video
API.

Expand the box feature slightly to resolve these two items.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
2b226cb9e7 expo: Allow changing scene_img data
In some cases we want to change the image data used by a scene_img. Add
a function to handle this.

Adjust the BMP function to use a const for the data, since it is not
allowed to change it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-05 13:59:50 -06:00
Simon Glass
872733ec11 expo: Allow the nominal display-size to be selected
At present all coordinates are absolute and must fit within the display.
This makes it hard to create an expo which can work on any size of
display, a key goal of expo.

Add the concept of a nominal size, to which all coordinates conform. Once
the real display-size is known, expo can in principle (i.e. with later
work) scale the coordinates and objects according.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-05 13:59:50 -06:00
Simon Glass
b03ea854d4 expo: Indicate with the pointed-to item has changed
Allow the caller to detect when a keypress has actually resulted in a
change of the item that is pointed to.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-05 13:59:50 -06:00
Simon Glass
e27b36c015 expo: Tidy up insets and improve tests
Insets are handled inconsistently at present, since menus use them to
offset the label text, whereas textlines don't. This is done because
menus need the margin to be visible when opened. However this causes an
alignment issue when menus and textlines appear in the same cedit.

Remove the offsets from menus and compensate by adjusting the bounding
boxes used for highlighting and the opened menu.

Line up menu items and textlines vertically and add a style option for
textlines to control how much padding is added.

Add a test to check the positions of objects in a cedit, since this is
more direct than the rendering tests. Add style information so that the
impact can be seen.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 08:19:02 +01:00
Simon Glass
44ac51e503 expo: Separate requested bbox from actual
With fixed coordinates it is difficult to create scenes that can work on
any display size. Add a separate 'requested' bounding box for each
object and sync it when required.

With future work, this will allow scaling the nominal coordinates so
that an expo can be rendered correctly on a wider range of displays.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 08:19:02 +01:00
Simon Glass
d854e1a777 expo: Record the pointer position in the menu item
Rather than drawing the poointer with a hard-coded position elsewhere in
the code, add a field to hold this value.

Move the check for the pointer position up so that the ordering of the
tests matches the order that the fields are dealt with in
scene_menu_arrange()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 08:19:01 +01:00
Simon Glass
04110615e0 expo: Separate out reading the theme from applying it
Rename the existing expo_apply_theme() to expo_setup_theme() and adjust
the former so that it applies a theme which has already been read into
the struct. This will make it easier for tests to check theme
adjustments, since they won't have to put them in a node.

Add the white-on-black property into the theme struct while we are.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 08:19:01 +01:00
Simon Glass
f20a1818cf expo: Create a function to arrange the current scene
Provide a convenient function which arranges the current scene in an
expo. Make use of this in bootflow_menu

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 08:19:01 +01:00
Simon Glass
baa389273a expo: Comment scene_obj fields which are for internal use
A few fields should not be changed by the controller code. Add a comment
so this is obvious.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 08:19:01 +01:00
Simon Glass
c0df894714 expo: Provide a way to position things relative to display
It is often necessary to centre objects within the display area. Add a
special position value to indicate this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
e42503b8d2 expo: Drop the render from expo_poll()
Within tests it is useful to be able to control rendering of the expo.
Drop the automatic call to expo_render() within expo_poll() and adjust
its callers to handle this instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
5214728e0b 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 <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
c256ad374f expo: Begin implementation of a text editor
It is useful to be able to edit text, e.g. to allow the user to edit the
environment or the command-line arguments for the OS.

Add the beginnings of an implementation. Future work is needed to finish
this: keypress handling and scrolling. For now it just displays the
text.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
eb84e601b3 expo: Support object alignment
Add support for left, right and centred alignment for text, in the
horizontal dimension.

Also support top, bottom and centred in the vertical dimension, for the
text object as a whole.

Alignment is not yet implemented for images. It has no meaning for
menus. A textline object uses a text object internally, so alignment
is supported there.

Provide some documentation to explain how objects are positioned.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
59f4889d42 expo: Implement a box
It is useful to be able to draw a box around elements in the menu. Add
support for an unfilled box with a selectable thickness.

Note that there is no support for selecting the colour for any expo
objects yet.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
a2d70450dd expo: Support rendering multiple lines of text
Use the measurement info to write each line of text separately, thus
respecting word-wrapping and newlines.

Fix up the comment for scene_obj_render() while we are here.

Since a lineedit does not support alignment, add a special case to just
display the text if there is no measurement. This happens assuming the
lineedit is initially empty.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
44e2655363 expo: Allow strings to be editable
In some cases dynamic text is needed, e.g. for a menu countdown. Add a
function which handles this, allowing the caller to take control of the
text that is shown on each render.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:52 -06:00
Simon Glass
b12300aa80 expo: Create a struct for generic text attributes
In preparation for adding more text types, refactor the common fields
into a new structure. This will allow common code to be used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
dc3e8f2a82 expo: Support setting the size and bounds of an object
Add a function to allow the size of an object to be set independently
of its position.

Also add a function to permit the object's bounding box to be set
independently of its dimensions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
8d4237592a expo: Separate dimensions from the bounding box
At present each object has a width and height and the bounding box is
implicit in that.

This is not flexible enough to handle objects which are larger than
their contents might need. For example, when centring a text object we
might want to have it stretch across the whole width of the display even
if the text itself does not need that much space.

Create a new 'dimensions' field and convert the existing width/height
into x1/y1 coordinates.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
bc6c19c87b expo: Use an abuf to hold strings
It is more convenient to put strings in an abuf so they can easily be
resized. Adjust the struct accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
6e1bc5458a expo: Rename x and y in struct scene_obj_bbox
These coordinates are the top left values, so rename them to x0 and y0
in preparation for changing the width and height to x1 and y1

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
bddff11f93 expo: Rename scene_dim to scene_obj_bbox
At present we assume that each object is a simple box and that it fills
the whole box.

This is quite limiting for text objects, which we may want to centre
within the box. We need a position within the box where drawing starts.

Rename the scene_dim struct to indicate that it is a bounding box.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
9af358a1dd expo: Provide access to the current menu item
Add functions to allow a caller to find out the current menu item and to
select a different one.

Update the event handling so that an attempt to change the current item
(e.g. by pressing the up-arrow key) is reported to the caller, since
this may be used to cancel an autoboot timeout.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
ccbd363252 expo: Move cedit-state fields into expo
Move the boolean flags into struct expo so that the state can be
maintained over function calls.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
a781c37746 expo: Add a function to poll for input
Both bootflow_menu and cedit use similar logic to poll an expo. Move
this into the expo library so the code can be shared.

Update bootflow_menu_run() to return -EPIPE when the user quits without
choosing anything, since -EAGAIN is ambiguous and elsewhere means that
there is no input yet.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
280b9bf36f expo: Add CLI context to the expo
An expo generally needs to keep track of the keyboard state while it is
running, so move the context into struct expo

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-02 09:45:51 -06:00
Simon Glass
ae3b5928d6 x86: coreboot: Allow building an expo for editing CMOS config
Coreboot provides the CMOS layout in the tables it passes to U-Boot.
Use that to build an editor for the CMOS settings.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-11-03 21:27:12 -06:00