osu/osu.Game/Overlays/Rankings/Tables/TableRowBackground.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.6 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2019-09-27 16:33:52 +00:00
// See the LICENCE file in the repository root for full licence text.
2022-06-17 07:37:17 +00:00
#nullable disable
2019-09-27 16:33:52 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osuTK.Graphics;
namespace osu.Game.Overlays.Rankings.Tables
{
public partial class TableRowBackground : CompositeDrawable
{
private const int fade_duration = 100;
private readonly Box background;
private Color4 idleColour;
private Color4 hoverColour;
public TableRowBackground()
2019-09-27 16:33:52 +00:00
{
RelativeSizeAxes = Axes.X;
CornerRadius = 4;
2019-09-27 16:33:52 +00:00
Masking = true;
MaskingSmoothness = 0.5f;
2019-09-27 16:33:52 +00:00
InternalChild = background = new Box
{
RelativeSizeAxes = Axes.Both,
};
}
[BackgroundDependencyLoader]
2020-02-03 18:22:37 +00:00
private void load(OverlayColourProvider colourProvider)
2019-09-27 16:33:52 +00:00
{
2020-02-03 18:22:37 +00:00
background.Colour = idleColour = colourProvider.Background4;
hoverColour = colourProvider.Background3;
2019-09-27 16:33:52 +00:00
}
protected override bool OnHover(HoverEvent e)
{
background.FadeColour(hoverColour, fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
background.FadeColour(idleColour, fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}
}