feat(layout): automatically update the screen's layout in lv_obj_scroll_to_view
This commit is contained in:
@@ -14,9 +14,6 @@ static void float_btn_event_cb(lv_obj_t * float_btn, lv_event_t e)
|
||||
|
||||
lv_obj_move_foreground(float_btn);
|
||||
|
||||
/* Layouts are only recalculated later but we need to know the updated position of the new button
|
||||
* to scroll to it. */
|
||||
lv_obj_update_layout(list);
|
||||
lv_obj_scroll_to_view(list_btn, LV_ANIM_ON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user