mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
ad947d3085
* add menu widget * Update lv_example_widgets.h * fix errors * Update lv_menu.c * try to fix errors * micropython * Fix colons * Simplify and optimise * Refactor * Update lv_example_menu_3.c * Update lv_example_menu_3.c * Add simple micropython examples * Improvements * Automatically set clickable flags * Custom header example * Include example * Refactor again * Fix error * Fix error * Add back micropython example * Hide back btn by default * Add config * Fix spacing * Fix spacing * Docs * Update lv_theme_default.c * Remove shaded text * Improve clarity * Create index.rst * Update custom header example * Change lv_menu_set_mode_sidebar to lv_menu_set_sidebar_page * Fix unused variable * Added ability to set title to page * Flex * Simplify sidebar check * Rename mode and update header btn * Run lv_conf_internal_gen.py * Run code-format.sh * Add contributors * Micropython example 3 * Micropython example 4 * Improve docs
60 lines
1.8 KiB
C
60 lines
1.8 KiB
C
#include "../../lv_examples.h"
|
|
#if LV_USE_MENU && LV_USE_USER_DATA && LV_BUILD_EXAMPLES
|
|
|
|
void lv_example_menu_3(void)
|
|
{
|
|
/*Create a menu object*/
|
|
lv_obj_t * 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);
|
|
|
|
/*Modify the header*/
|
|
lv_obj_t * back_btn = lv_menu_get_main_header_back_btn(menu);
|
|
lv_obj_t * back_btn_label = lv_label_create(back_btn);
|
|
lv_label_set_text(back_btn_label, "Back");
|
|
|
|
lv_obj_t * cont;
|
|
lv_obj_t * label;
|
|
|
|
/*Create sub pages*/
|
|
lv_obj_t * sub_1_page = lv_menu_page_create(menu, "Page 1");
|
|
|
|
cont = lv_menu_cont_create(sub_1_page);
|
|
label = lv_label_create(cont);
|
|
lv_label_set_text(label, "Hello, I am hiding here");
|
|
|
|
lv_obj_t * sub_2_page = lv_menu_page_create(menu, "Page 2");
|
|
|
|
cont = lv_menu_cont_create(sub_2_page);
|
|
label = lv_label_create(cont);
|
|
lv_label_set_text(label, "Hello, I am hiding here");
|
|
|
|
lv_obj_t * sub_3_page = lv_menu_page_create(menu, "Page 3");
|
|
|
|
cont = lv_menu_cont_create(sub_3_page);
|
|
label = lv_label_create(cont);
|
|
lv_label_set_text(label, "Hello, I am hiding here");
|
|
|
|
/*Create a main page*/
|
|
lv_obj_t * 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 (Click me!)");
|
|
lv_menu_set_load_page_event(menu, cont, sub_1_page);
|
|
|
|
cont = lv_menu_cont_create(main_page);
|
|
label = lv_label_create(cont);
|
|
lv_label_set_text(label, "Item 2 (Click me!)");
|
|
lv_menu_set_load_page_event(menu, cont, sub_2_page);
|
|
|
|
cont = lv_menu_cont_create(main_page);
|
|
label = lv_label_create(cont);
|
|
lv_label_set_text(label, "Item 3 (Click me!)");
|
|
lv_menu_set_load_page_event(menu, cont, sub_3_page);
|
|
|
|
lv_menu_set_page(menu, main_page);
|
|
}
|
|
|
|
#endif
|