Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright 2022 Google LLC |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | */ |
| 6 | |
Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 7 | #ifndef __EXPO_H |
| 8 | #define __EXPO_H |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 9 | |
Simon Glass | c999e17 | 2023-06-01 10:22:53 -0600 | [diff] [blame] | 10 | #include <dm/ofnode_decl.h> |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 11 | #include <linux/list.h> |
| 12 | |
| 13 | struct udevice; |
| 14 | |
| 15 | /** |
| 16 | * enum expoact_type - types of actions reported by the expo |
| 17 | * |
| 18 | * @EXPOACT_NONE: no action |
Simon Glass | f0e1e8c | 2023-06-01 10:22:59 -0600 | [diff] [blame] | 19 | * @EXPOACT_POINT_OBJ: object was highlighted (@id indicates which) |
Simon Glass | 719a3c6 | 2023-06-01 10:22:56 -0600 | [diff] [blame] | 20 | * @EXPOACT_POINT_ITEM: menu item was highlighted (@id indicates which) |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 21 | * @EXPOACT_SELECT: menu item was selected (@id indicates which) |
Simon Glass | f0e1e8c | 2023-06-01 10:22:59 -0600 | [diff] [blame] | 22 | * @EXPOACT_OPEN: menu was opened, so an item can be selected (@id indicates |
| 23 | * which menu object) |
| 24 | * @EXPOACT_CLOSE: menu was closed (@id indicates which menu object) |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 25 | * @EXPOACT_QUIT: request to exit the menu |
| 26 | */ |
| 27 | enum expoact_type { |
| 28 | EXPOACT_NONE, |
Simon Glass | f0e1e8c | 2023-06-01 10:22:59 -0600 | [diff] [blame] | 29 | EXPOACT_POINT_OBJ, |
Simon Glass | 719a3c6 | 2023-06-01 10:22:56 -0600 | [diff] [blame] | 30 | EXPOACT_POINT_ITEM, |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 31 | EXPOACT_SELECT, |
Simon Glass | f0e1e8c | 2023-06-01 10:22:59 -0600 | [diff] [blame] | 32 | EXPOACT_OPEN, |
| 33 | EXPOACT_CLOSE, |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 34 | EXPOACT_QUIT, |
| 35 | }; |
| 36 | |
| 37 | /** |
| 38 | * struct expo_action - an action report by the expo |
| 39 | * |
| 40 | * @type: Action type (EXPOACT_NONE if there is no action) |
Simon Glass | 719a3c6 | 2023-06-01 10:22:56 -0600 | [diff] [blame] | 41 | * @select: Used for EXPOACT_POINT_ITEM and EXPOACT_SELECT |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 42 | * @id: ID number of the object affected. |
| 43 | */ |
| 44 | struct expo_action { |
| 45 | enum expoact_type type; |
| 46 | union { |
| 47 | struct { |
| 48 | int id; |
| 49 | } select; |
| 50 | }; |
| 51 | }; |
| 52 | |
| 53 | /** |
Simon Glass | c999e17 | 2023-06-01 10:22:53 -0600 | [diff] [blame] | 54 | * struct expo_theme - theme for the expo |
| 55 | * |
| 56 | * @font_size: Default font size for all text |
| 57 | * @menu_inset: Inset width (on each side and top/bottom) for menu items |
| 58 | * @menuitem_gap_y: Gap between menu items in pixels |
| 59 | */ |
| 60 | struct expo_theme { |
| 61 | u32 font_size; |
| 62 | u32 menu_inset; |
| 63 | u32 menuitem_gap_y; |
| 64 | }; |
| 65 | |
| 66 | /** |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 67 | * struct expo - information about an expo |
| 68 | * |
| 69 | * A group of scenes which can be presented to the user, typically to obtain |
| 70 | * input or to make a selection. |
| 71 | * |
| 72 | * @name: Name of the expo (allocated) |
| 73 | * @display: Display to use (`UCLASS_VIDEO`), or NULL to use text mode |
Simon Glass | 67e2af1 | 2023-06-01 10:22:34 -0600 | [diff] [blame] | 74 | * @cons: Console to use (`UCLASS_VIDEO_CONSOLE`), or NULL to use text mode |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 75 | * @scene_id: Current scene ID (0 if none) |
| 76 | * @next_id: Next ID number to use, for automatic allocation |
| 77 | * @action: Action selected by user. At present only one is supported, with the |
| 78 | * type set to EXPOACT_NONE if there is no action |
| 79 | * @text_mode: true to use text mode for the menu (no vidconsole) |
Simon Glass | d353b75 | 2023-06-01 10:22:55 -0600 | [diff] [blame] | 80 | * @popup: true to use popup menus, instead of showing all items |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 81 | * @priv: Private data for the controller |
Simon Glass | c999e17 | 2023-06-01 10:22:53 -0600 | [diff] [blame] | 82 | * @theme: Information about fonts styles, etc. |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 83 | * @scene_head: List of scenes |
| 84 | * @str_head: list of strings |
| 85 | */ |
| 86 | struct expo { |
| 87 | char *name; |
| 88 | struct udevice *display; |
Simon Glass | 67e2af1 | 2023-06-01 10:22:34 -0600 | [diff] [blame] | 89 | struct udevice *cons; |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 90 | uint scene_id; |
| 91 | uint next_id; |
| 92 | struct expo_action action; |
| 93 | bool text_mode; |
Simon Glass | d353b75 | 2023-06-01 10:22:55 -0600 | [diff] [blame] | 94 | bool popup; |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 95 | void *priv; |
Simon Glass | c999e17 | 2023-06-01 10:22:53 -0600 | [diff] [blame] | 96 | struct expo_theme theme; |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 97 | struct list_head scene_head; |
| 98 | struct list_head str_head; |
| 99 | }; |
| 100 | |
| 101 | /** |
| 102 | * struct expo_string - a string that can be used in an expo |
| 103 | * |
| 104 | * @id: ID number of the string |
| 105 | * @str: String |
| 106 | * @sibling: Node to link this object to its siblings |
| 107 | */ |
| 108 | struct expo_string { |
| 109 | uint id; |
| 110 | const char *str; |
| 111 | struct list_head sibling; |
| 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * struct scene - information about a scene in an expo |
| 116 | * |
| 117 | * A collection of text/image/menu items in an expo |
| 118 | * |
| 119 | * @expo: Expo this scene is part of |
| 120 | * @name: Name of the scene (allocated) |
| 121 | * @id: ID number of the scene |
Simon Glass | ea274b6 | 2023-06-01 10:22:27 -0600 | [diff] [blame] | 122 | * @title_id: String ID of title of the scene (allocated) |
Simon Glass | d353b75 | 2023-06-01 10:22:55 -0600 | [diff] [blame] | 123 | * @highlight_id: ID of highlighted object, if any |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 124 | * @sibling: Node to link this scene to its siblings |
| 125 | * @obj_head: List of objects in the scene |
| 126 | */ |
| 127 | struct scene { |
| 128 | struct expo *expo; |
| 129 | char *name; |
| 130 | uint id; |
Simon Glass | ea274b6 | 2023-06-01 10:22:27 -0600 | [diff] [blame] | 131 | uint title_id; |
Simon Glass | d353b75 | 2023-06-01 10:22:55 -0600 | [diff] [blame] | 132 | uint highlight_id; |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 133 | struct list_head sibling; |
| 134 | struct list_head obj_head; |
| 135 | }; |
| 136 | |
| 137 | /** |
| 138 | * enum scene_obj_t - type of a scene object |
| 139 | * |
| 140 | * @SCENEOBJT_NONE: Used to indicate that the type does not matter |
| 141 | * @SCENEOBJT_IMAGE: Image data to render |
| 142 | * @SCENEOBJT_TEXT: Text line to render |
| 143 | * @SCENEOBJT_MENU: Menu containing items the user can select |
| 144 | */ |
| 145 | enum scene_obj_t { |
| 146 | SCENEOBJT_NONE = 0, |
| 147 | SCENEOBJT_IMAGE, |
| 148 | SCENEOBJT_TEXT, |
| 149 | SCENEOBJT_MENU, |
| 150 | }; |
| 151 | |
| 152 | /** |
Simon Glass | 7b04395 | 2023-06-01 10:22:49 -0600 | [diff] [blame] | 153 | * struct scene_dim - Dimensions of an object |
| 154 | * |
| 155 | * @x: x position, in pixels from left side |
| 156 | * @y: y position, in pixels from top |
| 157 | * @w: width, in pixels |
| 158 | * @h: height, in pixels |
| 159 | */ |
| 160 | struct scene_dim { |
| 161 | int x; |
| 162 | int y; |
| 163 | int w; |
| 164 | int h; |
| 165 | }; |
| 166 | |
| 167 | /** |
Simon Glass | 6081b0f | 2023-06-01 10:22:50 -0600 | [diff] [blame] | 168 | * enum scene_obj_flags_t - flags for objects |
| 169 | * |
| 170 | * @SCENEOF_HIDE: object should be hidden |
Simon Glass | d353b75 | 2023-06-01 10:22:55 -0600 | [diff] [blame] | 171 | * @SCENEOF_POINT: object should be highlighted |
| 172 | * @SCENEOF_OPEN: object should be opened (e.g. menu is opened so that an option |
| 173 | * can be selected) |
Simon Glass | 6081b0f | 2023-06-01 10:22:50 -0600 | [diff] [blame] | 174 | */ |
| 175 | enum scene_obj_flags_t { |
| 176 | SCENEOF_HIDE = 1 << 0, |
Simon Glass | d353b75 | 2023-06-01 10:22:55 -0600 | [diff] [blame] | 177 | SCENEOF_POINT = 1 << 1, |
| 178 | SCENEOF_OPEN = 1 << 2, |
Simon Glass | 6081b0f | 2023-06-01 10:22:50 -0600 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | /** |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 182 | * struct scene_obj - information about an object in a scene |
| 183 | * |
| 184 | * @scene: Scene that this object relates to |
| 185 | * @name: Name of the object (allocated) |
| 186 | * @id: ID number of the object |
| 187 | * @type: Type of this object |
Simon Glass | 7b04395 | 2023-06-01 10:22:49 -0600 | [diff] [blame] | 188 | * @dim: Dimensions for this object |
Simon Glass | 6081b0f | 2023-06-01 10:22:50 -0600 | [diff] [blame] | 189 | * @flags: Flags for this object |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 190 | * @sibling: Node to link this object to its siblings |
| 191 | */ |
| 192 | struct scene_obj { |
| 193 | struct scene *scene; |
| 194 | char *name; |
| 195 | uint id; |
| 196 | enum scene_obj_t type; |
Simon Glass | 7b04395 | 2023-06-01 10:22:49 -0600 | [diff] [blame] | 197 | struct scene_dim dim; |
Simon Glass | 6081b0f | 2023-06-01 10:22:50 -0600 | [diff] [blame] | 198 | int flags; |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 199 | struct list_head sibling; |
| 200 | }; |
| 201 | |
| 202 | /** |
| 203 | * struct scene_obj_img - information about an image object in a scene |
| 204 | * |
| 205 | * This is a rectangular image which is blitted onto the display |
| 206 | * |
| 207 | * @obj: Basic object information |
| 208 | * @data: Image data in BMP format |
| 209 | */ |
| 210 | struct scene_obj_img { |
| 211 | struct scene_obj obj; |
| 212 | char *data; |
| 213 | }; |
| 214 | |
| 215 | /** |
| 216 | * struct scene_obj_txt - information about a text object in a scene |
| 217 | * |
| 218 | * This is a single-line text object |
| 219 | * |
| 220 | * @obj: Basic object information |
| 221 | * @str_id: ID of the text string to display |
| 222 | * @font_name: Name of font (allocated by caller) |
| 223 | * @font_size: Nominal size of font in pixels |
| 224 | */ |
| 225 | struct scene_obj_txt { |
| 226 | struct scene_obj obj; |
| 227 | uint str_id; |
| 228 | const char *font_name; |
| 229 | uint font_size; |
| 230 | }; |
| 231 | |
| 232 | /** |
| 233 | * struct scene_obj_menu - information about a menu object in a scene |
| 234 | * |
| 235 | * A menu has a number of items which can be selected by the user |
| 236 | * |
| 237 | * It also has: |
| 238 | * |
| 239 | * - a text/image object (@pointer_id) which points to the current item |
| 240 | * (@cur_item_id) |
| 241 | * |
| 242 | * - a preview object which shows an image related to the current item |
| 243 | * |
| 244 | * @obj: Basic object information |
| 245 | * @title_id: ID of the title text, or 0 if none |
| 246 | * @cur_item_id: ID of the current menu item, or 0 if none |
| 247 | * @pointer_id: ID of the object pointing to the current selection |
| 248 | * @item_head: List of items in the menu |
| 249 | */ |
| 250 | struct scene_obj_menu { |
| 251 | struct scene_obj obj; |
| 252 | uint title_id; |
| 253 | uint cur_item_id; |
| 254 | uint pointer_id; |
| 255 | struct list_head item_head; |
| 256 | }; |
| 257 | |
| 258 | /** |
| 259 | * enum scene_menuitem_flags_t - flags for menu items |
| 260 | * |
| 261 | * @SCENEMIF_GAP_BEFORE: Add a gap before this item |
| 262 | */ |
| 263 | enum scene_menuitem_flags_t { |
| 264 | SCENEMIF_GAP_BEFORE = 1 << 0, |
| 265 | }; |
| 266 | |
| 267 | /** |
| 268 | * struct scene_menitem - a menu item in a menu |
| 269 | * |
| 270 | * A menu item has: |
| 271 | * |
| 272 | * - text object holding the name (short) and description (can be longer) |
| 273 | * - a text object holding the keypress |
| 274 | * |
| 275 | * @name: Name of the item (this is allocated by this call) |
| 276 | * @id: ID number of the object |
| 277 | * @key_id: ID of text object to use as the keypress to show |
| 278 | * @label_id: ID of text object to use as the label text |
| 279 | * @desc_id: ID of text object to use as the description text |
| 280 | * @preview_id: ID of the preview object, or 0 if none |
| 281 | * @flags: Flags for this item |
| 282 | * @sibling: Node to link this item to its siblings |
| 283 | */ |
| 284 | struct scene_menitem { |
| 285 | char *name; |
| 286 | uint id; |
| 287 | uint key_id; |
| 288 | uint label_id; |
| 289 | uint desc_id; |
| 290 | uint preview_id; |
| 291 | uint flags; |
| 292 | struct list_head sibling; |
| 293 | }; |
| 294 | |
| 295 | /** |
| 296 | * expo_new() - create a new expo |
| 297 | * |
| 298 | * Allocates a new expo |
| 299 | * |
| 300 | * @name: Name of expo (this is allocated by this call) |
| 301 | * @priv: Private data for the controller |
| 302 | * @expp: Returns a pointer to the new expo on success |
| 303 | * Returns: 0 if OK, -ENOMEM if out of memory |
| 304 | */ |
| 305 | int expo_new(const char *name, void *priv, struct expo **expp); |
| 306 | |
| 307 | /** |
| 308 | * expo_destroy() - Destroy an expo and free all its memory |
| 309 | * |
| 310 | * @exp: Expo to destroy |
| 311 | */ |
| 312 | void expo_destroy(struct expo *exp); |
| 313 | |
| 314 | /** |
Simon Glass | 6e9e415 | 2023-06-01 10:22:47 -0600 | [diff] [blame] | 315 | * expo_set_dynamic_start() - Set the start of the 'dynamic' IDs |
| 316 | * |
| 317 | * It is common for a set of 'static' IDs to be used to refer to objects in the |
| 318 | * expo. These typically use an enum so that they are defined in sequential |
| 319 | * order. |
| 320 | * |
| 321 | * Dynamic IDs (for objects not in the enum) are intended to be used for |
| 322 | * objects to which the code does not need to refer. These are ideally located |
| 323 | * above the static IDs. |
| 324 | * |
| 325 | * Use this function to set the start of the dynamic range, making sure that the |
| 326 | * value is higher than all the statically allocated IDs. |
| 327 | * |
| 328 | * @exp: Expo to update |
| 329 | * @dyn_start: Start ID that expo should use for dynamic allocation |
| 330 | */ |
| 331 | void expo_set_dynamic_start(struct expo *exp, uint dyn_start); |
| 332 | |
| 333 | /** |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 334 | * expo_str() - add a new string to an expo |
| 335 | * |
| 336 | * @exp: Expo to update |
| 337 | * @name: Name to use (this is allocated by this call) |
| 338 | * @id: ID to use for the new object (0 to allocate one) |
| 339 | * @str: Pointer to text to display (allocated by caller) |
| 340 | * Returns: ID number for the object (typically @id), or -ve on error |
| 341 | */ |
| 342 | int expo_str(struct expo *exp, const char *name, uint id, const char *str); |
| 343 | |
| 344 | /** |
| 345 | * expo_get_str() - Get a string by ID |
| 346 | * |
| 347 | * @exp: Expo to use |
| 348 | * @id: String ID to look up |
| 349 | * @returns string, or NULL if not found |
| 350 | */ |
| 351 | const char *expo_get_str(struct expo *exp, uint id); |
| 352 | |
| 353 | /** |
| 354 | * expo_set_display() - set the display to use for a expo |
| 355 | * |
| 356 | * @exp: Expo to update |
| 357 | * @dev: Display to use (`UCLASS_VIDEO`), NULL to use text mode |
| 358 | * Returns: 0 (always) |
| 359 | */ |
| 360 | int expo_set_display(struct expo *exp, struct udevice *dev); |
| 361 | |
| 362 | /** |
Simon Glass | 7a96005 | 2023-06-01 10:22:52 -0600 | [diff] [blame] | 363 | * expo_calc_dims() - Calculate the dimensions of the objects |
| 364 | * |
| 365 | * Updates the width and height of all objects based on their contents |
| 366 | * |
| 367 | * @exp: Expo to update |
| 368 | * Returns 0 if OK, -ENOTSUPP if there is no graphical console |
| 369 | */ |
| 370 | int expo_calc_dims(struct expo *exp); |
| 371 | |
| 372 | /** |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 373 | * expo_set_scene_id() - Set the current scene ID |
| 374 | * |
| 375 | * @exp: Expo to update |
| 376 | * @scene_id: New scene ID to use (0 to select no scene) |
| 377 | * Returns: 0 if OK, -ENOENT if there is no scene with that ID |
| 378 | */ |
| 379 | int expo_set_scene_id(struct expo *exp, uint scene_id); |
| 380 | |
| 381 | /** |
Simon Glass | c892511 | 2023-06-01 10:23:02 -0600 | [diff] [blame] | 382 | * expo_first_scene_id() - Get the ID of the first scene |
| 383 | * |
| 384 | * @exp: Expo to check |
| 385 | * Returns: Scene ID of first scene, or -ENOENT if there are no scenes |
| 386 | */ |
| 387 | int expo_first_scene_id(struct expo *exp); |
| 388 | |
| 389 | /** |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 390 | * expo_render() - render the expo on the display / console |
| 391 | * |
| 392 | * @exp: Expo to render |
| 393 | * |
| 394 | * Returns: 0 if OK, -ECHILD if there is no current scene, -ENOENT if the |
| 395 | * current scene is not found, other error if something else goes wrong |
| 396 | */ |
| 397 | int expo_render(struct expo *exp); |
| 398 | |
| 399 | /** |
Simon Glass | b2c4034 | 2023-06-01 10:22:37 -0600 | [diff] [blame] | 400 | * expo_set_text_mode() - Controls whether the expo renders in text mode |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 401 | * |
| 402 | * @exp: Expo to update |
| 403 | * @text_mode: true to use text mode, false to use the console |
| 404 | */ |
Simon Glass | b2c4034 | 2023-06-01 10:22:37 -0600 | [diff] [blame] | 405 | void expo_set_text_mode(struct expo *exp, bool text_mode); |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 406 | |
| 407 | /** |
| 408 | * scene_new() - create a new scene in a expo |
| 409 | * |
| 410 | * The scene is given the ID @id which must be unique across all scenes, objects |
| 411 | * and items. The expo's @next_id is updated to at least @id + 1 |
| 412 | * |
| 413 | * @exp: Expo to update |
| 414 | * @name: Name to use (this is allocated by this call) |
| 415 | * @id: ID to use for the new scene (0 to allocate one) |
| 416 | * @scnp: Returns a pointer to the new scene on success |
| 417 | * Returns: ID number for the scene (typically @id), or -ve on error |
| 418 | */ |
| 419 | int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp); |
| 420 | |
| 421 | /** |
| 422 | * expo_lookup_scene_id() - Look up a scene by ID |
| 423 | * |
| 424 | * @exp: Expo to check |
| 425 | * @scene_id: Scene ID to look up |
| 426 | * @returns pointer to scene if found, else NULL |
| 427 | */ |
| 428 | struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id); |
| 429 | |
| 430 | /** |
Simon Glass | 01922ec | 2023-06-01 10:22:57 -0600 | [diff] [blame] | 431 | * scene_highlight_first() - Highlight the first item in a scene |
| 432 | * |
| 433 | * This highlights the first item, so that the user can see that it is pointed |
| 434 | * to |
| 435 | * |
| 436 | * @scn: Scene to update |
| 437 | */ |
| 438 | void scene_highlight_first(struct scene *scn); |
| 439 | |
| 440 | /** |
| 441 | * scene_set_highlight_id() - Set the object which is highlighted |
| 442 | * |
| 443 | * Sets a new object to highlight in the scene |
| 444 | * |
| 445 | * @scn: Scene to update |
| 446 | * @id: ID of object to highlight |
| 447 | */ |
| 448 | void scene_set_highlight_id(struct scene *scn, uint id); |
| 449 | |
| 450 | /** |
| 451 | * scene_set_open() - Set whether an item is open or not |
| 452 | * |
| 453 | * @scn: Scene to update |
| 454 | * @id: ID of object to update |
| 455 | * @open: true to open the object, false to close it |
| 456 | * Returns: 0 if OK, -ENOENT if @id is invalid |
| 457 | */ |
| 458 | int scene_set_open(struct scene *scn, uint id, bool open); |
| 459 | |
| 460 | /** |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 461 | * scene_title_set() - set the scene title |
| 462 | * |
| 463 | * @scn: Scene to update |
Simon Glass | ea274b6 | 2023-06-01 10:22:27 -0600 | [diff] [blame] | 464 | * @title_id: Title ID to set |
| 465 | * Returns: 0 if OK |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 466 | */ |
Simon Glass | ea274b6 | 2023-06-01 10:22:27 -0600 | [diff] [blame] | 467 | int scene_title_set(struct scene *scn, uint title_id); |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 468 | |
| 469 | /** |
| 470 | * scene_obj_count() - Count the number of objects in a scene |
| 471 | * |
| 472 | * @scn: Scene to check |
| 473 | * Returns: number of objects in the scene, 0 if none |
| 474 | */ |
| 475 | int scene_obj_count(struct scene *scn); |
| 476 | |
| 477 | /** |
| 478 | * scene_img() - add a new image to a scene |
| 479 | * |
| 480 | * @scn: Scene to update |
| 481 | * @name: Name to use (this is allocated by this call) |
| 482 | * @id: ID to use for the new object (0 to allocate one) |
| 483 | * @data: Pointer to image data |
| 484 | * @imgp: If non-NULL, returns the new object |
| 485 | * Returns: ID number for the object (typically @id), or -ve on error |
| 486 | */ |
| 487 | int scene_img(struct scene *scn, const char *name, uint id, char *data, |
| 488 | struct scene_obj_img **imgp); |
| 489 | |
| 490 | /** |
| 491 | * scene_txt() - add a new text object to a scene |
| 492 | * |
| 493 | * @scn: Scene to update |
| 494 | * @name: Name to use (this is allocated by this call) |
| 495 | * @id: ID to use for the new object (0 to allocate one) |
| 496 | * @str_id: ID of the string to use |
| 497 | * @txtp: If non-NULL, returns the new object |
| 498 | * Returns: ID number for the object (typically @id), or -ve on error |
| 499 | */ |
| 500 | int scene_txt(struct scene *scn, const char *name, uint id, uint str_id, |
| 501 | struct scene_obj_txt **txtp); |
| 502 | |
| 503 | /** |
| 504 | * scene_txt_str() - add a new string to expr and text object to a scene |
| 505 | * |
| 506 | * @scn: Scene to update |
| 507 | * @name: Name to use (this is allocated by this call) |
| 508 | * @id: ID to use for the new object (0 to allocate one) |
| 509 | * @str_id: ID of the string to use |
| 510 | * @str: Pointer to text to display (allocated by caller) |
| 511 | * @txtp: If non-NULL, returns the new object |
| 512 | * Returns: ID number for the object (typically @id), or -ve on error |
| 513 | */ |
| 514 | int scene_txt_str(struct scene *scn, const char *name, uint id, uint str_id, |
| 515 | const char *str, struct scene_obj_txt **txtp); |
| 516 | |
| 517 | /** |
| 518 | * scene_menu() - create a menu |
| 519 | * |
| 520 | * @scn: Scene to update |
| 521 | * @name: Name to use (this is allocated by this call) |
| 522 | * @id: ID to use for the new object (0 to allocate one) |
| 523 | * @menup: If non-NULL, returns the new object |
| 524 | * Returns: ID number for the object (typically @id), or -ve on error |
| 525 | */ |
| 526 | int scene_menu(struct scene *scn, const char *name, uint id, |
| 527 | struct scene_obj_menu **menup); |
| 528 | |
| 529 | /** |
| 530 | * scene_txt_set_font() - Set the font for an object |
| 531 | * |
| 532 | * @scn: Scene to update |
| 533 | * @id: ID of object to update |
| 534 | * @font_name: Font name to use (allocated by caller) |
| 535 | * @font_size: Font size to use (nominal height in pixels) |
| 536 | */ |
| 537 | int scene_txt_set_font(struct scene *scn, uint id, const char *font_name, |
| 538 | uint font_size); |
| 539 | |
| 540 | /** |
| 541 | * scene_obj_set_pos() - Set the postion of an object |
| 542 | * |
| 543 | * @scn: Scene to update |
| 544 | * @id: ID of object to update |
| 545 | * @x: x position, in pixels from left side |
| 546 | * @y: y position, in pixels from top |
| 547 | * Returns: 0 if OK, -ENOENT if @id is invalid |
| 548 | */ |
| 549 | int scene_obj_set_pos(struct scene *scn, uint id, int x, int y); |
| 550 | |
| 551 | /** |
Simon Glass | 7a96005 | 2023-06-01 10:22:52 -0600 | [diff] [blame] | 552 | * scene_obj_set_size() - Set the size of an object |
| 553 | * |
| 554 | * @scn: Scene to update |
| 555 | * @id: ID of object to update |
| 556 | * @w: width in pixels |
| 557 | * @h: height in pixels |
| 558 | * Returns: 0 if OK, -ENOENT if @id is invalid |
| 559 | */ |
| 560 | int scene_obj_set_size(struct scene *scn, uint id, int w, int h); |
| 561 | |
| 562 | /** |
Simon Glass | d8adbe9 | 2023-01-06 08:52:36 -0600 | [diff] [blame] | 563 | * scene_obj_set_hide() - Set whether an object is hidden |
| 564 | * |
| 565 | * The update happens when the expo is next rendered. |
| 566 | * |
| 567 | * @scn: Scene to update |
| 568 | * @id: ID of object to update |
| 569 | * @hide: true to hide the object, false to show it |
| 570 | * Returns: 0 if OK, -ENOENT if @id is invalid |
| 571 | */ |
| 572 | int scene_obj_set_hide(struct scene *scn, uint id, bool hide); |
| 573 | |
| 574 | /** |
| 575 | * scene_menu_set_title() - Set the title of a menu |
| 576 | * |
| 577 | * @scn: Scene to update |
| 578 | * @id: ID of menu object to update |
| 579 | * @title_id: ID of text object to use as the title |
| 580 | * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @title_id is invalid |
| 581 | */ |
| 582 | int scene_menu_set_title(struct scene *scn, uint id, uint title_id); |
| 583 | |
| 584 | /** |
| 585 | * scene_menu_set_pointer() - Set the item pointer for a menu |
| 586 | * |
| 587 | * This is a visual indicator of the current item, typically a ">" character |
| 588 | * which sits next to the current item and moves when the user presses the |
| 589 | * up/down arrow keys |
| 590 | * |
| 591 | * @scn: Scene to update |
| 592 | * @id: ID of menu object to update |
| 593 | * @cur_item_id: ID of text or image object to use as a pointer to the current |
| 594 | * item |
| 595 | * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @cur_item_id is invalid |
| 596 | */ |
| 597 | int scene_menu_set_pointer(struct scene *scn, uint id, uint cur_item_id); |
| 598 | |
| 599 | /** |
| 600 | * scene_obj_get_hw() - Get width and height of an object in a scene |
| 601 | * |
| 602 | * @scn: Scene to check |
| 603 | * @id: ID of menu object to check |
| 604 | * @widthp: If non-NULL, returns width of object in pixels |
| 605 | * Returns: Height of object in pixels |
| 606 | */ |
| 607 | int scene_obj_get_hw(struct scene *scn, uint id, int *widthp); |
| 608 | |
| 609 | /** |
| 610 | * scene_menuitem() - Add an item to a menu |
| 611 | * |
| 612 | * @scn: Scene to update |
| 613 | * @menu_id: ID of menu object to update |
| 614 | * @name: Name to use (this is allocated by this call) |
| 615 | * @id: ID to use for the new object (0 to allocate one) |
| 616 | * @key_id: ID of text object to use as the keypress to show |
| 617 | * @label_id: ID of text object to use as the label text |
| 618 | * @desc_id: ID of text object to use as the description text |
| 619 | * @preview_id: ID of object to use as the preview (text or image) |
| 620 | * @flags: Flags for this item (enum scene_menuitem_flags_t) |
| 621 | * @itemp: If non-NULL, returns the new object |
| 622 | * Returns: ID number for the item (typically @id), or -ve on error |
| 623 | */ |
| 624 | int scene_menuitem(struct scene *scn, uint menu_id, const char *name, uint id, |
| 625 | uint key_id, uint label_id, uint desc_id, uint preview_id, |
| 626 | uint flags, struct scene_menitem **itemp); |
| 627 | |
| 628 | /** |
| 629 | * scene_arrange() - Arrange the scene to deal with object sizes |
| 630 | * |
| 631 | * Updates any menus in the scene so that their objects are in the right place. |
| 632 | * |
| 633 | * @scn: Scene to arrange |
| 634 | * Returns: 0 if OK, -ve on error |
| 635 | */ |
| 636 | int scene_arrange(struct scene *scn); |
| 637 | |
| 638 | /** |
| 639 | * expo_send_key() - set a keypress to the expo |
| 640 | * |
| 641 | * @exp: Expo to receive the key |
| 642 | * @key: Key to send (ASCII or enum bootmenu_key) |
| 643 | * Returns: 0 if OK, -ECHILD if there is no current scene |
| 644 | */ |
| 645 | int expo_send_key(struct expo *exp, int key); |
| 646 | |
| 647 | /** |
| 648 | * expo_action_get() - read user input from the expo |
| 649 | * |
| 650 | * @exp: Expo to check |
| 651 | * @act: Returns action |
| 652 | * Returns: 0 if OK, -EAGAIN if there was no action to return |
| 653 | */ |
| 654 | int expo_action_get(struct expo *exp, struct expo_action *act); |
| 655 | |
Simon Glass | c999e17 | 2023-06-01 10:22:53 -0600 | [diff] [blame] | 656 | /** |
| 657 | * expo_apply_theme() - Apply a theme to an expo |
| 658 | * |
| 659 | * @exp: Expo to update |
| 660 | * @node: Node containing the theme |
| 661 | */ |
| 662 | int expo_apply_theme(struct expo *exp, ofnode node); |
| 663 | |
Simon Glass | 6130072 | 2023-06-01 10:23:01 -0600 | [diff] [blame] | 664 | /** |
| 665 | * expo_build() - Build an expo from an FDT description |
| 666 | * |
| 667 | * Build a complete expo from a description in the provided devicetree. |
| 668 | * |
| 669 | * See doc/developer/expo.rst for a description of the format |
| 670 | * |
| 671 | * @root: Root node for expo description |
| 672 | * @expp: Returns the new expo |
| 673 | * Returns: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is a format |
| 674 | * error, -ENOENT if there is a references to a non-existent string |
| 675 | */ |
| 676 | int expo_build(ofnode root, struct expo **expp); |
| 677 | |
Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 678 | #endif /*__EXPO_H */ |