diff --git a/osu.Game/Graphics/UserInterfaceV2/ColourDisplay.cs b/osu.Game/Graphics/UserInterfaceV2/ColourDisplay.cs
index dfdc76687f..25f89fdcaa 100644
--- a/osu.Game/Graphics/UserInterfaceV2/ColourDisplay.cs
+++ b/osu.Game/Graphics/UserInterfaceV2/ColourDisplay.cs
@@ -3,11 +3,14 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
+using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
+using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osuTK;
@@ -16,7 +19,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
///
/// A component which displays a colour along with related description text.
///
- public class ColourDisplay : CompositeDrawable, IHasCurrentValue
+ public class ColourDisplay : CompositeDrawable, IHasCurrentValue, IHasPopover
{
private readonly BindableWithCurrent current = new BindableWithCurrent();
@@ -60,10 +63,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{
- new CircularContainer
+ new OsuClickableContainer
{
RelativeSizeAxes = Axes.X,
Height = 100,
+ CornerRadius = 50,
Masking = true,
Children = new Drawable[]
{
@@ -77,7 +81,8 @@ namespace osu.Game.Graphics.UserInterfaceV2
Origin = Anchor.Centre,
Font = OsuFont.Default.With(size: 12)
}
- }
+ },
+ Action = this.ShowPopover
},
colourName = new OsuSpriteText
{
@@ -101,5 +106,13 @@ namespace osu.Game.Graphics.UserInterfaceV2
colourHexCode.Text = current.Value.ToHex();
colourHexCode.Colour = OsuColour.ForegroundTextColourFor(current.Value);
}
+
+ public Popover GetPopover() => new OsuPopover(false)
+ {
+ Child = new OsuColourPicker
+ {
+ Current = { BindTarget = Current }
+ }
+ };
}
}
diff --git a/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs b/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs
index a32257ef79..d8edd00c16 100644
--- a/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs
+++ b/osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Collections.Specialized;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@@ -72,14 +73,17 @@ namespace osu.Game.Graphics.UserInterfaceV2
{
base.LoadComplete();
- Colours.BindCollectionChanged((_, __) => updatePalette(), true);
+ Colours.BindCollectionChanged((_, args) => updatePalette(args), true);
FinishTransforms(true);
}
private const int fade_duration = 200;
- private void updatePalette()
+ private void updatePalette(NotifyCollectionChangedEventArgs args)
{
+ if (args.Action == NotifyCollectionChangedAction.Replace)
+ return;
+
palette.Clear();
if (Colours.Any())
@@ -93,12 +97,18 @@ namespace osu.Game.Graphics.UserInterfaceV2
placeholder.FadeIn(fade_duration, Easing.OutQuint);
}
- foreach (var item in Colours)
+ for (int i = 0; i < Colours.Count; ++i)
{
- palette.Add(new ColourDisplay
+ // copy to avoid accesses to modified closure.
+ int colourIndex = i;
+ ColourDisplay display;
+
+ palette.Add(display = new ColourDisplay
{
- Current = { Value = item }
+ Current = { Value = Colours[colourIndex] }
});
+
+ display.Current.BindValueChanged(colour => Colours[colourIndex] = colour.NewValue);
}
reindexItems();