mirror of https://github.com/ppy/osu
Handle unhover state change better
This commit is contained in:
parent
89e62c3d30
commit
5ed1540a12
|
@ -20,19 +20,41 @@ public class OsuHoverContainer : OsuClickableContainer
|
|||
|
||||
protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content };
|
||||
|
||||
public OsuHoverContainer()
|
||||
{
|
||||
Enabled.ValueChanged += e =>
|
||||
{
|
||||
if (!e.NewValue) unhover();
|
||||
};
|
||||
}
|
||||
|
||||
private bool isHovered;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (Action != null)
|
||||
EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint));
|
||||
if (!Enabled.Value)
|
||||
return false;
|
||||
|
||||
EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint));
|
||||
isHovered = true;
|
||||
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint));
|
||||
unhover();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private void unhover()
|
||||
{
|
||||
if (!isHovered) return;
|
||||
|
||||
isHovered = false;
|
||||
EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue