mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Ensure drag position is reset when transferred to tray
This commit is contained in:
@ -159,7 +159,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
if (State.Value == Visibility.Hidden)
|
if (State.Value == Visibility.Hidden)
|
||||||
{
|
{
|
||||||
notification.IsInTray = true;
|
notification.IsInToastTray = true;
|
||||||
toastTray.Post(notification);
|
toastTray.Post(notification);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -170,7 +170,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private void addPermanently(Notification notification)
|
private void addPermanently(Notification notification)
|
||||||
{
|
{
|
||||||
notification.IsInTray = false;
|
notification.IsInToastTray = false;
|
||||||
|
|
||||||
var ourType = notification.GetType();
|
var ourType = notification.GetType();
|
||||||
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
||||||
|
@ -68,10 +68,21 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
private bool isInToastTray;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this notification is in the <see cref="NotificationOverlayToastTray"/>.
|
/// Whether this notification is in the <see cref="NotificationOverlayToastTray"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsInTray { get; set; }
|
public bool IsInToastTray
|
||||||
|
{
|
||||||
|
private get => isInToastTray;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isInToastTray = value;
|
||||||
|
if (!isInToastTray)
|
||||||
|
dragContainer.ResetPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly Box initialFlash;
|
private readonly Box initialFlash;
|
||||||
|
|
||||||
@ -267,10 +278,13 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnDragStart(DragStartEvent e) => notification.IsInTray;
|
protected override bool OnDragStart(DragStartEvent e) => notification.IsInToastTray;
|
||||||
|
|
||||||
protected override void OnDrag(DragEvent e)
|
protected override void OnDrag(DragEvent e)
|
||||||
{
|
{
|
||||||
|
if (!notification.IsInToastTray)
|
||||||
|
return;
|
||||||
|
|
||||||
Vector2 change = e.MousePosition - e.MouseDownPosition;
|
Vector2 change = e.MousePosition - e.MouseDownPosition;
|
||||||
|
|
||||||
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
||||||
@ -286,14 +300,9 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
protected override void OnDragEnd(DragEndEvent e)
|
protected override void OnDragEnd(DragEndEvent e)
|
||||||
{
|
{
|
||||||
if (Rotation < -10 || velocity.X < -0.3f)
|
if (Rotation < -10 || velocity.X < -0.3f)
|
||||||
{
|
|
||||||
FlingLeft();
|
FlingLeft();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
ResetPosition();
|
||||||
this.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
|
|
||||||
this.RotateTo(0, 800, Easing.OutElastic);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnDragEnd(e);
|
base.OnDragEnd(e);
|
||||||
}
|
}
|
||||||
@ -331,7 +340,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
public bool FlingLeft()
|
public bool FlingLeft()
|
||||||
{
|
{
|
||||||
if (!notification.IsInTray)
|
if (!notification.IsInToastTray)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (flinging)
|
if (flinging)
|
||||||
@ -345,6 +354,12 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
notification.Close();
|
notification.Close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetPosition()
|
||||||
|
{
|
||||||
|
this.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
|
||||||
|
this.RotateTo(0, 800, Easing.OutElastic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class CloseButton : OsuClickableContainer
|
internal class CloseButton : OsuClickableContainer
|
||||||
|
Reference in New Issue
Block a user