add lv_obj_invalidate_area to replace lv_inv_area in objects. Fixes #1360
This commit is contained in:
@@ -521,10 +521,12 @@ void lv_obj_clean(lv_obj_t * obj)
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* Mark an area of an object as invalid.
|
||||
* This area will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
* @param area the area to redraw
|
||||
*/
|
||||
void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
@@ -535,31 +537,56 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
lv_disp_t * disp = lv_obj_get_disp(obj_scr);
|
||||
if(obj_scr == lv_disp_get_scr_act(disp) || obj_scr == lv_disp_get_layer_top(disp) ||
|
||||
obj_scr == lv_disp_get_layer_sys(disp)) {
|
||||
/*Truncate recursively to the parents*/
|
||||
lv_area_t area_trunc;
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
bool union_ok = true;
|
||||
/*Start with the original coordinates*/
|
||||
lv_coord_t ext_size = obj->ext_draw_pad;
|
||||
lv_area_copy(&area_trunc, &obj->coords);
|
||||
area_trunc.x1 -= ext_size;
|
||||
area_trunc.y1 -= ext_size;
|
||||
area_trunc.x2 += ext_size;
|
||||
area_trunc.y2 += ext_size;
|
||||
|
||||
/*Check through all parents*/
|
||||
/*Truncate the area to the object*/
|
||||
lv_area_t obj_coords;
|
||||
lv_coord_t ext_size = obj->ext_draw_pad;
|
||||
lv_area_copy(&obj_coords, &obj->coords);
|
||||
obj_coords.x1 -= ext_size;
|
||||
obj_coords.y1 -= ext_size;
|
||||
obj_coords.x2 += ext_size;
|
||||
obj_coords.y2 += ext_size;
|
||||
|
||||
bool is_common;
|
||||
lv_area_t area_trunc;
|
||||
|
||||
is_common = lv_area_intersect(&area_trunc, area, &obj_coords);
|
||||
if(is_common == false) return; /*The area is not on the object*/
|
||||
|
||||
/*Truncate recursively to the parents*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
while(par != NULL) {
|
||||
union_ok = lv_area_intersect(&area_trunc, &area_trunc, &par->coords);
|
||||
if(union_ok == false) break; /*If no common parts with parent break;*/
|
||||
is_common = lv_area_intersect(&area_trunc, &area_trunc, &par->coords);
|
||||
if(is_common == false) break; /*If no common parts with parent break;*/
|
||||
if(lv_obj_get_hidden(par)) return; /*If the parent is hidden then the child is hidden and won't be drawn*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
|
||||
if(union_ok) lv_inv_area(disp, &area_trunc);
|
||||
if(is_common) lv_inv_area(disp, &area_trunc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
/*Truncate the area to the object*/
|
||||
lv_area_t obj_coords;
|
||||
lv_coord_t ext_size = obj->ext_draw_pad;
|
||||
lv_area_copy(&obj_coords, &obj->coords);
|
||||
obj_coords.x1 -= ext_size;
|
||||
obj_coords.y1 -= ext_size;
|
||||
obj_coords.x2 += ext_size;
|
||||
obj_coords.y2 += ext_size;
|
||||
|
||||
lv_obj_invalidate_area(obj, &obj_coords);
|
||||
|
||||
}
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
@@ -312,6 +312,15 @@ void lv_obj_del_async(struct _lv_obj_t *obj);
|
||||
*/
|
||||
void lv_obj_clean(lv_obj_t * obj);
|
||||
|
||||
|
||||
/**
|
||||
* Mark an area of an object as invalid.
|
||||
* This area will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
* @param area the area to redraw
|
||||
*/
|
||||
void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
|
||||
@@ -1084,7 +1084,7 @@ static void invalidate_button_area(const lv_obj_t * btnm, uint16_t btn_idx)
|
||||
btn_area.x2 += btnm_area.x1;
|
||||
btn_area.y2 += btnm_area.y1;
|
||||
|
||||
lv_inv_area(lv_obj_get_disp(btnm), &btn_area);
|
||||
lv_obj_invalidate_area(btnm, &btn_area);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1496,13 +1496,13 @@ static void lv_chart_inv_lines(lv_obj_t * chart, uint16_t i)
|
||||
if(i < ext->point_cnt - 1) {
|
||||
coords.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs - ext->series.width;
|
||||
coords.x2 = ((w * (i + 1)) / (ext->point_cnt - 1)) + x_ofs + ext->series.width;
|
||||
lv_inv_area(lv_obj_get_disp(chart), &coords);
|
||||
lv_obj_invalidate_area(chart, &coords);
|
||||
}
|
||||
|
||||
if(i > 0) {
|
||||
coords.x1 = ((w * (i - 1)) / (ext->point_cnt - 1)) + x_ofs - ext->series.width;
|
||||
coords.x2 = ((w * i) / (ext->point_cnt - 1)) + x_ofs + ext->series.width;
|
||||
lv_inv_area(lv_obj_get_disp(chart), &coords);
|
||||
lv_obj_invalidate_area(chart, &coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ static void invalidate_indic(lv_obj_t * cpicker)
|
||||
{
|
||||
lv_area_t indic_area = get_indic_area(cpicker);
|
||||
|
||||
lv_inv_area(lv_obj_get_disp(cpicker), &indic_area);
|
||||
lv_obj_invalidate_area(cpicker, &indic_area);
|
||||
}
|
||||
|
||||
static lv_area_t get_indic_area(lv_obj_t * cpicker)
|
||||
|
||||
@@ -1081,7 +1081,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
lv_obj_invalidate_area(page, &sb_area_tmp);
|
||||
page_ext->sb.hor_draw = 0;
|
||||
}
|
||||
if(page_ext->sb.ver_draw) {
|
||||
@@ -1090,7 +1090,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
lv_obj_invalidate_area(page, &sb_area_tmp);
|
||||
page_ext->sb.ver_draw = 0;
|
||||
}
|
||||
}
|
||||
@@ -1158,7 +1158,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
lv_obj_invalidate_area(page, &sb_area_tmp);
|
||||
}
|
||||
if(ext->sb.ver_draw != 0) {
|
||||
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
|
||||
@@ -1166,7 +1166,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
lv_obj_invalidate_area(page, &sb_area_tmp);
|
||||
}
|
||||
|
||||
if(ext->sb.mode == LV_SB_MODE_DRAG && lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
||||
@@ -1228,7 +1228,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
lv_obj_invalidate_area(page, &sb_area_tmp);
|
||||
}
|
||||
if(ext->sb.ver_draw != 0) {
|
||||
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
|
||||
@@ -1236,7 +1236,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
lv_obj_invalidate_area(page, &sb_area_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1591,14 +1591,13 @@ static void cursor_blink_anim(lv_obj_t * ta, lv_anim_value_t show)
|
||||
if(show != ext->cursor.state) {
|
||||
ext->cursor.state = show == 0 ? 0 : 1;
|
||||
if(ext->cursor.type != LV_CURSOR_NONE && (ext->cursor.type & LV_CURSOR_HIDDEN) == 0) {
|
||||
lv_disp_t * disp = lv_obj_get_disp(ta);
|
||||
lv_area_t area_tmp;
|
||||
lv_area_copy(&area_tmp, &ext->cursor.area);
|
||||
area_tmp.x1 += ext->label->coords.x1;
|
||||
area_tmp.y1 += ext->label->coords.y1;
|
||||
area_tmp.x2 += ext->label->coords.x1;
|
||||
area_tmp.y2 += ext->label->coords.y1;
|
||||
lv_inv_area(disp, &area_tmp);
|
||||
lv_obj_invalidate_area(ta, &area_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1793,14 +1792,13 @@ static void refr_cursor_area(lv_obj_t * ta)
|
||||
}
|
||||
|
||||
/*Save the new area*/
|
||||
lv_disp_t * disp = lv_obj_get_disp(ta);
|
||||
lv_area_t area_tmp;
|
||||
lv_area_copy(&area_tmp, &ext->cursor.area);
|
||||
area_tmp.x1 += ext->label->coords.x1;
|
||||
area_tmp.y1 += ext->label->coords.y1;
|
||||
area_tmp.x2 += ext->label->coords.x1;
|
||||
area_tmp.y2 += ext->label->coords.y1;
|
||||
lv_inv_area(disp, &area_tmp);
|
||||
lv_obj_invalidate_area(ta, &area_tmp);
|
||||
|
||||
lv_area_copy(&ext->cursor.area, &cur_area);
|
||||
|
||||
@@ -1809,7 +1807,7 @@ static void refr_cursor_area(lv_obj_t * ta)
|
||||
area_tmp.y1 += ext->label->coords.y1;
|
||||
area_tmp.x2 += ext->label->coords.x1;
|
||||
area_tmp.y2 += ext->label->coords.y1;
|
||||
lv_inv_area(disp, &area_tmp);
|
||||
lv_obj_invalidate_area(ta, &area_tmp);
|
||||
}
|
||||
|
||||
static void placeholder_update(lv_obj_t * ta)
|
||||
|
||||
Reference in New Issue
Block a user