lv_group.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * @file lv_group.h
  3. *
  4. */
  5. #ifndef LV_GROUP_H
  6. #define LV_GROUP_H
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /*********************
  11. * INCLUDES
  12. *********************/
  13. #include "../../lv_conf.h"
  14. #include "lv_obj.h"
  15. /*********************
  16. * DEFINES
  17. *********************/
  18. /*Predefined keys to control the focused object via lv_group_send(group, c)*/
  19. /*For compatibility in signal function define the keys regardless to LV_GROUP*/
  20. #define LV_GROUP_KEY_UP 17 /*0x11*/
  21. #define LV_GROUP_KEY_DOWN 18 /*0x12*/
  22. #define LV_GROUP_KEY_RIGHT 19 /*0x13*/
  23. #define LV_GROUP_KEY_LEFT 20 /*0x14*/
  24. #define LV_GROUP_KEY_ESC 27 /*0x1B*/
  25. #define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/
  26. #define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/
  27. #define LV_GROUP_KEY_PREV 11 /*0x0B, '*/
  28. #define LV_GROUP_KEY_ENTER_LONG 14 /*0x0E, Sent by the library if ENTER is long pressed*/
  29. #if USE_LV_GROUP != 0
  30. /**********************
  31. * TYPEDEFS
  32. **********************/
  33. struct _lv_group_t;
  34. typedef void (*lv_group_style_mod_func_t)(lv_style_t *);
  35. typedef void (*lv_group_focus_cb_t)(struct _lv_group_t *);
  36. typedef struct _lv_group_t
  37. {
  38. lv_ll_t obj_ll; /*Linked list to store the objects in the group */
  39. lv_obj_t ** obj_focus; /*The object in focus*/
  40. lv_group_style_mod_func_t style_mod; /*A function which modifies the style of the focused object*/
  41. lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/
  42. lv_style_t style_tmp; /*Stores the modified style of the focused object */
  43. uint8_t frozen:1; /*1: can't focus to new object*/
  44. }lv_group_t;
  45. /**********************
  46. * GLOBAL PROTOTYPES
  47. **********************/
  48. /**
  49. * Create a new object group
  50. * @return pointer to the new object group
  51. */
  52. lv_group_t * lv_group_create(void);
  53. /**
  54. * Delete a group object
  55. * @param group pointer to a group
  56. */
  57. void lv_group_del(lv_group_t * group);
  58. /**
  59. * Add an object to a group
  60. * @param group pointer to a group
  61. * @param obj pointer to an object to add
  62. */
  63. void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj);
  64. /**
  65. * Remove an object from its group
  66. * @param obj pointer to an object to remove
  67. */
  68. void lv_group_remove_obj(lv_obj_t * obj);
  69. /**
  70. * Focus on an object (defocus the current)
  71. * @param obj pointer to an object to focus on
  72. */
  73. void lv_group_focus_obj(lv_obj_t * obj);
  74. /**
  75. * Focus the next object in a group (defocus the current)
  76. * @param group pointer to a group
  77. */
  78. void lv_group_focus_next(lv_group_t * group);
  79. /**
  80. * Focus the previous object in a group (defocus the current)
  81. * @param group pointer to a group
  82. */
  83. void lv_group_focus_prev(lv_group_t * group);
  84. /**
  85. * Do not let to change the focus from the current object
  86. * @param group pointer to a group
  87. * @param en true: freeze, false: release freezing (normal mode)
  88. */
  89. void lv_group_focus_freeze(lv_group_t * group, bool en);
  90. /**
  91. * Send a control character to the focuses object of a group
  92. * @param group pointer to a group
  93. * @param c a character (use LV_GROUP_KEY_.. to navigate)
  94. */
  95. void lv_group_send_data(lv_group_t * group, uint32_t c);
  96. /**
  97. * Set a function for a group which will modify the object's style if it is in focus
  98. * @param group pointer to a group
  99. * @param style_mod_func the style modifier function pointer
  100. */
  101. void lv_group_set_style_mod_cb(lv_group_t * group,lv_group_style_mod_func_t style_mod_func);
  102. /**
  103. * Set a function for a group which will be called when a new object is focused
  104. * @param group pointer to a group
  105. * @param focus_cb the call back function or NULL if unused
  106. */
  107. void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb);
  108. /**
  109. * Modify a style with the set 'style_mod' function. The input style remains unchanged.
  110. * @param group pointer to group
  111. * @param style pointer to a style to modify
  112. * @return a copy of the input style but modified with the 'style_mod' function
  113. */
  114. lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style);
  115. /**
  116. * Get the focused object or NULL if there isn't one
  117. * @param group pointer to a group
  118. * @return pointer to the focused object
  119. */
  120. lv_obj_t * lv_group_get_focused(lv_group_t * group);
  121. /**
  122. * Get a the style modifier function of a group
  123. * @param group pointer to a group
  124. * @return pointer to the style modifier function
  125. */
  126. lv_group_style_mod_func_t lv_group_get_style_mod_cb(lv_group_t * group);
  127. /**
  128. * Get the focus callback function of a group
  129. * @param group pointer to a group
  130. * @return the call back function or NULL if not set
  131. */
  132. lv_group_focus_cb_t lv_group_get_focus_cb(lv_group_t * group);
  133. /**********************
  134. * MACROS
  135. **********************/
  136. #endif /*USE_LV_GROUP != 0*/
  137. #ifdef __cplusplus
  138. } /* extern "C" */
  139. #endif
  140. #endif /*LV_GROUP_H*/