blob: 2544c961dab4143ce2d65e3fe94275b8f9e8f573 [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/**
Simon Glass6081b0f2023-06-01 10:22:50 -060058 * scene_obj_flag_clrset() - Adjust object flags
59 *
60 * @scn: Scene to update
61 * @id: ID of object to update
62 * @clr: Bits to clear in the object's flags
63 * @set: Bits to set in the object's flags
64 * Returns 0 if OK, -ENOENT if the object was not found
65 */
66int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
67
68/**
Simon Glass7a960052023-06-01 10:22:52 -060069 * scene_calc_dims() - Calculate the dimensions of the scene objects
70 *
71 * Updates the width and height of all objects based on their contents
72 *
73 * @scn: Scene to update
74 * @do_menus: true to calculate only menus, false to calculate everything else
75 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
76 */
77int scene_calc_dims(struct scene *scn, bool do_menus);
78
79/**
Simon Glass0a4d14b2023-01-06 08:52:37 -060080 * scene_menu_arrange() - Set the position of things in the menu
81 *
82 * This updates any items associated with a menu to make sure they are
83 * positioned correctly relative to the menu. It also selects the first item
84 * if not already done
85 *
86 * @scn: Scene to update
87 * @menu: Menu to process
Simon Glassc6e9f4c2023-06-01 10:22:26 -060088 * Returns: 0 if OK, -ve on error
Simon Glass0a4d14b2023-01-06 08:52:37 -060089 */
90int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
91
92/**
Simon Glassc999e172023-06-01 10:22:53 -060093 * scene_apply_theme() - Apply a theme to a scene
94 *
95 * @scn: Scene to update
96 * @theme: Theme to apply
97 * Returns: 0 if OK, -ve on error
98 */
99int scene_apply_theme(struct scene *scn, struct expo_theme *theme);
100
101/**
Simon Glass0a4d14b2023-01-06 08:52:37 -0600102 * scene_menu_send_key() - Send a key to a menu for processing
103 *
104 * @scn: Scene to use
105 * @menu: Menu to use
106 * @key: Key code to send (KEY_...)
107 * @event: Place to put any event which is generated by the key
Simon Glassc6e9f4c2023-06-01 10:22:26 -0600108 * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other
Simon Glass0a4d14b2023-01-06 08:52:37 -0600109 * error
110 */
111int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
112 struct expo_action *event);
113
114/**
115 * scene_menu_destroy() - Destroy a menu in a scene
116 *
117 * @scn: Scene to destroy
118 */
119void scene_menu_destroy(struct scene_obj_menu *menu);
120
121/**
122 * scene_menu_display() - Display a menu as text
123 *
124 * @menu: Menu to display
Simon Glassc6e9f4c2023-06-01 10:22:26 -0600125 * Returns: 0 if OK, -ENOENT if @id is invalid
Simon Glass0a4d14b2023-01-06 08:52:37 -0600126 */
127int scene_menu_display(struct scene_obj_menu *menu);
128
129/**
130 * scene_destroy() - Destroy a scene and all its memory
131 *
132 * @scn: Scene to destroy
133 */
134void scene_destroy(struct scene *scn);
135
136/**
137 * scene_render() - Render a scene
138 *
139 * This is called from expo_render()
140 *
141 * @scn: Scene to render
142 * Returns: 0 if OK, -ve on error
143 */
144int scene_render(struct scene *scn);
145
146/**
147 * scene_send_key() - set a keypress to a scene
148 *
149 * @scn: Scene to receive the key
150 * @key: Key to send (KEYCODE_UP)
151 * @event: Returns resulting event from this keypress
152 * Returns: 0 if OK, -ve on error
153 */
154int scene_send_key(struct scene *scn, int key, struct expo_action *event);
155
Simon Glass7a960052023-06-01 10:22:52 -0600156/**
Simon Glass01922ec2023-06-01 10:22:57 -0600157 * scene_menu_render() - Render the background behind a menu
158 *
159 * @menu: Menu to render
160 */
161void scene_menu_render(struct scene_obj_menu *menu);
162
163/**
Simon Glass7a960052023-06-01 10:22:52 -0600164 * scene_menu_calc_dims() - Calculate the dimensions of a menu
165 *
166 * Updates the width and height of the menu based on its contents
167 *
168 * @menu: Menu to update
169 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
170 */
171int scene_menu_calc_dims(struct scene_obj_menu *menu);
172
Simon Glass0a4d14b2023-01-06 08:52:37 -0600173#endif /* __SCENE_INTERNAL_H */