2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2023-12-27 01:54:24 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-10-03 23:30:22 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public abstract partial class SidebarButton : OsuButton
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-10 10:55:45 +08:00
|
|
|
|
protected const double FADE_DURATION = 500;
|
2021-10-03 23:30:22 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
2023-06-23 00:37:25 +08:00
|
|
|
|
protected OverlayColourProvider ColourProvider { get; private set; } = null!;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2023-10-20 13:36:36 +08:00
|
|
|
|
protected SidebarButton(HoverSampleSet? hoverSounds = HoverSampleSet.ButtonSidebar)
|
|
|
|
|
: base(hoverSounds)
|
2022-10-21 17:06:38 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2021-10-03 23:30:22 +08:00
|
|
|
|
private void load()
|
|
|
|
|
{
|
2021-10-10 02:43:18 +08:00
|
|
|
|
BackgroundColour = ColourProvider.Background5;
|
2023-12-27 01:54:24 +08:00
|
|
|
|
Hover.Colour = ColourProvider.Light4;
|
2021-10-03 23:30:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2021-10-10 02:43:18 +08:00
|
|
|
|
UpdateState();
|
|
|
|
|
FinishTransforms(true);
|
2021-10-03 23:30:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-10 02:43:18 +08:00
|
|
|
|
UpdateState();
|
2021-10-03 23:30:22 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-10 02:43:18 +08:00
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e) => UpdateState();
|
2021-10-03 23:30:22 +08:00
|
|
|
|
|
2023-12-27 01:54:24 +08:00
|
|
|
|
protected virtual void UpdateState()
|
|
|
|
|
{
|
|
|
|
|
Hover.FadeTo(IsHovered ? 0.1f : 0, FADE_DURATION, Easing.OutQuint);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|