ui_service.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief ui service interface
  9. */
  10. #ifndef FRAMEWORK_DISPLAY_INCLUDE_UI_SERVICE_H_
  11. #define FRAMEWORK_DISPLAY_INCLUDE_UI_SERVICE_H_
  12. /**
  13. * @defgroup ui_manager_apis app ui Manager APIs
  14. * @ingroup system_apis
  15. * @{
  16. */
  17. #include <input_manager.h>
  18. #include <view_manager.h>
  19. #include <ui_surface.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. enum {
  24. VIEW_SCROLL_MEM_DEF = 0,
  25. VIEW_SCROLL_MEM_SAVE,
  26. VIEW_SCROLL_MEM_LOWEST,
  27. };
  28. typedef struct ui_srv_init_param {
  29. /* allow paused view (has no surface buffer) to scroll */
  30. uint8_t scrl_mem_mode;
  31. uint8_t view_ovl_opa;
  32. uint8_t trans_buf_cnt;
  33. } ui_srv_init_param_t;
  34. /**
  35. * @struct ui_view_gui_callback
  36. * @brief Structure to register gui view callback
  37. */
  38. typedef struct ui_view_gui_callback {
  39. /* init the GUI, must return the GUI context/display from surface */
  40. void * (*init)(surface_t * surface);
  41. /* deinit the GUI context/display */
  42. void (*deinit)(void * display);
  43. /* draw(refresh) paused */
  44. int (*pause)(void * display);
  45. /* draw(refresh) resumed, also decide whether invalidate all */
  46. int (*resume)(void * display, bool full_invalidate);
  47. /* set as the default context for convenience */
  48. int (*set_default)(void * display);
  49. /* make the GUI can get the input event */
  50. int (*focus)(void * display, bool focus);
  51. /* draw(refresh) the GUI dirty or full-screen region immediately */
  52. int (*refresh)(void * display, bool full_refresh);
  53. /* GUI period task handler */
  54. void (*task_handler)(void);
  55. } ui_view_gui_callback_t;
  56. /**
  57. * @struct ui_input_gui_callback
  58. * @brief Structure to register gui input callback
  59. */
  60. typedef struct ui_input_gui_callback {
  61. /* do nothing until next release, except preserving the current pressing
  62. * widget's pressed state.
  63. * will be called when view scrolling begin or focus change
  64. */
  65. void (*wait_release)(void * user_data);
  66. /* enable/disable input */
  67. void (*enable)(bool en, void * user_data);
  68. /* put input data into GUI */
  69. int (*put_data)(const input_dev_data_t * data, void * user_data);
  70. } ui_input_gui_callback_t;
  71. /**
  72. * @struct ui_gesture_callback
  73. * @brief Structure to register gesture callback
  74. */
  75. typedef struct ui_gesture_callback {
  76. /* scroll begin.
  77. * return 0 on success else negative code
  78. */
  79. int (*scroll_begin)(input_dev_t * pointer_dev);
  80. /* scroll the gui views */
  81. void (*scroll)(input_dev_t * pointer_dev);
  82. /* scroll end */
  83. void (*scroll_end)(input_dev_t * pointer_dev);
  84. } ui_gesture_callback_t;
  85. /**
  86. * @brief Register gui callback to view manager
  87. *
  88. * @param type ui view type, see @enum UI_VIEW_TYPE
  89. * @param opa_pixel_format perferred opaque pixel format
  90. * @param trans_pixel_format perferred transparent pixel format
  91. * @param callback pointer to structure ui_view_gui_callback
  92. *
  93. * @retval 0 on success else negative errno code.
  94. */
  95. int ui_service_register_gui_view_callback(uint8_t type,
  96. uint32_t opa_pixel_format, uint32_t trans_pixel_format,
  97. const ui_view_gui_callback_t *callback);
  98. /**
  99. * @brief Register gui callback to input dispatcher
  100. *
  101. * @param type input type, INPUT_DEV_TYPE_x
  102. * @param callback pointer to structure ui_input_gui_callback
  103. * @param user_data user data passed to callback function.
  104. *
  105. * @retval 0 on success else negative errno code.
  106. */
  107. int ui_service_register_gui_input_callback(uint8_t type,
  108. const ui_input_gui_callback_t *callback, void *user_data);
  109. /**
  110. * @brief Register gesture callback to ui service
  111. *
  112. * @param callback pointer to structure ui_input_gui_callback
  113. *
  114. * @retval 0 on success else negative errno code.
  115. */
  116. int ui_service_register_gesture_callback(const ui_gesture_callback_t *callback);
  117. /**
  118. * @brief Register gesture default callback to ui service
  119. *
  120. * @retval 0 on success else negative errno code.
  121. */
  122. int ui_service_register_gesture_default_callback(void);
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. /**
  127. * @} end defgroup system_apis
  128. */
  129. #endif /* FRAMEWORK_DISPLAY_INCLUDE_UI_SERVICE_H_ */