A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using osu.Framework.Graphics.Shapes;
5
6namespace osu.Framework.Graphics.UserInterface
7{
8 public class BasicHexColourPicker : HexColourPicker
9 {
10 public BasicHexColourPicker()
11 {
12 Background.Colour = FrameworkColour.GreenDarker;
13
14 Padding = new MarginPadding(20);
15 Spacing = 10;
16 }
17
18 protected override TextBox CreateHexCodeTextBox() => new BasicTextBox
19 {
20 Height = 40
21 };
22
23 protected override ColourPreview CreateColourPreview() => new BasicColourPreview();
24
25 private class BasicColourPreview : ColourPreview
26 {
27 private readonly Box previewBox;
28
29 public BasicColourPreview()
30 {
31 InternalChild = previewBox = new Box
32 {
33 RelativeSizeAxes = Axes.Both
34 };
35 }
36
37 protected override void LoadComplete()
38 {
39 base.LoadComplete();
40
41 Current.BindValueChanged(_ => updatePreview(), true);
42 }
43
44 private void updatePreview()
45 {
46 previewBox.Colour = Current.Value;
47 }
48 }
49 }
50}