From 5dfed1dba5afa0c740cc6f8884f08a49d78bf5ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:52:29 +0900 Subject: [PATCH 1/4] Add word-wrap functionality of ProgressNotification Fixes a potential threading issue when updating Text. --- .../Notifications/ProgressNotification.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 98aac3a02d..aa65f09ece 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -6,9 +6,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; @@ -18,10 +16,9 @@ namespace osu.Game.Overlays.Notifications { public string Text { - get { return textDrawable.Text; } set { - textDrawable.Text = value; + Schedule(() => textDrawable.Text = value); } } @@ -90,7 +87,7 @@ namespace osu.Game.Overlays.Notifications protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification { Activated = CompletionClickAction, - Text = $"Task \"{Text}\" has completed!" + Text = "Task has completed!" }; protected virtual void Completed() @@ -106,7 +103,7 @@ namespace osu.Game.Overlays.Notifications private Color4 colourActive; private Color4 colourCancelled; - private readonly SpriteText textDrawable; + private readonly TextFlowContainer textDrawable; public ProgressNotification() { @@ -115,9 +112,11 @@ namespace osu.Game.Overlays.Notifications RelativeSizeAxes = Axes.Both, }); - Content.Add(textDrawable = new OsuSpriteText + Content.Add(textDrawable = new TextFlowContainer(t => + { + t.TextSize = 16; + }) { - TextSize = 16, Colour = OsuColour.Gray(128), AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, From b3e3c4a2260f9fd9eae36848701c0d7f728fe0c9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:53:37 +0900 Subject: [PATCH 2/4] Fix setting a ProgressNotification's progress too early crashing --- .../Notifications/ProgressNotification.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index aa65f09ece..43a0a5f7a3 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -166,7 +166,7 @@ namespace osu.Game.Overlays.Notifications private class ProgressBar : Container { - private Box box; + private readonly Box box; private Color4 colourActive; private Color4 colourInactive; @@ -196,15 +196,8 @@ namespace osu.Game.Overlays.Notifications } } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) + public ProgressBar() { - colourActive = colours.Blue; - Colour = colourInactive = OsuColour.Gray(0.5f); - - Height = 5; - Children = new[] { box = new Box @@ -214,6 +207,15 @@ namespace osu.Game.Overlays.Notifications } }; } + + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + colourActive = colours.Blue; + Colour = colourInactive = OsuColour.Gray(0.5f); + Height = 5; + } } } From 74044baefff03e64731707e5007313871f4260ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:53:49 +0900 Subject: [PATCH 3/4] Don't cancel a ProgressNotification when clicking by default --- osu.Game/Overlays/Notifications/ProgressNotification.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 43a0a5f7a3..f42b4b6cb3 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -130,6 +130,9 @@ namespace osu.Game.Overlays.Notifications }); State = ProgressNotificationState.Queued; + + // don't close on click by default. + Activated = () => false; } [BackgroundDependencyLoader] From 4bb8f40b49bd3606ea9ec6138c3adc5d07603009 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:54:09 +0900 Subject: [PATCH 4/4] AutoSize notifications (and add animation) --- osu.Game/Overlays/Notifications/Notification.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index a590507f41..49b2823531 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -63,6 +63,8 @@ namespace osu.Game.Overlays.Notifications Masking = true, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + AutoSizeDuration = 400, + AutoSizeEasing = Easing.OutQuint, Children = new Drawable[] { new Box @@ -74,7 +76,7 @@ namespace osu.Game.Overlays.Notifications { RelativeSizeAxes = Axes.X, Padding = new MarginPadding(5), - Height = 60, + AutoSizeAxes = Axes.Y, Children = new Drawable[] { IconContent = new Container