mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 22:27:25 +08:00
Replace separated top-centered rotation button with rotation drag handles
This commit is contained in:
parent
77f7d4c963
commit
a8c460f7df
@ -92,7 +92,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Container dragHandles;
|
private SelectionBoxDragHandleDisplay dragHandles;
|
||||||
private FillFlowContainer buttons;
|
private FillFlowContainer buttons;
|
||||||
|
|
||||||
public const float BORDER_RADIUS = 3;
|
public const float BORDER_RADIUS = 3;
|
||||||
@ -161,7 +161,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dragHandles = new Container
|
dragHandles = new SelectionBoxDragHandleDisplay
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
// ensures that the centres of all drag handles line up with the middle of the selection box border.
|
// ensures that the centres of all drag handles line up with the middle of the selection box border.
|
||||||
@ -186,75 +186,76 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private void addRotationComponents()
|
private void addRotationComponents()
|
||||||
{
|
{
|
||||||
const float separation = 40;
|
|
||||||
|
|
||||||
addButton(FontAwesome.Solid.Undo, "Rotate 90 degrees counter-clockwise", () => OnRotation?.Invoke(-90));
|
addButton(FontAwesome.Solid.Undo, "Rotate 90 degrees counter-clockwise", () => OnRotation?.Invoke(-90));
|
||||||
addButton(FontAwesome.Solid.Redo, "Rotate 90 degrees clockwise", () => OnRotation?.Invoke(90));
|
addButton(FontAwesome.Solid.Redo, "Rotate 90 degrees clockwise", () => OnRotation?.Invoke(90));
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
addRotateHandle(Anchor.TopLeft);
|
||||||
{
|
addRotateHandle(Anchor.TopRight);
|
||||||
new Box
|
addRotateHandle(Anchor.BottomLeft);
|
||||||
{
|
addRotateHandle(Anchor.BottomRight);
|
||||||
Depth = float.MaxValue,
|
|
||||||
Colour = colours.YellowLight,
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
Alpha = 0.3f,
|
|
||||||
Size = new Vector2(BORDER_RADIUS, separation),
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
},
|
|
||||||
new SelectionBoxDragHandleButton(FontAwesome.Solid.Redo, "Free rotate")
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Y = -separation,
|
|
||||||
HandleDrag = e => OnRotation?.Invoke(convertDragEventToAngleOfRotation(e)),
|
|
||||||
OperationStarted = operationStarted,
|
|
||||||
OperationEnded = operationEnded
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addYScaleComponents()
|
private void addYScaleComponents()
|
||||||
{
|
{
|
||||||
addButton(FontAwesome.Solid.ArrowsAltV, "Flip vertically (Ctrl-J)", () => OnFlip?.Invoke(Direction.Vertical));
|
addButton(FontAwesome.Solid.ArrowsAltV, "Flip vertically (Ctrl-J)", () => OnFlip?.Invoke(Direction.Vertical));
|
||||||
|
|
||||||
addDragHandle(Anchor.TopCentre);
|
addScaleHandle(Anchor.TopCentre);
|
||||||
addDragHandle(Anchor.BottomCentre);
|
addScaleHandle(Anchor.BottomCentre);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFullScaleComponents()
|
private void addFullScaleComponents()
|
||||||
{
|
{
|
||||||
addDragHandle(Anchor.TopLeft);
|
addScaleHandle(Anchor.TopLeft);
|
||||||
addDragHandle(Anchor.TopRight);
|
addScaleHandle(Anchor.TopRight);
|
||||||
addDragHandle(Anchor.BottomLeft);
|
addScaleHandle(Anchor.BottomLeft);
|
||||||
addDragHandle(Anchor.BottomRight);
|
addScaleHandle(Anchor.BottomRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addXScaleComponents()
|
private void addXScaleComponents()
|
||||||
{
|
{
|
||||||
addButton(FontAwesome.Solid.ArrowsAltH, "Flip horizontally (Ctrl-H)", () => OnFlip?.Invoke(Direction.Horizontal));
|
addButton(FontAwesome.Solid.ArrowsAltH, "Flip horizontally (Ctrl-H)", () => OnFlip?.Invoke(Direction.Horizontal));
|
||||||
|
|
||||||
addDragHandle(Anchor.CentreLeft);
|
addScaleHandle(Anchor.CentreLeft);
|
||||||
addDragHandle(Anchor.CentreRight);
|
addScaleHandle(Anchor.CentreRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addButton(IconUsage icon, string tooltip, Action action)
|
private void addButton(IconUsage icon, string tooltip, Action action)
|
||||||
{
|
{
|
||||||
buttons.Add(new SelectionBoxDragHandleButton(icon, tooltip)
|
var button = new SelectionBoxButton(icon, tooltip)
|
||||||
{
|
{
|
||||||
OperationStarted = operationStarted,
|
|
||||||
OperationEnded = operationEnded,
|
|
||||||
Action = action
|
Action = action
|
||||||
});
|
};
|
||||||
|
|
||||||
|
button.OperationStarted += operationStarted;
|
||||||
|
button.OperationEnded += operationEnded;
|
||||||
|
buttons.Add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDragHandle(Anchor anchor) => dragHandles.Add(new SelectionBoxDragHandle
|
private void addScaleHandle(Anchor anchor)
|
||||||
{
|
{
|
||||||
Anchor = anchor,
|
var handle = new SelectionBoxScaleHandle
|
||||||
HandleDrag = e => OnScale?.Invoke(e.Delta, anchor),
|
{
|
||||||
OperationStarted = operationStarted,
|
Anchor = anchor,
|
||||||
OperationEnded = operationEnded
|
HandleDrag = e => OnScale?.Invoke(e.Delta, anchor)
|
||||||
});
|
};
|
||||||
|
|
||||||
|
handle.OperationStarted += operationStarted;
|
||||||
|
handle.OperationEnded += operationEnded;
|
||||||
|
dragHandles.AddScaleHandle(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRotateHandle(Anchor anchor)
|
||||||
|
{
|
||||||
|
var handle = new SelectionBoxRotationHandle
|
||||||
|
{
|
||||||
|
Anchor = anchor,
|
||||||
|
HandleDrag = e => OnRotation?.Invoke(convertDragEventToAngleOfRotation(e))
|
||||||
|
};
|
||||||
|
|
||||||
|
handle.OperationStarted += operationStarted;
|
||||||
|
handle.OperationEnded += operationEnded;
|
||||||
|
dragHandles.AddRotationHandle(handle);
|
||||||
|
}
|
||||||
|
|
||||||
private int activeOperations;
|
private int activeOperations;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user