1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 12:37:47 +08:00
osu-lazer/osu.Game/Overlays/Settings/SidebarButton.cs

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

51 lines
1.4 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Settings
2016-11-12 14:53:20 +08:00
{
public abstract partial class SidebarButton : OsuButton
2016-11-12 14:53:20 +08:00
{
protected const double FADE_DURATION = 500;
[Resolved]
protected OverlayColourProvider ColourProvider { get; private set; } = null!;
2018-04-13 17:19:50 +08:00
protected SidebarButton(HoverSampleSet? hoverSounds = HoverSampleSet.ButtonSidebar)
: base(hoverSounds)
{
}
[BackgroundDependencyLoader]
private void load()
{
BackgroundColour = ColourProvider.Background5;
Hover.Colour = ColourProvider.Light4;
}
protected override void LoadComplete()
{
base.LoadComplete();
UpdateState();
FinishTransforms(true);
}
protected override bool OnHover(HoverEvent e)
{
UpdateState();
return false;
}
protected override void OnHoverLost(HoverLostEvent e) => UpdateState();
protected virtual void UpdateState()
{
Hover.FadeTo(IsHovered ? 0.1f : 0, FADE_DURATION, Easing.OutQuint);
}
2016-11-12 14:53:20 +08:00
}
}