2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2016-12-06 17:56:20 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-08 11:53:46 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +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>
|
2017-03-02 02:33:01 +08:00
|
|
|
|
public partial class FlowContainerWithOrigin : FillFlowContainer
|
2016-10-08 11:53:46 +08:00
|
|
|
|
{
|
|
|
|
|
/// <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;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-07-12 02:21:58 +08:00
|
|
|
|
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-10-08 11:53:46 +08:00
|
|
|
|
public override Anchor Origin => Anchor.Custom;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-10-08 11:53:46 +08:00
|
|
|
|
public override Vector2 OriginPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (CentreTarget == null)
|
|
|
|
|
return base.OriginPosition;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-04-08 14:24:09 +08:00
|
|
|
|
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2 * CentreTarget.Scale;
|
2016-10-08 11:53:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|