mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Consider drag handles active using mouse down instead of when dragged
This commit is contained in:
parent
5f33c3514e
commit
b2a0c2b563
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
protected override void UpdateHoverState()
|
||||
{
|
||||
base.UpdateHoverState();
|
||||
icon.FadeColour(!HandlingMouse && IsHovered ? Color4.White : Color4.Black, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
icon.FadeColour(!IsHeld && IsHovered ? Color4.White : Color4.Black, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public string TooltipText { get; }
|
||||
|
@ -25,9 +25,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
private Circle circle;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this control is currently being operated on by the user.
|
||||
/// Whether the user is currently holding the control with mouse.
|
||||
/// </summary>
|
||||
public bool InOperation { get; private set; }
|
||||
public bool IsHeld { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
protected OsuColour Colours { get; private set; }
|
||||
@ -67,44 +67,31 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
UpdateHoverState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether this control is currently handling mouse down input.
|
||||
/// </summary>
|
||||
protected bool HandlingMouse { get; private set; }
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
HandlingMouse = true;
|
||||
IsHeld = true;
|
||||
UpdateHoverState();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
HandlingMouse = false;
|
||||
IsHeld = false;
|
||||
UpdateHoverState();
|
||||
}
|
||||
|
||||
protected virtual void UpdateHoverState()
|
||||
{
|
||||
if (HandlingMouse)
|
||||
if (IsHeld)
|
||||
circle.FadeColour(Colours.GrayF, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
else
|
||||
circle.FadeColour(IsHovered ? Colours.Red : Colours.YellowDark, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
|
||||
this.ScaleTo(HandlingMouse || IsHovered ? 1.5f : 1, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
this.ScaleTo(IsHeld || IsHovered ? 1.5f : 1, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected void OnOperationStarted()
|
||||
{
|
||||
InOperation = true;
|
||||
OperationStarted?.Invoke();
|
||||
}
|
||||
protected void OnOperationStarted() => OperationStarted?.Invoke();
|
||||
|
||||
protected void OnOperationEnded()
|
||||
{
|
||||
InOperation = false;
|
||||
OperationEnded?.Invoke();
|
||||
}
|
||||
protected void OnOperationEnded() => OperationEnded?.Invoke();
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
internal event Action HoverGained;
|
||||
internal event Action HoverLost;
|
||||
internal event Action MouseDown;
|
||||
internal event Action MouseUp;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
@ -48,6 +50,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
HoverLost?.Invoke();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
bool result = base.OnMouseDown(e);
|
||||
MouseDown?.Invoke();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
MouseUp?.Invoke();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
handle.HoverGained += updateRotationHandlesVisibility;
|
||||
handle.HoverLost += updateRotationHandlesVisibility;
|
||||
handle.OperationStarted += updateRotationHandlesVisibility;
|
||||
handle.OperationEnded += updateRotationHandlesVisibility;
|
||||
handle.MouseDown += updateRotationHandlesVisibility;
|
||||
handle.MouseUp += updateRotationHandlesVisibility;
|
||||
allDragHandles.Add(handle);
|
||||
}
|
||||
|
||||
@ -72,13 +72,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
private void updateRotationHandlesVisibility()
|
||||
{
|
||||
if (activeHandle?.InOperation == true || activeHandle?.IsHovered == true)
|
||||
if (activeHandle?.IsHeld == true || activeHandle?.IsHovered == true)
|
||||
return;
|
||||
|
||||
displayedRotationHandle?.FadeOut(SelectionBoxControl.TRANSFORM_DURATION, Easing.OutQuint);
|
||||
displayedRotationHandle = null;
|
||||
|
||||
activeHandle = allDragHandles.SingleOrDefault(h => h.InOperation);
|
||||
activeHandle = allDragHandles.SingleOrDefault(h => h.IsHeld);
|
||||
activeHandle ??= allDragHandles.SingleOrDefault(h => h.IsHovered);
|
||||
|
||||
if (activeHandle != null)
|
||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
protected override void UpdateHoverState()
|
||||
{
|
||||
base.UpdateHoverState();
|
||||
icon.FadeColour(!HandlingMouse && IsHovered ? Color4.White : Color4.Black, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
icon.FadeColour(!IsHeld && IsHovered ? Color4.White : Color4.Black, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user