1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

prevent image sprite exceed its parent width

This commit is contained in:
Gagah Pangeran Rosfatiputra 2021-06-29 09:49:45 +07:00
parent e58f690210
commit d88d264491
No known key found for this signature in database
GPG Key ID: 25F6F17FD29031E2

View File

@ -63,11 +63,28 @@ namespace osu.Game.Overlays.Wiki.Markdown
RelativeSizeAxes = Axes.X;
}
protected override Sprite CreateSpriteImage() => base.CreateSpriteImage().With(s =>
protected override Sprite CreateSpriteImage() => new ImageSprite();
private class ImageSprite : Sprite
{
s.Anchor = Anchor.TopCentre;
s.Origin = Anchor.TopCentre;
});
public ImageSprite()
{
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
}
protected override void Update()
{
base.Update();
if (Width > Parent.DrawWidth)
{
float ratio = Height / Width;
Width = Parent.DrawWidth;
Height = ratio * Width;
}
}
}
}
}
}