You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
#include "../../lv_examples.h"
|
|
#if LV_USE_GRIDNAV && LV_USE_LIST && LV_BUILD_EXAMPLES
|
|
|
|
/**
|
|
* Grid navigation on a list
|
|
*/
|
|
void lv_example_gridnav_2(void)
|
|
{
|
|
/*It's assumed that the default group is set and
|
|
*there is a keyboard indev*/
|
|
|
|
lv_obj_t * list1 = lv_list_create(lv_scr_act());
|
|
lv_gridnav_add(list1, LV_GRIDNAV_CTRL_NONE);
|
|
lv_obj_set_size(list1, lv_pct(45), lv_pct(80));
|
|
lv_obj_align(list1, LV_ALIGN_LEFT_MID, 5, 0);
|
|
lv_obj_set_style_bg_color(list1, lv_palette_lighten(LV_PALETTE_BLUE, 5), LV_STATE_FOCUSED);
|
|
lv_group_add_obj(lv_group_get_default(), list1);
|
|
|
|
|
|
char buf[32];
|
|
uint32_t i;
|
|
for(i = 0; i < 15; i++) {
|
|
lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
|
|
lv_obj_t * item = lv_list_add_btn(list1, LV_SYMBOL_FILE, buf);
|
|
lv_obj_set_style_bg_opa(item, 0, 0);
|
|
lv_group_remove_obj(item); /*Not needed, we use the gridnav instead*/
|
|
}
|
|
|
|
lv_obj_t * list2 = lv_list_create(lv_scr_act());
|
|
lv_gridnav_add(list2, LV_GRIDNAV_CTRL_ROLLOVER);
|
|
lv_obj_set_size(list2, lv_pct(45), lv_pct(80));
|
|
lv_obj_align(list2, LV_ALIGN_RIGHT_MID, -5, 0);
|
|
lv_obj_set_style_bg_color(list2, lv_palette_lighten(LV_PALETTE_BLUE, 5), LV_STATE_FOCUSED);
|
|
lv_group_add_obj(lv_group_get_default(), list2);
|
|
|
|
for(i = 0; i < 15; i++) {
|
|
lv_snprintf(buf, sizeof(buf), "Folder %d", i + 1);
|
|
lv_obj_t * item = lv_list_add_btn(list2, LV_SYMBOL_DIRECTORY, buf);
|
|
lv_obj_set_style_bg_opa(item, 0, 0);
|
|
lv_group_remove_obj(item);
|
|
}
|
|
}
|
|
|
|
#endif
|