2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
2018-12-06 15:29:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A loading spinner.
|
|
|
|
|
/// </summary>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public class LoadingAnimation : VisibilityContainer
|
|
|
|
|
{
|
|
|
|
|
private readonly SpriteIcon spinner;
|
2018-06-22 11:30:40 +08:00
|
|
|
|
private readonly SpriteIcon spinnerShadow;
|
|
|
|
|
|
|
|
|
|
private const float spin_duration = 600;
|
|
|
|
|
private const float transition_duration = 200;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public LoadingAnimation()
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(20);
|
|
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-06-22 11:30:40 +08:00
|
|
|
|
spinnerShadow = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-06-27 11:59:19 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Position = new Vector2(1, 1),
|
2018-06-22 11:30:40 +08:00
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
Alpha = 0.4f,
|
2019-03-27 18:29:27 +08:00
|
|
|
|
Icon = FontAwesome.CircleONotch
|
2018-06-22 11:30:40 +08:00
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
|
spinner = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-06-27 11:59:19 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-03-27 18:29:27 +08:00
|
|
|
|
Icon = FontAwesome.CircleONotch
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2018-06-22 11:30:40 +08:00
|
|
|
|
spinner.Spin(spin_duration, RotationDirection.Clockwise);
|
|
|
|
|
spinnerShadow.Spin(spin_duration, RotationDirection.Clockwise);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-22 13:26:24 +08:00
|
|
|
|
protected override void PopIn() => this.FadeIn(transition_duration * 2, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|