1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-16 06:08:46 +02: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;
if (this.SetHeightBasedOnAspect)
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;
}