feat: add a new awesome feature

This commit is contained in:
2025-11-04 16:48:53 +08:00
parent 8dee285de8
commit 7b087e296a
22 changed files with 210 additions and 58 deletions

View File

@@ -27,8 +27,9 @@ void Canvas::draw()
setfillcolor(canvasBkClor);//设置填充色
setfillstyle((int)canvasFillMode);//设置填充模式
setlinestyle((int)canvasLineStyle, canvaslinewidth);
if ((saveBkX != this->x) || (saveBkY != this->y) || (!hasSnap) || (saveWidth != this->width) || (saveHeight != this->height) || !saveBkImage)
saveBackground(this->x, this->y, this->width, this->height);
saveBackground(x, y, width, height);
// 恢复背景(清除旧内容)
restBackground();
//根据画布形状绘制
@@ -69,7 +70,7 @@ bool Canvas::handleEvent(const ExMessage& msg)
consumed |= it->get()->handleEvent(msg);
if (it->get()->isDirty()) anyDirty = true;
}
if (anyDirty) requestRepaint();
if (anyDirty) requestRepaint(parent);
return consumed;
}
@@ -159,5 +160,20 @@ void Canvas::onWindowResize()
ch->onWindowResize();
}
void Canvas::requestRepaint(Control* parent)
{
if (this == parent)
{
for (auto& control : controls)
if (control->isDirty() && control->IsVisible())
{
control->draw();
break;
}
}
else
onRequestRepaintAsRoot();
}