[lua] Add support to paint horizontal/vertical theme parts (e.g. separators)

This commit is contained in:
David Capello 2023-01-10 16:58:28 -03:00
parent 9e34656694
commit 7460e5f830

View File

@ -84,7 +84,34 @@ void GraphicsContext::drawThemeRect(const std::string& partId, const gfx::Rect&
skin::SkinPartPtr part = theme->getPartById(partId);
if (part && part->bitmap(0)) {
ui::Graphics g(nullptr, m_surface, 0, 0);
theme->drawRect(&g, rc, part.get(), true);
// TODO Copy code from Theme::paintLayer()
// 9-slices
if (!part->slicesBounds().isEmpty()) {
theme->drawRect(&g, rc, part.get(), true);
}
else {
ui::IntersectClip clip(&g, rc);
if (clip) {
// Horizontal line
if (rc.w > part->spriteBounds().w) {
for (int x=rc.x; x<rc.x2(); x+=part->spriteBounds().w) {
g.drawRgbaSurface(
part->bitmap(0),
x, rc.y+rc.h/2-part->spriteBounds().h/2);
}
}
// Vertical line
else {
for (int y=rc.y; y<rc.y2(); y+=part->spriteBounds().h) {
g.drawRgbaSurface(
part->bitmap(0),
rc.x+rc.w/2-part->spriteBounds().w/2, y);
}
}
}
}
}
}
}