mirror of
https://github.com/ppy/osu.git
synced 2024-11-18 18:12:59 +08:00
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
// 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.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Game.Graphics.Sprites;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Graphics.UserInterface.PageSelector
|
|
{
|
|
public class PageSelectorPrevNextButton : PageSelectorButton
|
|
{
|
|
private readonly bool rightAligned;
|
|
private readonly string text;
|
|
|
|
private SpriteIcon icon;
|
|
private OsuSpriteText name;
|
|
|
|
public PageSelectorPrevNextButton(bool rightAligned, string text)
|
|
{
|
|
this.rightAligned = rightAligned;
|
|
this.text = text;
|
|
}
|
|
|
|
protected override Drawable CreateContent() => new Container
|
|
{
|
|
RelativeSizeAxes = Axes.Y,
|
|
AutoSizeAxes = Axes.X,
|
|
Children = new Drawable[]
|
|
{
|
|
new FillFlowContainer
|
|
{
|
|
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 = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
Text = text.ToUpper(),
|
|
},
|
|
icon = new SpriteIcon
|
|
{
|
|
Icon = rightAligned ? FontAwesome.Solid.ChevronRight : FontAwesome.Solid.ChevronLeft,
|
|
Size = new Vector2(8),
|
|
Anchor = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
},
|
|
}
|
|
},
|
|
}
|
|
};
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
Background.Colour = ColourProvider.Dark4;
|
|
name.Colour = icon.Colour = ColourProvider.Light1;
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
Enabled.BindValueChanged(enabled => Background.FadeTo(enabled.NewValue ? 1 : 0.5f, DURATION), true);
|
|
}
|
|
|
|
protected override void UpdateHoverState() =>
|
|
Background.FadeColour(IsHovered ? ColourProvider.Dark3 : ColourProvider.Dark4, DURATION, Easing.OutQuint);
|
|
}
|
|
}
|