Fixed aspect ratio for icon button widget.

It happened when using non-hd textures. Textures with aspect ratio != 1, are scaled to MAX_TEXTURE_SIZE, for example from 512x256 to 256x256, so we can't base on scaled texture size.

Btw. such behaviour seems to not have a sense (for example 2048x256 will be scaled down to 256x256), so it may need some work in stk_texture.cpp.
This commit is contained in:
deve 2017-09-12 06:10:23 +02:00
parent fd00ef4d92
commit 6829bb1e51

View File

@ -125,7 +125,9 @@ void IconButtonWidget::add()
if (m_scale_mode == SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO)
{
useAspectRatio = (float)m_texture_w / (float)m_texture_h;
assert(m_texture->getOriginalSize().Height > 0);
useAspectRatio = (float)m_texture->getOriginalSize().Width /
(float)m_texture->getOriginalSize().Height;
}
else if (m_scale_mode == SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO)
{