1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-10-31 21:00:51 +01:00

fixed SetWidth/HeightBasedOnAspect behaving unexpectedly if an image has no texture

This commit is contained in:
Ell 2024-03-30 12:10:50 +01:00
parent 60af21aff4
commit 5d4f1293c7

View file

@ -144,6 +144,12 @@ namespace MLEM.Ui.Elements {
ret.X = ret.Y * this.Texture.Width / this.Texture.Height + this.ScaledAutoSizeAddedAbsolute.X; ret.X = ret.Y * this.Texture.Width / this.Texture.Height + this.ScaledAutoSizeAddedAbsolute.X;
if (this.SetHeightBasedOnAspect) if (this.SetHeightBasedOnAspect)
ret.Y = ret.X * this.Texture.Height / this.Texture.Width + this.ScaledAutoSizeAddedAbsolute.Y; ret.Y = ret.X * this.Texture.Height / this.Texture.Width + this.ScaledAutoSizeAddedAbsolute.Y;
} else {
// if we don't have a texture and we auto-set width or height, calculate as if we had a texture with a size of 0
if (this.SetWidthBasedOnAspect)
ret.X = this.ScaledAutoSizeAddedAbsolute.X;
if (this.SetHeightBasedOnAspect)
ret.Y = this.ScaledAutoSizeAddedAbsolute.Y;
} }
return ret; return ret;
} }