diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledColourPalette.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledColourPalette.cs index 325e71f76a..826da17ca8 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledColourPalette.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledColourPalette.cs @@ -20,13 +20,14 @@ namespace osu.Game.Tests.Visual.UserInterface createColourPalette(hasDescription); AddRepeatStep("add random colour", () => component.Colours.Add(randomColour()), 4); + + AddStep("set custom prefix", () => component.ColourNamePrefix = "Combo"); + AddRepeatStep("remove random colour", () => { if (component.Colours.Count > 0) component.Colours.RemoveAt(RNG.Next(component.Colours.Count)); - }, 5); - - AddStep("set custom prefix", () => component.ColourNamePrefix = "Combo"); + }, 8); } private void createColourPalette(bool hasDescription = false) diff --git a/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs b/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs index 38ac51b955..3ca5c2d8d1 100644 --- a/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs +++ b/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs @@ -1,10 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osuTK; using osuTK.Graphics; @@ -32,6 +34,7 @@ namespace osu.Game.Graphics.UserInterfaceV2 } private FillFlowContainer palette; + private Container placeholder; [BackgroundDependencyLoader] private void load() @@ -39,12 +42,27 @@ namespace osu.Game.Graphics.UserInterfaceV2 RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - InternalChild = palette = new FillFlowContainer + InternalChildren = new Drawable[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(10), - Direction = FillDirection.Full + palette = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(10), + Direction = FillDirection.Full + }, + placeholder = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Child = new OsuSpriteText + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Text = "(none)", + Font = OsuFont.Default.With(weight: FontWeight.Bold) + } + } }; } @@ -53,12 +71,26 @@ namespace osu.Game.Graphics.UserInterfaceV2 base.LoadComplete(); Colours.BindCollectionChanged((_, __) => updatePalette(), true); + FinishTransforms(true); } + private const int fade_duration = 200; + private void updatePalette() { palette.Clear(); + if (Colours.Any()) + { + palette.FadeIn(fade_duration, Easing.OutQuint); + placeholder.FadeOut(fade_duration, Easing.OutQuint); + } + else + { + palette.FadeOut(fade_duration, Easing.OutQuint); + placeholder.FadeIn(fade_duration, Easing.OutQuint); + } + foreach (var item in Colours) { palette.Add(new ColourDisplay