2019-10-13 11:43:30 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-05-30 19:55:59 +00:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2020-07-30 01:51:09 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-05-30 19:55:59 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-07-30 01:51:09 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2019-05-30 19:55:59 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-07-30 01:51:09 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2019-05-30 19:55:59 +00:00
|
|
|
|
using osuTK;
|
|
|
|
|
using System.Collections.Generic;
|
2021-02-22 08:14:00 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-05-30 19:55:59 +00:00
|
|
|
|
|
2019-10-13 11:43:30 +00:00
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
2019-05-30 19:55:59 +00:00
|
|
|
|
{
|
2019-10-17 10:57:17 +00:00
|
|
|
|
public class ShowMoreButton : LoadingButton
|
2019-05-30 19:55:59 +00:00
|
|
|
|
{
|
2019-10-24 14:49:34 +00:00
|
|
|
|
private const int duration = 200;
|
|
|
|
|
|
2021-02-22 08:14:00 +00:00
|
|
|
|
public LocalisableString Text
|
2019-10-13 11:43:30 +00:00
|
|
|
|
{
|
|
|
|
|
get => text.Text;
|
2019-10-14 14:33:14 +00:00
|
|
|
|
set => text.Text = value;
|
2019-10-13 11:43:30 +00:00
|
|
|
|
}
|
2019-05-30 19:55:59 +00:00
|
|
|
|
|
2019-10-13 11:43:30 +00:00
|
|
|
|
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
|
|
|
|
|
2020-07-30 01:51:09 +00:00
|
|
|
|
private ChevronIcon leftIcon;
|
|
|
|
|
private ChevronIcon rightIcon;
|
2019-10-17 10:57:17 +00:00
|
|
|
|
private SpriteText text;
|
|
|
|
|
private Box background;
|
2019-10-24 14:49:34 +00:00
|
|
|
|
private FillFlowContainer textContainer;
|
2019-10-17 10:57:17 +00:00
|
|
|
|
|
2019-05-30 19:55:59 +00:00
|
|
|
|
public ShowMoreButton()
|
|
|
|
|
{
|
2020-07-30 01:51:09 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
IdleColour = colourProvider.Background2;
|
|
|
|
|
HoverColour = colourProvider.Background1;
|
2019-05-30 19:55:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-24 14:49:34 +00:00
|
|
|
|
protected override Drawable CreateContent() => new CircularContainer
|
2019-05-30 19:55:59 +00:00
|
|
|
|
{
|
2019-10-17 10:57:17 +00:00
|
|
|
|
Masking = true,
|
2020-07-30 01:51:09 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2019-10-17 10:57:17 +00:00
|
|
|
|
Children = new Drawable[]
|
2019-06-04 01:26:21 +00:00
|
|
|
|
{
|
2019-10-24 14:49:34 +00:00
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
textContainer = new FillFlowContainer
|
2019-10-17 10:57:17 +00:00
|
|
|
|
{
|
2020-07-30 01:51:09 +00:00
|
|
|
|
AlwaysPresent = true,
|
2019-10-17 10:57:17 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-10-24 14:49:34 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2020-07-30 01:51:09 +00:00
|
|
|
|
Spacing = new Vector2(10),
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Horizontal = 20,
|
|
|
|
|
Vertical = 5
|
|
|
|
|
},
|
2019-10-24 14:49:34 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-07-30 01:51:09 +00:00
|
|
|
|
leftIcon = new ChevronIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
2019-10-24 14:49:34 +00:00
|
|
|
|
text = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2020-07-30 01:51:09 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
2019-10-24 14:49:34 +00:00
|
|
|
|
Text = "show more".ToUpper(),
|
|
|
|
|
},
|
2020-07-30 01:51:09 +00:00
|
|
|
|
rightIcon = new ChevronIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
}
|
2019-10-24 14:49:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-04 01:26:21 +00:00
|
|
|
|
}
|
2019-10-17 10:57:17 +00:00
|
|
|
|
};
|
2019-05-30 19:55:59 +00:00
|
|
|
|
|
2019-10-24 14:49:34 +00:00
|
|
|
|
protected override void OnLoadStarted() => textContainer.FadeOut(duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
protected override void OnLoadFinished() => textContainer.FadeIn(duration, Easing.OutQuint);
|
|
|
|
|
|
2020-07-30 01:51:09 +00:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2019-05-30 19:55:59 +00:00
|
|
|
|
{
|
2020-07-30 01:51:09 +00:00
|
|
|
|
base.OnHover(e);
|
2020-07-30 04:49:04 +00:00
|
|
|
|
leftIcon.SetHoveredState(true);
|
|
|
|
|
rightIcon.SetHoveredState(true);
|
2020-07-30 01:51:09 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHoverLost(e);
|
2020-07-30 04:49:04 +00:00
|
|
|
|
leftIcon.SetHoveredState(false);
|
|
|
|
|
rightIcon.SetHoveredState(false);
|
2020-07-30 01:51:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ChevronIcon : SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OverlayColourProvider colourProvider { get; set; }
|
2019-05-30 19:55:59 +00:00
|
|
|
|
|
|
|
|
|
public ChevronIcon()
|
|
|
|
|
{
|
2020-07-30 01:51:09 +00:00
|
|
|
|
Size = new Vector2(7.5f);
|
2019-05-30 19:55:59 +00:00
|
|
|
|
Icon = FontAwesome.Solid.ChevronDown;
|
|
|
|
|
}
|
2020-07-30 01:51:09 +00:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Colour = colourProvider.Foreground1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 04:49:04 +00:00
|
|
|
|
public void SetHoveredState(bool hovered) =>
|
|
|
|
|
this.FadeColour(hovered ? colourProvider.Light1 : colourProvider.Foreground1, 200, Easing.OutQuint);
|
2019-05-30 19:55:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|