improve widget invalidate

This commit is contained in:
lixianjing 2019-10-10 10:15:06 +08:00
parent 5918e4ea8e
commit 3117f2893a
2 changed files with 33 additions and 23 deletions

View File

@ -2,6 +2,7 @@
* 2019/10/10
* 修改canvas draw image repeatx/repeaty的问题感谢俊杰提供补丁
* canvas增加repeat\_y\_inverse图片绘制方式。
* 完善widget\_invalidate
* 2019/10/09
* slider 的min/max/value/step使用浮动数。

View File

@ -2247,29 +2247,8 @@ static ret_t widget_set_dirty(widget_t* widget) {
return RET_OK;
}
ret_t widget_invalidate(widget_t* widget, rect_t* r) {
rect_t rself;
if (r == NULL) {
rself = rect_init(0, 0, widget->w, widget->h);
r = &rself;
}
return_value_if_fail(widget != NULL && r != NULL, RET_BAD_PARAMS);
if (widget->dirty) {
return RET_OK;
}
widget_set_dirty(widget);
if (widget->vt && widget->vt->invalidate) {
return widget->vt->invalidate(widget, r);
} else {
return widget_invalidate_default(widget, r);
}
}
ret_t widget_invalidate_force(widget_t* widget, rect_t* r) {
widget_t* iter = widget;
static ret_t widget_set_parent_not_dirty(widget_t* widget) {
widget_t* iter = widget->parent;
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
while (iter != NULL) {
@ -2280,6 +2259,36 @@ ret_t widget_invalidate_force(widget_t* widget, rect_t* r) {
iter = iter->parent;
}
return RET_OK;
}
ret_t widget_invalidate(widget_t* widget, rect_t* r) {
rect_t rself;
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
if (widget->dirty) {
return RET_OK;
}
if (r == NULL) {
rself = rect_init(0, 0, widget->w, widget->h);
r = &rself;
}
widget_set_dirty(widget);
widget_set_parent_not_dirty(widget);
if (widget->vt && widget->vt->invalidate) {
return widget->vt->invalidate(widget, r);
} else {
return widget_invalidate_default(widget, r);
}
}
ret_t widget_invalidate_force(widget_t* widget, rect_t* r) {
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
widget->dirty = FALSE;
return widget_invalidate(widget, NULL);
}