1 #include "../../lv_examples.h"
2 #if LV_USE_GRIDNAV && LV_USE_LIST && LV_BUILD_EXAMPLES
3
4 /**
5 * Grid navigation on a list
6 */
lv_example_gridnav_2(void)7 void lv_example_gridnav_2(void)
8 {
9 /*It's assumed that the default group is set and
10 *there is a keyboard indev*/
11
12 lv_obj_t * list1 = lv_list_create(lv_scr_act());
13 lv_gridnav_add(list1, LV_GRIDNAV_CTRL_NONE);
14 lv_obj_set_size(list1, lv_pct(45), lv_pct(80));
15 lv_obj_align(list1, LV_ALIGN_LEFT_MID, 5, 0);
16 lv_obj_set_style_bg_color(list1, lv_palette_lighten(LV_PALETTE_BLUE, 5), LV_STATE_FOCUSED);
17 lv_group_add_obj(lv_group_get_default(), list1);
18
19
20 char buf[32];
21 uint32_t i;
22 for(i = 0; i < 15; i++) {
23 lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
24 lv_obj_t * item = lv_list_add_btn(list1, LV_SYMBOL_FILE, buf);
25 lv_obj_set_style_bg_opa(item, 0, 0);
26 lv_group_remove_obj(item); /*Not needed, we use the gridnav instead*/
27 }
28
29 lv_obj_t * list2 = lv_list_create(lv_scr_act());
30 lv_gridnav_add(list2, LV_GRIDNAV_CTRL_ROLLOVER);
31 lv_obj_set_size(list2, lv_pct(45), lv_pct(80));
32 lv_obj_align(list2, LV_ALIGN_RIGHT_MID, -5, 0);
33 lv_obj_set_style_bg_color(list2, lv_palette_lighten(LV_PALETTE_BLUE, 5), LV_STATE_FOCUSED);
34 lv_group_add_obj(lv_group_get_default(), list2);
35
36 for(i = 0; i < 15; i++) {
37 lv_snprintf(buf, sizeof(buf), "Folder %d", i + 1);
38 lv_obj_t * item = lv_list_add_btn(list2, LV_SYMBOL_DIRECTORY, buf);
39 lv_obj_set_style_bg_opa(item, 0, 0);
40 lv_group_remove_obj(item);
41 }
42 }
43
44 #endif
45