Skip to content

Commit f02756c

Browse files
authored
Adjust colour swatch to be more friendly to use osu! side (#6782)
1 parent 21e4095 commit f02756c

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

osu.Framework/Graphics/UserInterface/ColourPicker.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
using System.Collections.Generic;
5+
using osu.Framework.Allocation;
56
using osu.Framework.Bindables;
67
using osu.Framework.Graphics.Containers;
78

@@ -22,16 +23,20 @@ public Bindable<Colour4> Current
2223
set => current.Current = value;
2324
}
2425

25-
private readonly HSVColourPicker hsvColourPicker;
26-
private readonly SwatchColourPicker? swatchColourPicker;
27-
private readonly HexColourPicker hexColourPicker;
26+
private HSVColourPicker hsvColourPicker = null!;
27+
private HexColourPicker hexColourPicker = null!;
28+
private SwatchColourPicker? swatchColourPicker;
2829

2930
protected ColourPicker()
3031
{
3132
Current.Value = Colour4.White;
3233
AutoSizeAxes = Axes.Y;
3334
Width = 300;
35+
}
3436

37+
[BackgroundDependencyLoader]
38+
private void load()
39+
{
3540
hsvColourPicker = CreateHSVColourPicker().With(d =>
3641
{
3742
d.RelativeSizeAxes = Axes.X;
@@ -72,7 +77,7 @@ protected ColourPicker()
7277
protected abstract HSVColourPicker CreateHSVColourPicker();
7378

7479
/// <summary>
75-
/// Creates an optional control that shows clickable colour presets.
80+
/// Creates the optional control that shows clickable colour presets.
7681
/// </summary>
7782
protected virtual SwatchColourPicker? CreateSwatchColourPicker() => null;
7883

osu.Framework/Graphics/UserInterface/SwatchColourPicker.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public Bindable<Colour4> Current
2929
/// <summary>
3030
/// The preset colours to display as swatches.
3131
/// </summary>
32-
public BindableList<Colour4> Colours { get; }
32+
public BindableList<Colour4> Colours { get; } = new BindableList<Colour4>();
3333

3434
/// <summary>
3535
/// The background of the control.
@@ -41,10 +41,8 @@ public Bindable<Colour4> Current
4141
/// </summary>
4242
protected FillFlowContainer Content { get; }
4343

44-
protected SwatchColourPicker(BindableList<Colour4>? colours = null)
44+
protected SwatchColourPicker()
4545
{
46-
Colours = colours ?? new BindableList<Colour4>();
47-
4846
RelativeSizeAxes = Axes.X;
4947
AutoSizeAxes = Axes.Y;
5048

0 commit comments

Comments
 (0)