]>
Commit | Line | Data |
---|---|---|
5e2607ae SG |
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 <[email protected]> | |
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 | |
d2043b56 | 26 | * Returns: Either @id, or the auto-allocated ID |
5e2607ae SG |
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 | |
d2043b56 | 39 | * Returns: Object found, or NULL if not found |
5e2607ae SG |
40 | */ |
41 | void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type); | |
42 | ||
a0874dc4 SG |
43 | /** |
44 | * 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 | */ | |
49 | void *scene_obj_find_by_name(struct scene *scn, const char *name); | |
50 | ||
5e2607ae SG |
51 | /** |
52 | * 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 | */ | |
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); | |
64 | ||
ce72c9ec SG |
65 | /** |
66 | * 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 | */ | |
74 | int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set); | |
75 | ||
699b0acb SG |
76 | /** |
77 | * 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 | */ | |
85 | int scene_calc_dims(struct scene *scn, bool do_menus); | |
86 | ||
5e2607ae SG |
87 | /** |
88 | * 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 | |
d2043b56 | 96 | * Returns: 0 if OK, -ve on error |
5e2607ae SG |
97 | */ |
98 | int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu); | |
99 | ||
2e593897 SG |
100 | /** |
101 | * 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 | */ | |
107 | int scene_apply_theme(struct scene *scn, struct expo_theme *theme); | |
108 | ||
5e2607ae SG |
109 | /** |
110 | * 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 | |
d2043b56 | 116 | * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other |
5e2607ae SG |
117 | * error |
118 | */ | |
119 | int 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 | */ | |
127 | void 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 | |
d2043b56 | 133 | * Returns: 0 if OK, -ENOENT if @id is invalid |
5e2607ae SG |
134 | */ |
135 | int 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 | */ | |
142 | void 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 | */ | |
152 | int 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 | */ | |
162 | int scene_send_key(struct scene *scn, int key, struct expo_action *event); | |
163 | ||
756c9559 SG |
164 | /** |
165 | * scene_menu_render() - Render the background behind a menu | |
166 | * | |
167 | * @menu: Menu to render | |
168 | */ | |
169 | void scene_menu_render(struct scene_obj_menu *menu); | |
170 | ||
4c87e073 SG |
171 | /** |
172 | * 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 | */ | |
178 | int 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 | */ | |
189 | int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu); | |
190 | ||
699b0acb SG |
191 | /** |
192 | * 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 | */ | |
199 | int scene_menu_calc_dims(struct scene_obj_menu *menu); | |
200 | ||
5e2607ae | 201 | #endif /* __SCENE_INTERNAL_H */ |