2016-12-06 17:56:20 +08:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-08 11:53:46 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using OpenTK;
|
2016-11-30 13:38:45 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2016-10-08 11:53:46 +08:00
|
|
|
|
|
2016-11-14 16:23:33 +08:00
|
|
|
|
namespace osu.Game.Screens.Menu
|
2016-10-08 11:53:46 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A flow container with an origin based on one of its contained drawables.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FlowContainerWithOrigin : FlowContainer
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A target drawable which this flowcontainer should be centered around.
|
2016-10-12 14:28:28 +08:00
|
|
|
|
/// This target should be a direct child of this FlowContainer.
|
2016-10-08 11:53:46 +08:00
|
|
|
|
/// </summary>
|
2016-10-12 14:28:28 +08:00
|
|
|
|
public Drawable CentreTarget;
|
2016-10-08 11:53:46 +08:00
|
|
|
|
|
2016-11-30 14:49:26 +08:00
|
|
|
|
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();
|
2016-11-30 13:38:45 +08:00
|
|
|
|
|
|
|
|
|
protected override IEnumerable<Drawable> SortedChildren => base.SortedChildren.Reverse();
|
|
|
|
|
|
2016-10-08 11:53:46 +08:00
|
|
|
|
public override Anchor Origin => Anchor.Custom;
|
|
|
|
|
|
|
|
|
|
public override Vector2 OriginPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (CentreTarget == null)
|
|
|
|
|
return base.OriginPosition;
|
|
|
|
|
|
2016-10-19 00:53:31 +08:00
|
|
|
|
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2;
|
2016-10-08 11:53:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|