// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using osu.Framework.Input; using osu.Framework.Input.Events; namespace osu.Framework.Graphics.Containers { /// /// An element which starts hidden and can be toggled to visible. /// public abstract class OverlayContainer : VisibilityContainer { /// /// Whether we should block any positional input from interacting with things behind us. /// protected virtual bool BlockPositionalInput => true; /// /// Scroll events are sometimes required to be handled differently to general positional input. /// This covers whether scroll events that occur within this overlay's bounds are blocked or not. /// Defaults to the same value as /// protected virtual bool BlockScrollInput => BlockPositionalInput; /// /// Whether we should block any non-positional input from interacting with things behind us. /// protected virtual bool BlockNonPositionalInput => false; internal override bool BuildNonPositionalInputQueue(List queue, bool allowBlocking = true) { if (PropagateNonPositionalInputSubTree && HandleNonPositionalInput && BlockNonPositionalInput) { // when blocking non-positional input behind us, we still want to make sure the global handlers receive events // but we don't want other drawables behind us handling them. queue.RemoveAll(d => !(d is IHandleGlobalKeyboardInput)); } return base.BuildNonPositionalInputQueue(queue, allowBlocking); } public override bool DragBlocksClick => false; protected override bool Handle(UIEvent e) { switch (e) { case ScrollEvent _: if (BlockScrollInput && base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition)) return true; break; case MouseEvent _: if (BlockPositionalInput) return true; break; } return base.Handle(e); } } }