mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Update ShowMoreButton in line with web
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
// 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.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -16,14 +18,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
private const int duration = 200;
|
||||
|
||||
private Color4 chevronIconColour;
|
||||
|
||||
protected Color4 ChevronIconColour
|
||||
{
|
||||
get => chevronIconColour;
|
||||
set => chevronIconColour = leftChevron.Colour = rightChevron.Colour = value;
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => text.Text;
|
||||
@ -32,22 +26,28 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
|
||||
private ChevronIcon leftChevron;
|
||||
private ChevronIcon rightChevron;
|
||||
private ChevronIcon leftIcon;
|
||||
private ChevronIcon rightIcon;
|
||||
private SpriteText text;
|
||||
private Box background;
|
||||
private FillFlowContainer textContainer;
|
||||
|
||||
public ShowMoreButton()
|
||||
{
|
||||
Height = 30;
|
||||
Width = 140;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
IdleColour = colourProvider.Background2;
|
||||
HoverColour = colourProvider.Background1;
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
@ -56,22 +56,36 @@ namespace osu.Game.Graphics.UserInterface
|
||||
},
|
||||
textContainer = new FillFlowContainer
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(7),
|
||||
Spacing = new Vector2(10),
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Horizontal = 20,
|
||||
Vertical = 5
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
leftChevron = new ChevronIcon(),
|
||||
leftIcon = new ChevronIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
||||
Text = "show more".ToUpper(),
|
||||
},
|
||||
rightChevron = new ChevronIcon(),
|
||||
rightIcon = new ChevronIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,17 +95,41 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override void OnLoadFinished() => textContainer.FadeIn(duration, Easing.OutQuint);
|
||||
|
||||
private class ChevronIcon : SpriteIcon
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
private const int icon_size = 8;
|
||||
base.OnHover(e);
|
||||
leftIcon.FadeHoverColour();
|
||||
rightIcon.FadeHoverColour();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
leftIcon.FadeIdleColour();
|
||||
rightIcon.FadeIdleColour();
|
||||
}
|
||||
|
||||
public class ChevronIcon : SpriteIcon
|
||||
{
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
public ChevronIcon()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(icon_size);
|
||||
Size = new Vector2(7.5f);
|
||||
Icon = FontAwesome.Solid.ChevronDown;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Colour = colourProvider.Foreground1;
|
||||
}
|
||||
|
||||
public void FadeHoverColour() => this.FadeColour(colourProvider.Light1, 200, Easing.OutQuint);
|
||||
|
||||
public void FadeIdleColour() => this.FadeColour(colourProvider.Foreground1, 200, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user