From 8941c8658cf50f7e505a9c6bb4d559af30932f20 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 7 Aug 2017 09:50:04 +0900 Subject: [PATCH] Use nested containers for shadow --- osu.Game/Graphics/SpriteIcon.cs | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/osu.Game/Graphics/SpriteIcon.cs b/osu.Game/Graphics/SpriteIcon.cs index 4bf4af922a..93c85d67cb 100644 --- a/osu.Game/Graphics/SpriteIcon.cs +++ b/osu.Game/Graphics/SpriteIcon.cs @@ -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 - { - 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[] + 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, + Y = 2, + Colour = new Color4(0f, 0f, 0f, 0.2f), + }, + 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; } }