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
13 * expo_lookup_scene_id() - Look up a scene ID
16 * @id: scene ID to look up
17 * Returns: Scene for that ID, or NULL if none
19 struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
22 * resolve_id() - Automatically allocate an ID if needed
25 * @id: ID to use, or 0 to auto-allocate one
26 * Returns: Either @id, or the auto-allocated ID
28 uint resolve_id(struct expo *exp, uint id);
31 * scene_obj_find() - Find an object in a scene
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
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 * Returns: Object found, or NULL if not found
41 void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type);
44 * scene_obj_find_by_name() - Find an object in a scene by name
46 * @scn: Scene to search
47 * @name: Name to search for
49 void *scene_obj_find_by_name(struct scene *scn, const char *name);
52 * scene_obj_add() - Add a new object to a scene
54 * @scn: Scene to update
55 * @name: Name to use (this is allocated by this call)
56 * @id: ID to use for the new object (0 to allocate one)
57 * @type: Type of object to add
58 * @size: Size to allocate for the object, in bytes
59 * @objp: Returns a pointer to the new object (must not be NULL)
60 * Returns: ID number for the object (generally @id), or -ve on error
62 int scene_obj_add(struct scene *scn, const char *name, uint id,
63 enum scene_obj_t type, uint size, struct scene_obj **objp);
66 * scene_obj_flag_clrset() - Adjust object flags
68 * @scn: Scene to update
69 * @id: ID of object to update
70 * @clr: Bits to clear in the object's flags
71 * @set: Bits to set in the object's flags
72 * Returns 0 if OK, -ENOENT if the object was not found
74 int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
77 * scene_calc_dims() - Calculate the dimensions of the scene objects
79 * Updates the width and height of all objects based on their contents
81 * @scn: Scene to update
82 * @do_menus: true to calculate only menus, false to calculate everything else
83 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
85 int scene_calc_dims(struct scene *scn, bool do_menus);
88 * scene_menu_arrange() - Set the position of things in the menu
90 * This updates any items associated with a menu to make sure they are
91 * positioned correctly relative to the menu. It also selects the first item
94 * @scn: Scene to update
95 * @menu: Menu to process
96 * Returns: 0 if OK, -ve on error
98 int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
101 * scene_apply_theme() - Apply a theme to a scene
103 * @scn: Scene to update
104 * @theme: Theme to apply
105 * Returns: 0 if OK, -ve on error
107 int scene_apply_theme(struct scene *scn, struct expo_theme *theme);
110 * scene_menu_send_key() - Send a key to a menu for processing
114 * @key: Key code to send (KEY_...)
115 * @event: Place to put any event which is generated by the key
116 * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other
119 int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
120 struct expo_action *event);
123 * scene_menu_destroy() - Destroy a menu in a scene
125 * @scn: Scene to destroy
127 void scene_menu_destroy(struct scene_obj_menu *menu);
130 * scene_menu_display() - Display a menu as text
132 * @menu: Menu to display
133 * Returns: 0 if OK, -ENOENT if @id is invalid
135 int scene_menu_display(struct scene_obj_menu *menu);
138 * scene_destroy() - Destroy a scene and all its memory
140 * @scn: Scene to destroy
142 void scene_destroy(struct scene *scn);
145 * scene_render() - Render a scene
147 * This is called from expo_render()
149 * @scn: Scene to render
150 * Returns: 0 if OK, -ve on error
152 int scene_render(struct scene *scn);
155 * scene_send_key() - set a keypress to a scene
157 * @scn: Scene to receive the key
158 * @key: Key to send (KEYCODE_UP)
159 * @event: Returns resulting event from this keypress
160 * Returns: 0 if OK, -ve on error
162 int scene_send_key(struct scene *scn, int key, struct expo_action *event);
165 * scene_menu_render() - Render the background behind a menu
167 * @menu: Menu to render
169 void scene_menu_render(struct scene_obj_menu *menu);
172 * scene_render_deps() - Render an object and its dependencies
174 * @scn: Scene to render
175 * @id: Object ID to render (or 0 for none)
176 * Returns: 0 if OK, -ve on error
178 int scene_render_deps(struct scene *scn, uint id);
181 * scene_menu_render_deps() - Render a menu and its dependencies
183 * Renders the menu and all of its attached objects
185 * @scn: Scene to render
187 * Returns: 0 if OK, -ve on error
189 int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu);
192 * scene_menu_calc_dims() - Calculate the dimensions of a menu
194 * Updates the width and height of the menu based on its contents
196 * @menu: Menu to update
197 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
199 int scene_menu_calc_dims(struct scene_obj_menu *menu);
201 #endif /* __SCENE_INTERNAL_H */