1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

FormSpec: 9-slice images, animated_images, and fgimg_middle (#12453)

* FormSpec: 9-slice images and animated_images

* Add fgimg_middle; clean up code

* Address issues, add tests

* Fix stupid error; bump formspec version

* Re-add image[] elements without a size
This commit is contained in:
Vincent Robinson 2022-07-03 05:52:26 -07:00 committed by GitHub
parent 5a562a597c
commit f7bcf7fa46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 222 additions and 204 deletions

View file

@ -48,21 +48,15 @@ void GUIBackgroundImage::draw()
video::IVideoDriver *driver = Environment->getVideoDriver();
core::rect<s32> srcrect(core::position2d<s32>(0, 0),
core::dimension2di(texture->getOriginalSize()));
if (m_middle.getArea() == 0) {
const video::SColor color(255, 255, 255, 255);
const video::SColor colors[] = {color, color, color, color};
draw2DImageFilterScaled(driver, texture, rect,
core::rect<s32>(core::position2d<s32>(0, 0),
core::dimension2di(texture->getOriginalSize())),
nullptr, colors, true);
draw2DImageFilterScaled(driver, texture, rect, srcrect, nullptr, colors, true);
} else {
core::rect<s32> middle = m_middle;
// `-x` is interpreted as `w - x`
if (middle.LowerRightCorner.X < 0)
middle.LowerRightCorner.X += texture->getOriginalSize().Width;
if (middle.LowerRightCorner.Y < 0)
middle.LowerRightCorner.Y += texture->getOriginalSize().Height;
draw2DImage9Slice(driver, texture, rect, middle);
draw2DImage9Slice(driver, texture, rect, srcrect, m_middle);
}
IGUIElement::draw();