Fix wrong use of guiScalingImageButton in formspecs buttons (#10094)
authorPierre-Yves Rollo <dev@pyrollo.com>
Wed, 24 Jun 2020 09:35:06 +0000 (11:35 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2020 09:35:06 +0000 (11:35 +0200)
src/gui/guiButton.cpp
src/gui/guiButtonImage.cpp

index ff35958fd0ddaf8f9fa88c80d479cf9470341d3a..6732a9233837b2283ebebbd9c4a0f474389216e2 100644 (file)
@@ -789,13 +789,12 @@ void GUIButton::setFromStyle(const StyleSpec& style)
        setDrawBorder(style.getBool(StyleSpec::BORDER, true));\r
        setUseAlphaChannel(style.getBool(StyleSpec::ALPHA, true));\r
 \r
-       const core::position2di buttonCenter(AbsoluteRect.getCenter());\r
-       core::position2d<s32> geom(buttonCenter);\r
        if (style.isNotDefault(StyleSpec::BGIMG)) {\r
                video::ITexture *texture = style.getTexture(StyleSpec::BGIMG,\r
                                getTextureSource());\r
                setImage(guiScalingImageButton(\r
-                               Environment->getVideoDriver(), texture, geom.X, geom.Y));\r
+                               Environment->getVideoDriver(), texture,\r
+                                               AbsoluteRect.getWidth(), AbsoluteRect.getHeight()));\r
                setScaleImage(true);\r
        } else {\r
                setImage(nullptr);\r
index 2658ad967126f4641112ee321c2abe52802ff5cd..b507ffecee0dacaaad250882309f8f71b69f0b33 100644 (file)
@@ -62,13 +62,12 @@ void GUIButtonImage::setFromStyle(const StyleSpec& style)
 
        video::IVideoDriver *driver = Environment->getVideoDriver();
 
-       const core::position2di buttonCenter(AbsoluteRect.getCenter());
-       core::position2d<s32> geom(buttonCenter);
        if (style.isNotDefault(StyleSpec::FGIMG)) {
                video::ITexture *texture = style.getTexture(StyleSpec::FGIMG,
                                getTextureSource());
 
-               setForegroundImage(guiScalingImageButton(driver, texture, geom.X, geom.Y));
+               setForegroundImage(guiScalingImageButton(driver, texture,
+                       AbsoluteRect.getWidth(), AbsoluteRect.getHeight()));
                setScaleImage(true);
        } else {
                setForegroundImage(nullptr);