1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Formspec: Fix broken 9-slice image button with gui_scaling_filter (#16146)

The setting 'gui_scaling_filter = true' previously broke 9-slice images.
With this change, custom button background images now scale the same as
backgrounds created using 'background9[...]' (9-slice images).
This commit is contained in:
SmallJoker 2025-05-24 15:58:04 +02:00 committed by GitHub
parent 66aa5f3fac
commit 2f1171e2a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -718,19 +718,24 @@ void GUIButton::setFromStyle(const StyleSpec& style)
setUseAlphaChannel(style.getBool(StyleSpec::ALPHA, true));
setOverrideFont(style.getFont());
BgMiddle = style.getRect(StyleSpec::BGIMG_MIDDLE, BgMiddle);
if (style.isNotDefault(StyleSpec::BGIMG)) {
video::ITexture *texture = style.getTexture(StyleSpec::BGIMG,
getTextureSource());
if (BgMiddle.getArea() == 0) {
setImage(guiScalingImageButton(
Environment->getVideoDriver(), texture,
AbsoluteRect.getWidth(), AbsoluteRect.getHeight()));
} else {
// Scaling happens in `draw2DImage9Slice`
setImage(texture);
}
setScaleImage(true);
} else {
setImage(nullptr);
}
BgMiddle = style.getRect(StyleSpec::BGIMG_MIDDLE, BgMiddle);
// Child padding and offset
Padding = style.getRect(StyleSpec::PADDING, core::rect<s32>());
Padding = core::rect<s32>(