mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 07:32:55 +08:00
Use nested containers for shadow
This commit is contained in:
parent
de3b65e1fa
commit
8941c8658c
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user