2020-09-29 18:07:40 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-09-29 18:19:48 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2020-09-29 18:07:40 +08:00
|
|
|
using osu.Game.Screens.Edit.Compose.Components;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
|
|
|
{
|
|
|
|
public class TestSceneComposeSelectBox : OsuTestScene
|
|
|
|
{
|
2020-09-29 18:19:48 +08:00
|
|
|
private Container selectionArea;
|
|
|
|
|
2020-09-29 18:07:40 +08:00
|
|
|
public TestSceneComposeSelectBox()
|
|
|
|
{
|
|
|
|
ComposeSelectionBox selectionBox = null;
|
|
|
|
|
|
|
|
AddStep("create box", () =>
|
2020-09-29 18:19:48 +08:00
|
|
|
Child = selectionArea = new Container
|
2020-09-29 18:07:40 +08:00
|
|
|
{
|
|
|
|
Size = new Vector2(300),
|
2020-09-29 18:19:48 +08:00
|
|
|
Position = -new Vector2(150),
|
2020-09-29 18:07:40 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
selectionBox = new ComposeSelectionBox
|
|
|
|
{
|
|
|
|
CanRotate = true,
|
|
|
|
CanScaleX = true,
|
2020-09-29 18:19:48 +08:00
|
|
|
CanScaleY = true,
|
|
|
|
|
|
|
|
OnRotation = handleRotation,
|
|
|
|
OnScaleX = handleScaleX,
|
|
|
|
OnScaleY = handleScaleY,
|
2020-09-29 18:07:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
AddToggleStep("toggle rotation", state => selectionBox.CanRotate = state);
|
|
|
|
AddToggleStep("toggle x", state => selectionBox.CanScaleX = state);
|
|
|
|
AddToggleStep("toggle y", state => selectionBox.CanScaleY = state);
|
|
|
|
}
|
2020-09-29 18:19:48 +08:00
|
|
|
|
|
|
|
private void handleScaleY(DragEvent e, Anchor reference)
|
|
|
|
{
|
|
|
|
int direction = (reference & Anchor.y0) > 0 ? -1 : 1;
|
|
|
|
if (direction < 0)
|
|
|
|
selectionArea.Y += e.Delta.Y;
|
|
|
|
selectionArea.Height += direction * e.Delta.Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleScaleX(DragEvent e, Anchor reference)
|
|
|
|
{
|
|
|
|
int direction = (reference & Anchor.x0) > 0 ? -1 : 1;
|
|
|
|
if (direction < 0)
|
|
|
|
selectionArea.X += e.Delta.X;
|
|
|
|
selectionArea.Width += direction * e.Delta.X;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleRotation(DragEvent e)
|
|
|
|
{
|
|
|
|
selectionArea.Rotation += e.Delta.X;
|
|
|
|
}
|
2020-09-29 18:07:40 +08:00
|
|
|
}
|
|
|
|
}
|