Move textline key handling outside the loop so keys are always sent
to the highlighted textline, regardless of whether it is open. This
allows the textline to respond to keyboard input even if not in a popup
expo.
Otherwise continue to send keys to menus as now.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a function to render a single object by its ID. This provides a
convenient way to render individual objects without needing to look up
the object pointer first.
Assume that text mode is not used.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The highlight_id needs to be considered for non-popup expos as well. As
a first step, use the variable 'cur' for the current object, i.e. the
one that is highlighted.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Currently textlines only support text entry when with popup expos. In
some cases we want to have menu items to support this, e.g. to enter a
passphrase to unlock an encrypted disk.
Add the missing logic.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
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>
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>
When the size of an object is calculated from its contents, we should
not set the SCENEOF_SIZE_VALID flag. This flag prevents the object from
resizing if the font is changed, for example. The flag is intended to
mean that the size was explicitly set by the controller, so we should
generally not set it in the expo implementation.
It is also inefficient to search for the object ID when we already
have the object.
Update scene_set_default_bbox() to just set the size and request that
it be synced.
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
At present only highlightable objects can be clicked on, i.e. menus and
textlines. Update scene_find_obj_within() so that it can find any type
of object, if requested. Update all the callers to false, so things work
the same.
Since the scene is drawn by iterating through the list of objects, when
the user clicks somewhere we should look at the top-most object under
the mouse first. So reverse the direction of the object search.
Update the tests to cover this new feature.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Since the scene is drawn by iterating through the list of objects, when
the user clicks somewhere we should look at the top-most object under
the mouse first.
This is not true when a menu is popped up, since we only care about the
menu in that case.
Add a way to reverse the direction of the object search. For now there
are no new test cases, since OBJ_OVERLAP is a text object and cannot
currently be clicked on.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
It is easier to test this function directly than via click_check(). Set up
a test expo with an extra overlapping object and add some tests.
Update the existing render test to take account of the new object.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
When the object pointer is already available we don't want to have to
look it up. Provide a new is_within() function which takes an object
pointer instead of an ID.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a few functions which can convert a flag and an object type to
strings.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
When rendering an expo we should normally only need to draw the objects
which are marked dirty. Add a way to calculate the bounding box of
these.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
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>
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>
Implement clicking on an object in the scene. For now only menus and
textlines respond to this. For menus the behaviour is different for
popups than for normal menus.
Signed-off-by: Simon Glass <sjg@chromium.org>
For a textline it is possible to click into the edit field. Provide a
function to check whether a position is within this field.
Signed-off-by: Simon Glass <sjg@chromium.org>
To implement mouse clicks we need a way to figure out what the user has
clicked on. As a starting point, create a scene_menu_within() function
which returns the item containing an x, y coordinate.
Provide a helper function in scene.c for use with this. Add a simple
for completeness.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Fix up send_key_obj() to mention a missing argument. Add a bit more
detail in scene_send_key() to explain what 'processing' means.
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
If there is no console (e.g. in a test) this function segfaults. Add
the console as a parameter so it is clear that it is needed. Check for
it in the caller.
Signed-off-by: Simon Glass <sjg@chromium.org>
At present only an outline boxes is supported, albeit with a thickness
parameter. Provide a way to draw a filled rectangle.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
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>
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>
It is possible that positions, styling or even text have changed since
the scene was initially arranged, so recalculate the dimensions of all
objects before arranging the scene.
Signed-off-by: Simon Glass <sjg@chromium.org>
A menu's dimensions are currently only used for positioning the
component parts of the menu, i.e. the label, key, description and
preview.
Move the logic for this entirely into the scene_menu file and drop the
logic at the top level.
Signed-off-by: Simon Glass <sjg@chromium.org>
We always call this with false first, then true. Drop the parameter and
handle this within the function itself.
Signed-off-by: Simon Glass <sjg@chromium.org>
Moving from one scene to another should not result in the scene being
re-arranged. Drop this, so that tests can have more control of when
scenes are arranged.
Also drop the scene_arrange() call when applying a theme, for the same
reason.
Add the now-required scene_arrange() to cedit and bootmenu
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
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>
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>
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>
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>
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>
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>
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>
In some cases it is useful to obtain more than just two bounding boxes
from a menu, e.g. to line up all descriptions vertically.
Use an array to obtain bounding-box information and calculate it
separately for each item.
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
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>
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>
This construct appears in various places. Reduce code size by adding a
function for it.
It inits the abuf, then allocates it to the requested size.
Signed-off-by: Simon Glass <sjg@chromium.org>
Expo needs to be able to word-wrap lines so that they are displayed as
the user expects. Add a limit on the width of each line and support this
in the measurement algorithm.
Add a log category to truetype while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Update the vidconsole API so that measure() can measure multiple lines
of text. This will make it easier to implement multi-line fields in
expo.
Tidy up the function comments while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>