Add word-wrap functionality of ProgressNotification

Fixes a potential threading issue when updating Text.
This commit is contained in:
Dean Herbert 2017-07-28 16:52:29 +09:00
parent bd79a69e2e
commit 5dfed1dba5

View File

@ -6,9 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -18,10 +16,9 @@ namespace osu.Game.Overlays.Notifications
{ {
public string Text public string Text
{ {
get { return textDrawable.Text; }
set set
{ {
textDrawable.Text = value; Schedule(() => textDrawable.Text = value);
} }
} }
@ -90,7 +87,7 @@ namespace osu.Game.Overlays.Notifications
protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification
{ {
Activated = CompletionClickAction, Activated = CompletionClickAction,
Text = $"Task \"{Text}\" has completed!" Text = "Task has completed!"
}; };
protected virtual void Completed() protected virtual void Completed()
@ -106,7 +103,7 @@ namespace osu.Game.Overlays.Notifications
private Color4 colourActive; private Color4 colourActive;
private Color4 colourCancelled; private Color4 colourCancelled;
private readonly SpriteText textDrawable; private readonly TextFlowContainer textDrawable;
public ProgressNotification() public ProgressNotification()
{ {
@ -115,9 +112,11 @@ namespace osu.Game.Overlays.Notifications
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}); });
Content.Add(textDrawable = new OsuSpriteText Content.Add(textDrawable = new TextFlowContainer(t =>
{
t.TextSize = 16;
})
{ {
TextSize = 16,
Colour = OsuColour.Gray(128), Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,