blob: 8cb37260db53e8904ecec7254868934f812a4513 [file] [log] [blame]
Simon Glass87c6f8a2023-01-06 08:52:36 -06001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright 2022 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
Simon Glass040b0462023-08-14 16:40:25 -06007#ifndef __EXPO_H
8#define __EXPO_H
Simon Glass87c6f8a2023-01-06 08:52:36 -06009
Simon Glass93f99b32023-10-01 19:13:31 -060010#include <abuf.h>
Simon Glass2e593892023-06-01 10:22:53 -060011#include <dm/ofnode_decl.h>
Simon Glass87c6f8a2023-01-06 08:52:36 -060012#include <linux/list.h>
13
14struct udevice;
15
Simon Glass93f99b32023-10-01 19:13:31 -060016#include <cli.h>
17
Simon Glass87c6f8a2023-01-06 08:52:36 -060018/**
Simon Glassd8ff97c2024-10-14 16:31:57 -060019 * enum expo_id_t - standard expo IDs
20 *
21 * These are assumed to be in use at all times. Expos should use IDs starting
22 * from EXPOID_BASE_ID,
23 *
24 * @EXPOID_NONE: Not used, invalid ID 0
25 * @EXPOID_SAVE: User has requested that the expo data be saved
26 * @EXPOID_DISCARD: User has requested that the expo data be discarded
27 * @EXPOID_BASE_ID: First ID which can be used for expo objects
28 */
29enum expo_id_t {
30 EXPOID_NONE,
31
32 EXPOID_SAVE,
33 EXPOID_DISCARD,
34
35 EXPOID_BASE_ID = 5,
36};
37
38/**
Simon Glass87c6f8a2023-01-06 08:52:36 -060039 * enum expoact_type - types of actions reported by the expo
40 *
41 * @EXPOACT_NONE: no action
Simon Glass4e64bee2023-06-01 10:22:59 -060042 * @EXPOACT_POINT_OBJ: object was highlighted (@id indicates which)
Simon Glass3f33b9c2023-06-01 10:22:56 -060043 * @EXPOACT_POINT_ITEM: menu item was highlighted (@id indicates which)
Simon Glass87c6f8a2023-01-06 08:52:36 -060044 * @EXPOACT_SELECT: menu item was selected (@id indicates which)
Simon Glass4e64bee2023-06-01 10:22:59 -060045 * @EXPOACT_OPEN: menu was opened, so an item can be selected (@id indicates
46 * which menu object)
47 * @EXPOACT_CLOSE: menu was closed (@id indicates which menu object)
Simon Glass87c6f8a2023-01-06 08:52:36 -060048 * @EXPOACT_QUIT: request to exit the menu
49 */
50enum expoact_type {
51 EXPOACT_NONE,
Simon Glass4e64bee2023-06-01 10:22:59 -060052 EXPOACT_POINT_OBJ,
Simon Glass3f33b9c2023-06-01 10:22:56 -060053 EXPOACT_POINT_ITEM,
Simon Glass87c6f8a2023-01-06 08:52:36 -060054 EXPOACT_SELECT,
Simon Glass4e64bee2023-06-01 10:22:59 -060055 EXPOACT_OPEN,
56 EXPOACT_CLOSE,
Simon Glass87c6f8a2023-01-06 08:52:36 -060057 EXPOACT_QUIT,
58};
59
60/**
61 * struct expo_action - an action report by the expo
62 *
63 * @type: Action type (EXPOACT_NONE if there is no action)
Simon Glass3f33b9c2023-06-01 10:22:56 -060064 * @select: Used for EXPOACT_POINT_ITEM and EXPOACT_SELECT
Heinrich Schuchardtd168c632024-09-18 23:58:03 +020065 * @select.id: ID number of the object affected.
Simon Glass87c6f8a2023-01-06 08:52:36 -060066 */
67struct expo_action {
68 enum expoact_type type;
69 union {
70 struct {
71 int id;
72 } select;
73 };
74};
75
76/**
Simon Glass2e593892023-06-01 10:22:53 -060077 * struct expo_theme - theme for the expo
78 *
79 * @font_size: Default font size for all text
80 * @menu_inset: Inset width (on each side and top/bottom) for menu items
81 * @menuitem_gap_y: Gap between menu items in pixels
Simon Glass54eca1d2024-10-14 16:31:55 -060082 * @menu_title_margin_x: Gap between right side of menu title and left size of
83 * menu label
Simon Glass2e593892023-06-01 10:22:53 -060084 */
85struct expo_theme {
86 u32 font_size;
87 u32 menu_inset;
88 u32 menuitem_gap_y;
Simon Glass54eca1d2024-10-14 16:31:55 -060089 u32 menu_title_margin_x;
Simon Glass2e593892023-06-01 10:22:53 -060090};
91
92/**
Simon Glass87c6f8a2023-01-06 08:52:36 -060093 * struct expo - information about an expo
94 *
95 * A group of scenes which can be presented to the user, typically to obtain
96 * input or to make a selection.
97 *
98 * @name: Name of the expo (allocated)
99 * @display: Display to use (`UCLASS_VIDEO`), or NULL to use text mode
Simon Glass42b18492023-06-01 10:22:34 -0600100 * @cons: Console to use (`UCLASS_VIDEO_CONSOLE`), or NULL to use text mode
Simon Glass87c6f8a2023-01-06 08:52:36 -0600101 * @scene_id: Current scene ID (0 if none)
102 * @next_id: Next ID number to use, for automatic allocation
103 * @action: Action selected by user. At present only one is supported, with the
104 * type set to EXPOACT_NONE if there is no action
105 * @text_mode: true to use text mode for the menu (no vidconsole)
Simon Glassd3db0212023-06-01 10:22:55 -0600106 * @popup: true to use popup menus, instead of showing all items
Simon Glass87c6f8a2023-01-06 08:52:36 -0600107 * @priv: Private data for the controller
Simon Glass2e593892023-06-01 10:22:53 -0600108 * @theme: Information about fonts styles, etc.
Simon Glass87c6f8a2023-01-06 08:52:36 -0600109 * @scene_head: List of scenes
110 * @str_head: list of strings
111 */
112struct expo {
113 char *name;
114 struct udevice *display;
Simon Glass42b18492023-06-01 10:22:34 -0600115 struct udevice *cons;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600116 uint scene_id;
117 uint next_id;
118 struct expo_action action;
119 bool text_mode;
Simon Glassd3db0212023-06-01 10:22:55 -0600120 bool popup;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600121 void *priv;
Simon Glass2e593892023-06-01 10:22:53 -0600122 struct expo_theme theme;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600123 struct list_head scene_head;
124 struct list_head str_head;
125};
126
127/**
128 * struct expo_string - a string that can be used in an expo
129 *
130 * @id: ID number of the string
131 * @str: String
132 * @sibling: Node to link this object to its siblings
133 */
134struct expo_string {
135 uint id;
136 const char *str;
137 struct list_head sibling;
138};
139
140/**
141 * struct scene - information about a scene in an expo
142 *
143 * A collection of text/image/menu items in an expo
144 *
145 * @expo: Expo this scene is part of
146 * @name: Name of the scene (allocated)
147 * @id: ID number of the scene
Simon Glassdef898c2023-06-01 10:22:27 -0600148 * @title_id: String ID of title of the scene (allocated)
Simon Glassd3db0212023-06-01 10:22:55 -0600149 * @highlight_id: ID of highlighted object, if any
Simon Glass93f99b32023-10-01 19:13:31 -0600150 * @cls: cread state to use for input
151 * @buf: Buffer for input
152 * @entry_save: Buffer to hold vidconsole text-entry information
Simon Glass87c6f8a2023-01-06 08:52:36 -0600153 * @sibling: Node to link this scene to its siblings
154 * @obj_head: List of objects in the scene
155 */
156struct scene {
157 struct expo *expo;
158 char *name;
159 uint id;
Simon Glassdef898c2023-06-01 10:22:27 -0600160 uint title_id;
Simon Glassd3db0212023-06-01 10:22:55 -0600161 uint highlight_id;
Simon Glass93f99b32023-10-01 19:13:31 -0600162 struct cli_line_state cls;
163 struct abuf buf;
164 struct abuf entry_save;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600165 struct list_head sibling;
166 struct list_head obj_head;
167};
168
169/**
170 * enum scene_obj_t - type of a scene object
171 *
172 * @SCENEOBJT_NONE: Used to indicate that the type does not matter
173 * @SCENEOBJT_IMAGE: Image data to render
174 * @SCENEOBJT_TEXT: Text line to render
175 * @SCENEOBJT_MENU: Menu containing items the user can select
Simon Glass4db75192023-10-01 19:13:32 -0600176 * @SCENEOBJT_TEXTLINE: Line of text the user can edit
Simon Glass87c6f8a2023-01-06 08:52:36 -0600177 */
178enum scene_obj_t {
179 SCENEOBJT_NONE = 0,
180 SCENEOBJT_IMAGE,
181 SCENEOBJT_TEXT,
Simon Glassd88edd22023-10-01 19:13:27 -0600182
183 /* types from here on can be highlighted */
Simon Glass87c6f8a2023-01-06 08:52:36 -0600184 SCENEOBJT_MENU,
Simon Glass4db75192023-10-01 19:13:32 -0600185 SCENEOBJT_TEXTLINE,
Simon Glass87c6f8a2023-01-06 08:52:36 -0600186};
187
188/**
Simon Glassae45d6c2023-06-01 10:22:49 -0600189 * struct scene_dim - Dimensions of an object
190 *
191 * @x: x position, in pixels from left side
192 * @y: y position, in pixels from top
193 * @w: width, in pixels
194 * @h: height, in pixels
195 */
196struct scene_dim {
197 int x;
198 int y;
199 int w;
200 int h;
201};
202
203/**
Simon Glassce72c9e2023-06-01 10:22:50 -0600204 * enum scene_obj_flags_t - flags for objects
205 *
206 * @SCENEOF_HIDE: object should be hidden
Simon Glassd3db0212023-06-01 10:22:55 -0600207 * @SCENEOF_POINT: object should be highlighted
208 * @SCENEOF_OPEN: object should be opened (e.g. menu is opened so that an option
209 * can be selected)
Simon Glassce72c9e2023-06-01 10:22:50 -0600210 */
211enum scene_obj_flags_t {
212 SCENEOF_HIDE = 1 << 0,
Simon Glassd3db0212023-06-01 10:22:55 -0600213 SCENEOF_POINT = 1 << 1,
214 SCENEOF_OPEN = 1 << 2,
Simon Glassce72c9e2023-06-01 10:22:50 -0600215};
216
Simon Glass93f99b32023-10-01 19:13:31 -0600217enum {
218 /* Maximum number of characters allowed in an line editor */
219 EXPO_MAX_CHARS = 250,
220};
221
Simon Glassce72c9e2023-06-01 10:22:50 -0600222/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600223 * struct scene_obj - information about an object in a scene
224 *
225 * @scene: Scene that this object relates to
226 * @name: Name of the object (allocated)
227 * @id: ID number of the object
228 * @type: Type of this object
Simon Glassae45d6c2023-06-01 10:22:49 -0600229 * @dim: Dimensions for this object
Simon Glassce72c9e2023-06-01 10:22:50 -0600230 * @flags: Flags for this object
Simon Glasseb6c71b2023-08-14 16:40:37 -0600231 * @bit_length: Number of bits used for this object in CMOS RAM
232 * @start_bit: Start bit to use for this object in CMOS RAM
Simon Glass87c6f8a2023-01-06 08:52:36 -0600233 * @sibling: Node to link this object to its siblings
234 */
235struct scene_obj {
236 struct scene *scene;
237 char *name;
238 uint id;
239 enum scene_obj_t type;
Simon Glassae45d6c2023-06-01 10:22:49 -0600240 struct scene_dim dim;
Simon Glasseb6c71b2023-08-14 16:40:37 -0600241 u8 flags;
242 u8 bit_length;
243 u16 start_bit;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600244 struct list_head sibling;
245};
246
Simon Glassd88edd22023-10-01 19:13:27 -0600247/* object can be highlighted when moving around expo */
248static inline bool scene_obj_can_highlight(const struct scene_obj *obj)
249{
250 return obj->type >= SCENEOBJT_MENU;
251}
252
Simon Glass87c6f8a2023-01-06 08:52:36 -0600253/**
254 * struct scene_obj_img - information about an image object in a scene
255 *
256 * This is a rectangular image which is blitted onto the display
257 *
258 * @obj: Basic object information
259 * @data: Image data in BMP format
260 */
261struct scene_obj_img {
262 struct scene_obj obj;
263 char *data;
264};
265
266/**
267 * struct scene_obj_txt - information about a text object in a scene
268 *
269 * This is a single-line text object
270 *
271 * @obj: Basic object information
272 * @str_id: ID of the text string to display
273 * @font_name: Name of font (allocated by caller)
274 * @font_size: Nominal size of font in pixels
275 */
276struct scene_obj_txt {
277 struct scene_obj obj;
278 uint str_id;
279 const char *font_name;
280 uint font_size;
281};
282
283/**
284 * struct scene_obj_menu - information about a menu object in a scene
285 *
286 * A menu has a number of items which can be selected by the user
287 *
288 * It also has:
289 *
290 * - a text/image object (@pointer_id) which points to the current item
291 * (@cur_item_id)
292 *
293 * - a preview object which shows an image related to the current item
294 *
295 * @obj: Basic object information
296 * @title_id: ID of the title text, or 0 if none
297 * @cur_item_id: ID of the current menu item, or 0 if none
298 * @pointer_id: ID of the object pointing to the current selection
299 * @item_head: List of items in the menu
300 */
301struct scene_obj_menu {
302 struct scene_obj obj;
303 uint title_id;
304 uint cur_item_id;
305 uint pointer_id;
306 struct list_head item_head;
307};
308
309/**
310 * enum scene_menuitem_flags_t - flags for menu items
311 *
312 * @SCENEMIF_GAP_BEFORE: Add a gap before this item
313 */
314enum scene_menuitem_flags_t {
315 SCENEMIF_GAP_BEFORE = 1 << 0,
316};
317
318/**
319 * struct scene_menitem - a menu item in a menu
320 *
321 * A menu item has:
322 *
323 * - text object holding the name (short) and description (can be longer)
324 * - a text object holding the keypress
325 *
326 * @name: Name of the item (this is allocated by this call)
327 * @id: ID number of the object
328 * @key_id: ID of text object to use as the keypress to show
329 * @label_id: ID of text object to use as the label text
330 * @desc_id: ID of text object to use as the description text
331 * @preview_id: ID of the preview object, or 0 if none
332 * @flags: Flags for this item
Simon Glass012e1e82024-10-14 16:31:58 -0600333 * @value: Value for this item, or INT_MAX to use sequence
Simon Glass87c6f8a2023-01-06 08:52:36 -0600334 * @sibling: Node to link this item to its siblings
335 */
336struct scene_menitem {
337 char *name;
338 uint id;
339 uint key_id;
340 uint label_id;
341 uint desc_id;
342 uint preview_id;
343 uint flags;
Simon Glass012e1e82024-10-14 16:31:58 -0600344 int value;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600345 struct list_head sibling;
346};
347
348/**
Simon Glass4db75192023-10-01 19:13:32 -0600349 * struct scene_obj_textline - information about a textline in a scene
350 *
351 * A textline has a prompt and a line of editable text
352 *
353 * @obj: Basic object information
354 * @label_id: ID of the label text, or 0 if none
355 * @edit_id: ID of the editable text
356 * @max_chars: Maximum number of characters allowed
357 * @buf: Text buffer containing current text
358 * @pos: Cursor position
359 */
360struct scene_obj_textline {
361 struct scene_obj obj;
362 uint label_id;
363 uint edit_id;
364 uint max_chars;
365 struct abuf buf;
366 uint pos;
367};
368
369/**
Simon Glass54eca1d2024-10-14 16:31:55 -0600370 * struct expo_arrange_info - Information used when arranging a scene
371 *
372 * @label_width: Maximum width of labels in scene
373 */
374struct expo_arrange_info {
375 int label_width;
376};
377
378/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600379 * expo_new() - create a new expo
380 *
381 * Allocates a new expo
382 *
383 * @name: Name of expo (this is allocated by this call)
384 * @priv: Private data for the controller
385 * @expp: Returns a pointer to the new expo on success
386 * Returns: 0 if OK, -ENOMEM if out of memory
387 */
388int expo_new(const char *name, void *priv, struct expo **expp);
389
390/**
391 * expo_destroy() - Destroy an expo and free all its memory
392 *
393 * @exp: Expo to destroy
394 */
395void expo_destroy(struct expo *exp);
396
397/**
Simon Glass9af34152023-06-01 10:22:47 -0600398 * expo_set_dynamic_start() - Set the start of the 'dynamic' IDs
399 *
400 * It is common for a set of 'static' IDs to be used to refer to objects in the
401 * expo. These typically use an enum so that they are defined in sequential
402 * order.
403 *
404 * Dynamic IDs (for objects not in the enum) are intended to be used for
405 * objects to which the code does not need to refer. These are ideally located
406 * above the static IDs.
407 *
408 * Use this function to set the start of the dynamic range, making sure that the
409 * value is higher than all the statically allocated IDs.
410 *
411 * @exp: Expo to update
412 * @dyn_start: Start ID that expo should use for dynamic allocation
413 */
414void expo_set_dynamic_start(struct expo *exp, uint dyn_start);
415
416/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600417 * expo_str() - add a new string to an expo
418 *
419 * @exp: Expo to update
420 * @name: Name to use (this is allocated by this call)
421 * @id: ID to use for the new object (0 to allocate one)
422 * @str: Pointer to text to display (allocated by caller)
423 * Returns: ID number for the object (typically @id), or -ve on error
424 */
425int expo_str(struct expo *exp, const char *name, uint id, const char *str);
426
427/**
428 * expo_get_str() - Get a string by ID
429 *
430 * @exp: Expo to use
431 * @id: String ID to look up
432 * @returns string, or NULL if not found
433 */
434const char *expo_get_str(struct expo *exp, uint id);
435
436/**
437 * expo_set_display() - set the display to use for a expo
438 *
439 * @exp: Expo to update
440 * @dev: Display to use (`UCLASS_VIDEO`), NULL to use text mode
441 * Returns: 0 (always)
442 */
443int expo_set_display(struct expo *exp, struct udevice *dev);
444
445/**
Simon Glass699b0ac2023-06-01 10:22:52 -0600446 * expo_calc_dims() - Calculate the dimensions of the objects
447 *
448 * Updates the width and height of all objects based on their contents
449 *
450 * @exp: Expo to update
451 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
452 */
453int expo_calc_dims(struct expo *exp);
454
455/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600456 * expo_set_scene_id() - Set the current scene ID
457 *
458 * @exp: Expo to update
459 * @scene_id: New scene ID to use (0 to select no scene)
460 * Returns: 0 if OK, -ENOENT if there is no scene with that ID
461 */
462int expo_set_scene_id(struct expo *exp, uint scene_id);
463
464/**
Simon Glassa0874dc2023-06-01 10:23:02 -0600465 * expo_first_scene_id() - Get the ID of the first scene
466 *
467 * @exp: Expo to check
468 * Returns: Scene ID of first scene, or -ENOENT if there are no scenes
469 */
470int expo_first_scene_id(struct expo *exp);
471
472/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600473 * expo_render() - render the expo on the display / console
474 *
475 * @exp: Expo to render
476 *
477 * Returns: 0 if OK, -ECHILD if there is no current scene, -ENOENT if the
478 * current scene is not found, other error if something else goes wrong
479 */
480int expo_render(struct expo *exp);
481
482/**
Simon Glass5904d952023-06-01 10:22:37 -0600483 * expo_set_text_mode() - Controls whether the expo renders in text mode
Simon Glass87c6f8a2023-01-06 08:52:36 -0600484 *
485 * @exp: Expo to update
486 * @text_mode: true to use text mode, false to use the console
487 */
Simon Glass5904d952023-06-01 10:22:37 -0600488void expo_set_text_mode(struct expo *exp, bool text_mode);
Simon Glass87c6f8a2023-01-06 08:52:36 -0600489
490/**
491 * scene_new() - create a new scene in a expo
492 *
493 * The scene is given the ID @id which must be unique across all scenes, objects
494 * and items. The expo's @next_id is updated to at least @id + 1
495 *
496 * @exp: Expo to update
497 * @name: Name to use (this is allocated by this call)
498 * @id: ID to use for the new scene (0 to allocate one)
499 * @scnp: Returns a pointer to the new scene on success
500 * Returns: ID number for the scene (typically @id), or -ve on error
501 */
502int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp);
503
504/**
505 * expo_lookup_scene_id() - Look up a scene by ID
506 *
507 * @exp: Expo to check
508 * @scene_id: Scene ID to look up
509 * @returns pointer to scene if found, else NULL
510 */
511struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
512
513/**
Simon Glass756c9552023-06-01 10:22:57 -0600514 * scene_highlight_first() - Highlight the first item in a scene
515 *
516 * This highlights the first item, so that the user can see that it is pointed
517 * to
518 *
519 * @scn: Scene to update
520 */
521void scene_highlight_first(struct scene *scn);
522
523/**
524 * scene_set_highlight_id() - Set the object which is highlighted
525 *
526 * Sets a new object to highlight in the scene
527 *
528 * @scn: Scene to update
529 * @id: ID of object to highlight
530 */
531void scene_set_highlight_id(struct scene *scn, uint id);
532
533/**
534 * scene_set_open() - Set whether an item is open or not
535 *
536 * @scn: Scene to update
537 * @id: ID of object to update
538 * @open: true to open the object, false to close it
539 * Returns: 0 if OK, -ENOENT if @id is invalid
540 */
541int scene_set_open(struct scene *scn, uint id, bool open);
542
543/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600544 * scene_obj_count() - Count the number of objects in a scene
545 *
546 * @scn: Scene to check
547 * Returns: number of objects in the scene, 0 if none
548 */
549int scene_obj_count(struct scene *scn);
550
551/**
552 * scene_img() - add a new image to a scene
553 *
554 * @scn: Scene to update
555 * @name: Name to use (this is allocated by this call)
556 * @id: ID to use for the new object (0 to allocate one)
557 * @data: Pointer to image data
558 * @imgp: If non-NULL, returns the new object
559 * Returns: ID number for the object (typically @id), or -ve on error
560 */
561int scene_img(struct scene *scn, const char *name, uint id, char *data,
562 struct scene_obj_img **imgp);
563
564/**
565 * scene_txt() - add a new text object to a scene
566 *
567 * @scn: Scene to update
568 * @name: Name to use (this is allocated by this call)
569 * @id: ID to use for the new object (0 to allocate one)
570 * @str_id: ID of the string to use
571 * @txtp: If non-NULL, returns the new object
572 * Returns: ID number for the object (typically @id), or -ve on error
573 */
574int scene_txt(struct scene *scn, const char *name, uint id, uint str_id,
575 struct scene_obj_txt **txtp);
576
577/**
Simon Glass909c4862023-10-01 19:13:23 -0600578 * scene_txt_str() - add a new string to expo and text object to a scene
Simon Glass87c6f8a2023-01-06 08:52:36 -0600579 *
580 * @scn: Scene to update
581 * @name: Name to use (this is allocated by this call)
582 * @id: ID to use for the new object (0 to allocate one)
583 * @str_id: ID of the string to use
584 * @str: Pointer to text to display (allocated by caller)
585 * @txtp: If non-NULL, returns the new object
586 * Returns: ID number for the object (typically @id), or -ve on error
587 */
588int scene_txt_str(struct scene *scn, const char *name, uint id, uint str_id,
589 const char *str, struct scene_obj_txt **txtp);
590
591/**
592 * scene_menu() - create a menu
593 *
594 * @scn: Scene to update
595 * @name: Name to use (this is allocated by this call)
596 * @id: ID to use for the new object (0 to allocate one)
597 * @menup: If non-NULL, returns the new object
598 * Returns: ID number for the object (typically @id), or -ve on error
599 */
600int scene_menu(struct scene *scn, const char *name, uint id,
601 struct scene_obj_menu **menup);
602
603/**
Simon Glass4db75192023-10-01 19:13:32 -0600604 * scene_textline() - create a textline
605 *
606 * @scn: Scene to update
607 * @name: Name to use (this is allocated by this call)
608 * @id: ID to use for the new object (0 to allocate one)
609 * @max_chars: Maximum length of the textline in characters
610 * @tlinep: If non-NULL, returns the new object
611 * Returns: ID number for the object (typically @id), or -ve on error
612 */
613int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars,
614 struct scene_obj_textline **tlinep);
615
616/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600617 * scene_txt_set_font() - Set the font for an object
618 *
619 * @scn: Scene to update
620 * @id: ID of object to update
621 * @font_name: Font name to use (allocated by caller)
622 * @font_size: Font size to use (nominal height in pixels)
623 */
624int scene_txt_set_font(struct scene *scn, uint id, const char *font_name,
625 uint font_size);
626
627/**
628 * scene_obj_set_pos() - Set the postion of an object
629 *
630 * @scn: Scene to update
631 * @id: ID of object to update
632 * @x: x position, in pixels from left side
633 * @y: y position, in pixels from top
634 * Returns: 0 if OK, -ENOENT if @id is invalid
635 */
636int scene_obj_set_pos(struct scene *scn, uint id, int x, int y);
637
638/**
Simon Glass699b0ac2023-06-01 10:22:52 -0600639 * scene_obj_set_size() - Set the size of an object
640 *
641 * @scn: Scene to update
642 * @id: ID of object to update
643 * @w: width in pixels
644 * @h: height in pixels
645 * Returns: 0 if OK, -ENOENT if @id is invalid
646 */
647int scene_obj_set_size(struct scene *scn, uint id, int w, int h);
648
649/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600650 * scene_obj_set_hide() - Set whether an object is hidden
651 *
652 * The update happens when the expo is next rendered.
653 *
654 * @scn: Scene to update
655 * @id: ID of object to update
656 * @hide: true to hide the object, false to show it
657 * Returns: 0 if OK, -ENOENT if @id is invalid
658 */
659int scene_obj_set_hide(struct scene *scn, uint id, bool hide);
660
661/**
662 * scene_menu_set_title() - Set the title of a menu
663 *
664 * @scn: Scene to update
665 * @id: ID of menu object to update
666 * @title_id: ID of text object to use as the title
667 * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @title_id is invalid
668 */
669int scene_menu_set_title(struct scene *scn, uint id, uint title_id);
670
671/**
672 * scene_menu_set_pointer() - Set the item pointer for a menu
673 *
674 * This is a visual indicator of the current item, typically a ">" character
675 * which sits next to the current item and moves when the user presses the
676 * up/down arrow keys
677 *
678 * @scn: Scene to update
679 * @id: ID of menu object to update
680 * @cur_item_id: ID of text or image object to use as a pointer to the current
681 * item
682 * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @cur_item_id is invalid
683 */
684int scene_menu_set_pointer(struct scene *scn, uint id, uint cur_item_id);
685
686/**
687 * scene_obj_get_hw() - Get width and height of an object in a scene
688 *
689 * @scn: Scene to check
690 * @id: ID of menu object to check
691 * @widthp: If non-NULL, returns width of object in pixels
692 * Returns: Height of object in pixels
693 */
694int scene_obj_get_hw(struct scene *scn, uint id, int *widthp);
695
696/**
697 * scene_menuitem() - Add an item to a menu
698 *
699 * @scn: Scene to update
700 * @menu_id: ID of menu object to update
701 * @name: Name to use (this is allocated by this call)
702 * @id: ID to use for the new object (0 to allocate one)
703 * @key_id: ID of text object to use as the keypress to show
704 * @label_id: ID of text object to use as the label text
705 * @desc_id: ID of text object to use as the description text
706 * @preview_id: ID of object to use as the preview (text or image)
707 * @flags: Flags for this item (enum scene_menuitem_flags_t)
708 * @itemp: If non-NULL, returns the new object
709 * Returns: ID number for the item (typically @id), or -ve on error
710 */
711int scene_menuitem(struct scene *scn, uint menu_id, const char *name, uint id,
712 uint key_id, uint label_id, uint desc_id, uint preview_id,
713 uint flags, struct scene_menitem **itemp);
714
715/**
716 * scene_arrange() - Arrange the scene to deal with object sizes
717 *
718 * Updates any menus in the scene so that their objects are in the right place.
719 *
720 * @scn: Scene to arrange
721 * Returns: 0 if OK, -ve on error
722 */
723int scene_arrange(struct scene *scn);
724
725/**
726 * expo_send_key() - set a keypress to the expo
727 *
728 * @exp: Expo to receive the key
729 * @key: Key to send (ASCII or enum bootmenu_key)
730 * Returns: 0 if OK, -ECHILD if there is no current scene
731 */
732int expo_send_key(struct expo *exp, int key);
733
734/**
735 * expo_action_get() - read user input from the expo
736 *
737 * @exp: Expo to check
738 * @act: Returns action
739 * Returns: 0 if OK, -EAGAIN if there was no action to return
740 */
741int expo_action_get(struct expo *exp, struct expo_action *act);
742
Simon Glass2e593892023-06-01 10:22:53 -0600743/**
744 * expo_apply_theme() - Apply a theme to an expo
745 *
746 * @exp: Expo to update
747 * @node: Node containing the theme
748 */
749int expo_apply_theme(struct expo *exp, ofnode node);
750
Simon Glass82cafee2023-06-01 10:23:01 -0600751/**
752 * expo_build() - Build an expo from an FDT description
753 *
754 * Build a complete expo from a description in the provided devicetree.
755 *
Massimo Pegorera3a057f2023-09-09 12:32:28 +0200756 * See doc/develop/expo.rst for a description of the format
Simon Glass82cafee2023-06-01 10:23:01 -0600757 *
758 * @root: Root node for expo description
759 * @expp: Returns the new expo
760 * Returns: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is a format
761 * error, -ENOENT if there is a references to a non-existent string
762 */
763int expo_build(ofnode root, struct expo **expp);
764
Simon Glass040b0462023-08-14 16:40:25 -0600765#endif /*__EXPO_H */