1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 21:43:21 +08:00

Merge pull request #20030 from peppy/notification-design-update

Update notification overlay design
This commit is contained in:
Dan Balasescu 2022-08-31 16:06:59 +09:00 committed by GitHub
commit ccc08b816c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 140 additions and 101 deletions

View File

@ -76,7 +76,7 @@ namespace osu.Desktop.Security
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Icon = FontAwesome.Solid.ShieldAlt; Icon = FontAwesome.Solid.ShieldAlt;
IconBackground.Colour = colours.YellowDark; IconContent.Colour = colours.YellowDark;
} }
} }
} }

View File

@ -20,7 +20,7 @@ namespace osu.Game.Database
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
IconBackground.Colour = colours.RedDark; IconContent.Colour = colours.RedDark;
} }
} }
} }

View File

@ -174,7 +174,7 @@ namespace osu.Game.Online.Chat
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay) private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
{ {
IconBackground.Colour = colours.PurpleDark; IconContent.Colour = colours.PurpleDark;
Activated = delegate Activated = delegate
{ {

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
@ -35,6 +34,9 @@ namespace osu.Game.Overlays
[Resolved] [Resolved]
private AudioManager audio { get; set; } = null!; private AudioManager audio { get; set; } = null!;
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
private readonly IBindable<Visibility> firstRunSetupVisibility = new Bindable<Visibility>(); private readonly IBindable<Visibility> firstRunSetupVisibility = new Bindable<Visibility>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -49,7 +51,7 @@ namespace osu.Game.Overlays
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.05f), Colour = colourProvider.Background4,
}, },
new OsuScrollContainer new OsuScrollContainer
{ {

View File

@ -46,22 +46,30 @@ namespace osu.Game.Overlays.Notifications
public virtual string PopInSampleName => "UI/notification-pop-in"; public virtual string PopInSampleName => "UI/notification-pop-in";
protected NotificationLight Light; protected NotificationLight Light;
private readonly CloseButton closeButton;
protected Container IconContent; protected Container IconContent;
private readonly Container content; private readonly Container content;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
protected Container NotificationContent; protected Container MainContent;
public virtual bool Read { get; set; } public virtual bool Read { get; set; }
protected virtual IconUsage CloseButtonIcon => FontAwesome.Solid.Check;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
private Box background = null!;
protected Notification() protected Notification()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
AddRangeInternal(new Drawable[] InternalChildren = new Drawable[]
{ {
Light = new NotificationLight Light = new NotificationLight
{ {
@ -69,9 +77,9 @@ namespace osu.Game.Overlays.Notifications
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
}, },
NotificationContent = new Container MainContent = new Container
{ {
CornerRadius = 8, CornerRadius = 6,
Masking = true, Masking = true,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
@ -79,61 +87,78 @@ namespace osu.Game.Overlays.Notifications
AutoSizeEasing = Easing.OutQuint, AutoSizeEasing = Easing.OutQuint,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.X,
Colour = Color4.White, AutoSizeAxes = Axes.Y,
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize, minSize: 60)
},
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
new Dimension(GridSizeMode.AutoSize),
},
Content = new[]
{
new Drawable[]
{
IconContent = new Container
{
Width = 40,
RelativeSizeAxes = Axes.Y,
}, },
new Container new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Padding = new MarginPadding(5),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(10),
Children = new Drawable[] Children = new Drawable[]
{ {
IconContent = new Container
{
Size = new Vector2(40),
Masking = true,
CornerRadius = 5,
},
content = new Container content = new Container
{ {
Masking = true,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding
{
Left = 45,
Right = 30
}, },
} }
}
}, },
closeButton = new CloseButton new CloseButton(CloseButtonIcon)
{ {
Alpha = 0,
Action = Close, Action = Close,
Anchor = Anchor.CentreRight, Anchor = Anchor.TopRight,
Origin = Anchor.CentreRight, Origin = Anchor.TopRight,
Margin = new MarginPadding }
{ }
Right = 5 },
}, },
} }
} }
};
} }
[BackgroundDependencyLoader]
private void load()
{
MainContent.Add(background = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background3,
Depth = float.MaxValue
}); });
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
closeButton.FadeIn(75); background.FadeColour(colourProvider.Background2, 200, Easing.OutQuint);
return base.OnHover(e); return base.OnHover(e);
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
closeButton.FadeOut(75); background.FadeColour(colourProvider.Background3, 200, Easing.OutQuint);
base.OnHoverLost(e); base.OnHoverLost(e);
} }
@ -150,8 +175,9 @@ namespace osu.Game.Overlays.Notifications
base.LoadComplete(); base.LoadComplete();
this.FadeInFromZero(200); this.FadeInFromZero(200);
NotificationContent.MoveToX(DrawSize.X);
NotificationContent.MoveToX(0, 500, Easing.OutQuint); MainContent.MoveToX(DrawSize.X);
MainContent.MoveToX(0, 500, Easing.OutQuint);
} }
public bool WasClosed; public bool WasClosed;
@ -169,40 +195,55 @@ namespace osu.Game.Overlays.Notifications
private class CloseButton : OsuClickableContainer private class CloseButton : OsuClickableContainer
{ {
private Color4 hoverColour; private SpriteIcon icon = null!;
private Box background = null!;
public CloseButton() private readonly IconUsage iconUsage;
{
Colour = OsuColour.Gray(0.2f);
AutoSizeAxes = Axes.Both;
Children = new[] [Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public CloseButton(IconUsage iconUsage)
{ {
new SpriteIcon this.iconUsage = iconUsage;
}
[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Y;
Width = 28;
Children = new Drawable[]
{
background = new Box
{
Colour = OsuColour.Gray(0).Opacity(0.15f),
Alpha = 0,
RelativeSizeAxes = Axes.Both,
},
icon = new SpriteIcon
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Icon = FontAwesome.Solid.TimesCircle, Icon = iconUsage,
Size = new Vector2(20), Size = new Vector2(12),
Colour = colourProvider.Foreground1,
} }
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoverColour = colours.Yellow;
}
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
this.FadeColour(hoverColour, 200); background.FadeIn(200, Easing.OutQuint);
icon.FadeColour(colourProvider.Content1, 200, Easing.OutQuint);
return base.OnHover(e); return base.OnHover(e);
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
this.FadeColour(OsuColour.Gray(0.2f), 200); background.FadeOut(200, Easing.OutQuint);
icon.FadeColour(colourProvider.Foreground1, 200, Easing.OutQuint);
base.OnHoverLost(e); base.OnHoverLost(e);
} }
} }

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Notifications
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
IconBackground.Colour = ColourInfo.GradientVertical(colours.GreenDark, colours.GreenLight); IconContent.Colour = ColourInfo.GradientVertical(colours.GreenDark, colours.GreenLight);
} }
} }
} }

