Lines Matching refs:menu
109 bool lv_menu_item_back_btn_is_root(lv_obj_t * menu, lv_obj_t * obj);
168 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_refr() local
169 lv_ll_t * history_ll = &(menu->history_ll); in lv_menu_refr()
181 menu->cur_depth--; in lv_menu_refr()
196 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_set_page() local
199 if(menu->main_page == page) { in lv_menu_set_page()
204 if(menu->main_page != NULL) { in lv_menu_set_page()
205 lv_obj_set_parent(menu->main_page, menu->storage); in lv_menu_set_page()
210 lv_ll_t * history_ll = &(menu->history_ll); in lv_menu_set_page()
214 menu->cur_depth++; in lv_menu_set_page()
217 lv_obj_set_parent(page, menu->main); in lv_menu_set_page()
224 menu->main_page = page; in lv_menu_set_page()
227 if(menu->selected_tab != NULL) { in lv_menu_set_page()
228 if(menu->sidebar_page != NULL) { in lv_menu_set_page()
229 lv_obj_add_state(menu->selected_tab, LV_STATE_CHECKED); in lv_menu_set_page()
232 lv_obj_clear_state(menu->selected_tab, LV_STATE_CHECKED); in lv_menu_set_page()
237 if(menu->sidebar_page != NULL) { in lv_menu_set_page()
239 if(menu->sidebar_generated) { in lv_menu_set_page()
240 if(menu->mode_root_back_btn == LV_MENU_ROOT_BACK_BTN_ENABLED) { in lv_menu_set_page()
242 lv_obj_clear_flag(menu->sidebar_header_back_btn, LV_OBJ_FLAG_HIDDEN); in lv_menu_set_page()
243 lv_obj_add_flag(menu->sidebar_header_back_btn, LV_OBJ_FLAG_CLICKABLE); in lv_menu_set_page()
246 lv_obj_add_flag(menu->sidebar_header_back_btn, LV_OBJ_FLAG_HIDDEN); in lv_menu_set_page()
247 lv_obj_clear_flag(menu->sidebar_header_back_btn, LV_OBJ_FLAG_CLICKABLE); in lv_menu_set_page()
251 if(menu->cur_depth >= 2) { in lv_menu_set_page()
252 lv_obj_clear_flag(menu->main_header_back_btn, LV_OBJ_FLAG_HIDDEN); in lv_menu_set_page()
253 lv_obj_add_flag(menu->main_header_back_btn, LV_OBJ_FLAG_CLICKABLE); in lv_menu_set_page()
256 lv_obj_add_flag(menu->main_header_back_btn, LV_OBJ_FLAG_HIDDEN); in lv_menu_set_page()
257 lv_obj_clear_flag(menu->main_header_back_btn, LV_OBJ_FLAG_CLICKABLE); in lv_menu_set_page()
262 if(menu->cur_depth >= 2 || menu->mode_root_back_btn == LV_MENU_ROOT_BACK_BTN_ENABLED) { in lv_menu_set_page()
263 lv_obj_clear_flag(menu->main_header_back_btn, LV_OBJ_FLAG_HIDDEN); in lv_menu_set_page()
264 lv_obj_add_flag(menu->main_header_back_btn, LV_OBJ_FLAG_CLICKABLE); in lv_menu_set_page()
267 lv_obj_add_flag(menu->main_header_back_btn, LV_OBJ_FLAG_HIDDEN); in lv_menu_set_page()
268 lv_obj_clear_flag(menu->main_header_back_btn, LV_OBJ_FLAG_CLICKABLE); in lv_menu_set_page()
272 lv_event_send((lv_obj_t *)menu, LV_EVENT_VALUE_CHANGED, NULL); in lv_menu_set_page()
281 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_set_sidebar_page() local
286 if(!menu->sidebar_generated) { in lv_menu_set_sidebar_page()
295 menu->sidebar = sidebar_cont; in lv_menu_set_sidebar_page()
304 menu->sidebar_header = sidebar_header; in lv_menu_set_sidebar_page()
306 lv_obj_t * sidebar_header_back_btn = lv_btn_create(menu->sidebar_header); in lv_menu_set_sidebar_page()
307 … lv_obj_add_event_cb(sidebar_header_back_btn, lv_menu_back_event_cb, LV_EVENT_CLICKED, menu); in lv_menu_set_sidebar_page()
310 menu->sidebar_header_back_btn = sidebar_header_back_btn; in lv_menu_set_sidebar_page()
312 lv_obj_t * sidebar_header_back_icon = lv_img_create(menu->sidebar_header_back_btn); in lv_menu_set_sidebar_page()
315 lv_obj_t * sidebar_header_title = lv_label_create(menu->sidebar_header); in lv_menu_set_sidebar_page()
317 menu->sidebar_header_title = sidebar_header_title; in lv_menu_set_sidebar_page()
319 menu->sidebar_generated = true; in lv_menu_set_sidebar_page()
322 lv_obj_set_parent(page, menu->sidebar); in lv_menu_set_sidebar_page()
328 if(menu->sidebar_generated) { in lv_menu_set_sidebar_page()
329 lv_obj_set_parent(menu->sidebar_page, menu->storage); in lv_menu_set_sidebar_page()
330 lv_obj_del(menu->sidebar); in lv_menu_set_sidebar_page()
332 menu->sidebar_generated = false; in lv_menu_set_sidebar_page()
336 menu->sidebar_page = page; in lv_menu_set_sidebar_page()
344 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_set_mode_header() local
346 if(menu->mode_header != mode_header) { in lv_menu_set_mode_header()
347 menu->mode_header = mode_header; in lv_menu_set_mode_header()
349 if(menu->sidebar_generated) lv_menu_refr_sidebar_header_mode(obj); in lv_menu_set_mode_header()
357 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_set_mode_root_back_btn() local
359 if(menu->mode_root_back_btn != mode_root_back_btn) { in lv_menu_set_mode_root_back_btn()
360 menu->mode_root_back_btn = mode_root_back_btn; in lv_menu_set_mode_root_back_btn()
365 void lv_menu_set_load_page_event(lv_obj_t * menu, lv_obj_t * obj, lv_obj_t * page) in lv_menu_set_load_page_event() argument
367 LV_ASSERT_OBJ(menu, MY_CLASS); in lv_menu_set_load_page_event()
380 event_data->menu = menu; in lv_menu_set_load_page_event()
394 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_get_cur_main_page() local
395 return menu->main_page; in lv_menu_get_cur_main_page()
402 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_get_cur_sidebar_page() local
403 return menu->sidebar_page; in lv_menu_get_cur_sidebar_page()
410 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_get_main_header() local
411 return menu->main_header; in lv_menu_get_main_header()
418 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_get_main_header_back_btn() local
419 return menu->main_header_back_btn; in lv_menu_get_main_header_back_btn()
426 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_get_sidebar_header() local
427 return menu->sidebar_header; in lv_menu_get_sidebar_header()
434 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_get_sidebar_header_back_btn() local
435 return menu->sidebar_header_back_btn; in lv_menu_get_sidebar_header_back_btn()
438 bool lv_menu_back_btn_is_root(lv_obj_t * menu, lv_obj_t * obj) in lv_menu_back_btn_is_root() argument
440 LV_ASSERT_OBJ(menu, MY_CLASS); in lv_menu_back_btn_is_root()
442 if(obj == ((lv_menu_t *)menu)->sidebar_header_back_btn) { in lv_menu_back_btn_is_root()
446 if(obj == ((lv_menu_t *)menu)->main_header_back_btn && ((lv_menu_t *)menu)->prev_depth <= 1) { in lv_menu_back_btn_is_root()
457 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_clear_history() local
458 lv_ll_t * history_ll = &(menu->history_ll); in lv_menu_clear_history()
462 menu->cur_depth = 0; in lv_menu_clear_history()
477 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_constructor() local
479 menu->mode_header = LV_MENU_HEADER_TOP_FIXED; in lv_menu_constructor()
480 menu->mode_root_back_btn = LV_MENU_ROOT_BACK_BTN_DISABLED; in lv_menu_constructor()
481 menu->cur_depth = 0; in lv_menu_constructor()
482 menu->prev_depth = 0; in lv_menu_constructor()
483 menu->sidebar_generated = false; in lv_menu_constructor()
485 _lv_ll_init(&(menu->history_ll), sizeof(lv_menu_history_t)); in lv_menu_constructor()
487 menu->storage = lv_obj_create(obj); in lv_menu_constructor()
488 lv_obj_add_flag(menu->storage, LV_OBJ_FLAG_HIDDEN); in lv_menu_constructor()
490 menu->sidebar = NULL; in lv_menu_constructor()
491 menu->sidebar_header = NULL; in lv_menu_constructor()
492 menu->sidebar_header_back_btn = NULL; in lv_menu_constructor()
493 menu->sidebar_header_title = NULL; in lv_menu_constructor()
494 menu->sidebar_page = NULL; in lv_menu_constructor()
503 menu->main = main_cont; in lv_menu_constructor()
512 menu->main_header = main_header; in lv_menu_constructor()
515 lv_obj_t * main_header_back_btn = lv_btn_create(menu->main_header); in lv_menu_constructor()
516 lv_obj_add_event_cb(main_header_back_btn, lv_menu_back_event_cb, LV_EVENT_CLICKED, menu); in lv_menu_constructor()
519 menu->main_header_back_btn = main_header_back_btn; in lv_menu_constructor()
521 lv_obj_t * main_header_back_icon = lv_img_create(menu->main_header_back_btn); in lv_menu_constructor()
524 lv_obj_t * main_header_title = lv_label_create(menu->main_header); in lv_menu_constructor()
526 menu->main_header_title = main_header_title; in lv_menu_constructor()
528 menu->main_page = NULL; in lv_menu_constructor()
529 menu->selected_tab = NULL; in lv_menu_constructor()
531 lv_obj_add_event_cb(obj, lv_menu_value_changed_event_cb, LV_EVENT_VALUE_CHANGED, menu); in lv_menu_constructor()
541 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_destructor() local
542 lv_ll_t * history_ll = &(menu->history_ll); in lv_menu_destructor()
553 lv_menu_t * menu = (lv_menu_t *)lv_obj_get_parent(obj); in lv_menu_page_constructor() local
555 lv_obj_set_parent(obj, ((lv_menu_t *)menu)->storage); in lv_menu_page_constructor()
592 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_refr_sidebar_header_mode() local
594 if(menu->sidebar_header == NULL || menu->sidebar_page == NULL) return; in lv_menu_refr_sidebar_header_mode()
596 switch(menu->mode_header) { in lv_menu_refr_sidebar_header_mode()
599 lv_obj_move_to_index(menu->sidebar_header, 0); in lv_menu_refr_sidebar_header_mode()
600 lv_obj_set_flex_grow(menu->sidebar_page, 1); in lv_menu_refr_sidebar_header_mode()
603 lv_obj_move_to_index(menu->sidebar_header, 0); in lv_menu_refr_sidebar_header_mode()
604 lv_obj_set_flex_grow(menu->sidebar_page, 0); in lv_menu_refr_sidebar_header_mode()
607 lv_obj_move_to_index(menu->sidebar_header, 1); in lv_menu_refr_sidebar_header_mode()
608 lv_obj_set_flex_grow(menu->sidebar_page, 1); in lv_menu_refr_sidebar_header_mode()
612 lv_obj_refr_size(menu->sidebar_header); in lv_menu_refr_sidebar_header_mode()
613 lv_obj_refr_size(menu->sidebar_page); in lv_menu_refr_sidebar_header_mode()
615 if(lv_obj_get_content_height(menu->sidebar_header) == 0) { in lv_menu_refr_sidebar_header_mode()
616 lv_obj_add_flag(menu->sidebar_header, LV_OBJ_FLAG_HIDDEN); in lv_menu_refr_sidebar_header_mode()
619 lv_obj_clear_flag(menu->sidebar_header, LV_OBJ_FLAG_HIDDEN); in lv_menu_refr_sidebar_header_mode()
627 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_refr_main_header_mode() local
629 if(menu->main_header == NULL || menu->main_page == NULL) return; in lv_menu_refr_main_header_mode()
631 switch(menu->mode_header) { in lv_menu_refr_main_header_mode()
634 lv_obj_move_to_index(menu->main_header, 0); in lv_menu_refr_main_header_mode()
635 lv_obj_set_flex_grow(menu->main_page, 1); in lv_menu_refr_main_header_mode()
638 lv_obj_move_to_index(menu->main_header, 0); in lv_menu_refr_main_header_mode()
639 lv_obj_set_flex_grow(menu->main_page, 0); in lv_menu_refr_main_header_mode()
642 lv_obj_move_to_index(menu->main_header, 1); in lv_menu_refr_main_header_mode()
643 lv_obj_set_flex_grow(menu->main_page, 1); in lv_menu_refr_main_header_mode()
647 lv_obj_refr_size(menu->main_header); in lv_menu_refr_main_header_mode()
648 lv_obj_refr_size(menu->main_page); in lv_menu_refr_main_header_mode()
649 lv_obj_update_layout(menu->main_header); in lv_menu_refr_main_header_mode()
651 if(lv_obj_get_content_height(menu->main_header) == 0) { in lv_menu_refr_main_header_mode()
652 lv_obj_add_flag(menu->main_header, LV_OBJ_FLAG_HIDDEN); in lv_menu_refr_main_header_mode()
655 lv_obj_clear_flag(menu->main_header, LV_OBJ_FLAG_HIDDEN); in lv_menu_refr_main_header_mode()
663 lv_menu_t * menu = (lv_menu_t *)(event_data->menu); in lv_menu_load_page_event_cb() local
666 if(menu->sidebar_page != NULL) { in lv_menu_load_page_event_cb()
672 if(parent == (lv_obj_t *)menu) break; in lv_menu_load_page_event_cb()
673 if(parent == menu->sidebar) { in lv_menu_load_page_event_cb()
682 if(menu->selected_tab != obj && menu->selected_tab != NULL) { in lv_menu_load_page_event_cb()
683 lv_obj_clear_state(menu->selected_tab, LV_STATE_CHECKED); in lv_menu_load_page_event_cb()
686 lv_menu_clear_history((lv_obj_t *)menu); in lv_menu_load_page_event_cb()
688 menu->selected_tab = obj; in lv_menu_load_page_event_cb()
692 lv_menu_set_page((lv_obj_t *)menu, page); in lv_menu_load_page_event_cb()
694 if(lv_group_get_default() != NULL && menu->sidebar_page == NULL) { in lv_menu_load_page_event_cb()
712 lv_menu_t * menu = (lv_menu_t *)lv_event_get_user_data(e); in lv_menu_back_event_cb() local
714 if(!(obj == menu->main_header_back_btn || obj == menu->sidebar_header_back_btn)) return; in lv_menu_back_event_cb()
716 menu->prev_depth = menu->cur_depth; /* Save the previous value for user event handler */ in lv_menu_back_event_cb()
718 if(lv_menu_back_btn_is_root((lv_obj_t *)menu, obj)) return; in lv_menu_back_event_cb()
720 lv_ll_t * history_ll = &(menu->history_ll); in lv_menu_back_event_cb()
733 menu->cur_depth--; in lv_menu_back_event_cb()
737 menu->cur_depth--; in lv_menu_back_event_cb()
738 lv_menu_set_page(&(menu->obj), prev_hist->page); in lv_menu_back_event_cb()
748 lv_menu_t * menu = (lv_menu_t *)obj; in lv_menu_value_changed_event_cb() local
751 if(main_page != NULL && menu->main_header_title != NULL) { in lv_menu_value_changed_event_cb()
753 lv_label_set_text(menu->main_header_title, main_page->title); in lv_menu_value_changed_event_cb()
754 lv_obj_clear_flag(menu->main_header_title, LV_OBJ_FLAG_HIDDEN); in lv_menu_value_changed_event_cb()
757 lv_obj_add_flag(menu->main_header_title, LV_OBJ_FLAG_HIDDEN); in lv_menu_value_changed_event_cb()
762 if(sidebar_page != NULL && menu->sidebar_header_title != NULL) { in lv_menu_value_changed_event_cb()
764 lv_label_set_text(menu->sidebar_header_title, sidebar_page->title); in lv_menu_value_changed_event_cb()
765 lv_obj_clear_flag(menu->sidebar_header_title, LV_OBJ_FLAG_HIDDEN); in lv_menu_value_changed_event_cb()
768 lv_obj_add_flag(menu->sidebar_header_title, LV_OBJ_FLAG_HIDDEN); in lv_menu_value_changed_event_cb()