// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; namespace osu.Game.Rulesets.Edit { /// /// A mask placed above a adding editing functionality. /// public class HitObjectMask : VisibilityContainer { /// /// Invoked when this has been selected. /// public event Action Selected; /// /// Invoked when this has been deselected. /// public event Action Deselected; /// /// The which this applies to. /// public readonly DrawableHitObject HitObject; protected override bool ShouldBeAlive => HitObject.IsAlive || State == Visibility.Visible; public override bool RemoveWhenNotAlive => false; public override bool HandleMouseInput => HitObject.IsPresent; public HitObjectMask(DrawableHitObject hitObject) { HitObject = hitObject; AlwaysPresent = true; State = Visibility.Hidden; } /// /// Selects this , causing it to become visible. /// /// True if the was selected. False if the was already selected. public bool Select() { if (State == Visibility.Visible) return false; Show(); Selected?.Invoke(this); return true; } /// /// Deselects this , causing it to become invisible. /// /// True if the was deselected. False if the was already deselected. public bool Deselect() { if (State == Visibility.Hidden) return false; Hide(); Deselected?.Invoke(this); return true; } protected override void PopIn() => Alpha = 1; protected override void PopOut() => Alpha = 0; /// /// The screen-space point that causes this to be selected. /// public virtual Vector2 SelectionPoint => ScreenSpaceDrawQuad.Centre; /// /// The screen-space quad that outlines this for selections. /// public virtual Quad SelectionQuad => ScreenSpaceDrawQuad; } }