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.
71 lines
2.0 KiB
C
71 lines
2.0 KiB
C
2 years ago
|
#include "../../lv_examples.h"
|
||
|
#if LV_USE_MENU && LV_BUILD_EXAMPLES
|
||
|
|
||
|
static uint32_t btn_cnt = 1;
|
||
|
static lv_obj_t * main_page;
|
||
|
static lv_obj_t * menu;
|
||
|
|
||
|
static void float_btn_event_cb(lv_event_t * e)
|
||
|
{
|
||
|
LV_UNUSED(e);
|
||
|
|
||
|
btn_cnt++;
|
||
|
|
||
|
lv_obj_t * cont;
|
||
|
lv_obj_t * label;
|
||
|
|
||
|
lv_obj_t * sub_page = lv_menu_page_create(menu, NULL);
|
||
|
|
||
|
cont = lv_menu_cont_create(sub_page);
|
||
|
label = lv_label_create(cont);
|
||
|
lv_label_set_text_fmt(label, "Hello, I am hiding inside %i", btn_cnt);
|
||
|
|
||
|
cont = lv_menu_cont_create(main_page);
|
||
|
label = lv_label_create(cont);
|
||
|
lv_label_set_text_fmt(label, "Item %i", btn_cnt);
|
||
|
lv_menu_set_load_page_event(menu, cont, sub_page);
|
||
|
|
||
|
lv_obj_scroll_to_view_recursive(cont, LV_ANIM_ON);
|
||
|
}
|
||
|
|
||
|
void lv_example_menu_4(void)
|
||
|
{
|
||
|
/*Create a menu object*/
|
||
|
menu = lv_menu_create(lv_scr_act());
|
||
|
lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
|
||
|
lv_obj_center(menu);
|
||
|
|
||
|
lv_obj_t * cont;
|
||
|
lv_obj_t * label;
|
||
|
|
||
|
/*Create a sub page*/
|
||
|
lv_obj_t * sub_page = lv_menu_page_create(menu, NULL);
|
||
|
|
||
|
cont = lv_menu_cont_create(sub_page);
|
||
|
label = lv_label_create(cont);
|
||
|
lv_label_set_text(label, "Hello, I am hiding inside the first item");
|
||
|
|
||
|
/*Create a main page*/
|
||
|
main_page = lv_menu_page_create(menu, NULL);
|
||
|
|
||
|
cont = lv_menu_cont_create(main_page);
|
||
|
label = lv_label_create(cont);
|
||
|
lv_label_set_text(label, "Item 1");
|
||
|
lv_menu_set_load_page_event(menu, cont, sub_page);
|
||
|
|
||
|
lv_menu_set_page(menu, main_page);
|
||
|
|
||
|
/*Create floating btn*/
|
||
|
lv_obj_t * float_btn = lv_btn_create(lv_scr_act());
|
||
|
lv_obj_set_size(float_btn, 50, 50);
|
||
|
lv_obj_add_flag(float_btn, LV_OBJ_FLAG_FLOATING);
|
||
|
lv_obj_align(float_btn, LV_ALIGN_BOTTOM_RIGHT, -10, -10);
|
||
|
lv_obj_add_event_cb(float_btn, float_btn_event_cb, LV_EVENT_CLICKED, menu);
|
||
|
lv_obj_set_style_radius(float_btn, LV_RADIUS_CIRCLE, 0);
|
||
|
lv_obj_set_style_bg_img_src(float_btn, LV_SYMBOL_PLUS, 0);
|
||
|
lv_obj_set_style_text_font(float_btn, lv_theme_get_font_large(float_btn), 0);
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|