1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Internal header file for scenes
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
9 #ifndef __SCENE_INTERNAL_H
10 #define __SCENE_INTERNAL_H
12 typedef int (*expo_scene_obj_iterator)(struct scene_obj *obj, void *priv);
15 * expo_lookup_scene_id() - Look up a scene ID
18 * @id: scene ID to look up
19 * Returns: Scene for that ID, or NULL if none
21 struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
24 * resolve_id() - Automatically allocate an ID if needed
27 * @id: ID to use, or 0 to auto-allocate one
28 * Returns: Either @id, or the auto-allocated ID
30 uint resolve_id(struct expo *exp, uint id);
33 * scene_obj_find() - Find an object in a scene
35 * Note that @type is used to restrict the search when the object type is known.
36 * If any type is acceptable, set @type to SCENEOBJT_NONE
38 * @scn: Scene to search
39 * @id: ID of object to find
40 * @type: Type of the object, or SCENEOBJT_NONE to match any type
41 * Returns: Object found, or NULL if not found
43 void *scene_obj_find(const struct scene *scn, uint id, enum scene_obj_t type);
46 * scene_obj_find_by_name() - Find an object in a scene by name
48 * @scn: Scene to search
49 * @name: Name to search for
51 void *scene_obj_find_by_name(struct scene *scn, const char *name);
54 * scene_obj_add() - Add a new object to a scene
56 * @scn: Scene to update
57 * @name: Name to use (this is allocated by this call)
58 * @id: ID to use for the new object (0 to allocate one)
59 * @type: Type of object to add
60 * @size: Size to allocate for the object, in bytes
61 * @objp: Returns a pointer to the new object (must not be NULL)
62 * Returns: ID number for the object (generally @id), or -ve on error
64 int scene_obj_add(struct scene *scn, const char *name, uint id,
65 enum scene_obj_t type, uint size, struct scene_obj **objp);
68 * scene_obj_flag_clrset() - Adjust object flags
70 * @scn: Scene to update
71 * @id: ID of object to update
72 * @clr: Bits to clear in the object's flags
73 * @set: Bits to set in the object's flags
74 * Returns 0 if OK, -ENOENT if the object was not found
76 int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
79 * scene_calc_dims() - Calculate the dimensions of the scene objects
81 * Updates the width and height of all objects based on their contents
83 * @scn: Scene to update
84 * @do_menus: true to calculate only menus, false to calculate everything else
85 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
87 int scene_calc_dims(struct scene *scn, bool do_menus);
90 * scene_menu_arrange() - Set the position of things in the menu
92 * This updates any items associated with a menu to make sure they are
93 * positioned correctly relative to the menu. It also selects the first item
96 * @scn: Scene to update
97 * @menu: Menu to process
98 * Returns: 0 if OK, -ve on error
100 int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
103 * scene_apply_theme() - Apply a theme to a scene
105 * @scn: Scene to update
106 * @theme: Theme to apply
107 * Returns: 0 if OK, -ve on error
109 int scene_apply_theme(struct scene *scn, struct expo_theme *theme);
112 * scene_menu_send_key() - Send a key to a menu for processing
116 * @key: Key code to send (KEY_...)
117 * @event: Place to put any event which is generated by the key
118 * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other
121 int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
122 struct expo_action *event);
125 * scene_menu_destroy() - Destroy a menu in a scene
127 * @scn: Scene to destroy
129 void scene_menu_destroy(struct scene_obj_menu *menu);
132 * scene_menu_display() - Display a menu as text
134 * @menu: Menu to display
135 * Returns: 0 if OK, -ENOENT if @id is invalid
137 int scene_menu_display(struct scene_obj_menu *menu);
140 * scene_destroy() - Destroy a scene and all its memory
142 * @scn: Scene to destroy
144 void scene_destroy(struct scene *scn);
147 * scene_render() - Render a scene
149 * This is called from expo_render()
151 * @scn: Scene to render
152 * Returns: 0 if OK, -ve on error
154 int scene_render(struct scene *scn);
157 * scene_send_key() - set a keypress to a scene
159 * @scn: Scene to receive the key
160 * @key: Key to send (KEYCODE_UP)
161 * @event: Returns resulting event from this keypress
162 * Returns: 0 if OK, -ve on error
164 int scene_send_key(struct scene *scn, int key, struct expo_action *event);
167 * scene_menu_render() - Render the background behind a menu
169 * @menu: Menu to render
171 void scene_menu_render(struct scene_obj_menu *menu);
174 * scene_render_deps() - Render an object and its dependencies
176 * @scn: Scene to render
177 * @id: Object ID to render (or 0 for none)
178 * Returns: 0 if OK, -ve on error
180 int scene_render_deps(struct scene *scn, uint id);
183 * scene_menu_render_deps() - Render a menu and its dependencies
185 * Renders the menu and all of its attached objects
187 * @scn: Scene to render
189 * Returns: 0 if OK, -ve on error
191 int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu);
194 * scene_menu_calc_dims() - Calculate the dimensions of a menu
196 * Updates the width and height of the menu based on its contents
198 * @menu: Menu to update
199 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
201 int scene_menu_calc_dims(struct scene_obj_menu *menu);
204 * scene_iter_objs() - Iterate through all scene objects
206 * @scn: Scene to process
207 * @iter: Iterator to call on each object
208 * @priv: Private data to pass to the iterator, in addition to the object
209 * Return: 0 if OK, -ve on error
211 int scene_iter_objs(struct scene *scn, expo_scene_obj_iterator iter,
215 * expo_iter_scene_objects() - Iterate through all scene objects
217 * @exp: Expo to process
218 * @iter: Iterator to call on each object
219 * @priv: Private data to pass to the iterator, in addition to the object
220 * Return: 0 if OK, -ve on error
222 int expo_iter_scene_objs(struct expo *exp, expo_scene_obj_iterator iter,
226 * scene_menuitem_find() - Find the menu item for an ID
228 * Looks up the menu to find the item with the given ID
230 * @menu: Menu to check
231 * @id: ID to look for
232 * Return: Menu item, or NULL if not found
234 struct scene_menitem *scene_menuitem_find(const struct scene_obj_menu *menu,
238 * scene_menuitem_find_seq() - Find the menu item at a sequential position
240 * This numbers the items from 0 and returns the seq'th one
242 * @menu: Menu to check
243 * @seq: Sequence number to look for
244 * Return: menu item if found, else NULL
246 struct scene_menitem *scene_menuitem_find_seq(const struct scene_obj_menu *menu,
249 #endif /* __SCENE_INTERNAL_H */