1 /**
2 * @file lv_tileview.h
3 *
4 */
5
6 #ifndef LV_TILEVIEW_H
7 #define LV_TILEVIEW_H
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 /*********************
14 * INCLUDES
15 *********************/
16 #include "../lv_conf_internal.h"
17
18 #if LV_USE_TILEVIEW != 0
19
20 #include "../lv_widgets/lv_page.h"
21
22 /*********************
23 * DEFINES
24 *********************/
25
26 /**********************
27 * TYPEDEFS
28 **********************/
29
30 /*Data of tileview*/
31 typedef struct {
32 lv_page_ext_t page;
33 /*New data for this type */
34 const lv_point_t * valid_pos;
35 uint16_t valid_pos_cnt;
36 #if LV_USE_ANIMATION
37 uint16_t anim_time;
38 #endif
39 lv_point_t act_id;
40 uint8_t drag_top_en : 1;
41 uint8_t drag_bottom_en : 1;
42 uint8_t drag_left_en : 1;
43 uint8_t drag_right_en : 1;
44 } lv_tileview_ext_t;
45
46 /*Parts of the Tileview*/
47 enum {
48 LV_TILEVIEW_PART_BG = LV_PAGE_PART_BG,
49 LV_TILEVIEW_PART_SCROLLBAR = LV_PAGE_PART_SCROLLBAR,
50 LV_TILEVIEW_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH,
51 _LV_TILEVIEW_PART_VIRTUAL_LAST = _LV_PAGE_PART_VIRTUAL_LAST,
52 _LV_TILEVIEW_PART_REAL_LAST = _LV_PAGE_PART_REAL_LAST
53 };
54
55 /**********************
56 * GLOBAL PROTOTYPES
57 **********************/
58
59 /**
60 * Create a tileview objects
61 * @param par pointer to an object, it will be the parent of the new tileview
62 * @param copy pointer to a tileview object, if not NULL then the new object will be copied from it
63 * @return pointer to the created tileview
64 */
65 lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy);
66
67 /*======================
68 * Add/remove functions
69 *=====================*/
70
71 /**
72 * Register an object on the tileview. The register object will able to slide the tileview
73 * @param tileview pointer to a Tileview object
74 * @param element pointer to an object
75 */
76 void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element);
77
78 /*=====================
79 * Setter functions
80 *====================*/
81
82 /**
83 * Set the valid position's indices. The scrolling will be possible only to these positions.
84 * @param tileview pointer to a Tileview object
85 * @param valid_pos array width the indices. E.g. `lv_point_t p[] = {{0,0}, {1,0}, {1,1}`.
86 * Only the pointer is saved so can't be a local variable.
87 * @param valid_pos_cnt number of elements in `valid_pos` array
88 */
89 void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t valid_pos[], uint16_t valid_pos_cnt);
90
91 /**
92 * Set the tile to be shown
93 * @param tileview pointer to a tileview object
94 * @param x column id (0, 1, 2...)
95 * @param y line id (0, 1, 2...)
96 * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
97 */
98 void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim);
99
100 /**
101 * Enable the edge flash effect. (Show an arc when the an edge is reached)
102 * @param tileview pointer to a Tileview
103 * @param en true or false to enable/disable end flash
104 */
lv_tileview_set_edge_flash(lv_obj_t * tileview,bool en)105 static inline void lv_tileview_set_edge_flash(lv_obj_t * tileview, bool en)
106 {
107 lv_page_set_edge_flash(tileview, en);
108 }
109
110 /**
111 * Set the animation time for the Tile view
112 * @param tileview pointer to a page object
113 * @param anim_time animation time in milliseconds
114 */
lv_tileview_set_anim_time(lv_obj_t * tileview,uint16_t anim_time)115 static inline void lv_tileview_set_anim_time(lv_obj_t * tileview, uint16_t anim_time)
116 {
117 lv_page_set_anim_time(tileview, anim_time);
118 }
119
120 /*=====================
121 * Getter functions
122 *====================*/
123 /**
124 * Get the tile to be shown
125 * @param tileview pointer to a tileview object
126 * @param x column id (0, 1, 2...)
127 * @param y line id (0, 1, 2...)
128 */
129 void lv_tileview_get_tile_act(lv_obj_t * tileview, lv_coord_t * x, lv_coord_t * y);
130 /**
131 * Get the scroll propagation property
132 * @param tileview pointer to a Tileview
133 * @return true or false
134 */
lv_tileview_get_edge_flash(lv_obj_t * tileview)135 static inline bool lv_tileview_get_edge_flash(lv_obj_t * tileview)
136 {
137 return lv_page_get_edge_flash(tileview);
138 }
139
140 /**
141 * Get the animation time for the Tile view
142 * @param tileview pointer to a page object
143 * @return animation time in milliseconds
144 */
lv_tileview_get_anim_time(lv_obj_t * tileview)145 static inline uint16_t lv_tileview_get_anim_time(lv_obj_t * tileview)
146 {
147 return lv_page_get_anim_time(tileview);
148 }
149
150 /*=====================
151 * Other functions
152 *====================*/
153
154 /**********************
155 * MACROS
156 **********************/
157
158 #endif /*LV_USE_TILEVIEW*/
159
160 #ifdef __cplusplus
161 } /* extern "C" */
162 #endif
163
164 #endif /*LV_TILEVIEW_H*/
165