blob: 9f173dd749f005096493343b40339227aec848b6 [file] [log] [blame]
Simon Glass0a4d14b2023-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 Glassc6e9f4c2023-06-01 10:22:26 -060026 * Returns: Either @id, or the auto-allocated ID
Simon Glass0a4d14b2023-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 Glassc6e9f4c2023-06-01 10:22:26 -060039 * Returns: Object found, or NULL if not found
Simon Glass0a4d14b2023-01-06 08:52:37 -060040 */
41void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type);
42
43/**
44 * scene_obj_add() - Add a new object to a scene
45 *
46 * @scn: Scene to update
47 * @name: Name to use (this is allocated by this call)
48 * @id: ID to use for the new object (0 to allocate one)
49 * @type: Type of object to add
50 * @size: Size to allocate for the object, in bytes
51 * @objp: Returns a pointer to the new object (must not be NULL)
52 * Returns: ID number for the object (generally @id), or -ve on error
53 */
54int scene_obj_add(struct scene *scn, const char *name, uint id,
55 enum scene_obj_t type, uint size, struct scene_obj **objp);
56
57/**
58 * scene_menu_arrange() - Set the position of things in the menu
59 *
60 * This updates any items associated with a menu to make sure they are
61 * positioned correctly relative to the menu. It also selects the first item
62 * if not already done
63 *
64 * @scn: Scene to update
65 * @menu: Menu to process
Simon Glassc6e9f4c2023-06-01 10:22:26 -060066 * Returns: 0 if OK, -ve on error
Simon Glass0a4d14b2023-01-06 08:52:37 -060067 */
68int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
69
70/**
71 * scene_menu_send_key() - Send a key to a menu for processing
72 *
73 * @scn: Scene to use
74 * @menu: Menu to use
75 * @key: Key code to send (KEY_...)
76 * @event: Place to put any event which is generated by the key
Simon Glassc6e9f4c2023-06-01 10:22:26 -060077 * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other
Simon Glass0a4d14b2023-01-06 08:52:37 -060078 * error
79 */
80int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
81 struct expo_action *event);
82
83/**
84 * scene_menu_destroy() - Destroy a menu in a scene
85 *
86 * @scn: Scene to destroy
87 */
88void scene_menu_destroy(struct scene_obj_menu *menu);
89
90/**
91 * scene_menu_display() - Display a menu as text
92 *
93 * @menu: Menu to display
Simon Glassc6e9f4c2023-06-01 10:22:26 -060094 * Returns: 0 if OK, -ENOENT if @id is invalid
Simon Glass0a4d14b2023-01-06 08:52:37 -060095 */
96int scene_menu_display(struct scene_obj_menu *menu);
97
98/**
99 * scene_destroy() - Destroy a scene and all its memory
100 *
101 * @scn: Scene to destroy
102 */
103void scene_destroy(struct scene *scn);
104
105/**
106 * scene_render() - Render a scene
107 *
108 * This is called from expo_render()
109 *
110 * @scn: Scene to render
111 * Returns: 0 if OK, -ve on error
112 */
113int scene_render(struct scene *scn);
114
115/**
116 * scene_send_key() - set a keypress to a scene
117 *
118 * @scn: Scene to receive the key
119 * @key: Key to send (KEYCODE_UP)
120 * @event: Returns resulting event from this keypress
121 * Returns: 0 if OK, -ve on error
122 */
123int scene_send_key(struct scene *scn, int key, struct expo_action *event);
124
125#endif /* __SCENE_INTERNAL_H */