osu/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs

32 lines
918 B
C#
Raw Normal View History

2016-11-14 08:23:33 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2016-11-14 08:23:33 +00:00
using OpenTK;
2016-11-14 08:23:33 +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 : FlowContainer
{
/// <summary>
/// A target drawable which this flowcontainer should be centered around.
2016-10-12 06:28:28 +00:00
/// This target should be a direct child of this FlowContainer.
/// </summary>
2016-10-12 06:28:28 +00:00
public Drawable CentreTarget;
public override Anchor Origin => Anchor.Custom;
public override Vector2 OriginPosition
{
get
{
if (CentreTarget == null)
return base.OriginPosition;
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2;
}
}
}
}