mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 06:02:54 +08:00
allow hover to expand ModCustomisationPanel
This commit is contained in:
parent
c90e04092a
commit
0cc6818b21
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -28,6 +29,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public readonly BindableBool Expanded = new BindableBool();
|
public readonly BindableBool Expanded = new BindableBool();
|
||||||
|
|
||||||
|
protected new ModCustomisationPanel Parent => (ModCustomisationPanel)base.Parent;
|
||||||
|
|
||||||
public ModCustomisationHeader()
|
public ModCustomisationHeader()
|
||||||
{
|
{
|
||||||
Action = Expanded.Toggle;
|
Action = Expanded.Toggle;
|
||||||
@ -91,5 +94,15 @@ namespace osu.Game.Overlays.Mods
|
|||||||
icon.ScaleTo(v.NewValue ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint);
|
icon.ScaleTo(v.NewValue ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint);
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
if (Enabled.Value)
|
||||||
|
{
|
||||||
|
Parent.UpdateHoverExpansion(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnHover(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,22 @@ namespace osu.Game.Overlays.Mods
|
|||||||
content.ResizeHeightTo(header_height, 400, Easing.OutQuint);
|
content.ResizeHeightTo(header_height, 400, Easing.OutQuint);
|
||||||
content.FadeOut(400, Easing.OutSine);
|
content.FadeOut(400, Easing.OutSine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expandedByHovering = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool expandedByHovering = false;
|
||||||
|
public void UpdateHoverExpansion(bool hovered)
|
||||||
|
{
|
||||||
|
if (hovered && !Expanded.Value)
|
||||||
|
{
|
||||||
|
Expanded.Value = true;
|
||||||
|
expandedByHovering = true;
|
||||||
|
}
|
||||||
|
else if (!hovered && expandedByHovering)
|
||||||
|
{
|
||||||
|
Expanded.Value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMods()
|
private void updateMods()
|
||||||
@ -206,6 +222,14 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public override bool RequestsFocus => Expanded.Value;
|
public override bool RequestsFocus => Expanded.Value;
|
||||||
public override bool AcceptsFocus => Expanded.Value;
|
public override bool AcceptsFocus => Expanded.Value;
|
||||||
|
|
||||||
|
public new ModCustomisationPanel Parent => (ModCustomisationPanel)base.Parent;
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
Parent.UpdateHoverExpansion(false);
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user