1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 23:03:20 +08:00

Remove DragLayer dependency on MaskContainer

This commit is contained in:
Dean Herbert 2018-04-04 18:20:32 +09:00
parent c2d371797e
commit b6b8c51657
2 changed files with 6 additions and 7 deletions

View File

@ -18,23 +18,22 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
/// </summary> /// </summary>
public class DragLayer : CompositeDrawable public class DragLayer : CompositeDrawable
{ {
private readonly Action<RectangleF> performSelection;
/// <summary> /// <summary>
/// Invoked when the drag selection has finished. /// Invoked when the drag selection has finished.
/// </summary> /// </summary>
public event Action DragEnd; public event Action DragEnd;
private readonly MaskContainer maskContainer;
private Drawable box; private Drawable box;
/// <summary> /// <summary>
/// Creates a new <see cref="DragLayer"/>. /// Creates a new <see cref="DragLayer"/>.
/// </summary> /// </summary>
/// <param name="maskContainer">The selectable <see cref="HitObjectMask"/>s.</param> /// <param name="maskContainer">The selectable <see cref="HitObjectMask"/>s.</param>
public DragLayer(MaskContainer maskContainer) public DragLayer(Action<RectangleF> performSelection)
{ {
this.maskContainer = maskContainer; this.performSelection = performSelection;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
AlwaysPresent = true; AlwaysPresent = true;
Alpha = 0; Alpha = 0;
@ -78,7 +77,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
box.Position = topLeft; box.Position = topLeft;
box.Size = bottomRight - topLeft; box.Size = bottomRight - topLeft;
maskContainer.Select(dragRectangle); performSelection?.Invoke(dragRectangle);
return true; return true;
} }

View File

@ -35,8 +35,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
selectionBox = composer.CreateSelectionBox(maskContainer); selectionBox = composer.CreateSelectionBox(maskContainer);
var dragLayer = new DragLayer(maskContainer);
dragLayer.DragEnd += () => selectionBox.UpdateVisibility(); dragLayer.DragEnd += () => selectionBox.UpdateVisibility();
var dragLayer = new DragLayer(maskContainer.Select);
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {