mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02: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:
@@ -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());
|
||||
setImage(guiScalingImageButton(
|
||||
Environment->getVideoDriver(), texture,
|
||||
AbsoluteRect.getWidth(), AbsoluteRect.getHeight()));
|
||||
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>(
|
||||
|
Reference in New Issue
Block a user