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:
parent
66aa5f3fac
commit
2f1171e2a7
1 changed files with 10 additions and 5 deletions
|
@ -718,19 +718,24 @@ void GUIButton::setFromStyle(const StyleSpec& style)
|
||||||
setUseAlphaChannel(style.getBool(StyleSpec::ALPHA, true));
|
setUseAlphaChannel(style.getBool(StyleSpec::ALPHA, true));
|
||||||
setOverrideFont(style.getFont());
|
setOverrideFont(style.getFont());
|
||||||
|
|
||||||
|
BgMiddle = style.getRect(StyleSpec::BGIMG_MIDDLE, BgMiddle);
|
||||||
|
|
||||||
if (style.isNotDefault(StyleSpec::BGIMG)) {
|
if (style.isNotDefault(StyleSpec::BGIMG)) {
|
||||||
video::ITexture *texture = style.getTexture(StyleSpec::BGIMG,
|
video::ITexture *texture = style.getTexture(StyleSpec::BGIMG,
|
||||||
getTextureSource());
|
getTextureSource());
|
||||||
setImage(guiScalingImageButton(
|
if (BgMiddle.getArea() == 0) {
|
||||||
Environment->getVideoDriver(), texture,
|
setImage(guiScalingImageButton(
|
||||||
AbsoluteRect.getWidth(), AbsoluteRect.getHeight()));
|
Environment->getVideoDriver(), texture,
|
||||||
|
AbsoluteRect.getWidth(), AbsoluteRect.getHeight()));
|
||||||
|
} else {
|
||||||
|
// Scaling happens in `draw2DImage9Slice`
|
||||||
|
setImage(texture);
|
||||||
|
}
|
||||||
setScaleImage(true);
|
setScaleImage(true);
|
||||||
} else {
|
} else {
|
||||||
setImage(nullptr);
|
setImage(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
BgMiddle = style.getRect(StyleSpec::BGIMG_MIDDLE, BgMiddle);
|
|
||||||
|
|
||||||
// Child padding and offset
|
// Child padding and offset
|
||||||
Padding = style.getRect(StyleSpec::PADDING, core::rect<s32>());
|
Padding = style.getRect(StyleSpec::PADDING, core::rect<s32>());
|
||||||
Padding = core::rect<s32>(
|
Padding = core::rect<s32>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue