scene_internal.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 <sjg@chromium.org>
  7. */
  8. #ifndef __SCENE_INTERNAL_H
  9. #define __SCENE_INTERNAL_H
  10. /**
  11. * expo_lookup_scene_id() - Look up a scene ID
  12. *
  13. * @exp: Expo to use
  14. * @id: scene ID to look up
  15. * Returns: Scene for that ID, or NULL if none
  16. */
  17. struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
  18. /**
  19. * resolve_id() - Automatically allocate an ID if needed
  20. *
  21. * @exp: Expo to use
  22. * @id: ID to use, or 0 to auto-allocate one
  23. * Returns: Either @id, or the auto-allocated ID
  24. */
  25. uint resolve_id(struct expo *exp, uint id);
  26. /**
  27. * scene_obj_find() - Find an object in a scene
  28. *
  29. * Note that @type is used to restrict the search when the object type is known.
  30. * If any type is acceptable, set @type to SCENEOBJT_NONE
  31. *
  32. * @scn: Scene to search
  33. * @id: ID of object to find
  34. * @type: Type of the object, or SCENEOBJT_NONE to match any type
  35. * Returns: Object found, or NULL if not found
  36. */
  37. void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type);
  38. /**
  39. * scene_obj_find_by_name() - Find an object in a scene by name
  40. *
  41. * @scn: Scene to search
  42. * @name: Name to search for
  43. */
  44. void *scene_obj_find_by_name(struct scene *scn, const char *name);
  45. /**
  46. * scene_obj_add() - Add a new object to a scene
  47. *
  48. * @scn: Scene to update
  49. * @name: Name to use (this is allocated by this call)
  50. * @id: ID to use for the new object (0 to allocate one)
  51. * @type: Type of object to add
  52. * @size: Size to allocate for the object, in bytes
  53. * @objp: Returns a pointer to the new object (must not be NULL)
  54. * Returns: ID number for the object (generally @id), or -ve on error
  55. */
  56. int scene_obj_add(struct scene *scn, const char *name, uint id,
  57. enum scene_obj_t type, uint size, struct scene_obj **objp);
  58. /**
  59. * scene_obj_flag_clrset() - Adjust object flags
  60. *
  61. * @scn: Scene to update
  62. * @id: ID of object to update
  63. * @clr: Bits to clear in the object's flags
  64. * @set: Bits to set in the object's flags
  65. * Returns 0 if OK, -ENOENT if the object was not found
  66. */
  67. int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
  68. /**
  69. * 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. */
  77. int scene_calc_dims(struct scene *scn, bool do_menus);
  78. /**
  79. * scene_menu_arrange() - Set the position of things in the menu
  80. *
  81. * This updates any items associated with a menu to make sure they are
  82. * positioned correctly relative to the menu. It also selects the first item
  83. * if not already done
  84. *
  85. * @scn: Scene to update
  86. * @menu: Menu to process
  87. * Returns: 0 if OK, -ve on error
  88. */
  89. int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
  90. /**
  91. * scene_apply_theme() - Apply a theme to a scene
  92. *
  93. * @scn: Scene to update
  94. * @theme: Theme to apply
  95. * Returns: 0 if OK, -ve on error
  96. */
  97. int scene_apply_theme(struct scene *scn, struct expo_theme *theme);
  98. /**
  99. * scene_menu_send_key() - Send a key to a menu for processing
  100. *
  101. * @scn: Scene to use
  102. * @menu: Menu to use
  103. * @key: Key code to send (KEY_...)
  104. * @event: Place to put any event which is generated by the key
  105. * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other
  106. * error
  107. */
  108. int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
  109. struct expo_action *event);
  110. /**
  111. * scene_menu_destroy() - Destroy a menu in a scene
  112. *
  113. * @scn: Scene to destroy
  114. */
  115. void scene_menu_destroy(struct scene_obj_menu *menu);
  116. /**
  117. * scene_menu_display() - Display a menu as text
  118. *
  119. * @menu: Menu to display
  120. * Returns: 0 if OK, -ENOENT if @id is invalid
  121. */
  122. int scene_menu_display(struct scene_obj_menu *menu);
  123. /**
  124. * scene_destroy() - Destroy a scene and all its memory
  125. *
  126. * @scn: Scene to destroy
  127. */
  128. void scene_destroy(struct scene *scn);
  129. /**
  130. * scene_render() - Render a scene
  131. *
  132. * This is called from expo_render()
  133. *
  134. * @scn: Scene to render
  135. * Returns: 0 if OK, -ve on error
  136. */
  137. int scene_render(struct scene *scn);
  138. /**
  139. * scene_send_key() - set a keypress to a scene
  140. *
  141. * @scn: Scene to receive the key
  142. * @key: Key to send (KEYCODE_UP)
  143. * @event: Returns resulting event from this keypress
  144. * Returns: 0 if OK, -ve on error
  145. */
  146. int scene_send_key(struct scene *scn, int key, struct expo_action *event);
  147. /**
  148. * scene_menu_render() - Render the background behind a menu
  149. *
  150. * @menu: Menu to render
  151. */
  152. void scene_menu_render(struct scene_obj_menu *menu);
  153. /**
  154. * scene_render_deps() - Render an object and its dependencies
  155. *
  156. * @scn: Scene to render
  157. * @id: Object ID to render (or 0 for none)
  158. * Returns: 0 if OK, -ve on error
  159. */
  160. int scene_render_deps(struct scene *scn, uint id);
  161. /**
  162. * scene_menu_render_deps() - Render a menu and its dependencies
  163. *
  164. * Renders the menu and all of its attached objects
  165. *
  166. * @scn: Scene to render
  167. * @menu: Menu render
  168. * Returns: 0 if OK, -ve on error
  169. */
  170. int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu);
  171. /**
  172. * scene_menu_calc_dims() - Calculate the dimensions of a menu
  173. *
  174. * Updates the width and height of the menu based on its contents
  175. *
  176. * @menu: Menu to update
  177. * Returns 0 if OK, -ENOTSUPP if there is no graphical console
  178. */
  179. int scene_menu_calc_dims(struct scene_obj_menu *menu);
  180. #endif /* __SCENE_INTERNAL_H */