// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; namespace osu.Framework.Graphics.UserInterface { /// /// A group of controls to be used for selecting a colour. /// Allows both for mouse-interactive input (via ) and textual input (via ). /// public abstract class ColourPicker : CompositeDrawable, IHasCurrentValue { private readonly BindableWithCurrent current = new BindableWithCurrent(); public Bindable Current { get => current.Current; set => current.Current = value; } private readonly HSVColourPicker hsvColourPicker; private readonly HexColourPicker hexColourPicker; protected ColourPicker() { Current.Value = Colour4.White; AutoSizeAxes = Axes.Y; Width = 300; InternalChildren = new Drawable[] { new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { hsvColourPicker = CreateHSVColourPicker().With(d => { d.RelativeSizeAxes = Axes.X; d.Width = 1; }), hexColourPicker = CreateHexColourPicker().With(d => { d.RelativeSizeAxes = Axes.X; d.Width = 1; }) } } }; } /// /// Creates the control that allows for interactively specifying the target colour, using the hue-saturation-value colour model. /// protected abstract HSVColourPicker CreateHSVColourPicker(); /// /// Creates the control that allows for specifying the target colour using a hex code. /// protected abstract HexColourPicker CreateHexColourPicker(); public override bool IsPresent => base.IsPresent || hsvColourPicker.IsPresent; protected override void LoadComplete() { base.LoadComplete(); hsvColourPicker.Current = Current; hexColourPicker.Current = Current; } } }