mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Improve the visibility of the global loading animation
Updates design to match new `osu-web` design. Adds TestCase for visual testing.
This commit is contained in:
63
osu.Game.Tests/Visual/TestCaseLoadingAnimation.cs
Normal file
63
osu.Game.Tests/Visual/TestCaseLoadingAnimation.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public class TestCaseLoadingAnimation : GridTestCase
|
||||||
|
{
|
||||||
|
public TestCaseLoadingAnimation()
|
||||||
|
: base(2, 2)
|
||||||
|
{
|
||||||
|
LoadingAnimation loading;
|
||||||
|
|
||||||
|
Cell(0).AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.Black,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
loading = new LoadingAnimation()
|
||||||
|
});
|
||||||
|
|
||||||
|
loading.Show();
|
||||||
|
|
||||||
|
Cell(1).AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.White,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
loading = new LoadingAnimation()
|
||||||
|
});
|
||||||
|
|
||||||
|
loading.Show();
|
||||||
|
|
||||||
|
Cell(2).AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.Gray,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
loading = new LoadingAnimation()
|
||||||
|
});
|
||||||
|
|
||||||
|
loading.Show();
|
||||||
|
|
||||||
|
Cell(3).AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
loading = new LoadingAnimation()
|
||||||
|
});
|
||||||
|
|
||||||
|
Scheduler.AddDelayed(() => loading.ToggleVisibility(), 200, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,12 +4,17 @@
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class LoadingAnimation : VisibilityContainer
|
public class LoadingAnimation : VisibilityContainer
|
||||||
{
|
{
|
||||||
private readonly SpriteIcon spinner;
|
private readonly SpriteIcon spinner;
|
||||||
|
private readonly SpriteIcon spinnerShadow;
|
||||||
|
|
||||||
|
private const float spin_duration = 600;
|
||||||
|
private const float transition_duration = 200;
|
||||||
|
|
||||||
public LoadingAnimation()
|
public LoadingAnimation()
|
||||||
{
|
{
|
||||||
@ -20,12 +25,22 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
spinner = new SpriteIcon
|
spinnerShadow = new SpriteIcon
|
||||||
{
|
{
|
||||||
Size = new Vector2(20),
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Position = new Vector2(1, 1),
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Icon = FontAwesome.fa_spinner
|
Colour = Color4.Black,
|
||||||
|
Alpha = 0.4f,
|
||||||
|
Icon = FontAwesome.fa_circle_o_notch
|
||||||
|
},
|
||||||
|
spinner = new SpriteIcon
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Icon = FontAwesome.fa_circle_o_notch
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -34,12 +49,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
spinner.Spin(2000, RotationDirection.Clockwise);
|
spinner.Spin(spin_duration, RotationDirection.Clockwise);
|
||||||
|
spinnerShadow.Spin(spin_duration, RotationDirection.Clockwise);
|
||||||
}
|
}
|
||||||
|
|
||||||
private const float transition_duration = 500;
|
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn(transition_duration * 5, Easing.OutQuint);
|
protected override void PopIn() => this.FadeIn(transition_duration, Easing.OutQuint);
|
||||||
|
|
||||||
protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint);
|
protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user