mirror of
https://github.com/ppy/osu
synced 2024-12-12 18:07:52 +00:00
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using OpenTK;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace osu.Game.Screens.Menu
|
|
{
|
|
/// <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.
|
|
/// This target should be a direct child of this FlowContainer.
|
|
/// </summary>
|
|
public Drawable CentreTarget;
|
|
|
|
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();
|
|
|
|
protected override IEnumerable<Drawable> SortedChildren => base.SortedChildren.Reverse();
|
|
|
|
public override Anchor Origin => Anchor.Custom;
|
|
|
|
public override Vector2 OriginPosition
|
|
{
|
|
get
|
|
{
|
|
if (CentreTarget == null)
|
|
return base.OriginPosition;
|
|
|
|
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2;
|
|
}
|
|
}
|
|
}
|
|
}
|