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 * @return: 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
40 void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type);
43 * scene_obj_add() - Add a new object to a scene
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
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);
57 * scene_menu_arrange() - Set the position of things in the menu
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
63 * @scn: Scene to update
64 * @menu: Menu to process
66 int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
69 * scene_menu_send_key() - Send a key to a menu for processing
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
78 int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
79 struct expo_action *event);
82 * scene_menu_destroy() - Destroy a menu in a scene
84 * @scn: Scene to destroy
86 void scene_menu_destroy(struct scene_obj_menu *menu);
89 * scene_menu_display() - Display a menu as text
91 * @menu: Menu to display
92 * @return 0 if OK, -ENOENT if @id is invalid
94 int scene_menu_display(struct scene_obj_menu *menu);
97 * scene_destroy() - Destroy a scene and all its memory
99 * @scn: Scene to destroy
101 void scene_destroy(struct scene *scn);
104 * scene_render() - Render a scene
106 * This is called from expo_render()
108 * @scn: Scene to render
109 * Returns: 0 if OK, -ve on error
111 int scene_render(struct scene *scn);
114 * scene_send_key() - set a keypress to a scene
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
121 int scene_send_key(struct scene *scn, int key, struct expo_action *event);
123 #endif /* __SCENE_INTERNAL_H */