aboutsummaryrefslogtreecommitdiff
path: root/src/gui/guiButton.cpp
diff options
context:
space:
mode:
authorHugues Ross <hugues.ross@gmail.com>2019-12-14 18:05:36 -0500
committersfan5 <sfan5@live.de>2019-12-16 19:26:57 +0100
commite42faae8d9db2381295fcbc85c860d328a3fe121 (patch)
tree3e826c880583c4e1833d1c27d4953f5a653e65c6 /src/gui/guiButton.cpp
parentbd4b8d40b31301700b6405d0952fe692b65b28f5 (diff)
downloadminetest-e42faae8d9db2381295fcbc85c860d328a3fe121.tar.gz
minetest-e42faae8d9db2381295fcbc85c860d328a3fe121.tar.bz2
minetest-e42faae8d9db2381295fcbc85c860d328a3fe121.zip
Remove the dependency on FGIMG/BGIMG from the hovered/pressed variants
- Make guiButtonImage support null images properly
Diffstat (limited to 'src/gui/guiButton.cpp')
-rw-r--r--src/gui/guiButton.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/gui/guiButton.cpp b/src/gui/guiButton.cpp
index 6518bbd1f..0d69ff143 100644
--- a/src/gui/guiButton.cpp
+++ b/src/gui/guiButton.cpp
@@ -778,18 +778,25 @@ void GUIButton::setFromStyle(const StyleSpec& style, ISimpleTextureSource *tsrc)
setDrawBorder(style.getBool(StyleSpec::BORDER, DrawBorder));
setUseAlphaChannel(style.getBool(StyleSpec::ALPHA, true));
+ const core::position2di buttonCenter(AbsoluteRect.getCenter());
+ core::position2d<s32> geom(buttonCenter);
if (style.isNotDefault(StyleSpec::BGIMG)) {
video::ITexture *texture = style.getTexture(StyleSpec::BGIMG, tsrc);
- video::ITexture *hovered_texture = style.getTexture(StyleSpec::BGIMG_HOVERED, tsrc, texture);
- video::ITexture *pressed_texture = style.getTexture(StyleSpec::BGIMG_PRESSED, tsrc, texture);
-
- const core::position2di buttonCenter(AbsoluteRect.getCenter());
- core::position2d<s32> geom(buttonCenter);
setImage(guiScalingImageButton(
Environment->getVideoDriver(), texture, geom.X, geom.Y));
+ setScaleImage(true);
+ }
+ if (style.isNotDefault(StyleSpec::BGIMG_HOVERED)) {
+ video::ITexture *hovered_texture = style.getTexture(StyleSpec::BGIMG_HOVERED, tsrc);
+
setHoveredImage(guiScalingImageButton(
Environment->getVideoDriver(), hovered_texture, geom.X, geom.Y));
+ setScaleImage(true);
+ }
+ if (style.isNotDefault(StyleSpec::BGIMG_PRESSED)) {
+ video::ITexture *pressed_texture = style.getTexture(StyleSpec::BGIMG_PRESSED, tsrc);
+
setPressedImage(guiScalingImageButton(
Environment->getVideoDriver(), pressed_texture, geom.X, geom.Y));
setScaleImage(true);