1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 17:32:55 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/PageSelector/PageSelectorButton.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.0 KiB
C#
Raw Normal View History

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