osu/osu.Game/Graphics/UserInterface/PageSelector/PageSelectorButton.cs

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

72 lines
2.0 KiB
C#
Raw Normal View History

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;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
2022-01-04 07:58:32 +00: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-04 18:14:56 +00:00
namespace osu.Game.Graphics.UserInterface.PageSelector
{
public abstract class PageSelectorButton : OsuClickableContainer
2020-01-04 18:14:56 +00:00
{
protected const int DURATION = 200;
[Resolved]
protected OverlayColourProvider ColourProvider { get; private set; }
2022-01-04 07:58:32 +00:00
protected Box Background;
2022-01-04 07:58:32 +00:00
protected PageSelectorButton()
2020-01-04 18:14:56 +00:00
{
AutoSizeAxes = Axes.X;
Height = 20;
2020-01-04 18:14:56 +00:00
}
[BackgroundDependencyLoader]
private void load()
2020-01-04 18:14:56 +00:00
{
Add(new CircularContainer
2020-01-04 18:14:56 +00:00
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Masking = true,
Children = new[]
2020-01-04 18:14:56 +00:00
{
Background = new Box
2022-01-04 07:58:32 +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
[NotNull]
protected abstract Drawable CreateContent();
protected override bool OnHover(HoverEvent e)
2020-01-04 18:14:56 +00:00
{
UpdateHoverState();
return base.OnHover(e);
2020-01-04 18:14:56 +00:00
}
protected override void OnHoverLost(HoverLostEvent e)
2020-01-04 18:14:56 +00:00
{
base.OnHoverLost(e);
UpdateHoverState();
2020-01-04 18:14:56 +00:00
}
protected abstract void UpdateHoverState();
2020-01-04 18:14:56 +00:00
}
}