diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d6918cffc..0ee2e99bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -131,6 +131,7 @@ Bug #6753: Info records without a DATA subrecords are loaded incorrectly Bug #6794: Light sources are attached to mesh bounds centers instead of mesh origins when AttachLight NiNode is missing Bug #6799: Game crashes if an NPC has no Class attached + Bug #6849: ImageButton texture is not scaled properly Feature #890: OpenMW-CS: Column filtering Feature #1465: "Reset" argument for AI functions Feature #2491: Ability to make OpenMW "portable" diff --git a/components/widgets/imagebutton.cpp b/components/widgets/imagebutton.cpp index bf2b1b24cb..6d71588830 100644 --- a/components/widgets/imagebutton.cpp +++ b/components/widgets/imagebutton.cpp @@ -1,5 +1,7 @@ #include "imagebutton.hpp" +#include + #include #include @@ -88,13 +90,17 @@ namespace Gui if (!mUseWholeTexture) { - int scale = 1.f; + float scale = 1.f; MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(textureName); if (texture && getHeight() != 0) - scale = texture->getHeight() / getHeight(); + scale = static_cast(texture->getHeight()) / getHeight(); - setImageTile(MyGUI::IntSize(mTextureRect.width * scale, mTextureRect.height * scale)); - MyGUI::IntCoord scaledSize(mTextureRect.left * scale, mTextureRect.top * scale, mTextureRect.width * scale, mTextureRect.height * scale); + const int width = static_cast(std::round(mTextureRect.width * scale)); + const int height = static_cast(std::round(mTextureRect.height * scale)); + setImageTile(MyGUI::IntSize(width, height)); + MyGUI::IntCoord scaledSize(static_cast(std::round(mTextureRect.left * scale)), + static_cast(std::round(mTextureRect.top * scale)), + width, height); setImageCoord(scaledSize); }