2020-01-04 18:14:56 +00: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.
|
|
|
|
|
|
2022-01-04 07:58:32 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-01-04 08:52:40 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Allocation;
|
2022-01-04 07:58:32 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-01-04 08:52:40 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using JetBrains.Annotations;
|
2022-01-04 09:14:42 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface.PageSelector
|
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
public abstract class PageSelectorButton : OsuClickableContainer
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
protected const int DURATION = 200;
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
2022-01-04 09:14:42 +00:00
|
|
|
|
protected OverlayColourProvider ColourProvider { get; private set; }
|
2022-01-04 07:58:32 +00:00
|
|
|
|
|
2022-01-04 08:52:40 +00:00
|
|
|
|
protected Box Background;
|
2022-01-04 07:58:32 +00:00
|
|
|
|
|
2022-01-04 08:52:40 +00:00
|
|
|
|
protected PageSelectorButton()
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
|
Height = 20;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 08:52:40 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 09:14:42 +00:00
|
|
|
|
Add(new CircularContainer
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
Background = new Box
|
2022-01-04 07:58:32 +00:00
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
CreateContent().With(content =>
|
|
|
|
|
{
|
|
|
|
|
content.Anchor = Anchor.Centre;
|
|
|
|
|
content.Origin = Anchor.Centre;
|
|
|
|
|
content.Margin = new MarginPadding { Horizontal = 10 };
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-01-04 18:14:56 +00:00
|
|
|
|
|
2022-01-04 08:52:40 +00:00
|
|
|
|
[NotNull]
|
|
|
|
|
protected abstract Drawable CreateContent();
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
UpdateHoverState();
|
|
|
|
|
return base.OnHover(e);
|
2020-01-04 18:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 08:52:40 +00:00
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 08:52:40 +00:00
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
|
UpdateHoverState();
|
2020-01-04 18:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 08:52:40 +00:00
|
|
|
|
protected abstract void UpdateHoverState();
|
2020-01-04 18:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|