1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 18:53:51 +08:00

Reorder methods in SkinSelectionHandler to follow standards

This commit is contained in:
Dean Herbert 2021-05-03 15:15:00 +09:00
parent a2faa0b74c
commit 51f4077b27

View File

@ -17,6 +17,46 @@ namespace osu.Game.Skinning.Editor
{
public class SkinSelectionHandler : SelectionHandler<ISkinnableComponent>
{
public override bool HandleRotation(float angle)
{
// TODO: this doesn't correctly account for origin/anchor specs being different in a multi-selection.
foreach (var c in SelectedBlueprints)
((Drawable)c.Item).Rotation += angle;
return base.HandleRotation(angle);
}
public override bool HandleScale(Vector2 scale, Anchor anchor)
{
adjustScaleFromAnchor(ref scale, anchor);
foreach (var c in SelectedBlueprints)
((Drawable)c.Item).Scale += scale * 0.01f;
return true;
}
public override bool HandleMovement(MoveSelectionEvent<ISkinnableComponent> moveEvent)
{
foreach (var c in SelectedBlueprints)
{
Drawable drawable = (Drawable)c.Item;
drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta);
}
return true;
}
protected override void OnSelectionChanged()
{
base.OnSelectionChanged();
SelectionBox.CanRotate = true;
SelectionBox.CanScaleX = true;
SelectionBox.CanScaleY = true;
SelectionBox.CanReverse = false;
}
protected override void DeleteItems(IEnumerable<ISkinnableComponent> items)
{
foreach (var i in items)
@ -67,46 +107,6 @@ namespace osu.Game.Skinning.Editor
((Drawable)item).Anchor = anchor;
}
protected override void OnSelectionChanged()
{
base.OnSelectionChanged();
SelectionBox.CanRotate = true;
SelectionBox.CanScaleX = true;
SelectionBox.CanScaleY = true;
SelectionBox.CanReverse = false;
}
public override bool HandleRotation(float angle)
{
// TODO: this doesn't correctly account for origin/anchor specs being different in a multi-selection.
foreach (var c in SelectedBlueprints)
((Drawable)c.Item).Rotation += angle;
return base.HandleRotation(angle);
}
public override bool HandleScale(Vector2 scale, Anchor anchor)
{
adjustScaleFromAnchor(ref scale, anchor);
foreach (var c in SelectedBlueprints)
((Drawable)c.Item).Scale += scale * 0.01f;
return true;
}
public override bool HandleMovement(MoveSelectionEvent<ISkinnableComponent> moveEvent)
{
foreach (var c in SelectedBlueprints)
{
Drawable drawable = (Drawable)c.Item;
drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta);
}
return true;
}
private static void adjustScaleFromAnchor(ref Vector2 scale, Anchor reference)
{
// cancel out scale in axes we don't care about (based on which drag handle was used).