Simon Glass | 0a4d14b | 2023-01-06 08:52:37 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Internal header file for scenes |
| 4 | * |
| 5 | * Copyright 2022 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #ifndef __SCENE_INTERNAL_H |
| 10 | #define __SCENE_INTERNAL_H |
| 11 | |
| 12 | /** |
| 13 | * expo_lookup_scene_id() - Look up a scene ID |
| 14 | * |
| 15 | * @exp: Expo to use |
| 16 | * @id: scene ID to look up |
| 17 | * Returns: Scene for that ID, or NULL if none |
| 18 | */ |
| 19 | struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id); |
| 20 | |
| 21 | /** |
| 22 | * resolve_id() - Automatically allocate an ID if needed |
| 23 | * |
| 24 | * @exp: Expo to use |
| 25 | * @id: ID to use, or 0 to auto-allocate one |
| 26 | * @return: Either @id, or the auto-allocated ID |
| 27 | */ |
| 28 | uint resolve_id(struct expo *exp, uint id); |
| 29 | |
| 30 | /** |
| 31 | * scene_obj_find() - Find an object in a scene |
| 32 | * |
| 33 | * Note that @type is used to restrict the search when the object type is known. |
| 34 | * If any type is acceptable, set @type to SCENEOBJT_NONE |
| 35 | * |
| 36 | * @scn: Scene to search |
| 37 | * @id: ID of object to find |
| 38 | * @type: Type of the object, or SCENEOBJT_NONE to match any type |
| 39 | */ |
| 40 | void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type); |
| 41 | |
| 42 | /** |
| 43 | * scene_obj_add() - Add a new object to a scene |
| 44 | * |
| 45 | * @scn: Scene to update |
| 46 | * @name: Name to use (this is allocated by this call) |
| 47 | * @id: ID to use for the new object (0 to allocate one) |
| 48 | * @type: Type of object to add |
| 49 | * @size: Size to allocate for the object, in bytes |
| 50 | * @objp: Returns a pointer to the new object (must not be NULL) |
| 51 | * Returns: ID number for the object (generally @id), or -ve on error |
| 52 | */ |
| 53 | int scene_obj_add(struct scene *scn, const char *name, uint id, |
| 54 | enum scene_obj_t type, uint size, struct scene_obj **objp); |
| 55 | |
| 56 | /** |
| 57 | * scene_menu_arrange() - Set the position of things in the menu |
| 58 | * |
| 59 | * This updates any items associated with a menu to make sure they are |
| 60 | * positioned correctly relative to the menu. It also selects the first item |
| 61 | * if not already done |
| 62 | * |
| 63 | * @scn: Scene to update |
| 64 | * @menu: Menu to process |
| 65 | */ |
| 66 | int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu); |
| 67 | |
| 68 | /** |
| 69 | * scene_menu_send_key() - Send a key to a menu for processing |
| 70 | * |
| 71 | * @scn: Scene to use |
| 72 | * @menu: Menu to use |
| 73 | * @key: Key code to send (KEY_...) |
| 74 | * @event: Place to put any event which is generated by the key |
| 75 | * @return 0 if OK, -ENOTTY if there is no current menu item, other -ve on other |
| 76 | * error |
| 77 | */ |
| 78 | int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key, |
| 79 | struct expo_action *event); |
| 80 | |
| 81 | /** |
| 82 | * scene_menu_destroy() - Destroy a menu in a scene |
| 83 | * |
| 84 | * @scn: Scene to destroy |
| 85 | */ |
| 86 | void scene_menu_destroy(struct scene_obj_menu *menu); |
| 87 | |
| 88 | /** |
| 89 | * scene_menu_display() - Display a menu as text |
| 90 | * |
| 91 | * @menu: Menu to display |
| 92 | * @return 0 if OK, -ENOENT if @id is invalid |
| 93 | */ |
| 94 | int scene_menu_display(struct scene_obj_menu *menu); |
| 95 | |
| 96 | /** |
| 97 | * scene_destroy() - Destroy a scene and all its memory |
| 98 | * |
| 99 | * @scn: Scene to destroy |
| 100 | */ |
| 101 | void scene_destroy(struct scene *scn); |
| 102 | |
| 103 | /** |
| 104 | * scene_render() - Render a scene |
| 105 | * |
| 106 | * This is called from expo_render() |
| 107 | * |
| 108 | * @scn: Scene to render |
| 109 | * Returns: 0 if OK, -ve on error |
| 110 | */ |
| 111 | int scene_render(struct scene *scn); |
| 112 | |
| 113 | /** |
| 114 | * scene_send_key() - set a keypress to a scene |
| 115 | * |
| 116 | * @scn: Scene to receive the key |
| 117 | * @key: Key to send (KEYCODE_UP) |
| 118 | * @event: Returns resulting event from this keypress |
| 119 | * Returns: 0 if OK, -ve on error |
| 120 | */ |
| 121 | int scene_send_key(struct scene *scn, int key, struct expo_action *event); |
| 122 | |
| 123 | #endif /* __SCENE_INTERNAL_H */ |