What do you want to achieve?
I’m trying to dynamically size my menus based on the content. I’m using LV_SIZE_CONTENT (see code below)… However, the menu is not displayed. I’ve stepped through the code and it appears that the menu pages are added to the menu->storage child object, which is the menu container automatically added when you create a menu object. That container is flagged as HIDDEN, which excludes it and its children from being included in the size calculation when using LV_SIZE_CONTENT. What am I doing wrong?
What have you tried so far?
See code below.
Code to reproduce
Here is my code, which is the LVGL sample code for the first menu sample. I have changed the menu size to be 200 width and LV_SIZE_CONTENT for the height.
/Create a menu object/
lv_obj_t* menu = lv_menu_create(lv_screen_active());
lv_obj_set_size(menu, 200, LV_SIZE_CONTENT);
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 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”);
cont = lv_menu_cont_create(main_page);
label = lv_label_create(cont);
lv_label_set_text(label, “Item 2”);
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_page);
lv_menu_set_page(menu, main_page);
Screenshot and/or video
Environment
Running on Windows using the example from LVGL. Note that if I change the menu width to something other than LV_SELF_CONTENT, the menu is displayed.
Thanks.