1 #include "../../lv_examples.h"
2 #if LV_USE_GRID && LV_BUILD_EXAMPLES
3
row_gap_anim(void * obj,int32_t v)4 static void row_gap_anim(void * obj, int32_t v)
5 {
6 lv_obj_set_style_pad_row(obj, v, 0);
7 }
8
column_gap_anim(void * obj,int32_t v)9 static void column_gap_anim(void * obj, int32_t v)
10 {
11 lv_obj_set_style_pad_column(obj, v, 0);
12 }
13
14 /**
15 * Demonstrate column and row gap
16 */
lv_example_grid_5(void)17 void lv_example_grid_5(void)
18 {
19
20 /*60x60 cells*/
21 static lv_coord_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
22 static lv_coord_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST};
23
24 /*Create a container with grid*/
25 lv_obj_t * cont = lv_obj_create(lv_scr_act());
26 lv_obj_set_size(cont, 300, 220);
27 lv_obj_center(cont);
28 lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc);
29
30 lv_obj_t * label;
31 lv_obj_t * obj;
32 uint32_t i;
33 for(i = 0; i < 9; i++) {
34 uint8_t col = i % 3;
35 uint8_t row = i / 3;
36
37 obj = lv_obj_create(cont);
38 lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1,
39 LV_GRID_ALIGN_STRETCH, row, 1);
40 label = lv_label_create(obj);
41 lv_label_set_text_fmt(label, "%d,%d", col, row);
42 lv_obj_center(label);
43 }
44
45 lv_anim_t a;
46 lv_anim_init(&a);
47 lv_anim_set_var(&a, cont);
48 lv_anim_set_values(&a, 0, 10);
49 lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
50
51 lv_anim_set_exec_cb(&a, row_gap_anim);
52 lv_anim_set_time(&a, 500);
53 lv_anim_set_playback_time(&a, 500);
54 lv_anim_start(&a);
55
56 lv_anim_set_exec_cb(&a, column_gap_anim);
57 lv_anim_set_time(&a, 3000);
58 lv_anim_set_playback_time(&a, 3000);
59 lv_anim_start(&a);
60 }
61
62 #endif
63
64