2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-08-10 00:50:44 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-01-09 19:22:23 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-08-09 05:11:46 +08:00
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Allocation;
|
2018-01-09 19:22:23 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2017-08-09 05:11:46 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Containers
|
|
|
|
|
{
|
|
|
|
|
public class OsuHoverContainer : OsuClickableContainer
|
|
|
|
|
{
|
2018-01-09 19:22:23 +08:00
|
|
|
|
protected Color4 HoverColour;
|
|
|
|
|
|
|
|
|
|
protected Color4 IdleColour = Color4.White;
|
|
|
|
|
|
|
|
|
|
protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content };
|
2017-08-09 05:11:46 +08:00
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
2018-01-09 19:22:23 +08:00
|
|
|
|
EffectTargets.ForEach(d => d.FadeColour(HoverColour, 500, Easing.OutQuint));
|
2017-08-09 05:11:46 +08:00
|
|
|
|
return base.OnHover(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
2018-01-09 19:22:23 +08:00
|
|
|
|
EffectTargets.ForEach(d => d.FadeColour(IdleColour, 500, Easing.OutQuint));
|
2017-08-09 05:11:46 +08:00
|
|
|
|
base.OnHoverLost(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2018-01-09 19:22:23 +08:00
|
|
|
|
HoverColour = colours.Yellow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
EffectTargets.ForEach(d => d.FadeColour(IdleColour));
|
2017-08-09 05:11:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|