1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-07 00:17:21 +08:00

98 lines
3.0 KiB
C#
Raw Normal View History

2019-10-13 14:43:30 +03:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2019-05-30 22:55:59 +03:00
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites;
using osuTK;
2019-10-13 14:43:30 +03:00
using osuTK.Graphics;
2019-05-30 22:55:59 +03:00
using System.Collections.Generic;
2019-10-13 14:43:30 +03:00
namespace osu.Game.Graphics.UserInterface
2019-05-30 22:55:59 +03:00
{
2019-10-17 13:57:17 +03:00
public class ShowMoreButton : LoadingButton
2019-05-30 22:55:59 +03:00
{
2019-10-24 17:49:34 +03:00
private const int duration = 200;
2019-10-13 14:43:30 +03:00
private Color4 chevronIconColour;
2019-05-30 22:55:59 +03:00
2019-10-16 15:54:00 +09:00
protected Color4 ChevronIconColour
2019-10-13 14:43:30 +03:00
{
get => chevronIconColour;
2019-10-15 00:10:02 +03:00
set => chevronIconColour = leftChevron.Colour = rightChevron.Colour = value;
2019-10-13 14:43:30 +03:00
}
public string Text
{
get => text.Text;
2019-10-14 17:33:14 +03:00
set => text.Text = value;
2019-10-13 14:43:30 +03:00
}
2019-05-30 22:55:59 +03:00
2019-10-13 14:43:30 +03:00
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
2019-10-17 13:57:17 +03:00
private ChevronIcon leftChevron;
private ChevronIcon rightChevron;
private SpriteText text;
private Box background;
2019-10-24 17:49:34 +03:00
private FillFlowContainer textContainer;
2019-10-17 13:57:17 +03:00
2019-05-30 22:55:59 +03:00
public ShowMoreButton()
{
2020-01-31 09:51:56 +03:00
Height = 30;
Width = 140;
2019-05-30 22:55:59 +03:00
}
2019-10-24 17:49:34 +03:00
protected override Drawable CreateContent() => new CircularContainer
2019-05-30 22:55:59 +03:00
{
2019-10-17 13:57:17 +03:00
Masking = true,
2020-01-31 09:51:56 +03:00
RelativeSizeAxes = Axes.Both,
2019-10-17 13:57:17 +03:00
Children = new Drawable[]
2019-06-04 10:26:21 +09:00
{
2019-10-24 17:49:34 +03:00
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
textContainer = new FillFlowContainer
2019-10-17 13:57:17 +03:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2019-10-24 17:49:34 +03:00
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(7),
Children = new Drawable[]
{
leftChevron = new ChevronIcon(),
text = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = "show more".ToUpper(),
},
rightChevron = new ChevronIcon(),
}
}
2019-06-04 10:26:21 +09:00
}
2019-10-17 13:57:17 +03:00
};
2019-05-30 22:55:59 +03:00
2019-10-24 17:49:34 +03:00
protected override void OnLoadStarted() => textContainer.FadeOut(duration, Easing.OutQuint);
protected override void OnLoadFinished() => textContainer.FadeIn(duration, Easing.OutQuint);
2019-05-30 22:55:59 +03:00
private class ChevronIcon : SpriteIcon
{
private const int icon_size = 8;
public ChevronIcon()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Size = new Vector2(icon_size);
Icon = FontAwesome.Solid.ChevronDown;
}
}
}
}