1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 05:53:11 +08:00

pass ModCustomisationPanel through ctor

This commit is contained in:
Caiyi Shyu 2024-08-01 18:38:01 +08:00
parent 5fb364cad6
commit 188ddbcad6
2 changed files with 13 additions and 7 deletions

View File

@ -29,10 +29,11 @@ namespace osu.Game.Overlays.Mods
public readonly BindableBool Expanded = new BindableBool(); public readonly BindableBool Expanded = new BindableBool();
protected new ModCustomisationPanel? Parent => (ModCustomisationPanel?)base.Parent; private readonly ModCustomisationPanel panel;
public ModCustomisationHeader() public ModCustomisationHeader(ModCustomisationPanel panel)
{ {
this.panel = panel;
Action = Expanded.Toggle; Action = Expanded.Toggle;
Enabled.Value = false; Enabled.Value = false;
} }
@ -113,7 +114,7 @@ namespace osu.Game.Overlays.Mods
if (Enabled.Value) if (Enabled.Value)
{ {
if (!touchedThisFrame) if (!touchedThisFrame)
Parent?.UpdateHoverExpansion(true); panel.UpdateHoverExpansion(true);
} }
return base.OnHover(e); return base.OnHover(e);

View File

@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Mods
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new ModCustomisationHeader new ModCustomisationHeader(this)
{ {
Depth = float.MinValue, Depth = float.MinValue,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Mods
Enabled = { BindTarget = Enabled }, Enabled = { BindTarget = Enabled },
Expanded = { BindTarget = Expanded }, Expanded = { BindTarget = Expanded },
}, },
content = new FocusGrabbingContainer content = new FocusGrabbingContainer(this)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
BorderColour = colourProvider.Dark3, BorderColour = colourProvider.Dark3,
@ -229,12 +229,17 @@ 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; private readonly ModCustomisationPanel panel;
public FocusGrabbingContainer(ModCustomisationPanel panel)
{
this.panel = panel;
}
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (ExpandedByHovering.Value && !ReceivePositionalInputAt(e.ScreenSpaceMousePosition)) if (ExpandedByHovering.Value && !ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
Parent?.UpdateHoverExpansion(false); panel.UpdateHoverExpansion(false);
base.OnHoverLost(e); base.OnHoverLost(e);
} }