View File

@ -57,11 +57,14 @@ namespace osu.Game.Overlays.Notifications
set set
{ {
progress = value; progress = value;
Scheduler.AddOnce(updateProgress, progress); Scheduler.AddOnce(p => progressBar.Progress = p, progress);
} }
} }
private void updateProgress(float progress) => progressBar.Progress = progress; protected override IconUsage CloseButtonIcon => FontAwesome.Solid.Times;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
protected override void LoadComplete() protected override void LoadComplete()
{ {
@ -100,7 +103,7 @@ namespace osu.Game.Overlays.Notifications
Light.Pulsate = false; Light.Pulsate = false;
progressBar.Active = false; progressBar.Active = false;
iconBackground.FadeColour(ColourInfo.GradientVertical(colourQueued, colourQueued.Lighten(0.5f)), colour_fade_duration); IconContent.FadeColour(ColourInfo.GradientVertical(colourQueued, colourQueued.Lighten(0.5f)), colour_fade_duration);
loadingSpinner.Show(); loadingSpinner.Show();
break; break;
@ -109,14 +112,14 @@ namespace osu.Game.Overlays.Notifications
Light.Pulsate = true; Light.Pulsate = true;
progressBar.Active = true; progressBar.Active = true;
iconBackground.FadeColour(ColourInfo.GradientVertical(colourActive, colourActive.Lighten(0.5f)), colour_fade_duration); IconContent.FadeColour(ColourInfo.GradientVertical(colourActive, colourActive.Lighten(0.5f)), colour_fade_duration);
loadingSpinner.Show(); loadingSpinner.Show();
break; break;
case ProgressNotificationState.Cancelled: case ProgressNotificationState.Cancelled:
cancellationTokenSource.Cancel(); cancellationTokenSource.Cancel();
iconBackground.FadeColour(ColourInfo.GradientVertical(Color4.Gray, Color4.Gray.Lighten(0.5f)), colour_fade_duration); IconContent.FadeColour(ColourInfo.GradientVertical(Color4.Gray, Color4.Gray.Lighten(0.5f)), colour_fade_duration);
loadingSpinner.Hide(); loadingSpinner.Hide();
var icon = new SpriteIcon var icon = new SpriteIcon
@ -138,8 +141,7 @@ namespace osu.Game.Overlays.Notifications
case ProgressNotificationState.Completed: case ProgressNotificationState.Completed:
loadingSpinner.Hide(); loadingSpinner.Hide();
NotificationContent.MoveToY(-DrawSize.Y / 2, 200, Easing.OutQuint); Completed();
this.FadeOut(200).Finally(_ => Completed());
break; break;
} }
} }
@ -165,21 +167,19 @@ namespace osu.Game.Overlays.Notifications
private Color4 colourActive; private Color4 colourActive;
private Color4 colourCancelled; private Color4 colourCancelled;
private Box iconBackground = null!;
private LoadingSpinner loadingSpinner = null!; private LoadingSpinner loadingSpinner = null!;
private readonly TextFlowContainer textDrawable; private readonly TextFlowContainer textDrawable;
public ProgressNotification() public ProgressNotification()
{ {
Content.Add(textDrawable = new OsuTextFlowContainer Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium))
{ {
Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}); });
NotificationContent.Add(progressBar = new ProgressBar MainContent.Add(progressBar = new ProgressBar
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
@ -204,10 +204,10 @@ namespace osu.Game.Overlays.Notifications
IconContent.AddRange(new Drawable[] IconContent.AddRange(new Drawable[]
{ {
iconBackground = new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.White, Colour = colourProvider.Background5,
}, },
loadingSpinner = new LoadingSpinner loadingSpinner = new LoadingSpinner
{ {

View File

@ -3,7 +3,6 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
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.Framework.Graphics.Sprites;
@ -24,6 +23,7 @@ namespace osu.Game.Overlays.Notifications
set set
{ {
text = value; text = value;
if (textDrawable != null)
textDrawable.Text = text; textDrawable.Text = text;
} }
} }
@ -36,48 +36,44 @@ namespace osu.Game.Overlays.Notifications
set set
{ {
icon = value; icon = value;
if (iconDrawable != null)
iconDrawable.Icon = icon; iconDrawable.Icon = icon;
} }
} }
private readonly TextFlowContainer textDrawable; private TextFlowContainer? textDrawable;
private readonly SpriteIcon iconDrawable;
protected Box IconBackground; private SpriteIcon? iconDrawable;
public SimpleNotification() [BackgroundDependencyLoader]
private void load(OsuColour colours, OverlayColourProvider colourProvider)
{ {
Light.Colour = colours.Green;
IconContent.AddRange(new Drawable[] IconContent.AddRange(new Drawable[]
{ {
IconBackground = new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f)) Colour = colourProvider.Background5,
}, },
iconDrawable = new SpriteIcon iconDrawable = new SpriteIcon
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Icon = icon, Icon = icon,
Size = new Vector2(20), Size = new Vector2(16),
} }
}); });
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14)) Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium))
{ {
Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Text = text Text = text
}); });
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Light.Colour = colours.Green;
}
public override bool Read public override bool Read
{ {
get => base.Read; get => base.Read;

View File

@ -530,7 +530,7 @@ namespace osu.Game.Screens.Play
private void load(OsuColour colours, AudioManager audioManager, INotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay) private void load(OsuColour colours, AudioManager audioManager, INotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
{ {
Icon = FontAwesome.Solid.VolumeMute; Icon = FontAwesome.Solid.VolumeMute;
IconBackground.Colour = colours.RedDark; IconContent.Colour = colours.RedDark;
Activated = delegate Activated = delegate
{ {
@ -584,7 +584,7 @@ namespace osu.Game.Screens.Play
private void load(OsuColour colours, INotificationOverlay notificationOverlay) private void load(OsuColour colours, INotificationOverlay notificationOverlay)
{ {
Icon = FontAwesome.Solid.BatteryQuarter; Icon = FontAwesome.Solid.BatteryQuarter;
IconBackground.Colour = colours.RedDark; IconContent.Colour = colours.RedDark;
Activated = delegate Activated = delegate
{ {

View File

@ -99,7 +99,7 @@ namespace osu.Game.Updater
private void load(OsuColour colours, ChangelogOverlay changelog, INotificationOverlay notificationOverlay) private void load(OsuColour colours, ChangelogOverlay changelog, INotificationOverlay notificationOverlay)
{ {
Icon = FontAwesome.Solid.CheckSquare; Icon = FontAwesome.Solid.CheckSquare;
IconBackground.Colour = colours.BlueDark; IconContent.Colour = colours.BlueDark;
Activated = delegate Activated = delegate
{ {