mirror of
https://github.com/ppy/osu.git
synced 2024-12-21 07:43:01 +08:00
60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
#nullable disable
|
|
|
|
using JetBrains.Annotations;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Framework.Graphics.UserInterface;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osu.Game.Overlays;
|
|
|
|
namespace osu.Game.Graphics.UserInterfaceV2
|
|
{
|
|
public class OsuHexColourPicker : HexColourPicker
|
|
{
|
|
public OsuHexColourPicker()
|
|
{
|
|
Padding = new MarginPadding(20);
|
|
Spacing = 20;
|
|
}
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
private void load([CanBeNull] OverlayColourProvider overlayColourProvider, OsuColour osuColour)
|
|
{
|
|
Background.Colour = overlayColourProvider?.Dark6 ?? osuColour.GreySeaFoamDarker;
|
|
}
|
|
|
|
protected override TextBox CreateHexCodeTextBox() => new OsuTextBox();
|
|
protected override ColourPreview CreateColourPreview() => new OsuColourPreview();
|
|
|
|
private class OsuColourPreview : ColourPreview
|
|
{
|
|
private readonly Box preview;
|
|
|
|
public OsuColourPreview()
|
|
{
|
|
InternalChild = new CircularContainer
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Masking = true,
|
|
Child = preview = new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both
|
|
}
|
|
};
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
Current.BindValueChanged(colour => preview.Colour = colour.NewValue, true);
|
|
}
|
|
}
|
|
}
|
|
}
|