Add better click-to-dismiss logic for sheared overlays

This commit is contained in:
Dean Herbert
2022-04-21 16:15:10 +09:00
parent 2769d8e8cf
commit 0f4b40ab15
3 changed files with 36 additions and 2 deletions

View File

@ -0,0 +1,21 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable enable
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
namespace osu.Game.Graphics
{
/// <summary>
/// A simple container which blocks input events from travelling through it.
/// </summary>
public class InputBlockingContainer : Container
{
protected override bool OnHover(HoverEvent e) => true;
protected override bool OnMouseDown(MouseDownEvent e) => true;
protected override bool OnClick(ClickEvent e) => true;
}
}

View File

@ -66,7 +66,7 @@ namespace osu.Game.Graphics.UserInterface
}, },
Children = new Drawable[] Children = new Drawable[]
{ {
underlayContainer = new Container underlayContainer = new InputBlockingContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = HEIGHT, Height = HEIGHT,

View File

@ -5,6 +5,8 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; 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.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -88,7 +90,7 @@ namespace osu.Game.Overlays.Mods
Bottom = footer_height + PADDING, Bottom = footer_height + PADDING,
} }
}, },
Footer = new Container Footer = new InputBlockingContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Depth = float.MinValue, Depth = float.MinValue,
@ -113,6 +115,17 @@ namespace osu.Game.Overlays.Mods
}; };
} }
protected override bool OnClick(ClickEvent e)
{
if (State.Value == Visibility.Visible)
{
Hide();
return true;
}
return base.OnClick(e);
}
protected override void PopIn() protected override void PopIn()
{ {
const double fade_in_duration = 400; const double fade_in_duration = 400;