1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 06:42:54 +08:00
osu-lazer/osu.Game/Rulesets/Edit/Layers/Selection/HandleContainer.cs

93 lines
3.0 KiB
C#
Raw Normal View History

2017-12-11 21:21:25 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Rulesets.Edit.Layers.Selection
{
/// <summary>
2017-12-18 18:21:26 +08:00
/// A <see cref="CompositeDrawable"/> that has <see cref="Handle"/>s around its border.
/// </summary>
2017-12-18 18:21:26 +08:00
public class HandleContainer : CompositeDrawable
{
/// <summary>
2017-12-18 18:21:26 +08:00
/// Invoked when a <see cref="Handle"/> requires the current drag rectangle.
/// </summary>
public Func<RectangleF> GetDragRectangle;
/// <summary>
2017-12-18 18:21:26 +08:00
/// Invoked when a <see cref="Handle"/> wants to update the drag rectangle.
/// </summary>
public Action<RectangleF> UpdateDragRectangle;
/// <summary>
2017-12-18 18:21:26 +08:00
/// Invoked when a <see cref="Handle"/> has finished updates to the drag rectangle.
/// </summary>
public Action FinishDrag;
2017-12-18 18:21:26 +08:00
public HandleContainer()
{
InternalChildren = new Drawable[]
{
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.TopLeft,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.TopRight,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.CentreRight,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.BottomRight,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new Handle
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.Centre
},
2017-12-18 18:21:26 +08:00
new OriginHandle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
}
};
2017-12-18 18:21:26 +08:00
InternalChildren.OfType<Handle>().ForEach(m =>
{
m.GetDragRectangle = () => GetDragRectangle();
m.UpdateDragRectangle = r => UpdateDragRectangle(r);
m.FinishDrag = () => FinishDrag();
});
}
}
}