// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using System.Collections.Generic; using System.Linq; namespace osu.Game.Screens.Menu { /// /// A flow container with an origin based on one of its contained drawables. /// public class FlowContainerWithOrigin : FillFlowContainer { /// /// A target drawable which this flowcontainer should be centered around. /// This target should be a direct child of this FlowContainer. /// public Drawable CentreTarget; protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); public override Anchor Origin => Anchor.Custom; public override Vector2 OriginPosition { get { if (CentreTarget == null) return base.OriginPosition; return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2; } } } }