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