blob: fb1ea5533b9ae6b3c4f7a2041633554a0bc7f043 [file] [log] [blame]
Simon Glass5e2607a2023-01-06 08:52:37 -06001/* 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 */
19struct 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
Simon Glassd2043b52023-06-01 10:22:26 -060026 * Returns: Either @id, or the auto-allocated ID
Simon Glass5e2607a2023-01-06 08:52:37 -060027 */
28uint 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
Simon Glassd2043b52023-06-01 10:22:26 -060039 * Returns: Object found, or NULL if not found
Simon Glass5e2607a2023-01-06 08:52:37 -060040 */
41void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type);
42
43/**
Simon Glassa0874dc2023-06-01 10:23:02 -060044 * scene_obj_find_by_name() - Find an object in a scene by name
45 *
46 * @scn: Scene to search
47 * @name: Name to search for
48 */
49void *scene_obj_find_by_name(struct scene *scn, const char *name);
50
51/**
Simon Glass5e2607a2023-01-06 08:52:37 -060052 * scene_obj_add() - Add a new object to a scene
53 *
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
61 */
62int scene_obj_add(struct scene *scn, const char *name, uint id,
63 enum scene_obj_t type, uint size, struct scene_obj **objp);
64
65/**
Simon Glassce72c9e2023-06-01 10:22:50 -060066 * scene_obj_flag_clrset() - Adjust object flags
67 *
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
73 */
74int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
75
76/**
Simon Glass699b0ac2023-06-01 10:22:52 -060077 * scene_calc_dims() - Calculate the dimensions of the scene objects
78 *
79 * Updates the width and height of all objects based on their contents
80 *
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
84 */
85int scene_calc_dims(struct scene *scn, bool do_menus);
86
87/**
Simon Glass5e2607a2023-01-06 08:52:37 -060088 * scene_menu_arrange() - Set the position of things in the menu
89 *
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
92 * if not already done
93 *
94 * @scn: Scene to update
95 * @menu: Menu to process
Simon Glassd2043b52023-06-01 10:22:26 -060096 * Returns: 0 if OK, -ve on error
Simon Glass5e2607a2023-01-06 08:52:37 -060097 */
98int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
99
100/**
Simon Glass2e593892023-06-01 10:22:53 -0600101 * scene_apply_theme() - Apply a theme to a scene
102 *
103 * @scn: Scene to update
104 * @theme: Theme to apply
105 * Returns: 0 if OK, -ve on error
106 */
107int scene_apply_theme(struct scene *scn, struct expo_theme *theme);
108
109/**
Simon Glass5e2607a2023-01-06 08:52:37 -0600110 * scene_menu_send_key() - Send a key to a menu for processing
111 *
112 * @scn: Scene to use
113 * @menu: Menu to use
114 * @key: Key code to send (KEY_...)
115 * @event: Place to put any event which is generated by the key
Simon Glassd2043b52023-06-01 10:22:26 -0600116 * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other
Simon Glass5e2607a2023-01-06 08:52:37 -0600117 * error
118 */
119int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
120 struct expo_action *event);
121
122/**
123 * scene_menu_destroy() - Destroy a menu in a scene
124 *
125 * @scn: Scene to destroy
126 */
127void scene_menu_destroy(struct scene_obj_menu *menu);
128
129/**
130 * scene_menu_display() - Display a menu as text
131 *
132 * @menu: Menu to display
Simon Glassd2043b52023-06-01 10:22:26 -0600133 * Returns: 0 if OK, -ENOENT if @id is invalid
Simon Glass5e2607a2023-01-06 08:52:37 -0600134 */
135int scene_menu_display(struct scene_obj_menu *menu);
136
137/**
138 * scene_destroy() - Destroy a scene and all its memory
139 *
140 * @scn: Scene to destroy
141 */
142void scene_destroy(struct scene *scn);
143
144/**
145 * scene_render() - Render a scene
146 *
147 * This is called from expo_render()
148 *
149 * @scn: Scene to render
150 * Returns: 0 if OK, -ve on error
151 */
152int scene_render(struct scene *scn);
153
154/**
155 * scene_send_key() - set a keypress to a scene
156 *
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
161 */
162int scene_send_key(struct scene *scn, int key, struct expo_action *event);
163
Simon Glass699b0ac2023-06-01 10:22:52 -0600164/**
Simon Glass756c9552023-06-01 10:22:57 -0600165 * scene_menu_render() - Render the background behind a menu
166 *
167 * @menu: Menu to render
168 */
169void scene_menu_render(struct scene_obj_menu *menu);
170
171/**
Simon Glass4c87e072023-06-01 10:22:58 -0600172 * scene_render_deps() - Render an object and its dependencies
173 *
174 * @scn: Scene to render
175 * @id: Object ID to render (or 0 for none)
176 * Returns: 0 if OK, -ve on error
177 */
178int scene_render_deps(struct scene *scn, uint id);
179
180/**
181 * scene_menu_render_deps() - Render a menu and its dependencies
182 *
183 * Renders the menu and all of its attached objects
184 *
185 * @scn: Scene to render
186 * @menu: Menu render
187 * Returns: 0 if OK, -ve on error
188 */
189int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu);
190
191/**
Simon Glass699b0ac2023-06-01 10:22:52 -0600192 * scene_menu_calc_dims() - Calculate the dimensions of a menu
193 *
194 * Updates the width and height of the menu based on its contents
195 *
196 * @menu: Menu to update
197 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
198 */
199int scene_menu_calc_dims(struct scene_obj_menu *menu);
200
Simon Glass5e2607a2023-01-06 08:52:37 -0600201#endif /* __SCENE_INTERNAL_H */