feat(layout): automatically update the screen's layout in lv_obj_scroll_to_view

This commit is contained in:
Gabor Kiss-Vamosi
2021-03-03 21:10:49 +01:00
parent 0d38d100c2
commit 376da66dab
4 changed files with 9 additions and 10 deletions

View File

@@ -188,8 +188,9 @@ void lv_obj_update_layout(lv_obj_t * obj)
}while(scr->layout_inv); /*Repeat until there where layout invalidations*/
/* Restore the global state because other calls of this function needs this info too.
* Other calls might use different start object, but they need to know if there is dirty layout somewhere.*/
scr->layout_inv = 1;
* Other calls might use different start object, but they need to know if there is dirty layout somewhere.
* However if the screen was updated it's sure that all layouts are ready. */
if(obj != scr) scr->layout_inv = 1;
}

View File

@@ -338,12 +338,18 @@ void lv_obj_scroll_to_y(lv_obj_t * obj, lv_coord_t y, lv_anim_enable_t anim_en)
void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en)
{
/*Be sure the screens layout is correct*/
lv_obj_update_layout(lv_obj_get_screen(obj));
lv_point_t p = {0, 0};
scroll_area_into_view(&obj->coords, obj, &p, anim_en);
}
void lv_obj_scroll_to_view_recursive(lv_obj_t * obj, lv_anim_enable_t anim_en)
{
/*Be sure the screens layout is correct*/
lv_obj_update_layout(lv_obj_get_screen(obj));
lv_point_t p = {0, 0};
lv_obj_t * child = obj;
lv_obj_t * parent = lv_obj_get_parent(child);

View File

@@ -203,15 +203,10 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
uint32_t i;
for(i = 0; i < disp_refr->screen_cnt; i++) {
lv_obj_update_layout(disp_refr->screens[i]);
disp_refr->screens[i]->layout_inv = 0;
}
lv_obj_update_layout(disp_refr->top_layer);
disp_refr->top_layer->layout_inv = 0;
lv_obj_update_layout(disp_refr->sys_layer);
disp_refr->sys_layer->layout_inv = 0;
/*Do nothing if there is no active screen*/
if(disp_refr->act_scr == NULL) {