mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:13:21 +08:00
Implement multiple selection
This commit is contained in:
parent
8d50b155e8
commit
20aeb7aaff
@ -93,11 +93,79 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
checkControlPointSelected(0, true);
|
checkControlPointSelected(0, true);
|
||||||
checkControlPointSelected(1, false);
|
checkControlPointSelected(1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSingleControlPointDeselectionViaOtherControlPoint()
|
||||||
|
{
|
||||||
|
moveMouseToControlPoint(0);
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
moveMouseToControlPoint(1);
|
moveMouseToControlPoint(1);
|
||||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
checkControlPointSelected(0, false);
|
checkControlPointSelected(0, false);
|
||||||
checkControlPointSelected(1, true);
|
checkControlPointSelected(1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSingleControlPointDeselectionViaClickOutside()
|
||||||
|
{
|
||||||
|
moveMouseToControlPoint(0);
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
AddStep("move mouse outside control point", () => InputManager.MoveMouseTo(drawableObject));
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
checkControlPointSelected(0, false);
|
||||||
|
checkControlPointSelected(1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleControlPointSelection()
|
||||||
|
{
|
||||||
|
moveMouseToControlPoint(0);
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
moveMouseToControlPoint(1);
|
||||||
|
AddStep("ctrl + click", () =>
|
||||||
|
{
|
||||||
|
InputManager.PressKey(Key.ControlLeft);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
InputManager.ReleaseKey(Key.ControlLeft);
|
||||||
|
});
|
||||||
|
checkControlPointSelected(0, true);
|
||||||
|
checkControlPointSelected(1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleControlPointDeselectionViaOtherControlPoint()
|
||||||
|
{
|
||||||
|
moveMouseToControlPoint(0);
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
moveMouseToControlPoint(1);
|
||||||
|
AddStep("ctrl + click", () =>
|
||||||
|
{
|
||||||
|
InputManager.PressKey(Key.ControlLeft);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
InputManager.ReleaseKey(Key.ControlLeft);
|
||||||
|
});
|
||||||
|
|
||||||
|
moveMouseToControlPoint(2);
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
checkControlPointSelected(0, false);
|
||||||
|
checkControlPointSelected(1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleControlPointDeselectionViaClickOutside()
|
||||||
|
{
|
||||||
|
moveMouseToControlPoint(0);
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
moveMouseToControlPoint(1);
|
||||||
|
AddStep("ctrl + click", () =>
|
||||||
|
{
|
||||||
|
InputManager.PressKey(Key.ControlLeft);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
InputManager.ReleaseKey(Key.ControlLeft);
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("move mouse outside control point", () => InputManager.MoveMouseTo(drawableObject));
|
AddStep("move mouse outside control point", () => InputManager.MoveMouseTo(drawableObject));
|
||||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -14,10 +15,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
{
|
{
|
||||||
public Action<Vector2[]> ControlPointsChanged;
|
public Action<Vector2[]> ControlPointsChanged;
|
||||||
|
|
||||||
internal Container<PathControlPointPiece> Pieces { get; }
|
internal readonly Container<PathControlPointPiece> Pieces;
|
||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
|
|
||||||
|
private InputManager inputManager;
|
||||||
|
|
||||||
public PathControlPointVisualiser(Slider slider)
|
public PathControlPointVisualiser(Slider slider)
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
@ -27,6 +29,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
InternalChild = Pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both };
|
InternalChild = Pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -53,8 +62,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
|
|
||||||
private void selectPiece(int index)
|
private void selectPiece(int index)
|
||||||
{
|
{
|
||||||
foreach (var piece in Pieces)
|
if (inputManager.CurrentState.Keyboard.ControlPressed)
|
||||||
piece.IsSelected.Value = piece.Index == index;
|
Pieces[index].IsSelected.Value = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var piece in Pieces)
|
||||||
|
piece.IsSelected.Value = piece.Index == index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user