2019-10-10 17:06:25 +08: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.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Comments
|
|
|
|
|
{
|
|
|
|
|
public class HeaderButton : Container
|
|
|
|
|
{
|
2019-10-14 20:32:16 +08:00
|
|
|
|
private const int transition_duration = 200;
|
2019-10-10 17:06:25 +08:00
|
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
|
|
private readonly Box background;
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
|
|
public HeaderButton()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X;
|
2019-10-14 20:32:16 +08:00
|
|
|
|
Height = 20;
|
2019-10-10 17:06:25 +08:00
|
|
|
|
Masking = true;
|
2019-10-14 20:32:16 +08:00
|
|
|
|
CornerRadius = 3;
|
2019-10-10 17:06:25 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-10-14 20:32:16 +08:00
|
|
|
|
Margin = new MarginPadding { Horizontal = 10 }
|
2019-10-10 17:06:25 +08:00
|
|
|
|
},
|
|
|
|
|
new HoverClickSounds(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-01-27 19:58:27 +08:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2019-10-10 17:06:25 +08:00
|
|
|
|
{
|
2020-01-27 19:58:27 +08:00
|
|
|
|
background.Colour = colourProvider.Background3;
|
2019-10-10 17:06:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
2019-10-14 20:32:16 +08:00
|
|
|
|
ShowBackground();
|
2019-10-10 17:06:25 +08:00
|
|
|
|
return base.OnHover(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHoverLost(e);
|
2019-10-14 20:32:16 +08:00
|
|
|
|
HideBackground();
|
2019-10-10 17:06:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 20:32:16 +08:00
|
|
|
|
protected void ShowBackground() => background.FadeIn(transition_duration, Easing.OutQuint);
|
2019-10-10 17:06:25 +08:00
|
|
|
|
|
2019-10-14 20:32:16 +08:00
|
|
|
|
protected void HideBackground() => background.FadeOut(transition_duration, Easing.OutQuint);
|
2019-10-10 17:06:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|