2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Menu
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A flow container with an origin based on one of its contained drawables.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FlowContainerWithOrigin : FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
/// <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 int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
|
|
|
|
|
|
|
|
|
public override Anchor Origin => Anchor.Custom;
|
|
|
|
|
|
|
|
|
|
public override Vector2 OriginPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (CentreTarget == null)
|
|
|
|
|
return base.OriginPosition;
|
|
|
|
|
|
2019-04-08 06:24:09 +00:00
|
|
|
|
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2 * CentreTarget.Scale;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|