mirror of https://github.com/ppy/osu
Add ability to flick notifications to the right to store for later
This commit is contained in:
parent
802c5629c0
commit
88107108ee
|
@ -48,6 +48,43 @@ public void SetUp() => Schedule(() =>
|
|||
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestForwardWithFlingRight()
|
||||
{
|
||||
bool activated = false;
|
||||
SimpleNotification notification = null!;
|
||||
|
||||
AddStep("post", () =>
|
||||
{
|
||||
activated = false;
|
||||
notificationOverlay.Post(notification = new SimpleNotification
|
||||
{
|
||||
Text = @"Welcome to osu!. Enjoy your stay!",
|
||||
Activated = () => activated = true,
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("start drag", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(notification.ChildrenOfType<Notification>().Single());
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
InputManager.MoveMouseTo(notification.ChildrenOfType<Notification>().Single().ScreenSpaceDrawQuad.Centre + new Vector2(500, 0));
|
||||
});
|
||||
|
||||
AddStep("fling away", () =>
|
||||
{
|
||||
InputManager.ReleaseButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("was not closed", () => !notification.WasClosed);
|
||||
AddAssert("was not activated", () => !activated);
|
||||
AddAssert("is not read", () => !notification.Read);
|
||||
AddAssert("is not toast", () => !notification.IsInToastTray);
|
||||
|
||||
AddStep("reset mouse position", () => InputManager.MoveMouseTo(Vector2.Zero));
|
||||
AddAssert("unread count one", () => notificationOverlay.UnreadCount.Value == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDismissWithoutActivationFling()
|
||||
{
|
||||
|
|
|
@ -100,6 +100,8 @@ public void Post(Notification notification)
|
|||
{
|
||||
++runningDepth;
|
||||
|
||||
notification.ForwardToOverlay = () => forwardNotification(notification);
|
||||
|
||||
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
||||
|
||||
toastFlow.Insert(depth, notification);
|
||||
|
@ -130,6 +132,9 @@ void scheduleDismissal() => Scheduler.AddDelayed(() =>
|
|||
|
||||
private void forwardNotification(Notification notification)
|
||||
{
|
||||
if (!notification.IsInToastTray)
|
||||
return;
|
||||
|
||||
Debug.Assert(notification.Parent == toastFlow);
|
||||
|
||||
// Temporarily remove from flow so we can animate the position off to the right.
|
||||
|
|
|
@ -42,6 +42,8 @@ public abstract class Notification : Container
|
|||
/// </summary>
|
||||
public Func<bool>? Activated;
|
||||
|
||||
public Action? ForwardToOverlay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Should we show at the top of our section on display?
|
||||
/// </summary>
|
||||
|
@ -310,6 +312,8 @@ protected override void OnDragEnd(DragEndEvent e)
|
|||
{
|
||||
if (Rotation < -10 || velocity.X < -0.3f)
|
||||
notification.Close(true);
|
||||
else if (X > 30 || velocity.X > 0.3f)
|
||||
notification.ForwardToOverlay?.Invoke();
|
||||
else
|
||||
ResetPosition();
|
||||
|
||||
|
|
Loading…
Reference in New Issue