1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-20 19:52:54 +08:00
osu-lazer/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs

62 lines
1.8 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
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Edit.Layers.Selection
{
public class SelectionLayer : CompositeDrawable
{
public readonly Bindable<SelectionInfo> Selection = new Bindable<SelectionInfo>();
private readonly Playfield playfield;
public SelectionLayer(Playfield playfield)
{
this.playfield = playfield;
RelativeSizeAxes = Axes.Both;
}
2017-12-18 18:16:33 +08:00
private HitObjectSelectionBox selectionBoxBox;
protected override bool OnDragStart(InputState state)
{
// Hide the previous drag box - we won't be working with it any longer
2017-12-18 18:16:33 +08:00
selectionBoxBox?.Hide();
2017-12-18 18:16:33 +08:00
AddInternal(selectionBoxBox = new HitObjectSelectionBox(ToLocalSpace(state.Mouse.NativeState.Position))
{
CapturableObjects = playfield.HitObjects.Objects,
});
2017-12-18 18:16:33 +08:00
Selection.BindTo(selectionBoxBox.Selection);
return true;
}
protected override bool OnDrag(InputState state)
{
2017-12-18 18:16:33 +08:00
selectionBoxBox.DragEndPosition = ToLocalSpace(state.Mouse.NativeState.Position);
selectionBoxBox.BeginCapture();
return true;
}
protected override bool OnDragEnd(InputState state)
{
2017-12-18 18:16:33 +08:00
selectionBoxBox.FinishCapture();
return true;
}
protected override bool OnClick(InputState state)
{
2017-12-18 18:16:33 +08:00
selectionBoxBox?.Hide();
return true;
}
}
}