A game framework written with osu! in mind.
at master 88 lines 3.0 kB view raw
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.Containers; 5using osu.Framework.Graphics.Shapes; 6using osuTK; 7 8namespace osu.Framework.Graphics.UserInterface 9{ 10 public class BasicHSVColourPicker : HSVColourPicker 11 { 12 public BasicHSVColourPicker() 13 { 14 Background.Colour = FrameworkColour.GreenDark; 15 16 Content.Padding = new MarginPadding(20); 17 Content.Spacing = new Vector2(0, 10); 18 } 19 20 protected override HueSelector CreateHueSelector() => new BasicHueSelector(); 21 protected override SaturationValueSelector CreateSaturationValueSelector() => new BasicSaturationValueSelector(); 22 23 public class BasicHueSelector : HueSelector 24 { 25 protected override Drawable CreateSliderNub() => new BasicHueSelectorNub(); 26 } 27 28 public class BasicHueSelectorNub : CompositeDrawable 29 { 30 public BasicHueSelectorNub() 31 { 32 InternalChild = new Container 33 { 34 RelativeSizeAxes = Axes.Y, 35 Width = 8, 36 Height = 1.2f, 37 Anchor = Anchor.Centre, 38 Origin = Anchor.Centre, 39 Child = new Box 40 { 41 RelativeSizeAxes = Axes.Both, 42 Alpha = 0, 43 AlwaysPresent = true 44 }, 45 Masking = true, 46 BorderColour = FrameworkColour.YellowGreen, 47 BorderThickness = 4 48 }; 49 } 50 } 51 52 public class BasicSaturationValueSelector : SaturationValueSelector 53 { 54 protected override Marker CreateMarker() => new BasicMarker(); 55 56 private class BasicMarker : Marker 57 { 58 private readonly Box colourPreview; 59 60 public BasicMarker() 61 { 62 InternalChild = new Container 63 { 64 Size = new Vector2(15), 65 Anchor = Anchor.Centre, 66 Origin = Anchor.Centre, 67 Masking = true, 68 BorderColour = FrameworkColour.YellowGreen, 69 BorderThickness = 4, 70 Child = colourPreview = new Box 71 { 72 RelativeSizeAxes = Axes.Both 73 } 74 }; 75 } 76 77 protected override void LoadComplete() 78 { 79 base.LoadComplete(); 80 81 Current.BindValueChanged(_ => updatePreview(), true); 82 } 83 84 private void updatePreview() => colourPreview.Colour = Current.Value; 85 } 86 } 87 } 88}