1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 13:47:21 +08:00
osu-lazer/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs

41 lines
1.3 KiB
C#
Raw Normal View History

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