1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 10:42:54 +08:00

Use nested containers for shadow

This commit is contained in:
Dean Herbert 2017-08-07 09:50:04 +09:00
parent de3b65e1fa
commit 8941c8658c

View File

@ -17,21 +17,28 @@ namespace osu.Game.Graphics
private readonly Sprite spriteShadow;
private readonly Sprite spriteMain;
private readonly Container shadowVisibility;
public SpriteIcon()
{
spriteShadow = new Sprite
InternalChildren = new Drawable[]
{
shadowVisibility = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Child = spriteShadow = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Depth = 2,
Y = 2,
Colour = new Color4(0f, 0f, 0f, 0.2f),
};
InternalChildren = new[]
{
},
Alpha = 0,
},
spriteMain = new Sprite
{
Anchor = Anchor.Centre,
@ -81,12 +88,7 @@ namespace osu.Game.Graphics
get { return spriteShadow.IsPresent; }
set
{
if (value == (spriteShadow.IsAlive && spriteShadow.IsLoaded)) return;
if (value)
AddInternal(spriteShadow);
else
RemoveInternal(spriteShadow);
shadowVisibility.Alpha = value ? 1 : 0;
}
}