mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
prevent image sprite exceed its parent width
This commit is contained in:
parent
e58f690210
commit
d88d264491
@ -63,11 +63,28 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
|||||||
RelativeSizeAxes = Axes.X;
|
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;
|
public ImageSprite()
|
||||||
s.Origin = Anchor.TopCentre;
|
{
|
||||||
});
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user