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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2022-01-04 07:58:32 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-01-04 07:58:32 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
using osuTK;
|
2022-01-04 07:58:32 +00:00
|
|
|
|
using osuTK.Graphics;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface.PageSelector
|
|
|
|
|
{
|
|
|
|
|
public class PageSelectorButton : PageSelectorItem
|
|
|
|
|
{
|
2022-01-04 07:58:32 +00:00
|
|
|
|
private readonly string text;
|
|
|
|
|
|
|
|
|
|
private Box fadeBox;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
private SpriteIcon icon;
|
|
|
|
|
private OsuSpriteText name;
|
2022-01-04 07:58:32 +00:00
|
|
|
|
|
|
|
|
|
private readonly Anchor alignment;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
|
|
|
|
|
public PageSelectorButton(bool rightAligned, string text)
|
|
|
|
|
{
|
2022-01-04 07:58:32 +00:00
|
|
|
|
this.text = text;
|
|
|
|
|
alignment = rightAligned ? Anchor.x0 : Anchor.x2;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 07:58:32 +00:00
|
|
|
|
protected override Drawable CreateContent() => new Container
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 07:58:32 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
2020-01-04 18:14:56 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2022-01-04 07:58:32 +00:00
|
|
|
|
new FillFlowContainer
|
2020-01-04 18:14:56 +00:00
|
|
|
|
{
|
2022-01-04 07:58:32 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Spacing = new Vector2(3, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
name = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 12),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Text = text.ToUpper(),
|
|
|
|
|
},
|
|
|
|
|
icon = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Icon = alignment == Anchor.x2 ? FontAwesome.Solid.ChevronLeft : FontAwesome.Solid.ChevronRight,
|
|
|
|
|
Size = new Vector2(8),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
}
|
2020-01-04 18:14:56 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2022-01-04 07:46:42 +00:00
|
|
|
|
Background.Colour = Colours.GreySeaFoamDark;
|
2020-01-04 18:14:56 +00:00
|
|
|
|
name.Colour = icon.Colour = Colours.Lime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2022-01-04 07:58:32 +00:00
|
|
|
|
|
|
|
|
|
CircularContent.Add(fadeBox = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black.Opacity(100)
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-04 18:14:56 +00:00
|
|
|
|
Enabled.BindValueChanged(enabled => fadeBox.FadeTo(enabled.NewValue ? 0 : 1, DURATION), true);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 07:46:42 +00:00
|
|
|
|
protected override void UpdateHoverState() => Background.FadeColour(IsHovered ? Colours.GreySeaFoam : Colours.GreySeaFoamDark, DURATION, Easing.OutQuint);
|
2020-01-04 18:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|