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;
|
2017-12-11 20:56:58 +08:00
|
|
|
|
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.
|
2017-12-11 20:56:58 +08:00
|
|
|
|
/// </summary>
|
2017-12-18 18:21:26 +08:00
|
|
|
|
public class HandleContainer : CompositeDrawable
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-18 18:21:26 +08:00
|
|
|
|
/// Invoked when a <see cref="Handle"/> requires the current drag rectangle.
|
2017-12-11 20:56:58 +08:00
|
|
|
|
/// </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.
|
2017-12-11 20:56:58 +08:00
|
|
|
|
/// </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.
|
2017-12-11 20:56:58 +08:00
|
|
|
|
/// </summary>
|
2017-12-18 18:24:41 +08:00
|
|
|
|
public Action FinishDrag;
|
2017-12-11 20:56:58 +08:00
|
|
|
|
|
2017-12-18 18:21:26 +08:00
|
|
|
|
public HandleContainer()
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new Handle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2017-12-18 18:21:26 +08:00
|
|
|
|
new OriginHandle
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-18 18:21:26 +08:00
|
|
|
|
InternalChildren.OfType<Handle>().ForEach(m =>
|
2017-12-11 20:56:58 +08:00
|
|
|
|
{
|
|
|
|
|
m.GetDragRectangle = () => GetDragRectangle();
|
|
|
|
|
m.UpdateDragRectangle = r => UpdateDragRectangle(r);
|
2017-12-18 18:24:41 +08:00
|
|
|
|
m.FinishDrag = () => FinishDrag();
|
2017-12-11 20:56:58 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|