public sealed class ColorPickerChoosing a colour: a field, two strips, a number, a palette and a dropper.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
⚠ The model is the source of truth, not the RGB. Grey has no hue and black has no saturation, so a picker that recomputed its axes from the colour would lose which hue the user was on the moment they dragged the saturation to nothing — and the field would snap back to red when they dragged it out again. Every picker that has had that bug has had it for that reason. What is stored is Hue, the field's position and the alpha; Value is derived, and assigning to it is the only thing that reconstructs them.
HDR is a multiplier beside a colour, not a colour with big numbers in it. An artist picks a hue and then says how bright the light is, and those are two decisions: keeping them apart means changing the intensity does not move the picker, and the chromaticity survives a round trip through a value of forty. Intensity is that number and HdrValue is the product.
⚠ The eyedropper cannot read the screen and does not pretend to. Sampling a pixel is a platform capability — a screen capture permission on macOS, a compositor protocol on Wayland — and this assembly has no platform. EyedropperRequested is what an app head answers, and Pick is how it answers.
Fields and properties (25)
public const float MaximumChromaThe chroma the perceptual field runs out to.
protected override string TagNameThe element name this type answers to when a caller does not choose one.
protected override bool AcceptsFocusWhether the focus can rest on this kind of control at all.
public ColorField FieldThe two-dimensional field.
public ColorStrip HueStripThe hue band.
public ColorStrip AlphaStripThe alpha band.
public ColorSwatch PreviewThe current colour, shown large.
public TextBox HexFieldThe hexadecimal field.
public IconButton EyedropperThe dropper.
public Slider IntensitySliderThe brightness multiplier, shown only when AllowHdr is set.
public UiElement PaletteWhere the saved colours go.
public IReadOnlyList<Color4> SwatchesThe saved colours.
public Color4 ValueThe chosen colour, with its alpha and without the intensity.
public Color4 HdrValueThe colour times the intensity, which is what a light or an emissive material wants.
public ColorModel Modelpublic bool AllowAlphapublic bool AllowHdrpublic float Intensitypublic float HueThe hue, in degrees, whichever model is in use.
public bool IsPickingWhether the dropper is waiting for a colour.
public string HexTextThe colour as #rrggbb, or #rrggbbaa when it is not opaque.
public static readonly UiPropertyKey ModelPropertyIdentity for Model.
public static readonly UiPropertyKey AllowAlphaPropertyIdentity for AllowAlpha.
public static readonly UiPropertyKey AllowHdrPropertyIdentity for AllowHdr.
public static readonly UiPropertyKey IntensityPropertyIdentity for Intensity.
Events (2)
public Action<ColorPicker, Color4>? ValueChangedRaised whenever the colour changes, however it changed.
public Action<ColorPicker>? EyedropperRequestedRaised when the dropper is pressed. Answer it with Pick.
Methods (9)
protected override void OnCreated()Builds whatever this element is made of, once, as it joins a document.
public void SetPalette(params ReadOnlySpan<Color4> colors)Replaces the saved colours.
public bool AddToPalette()Saves the current colour.
public void RequestEyedropper()Asks the application for a colour from the screen.
public void Pick(Color4 colour)Answers an eyedropper request, or just sets the colour.
public void ClearModel()Unsets Model, so it takes its default or its ancestor's value again.
public void ClearAllowAlpha()Unsets AllowAlpha, so it takes its default or its ancestor's value again.
public void ClearAllowHdr()Unsets AllowHdr, so it takes its default or its ancestor's value again.
public void ClearIntensity()Unsets Intensity, so it takes its default or its ancestor's value again.
Used by (7)
- ColorFieldVixen.Ui.Controls.Advanced
- ColorInputVixen.Ui.Controls.Advanced
- ColorInputTestsVixen.Ui.Controls.Advanced.Tests
- ColorPickerTestsVixen.Ui.Controls.Advanced.Tests
- ColorStripVixen.Ui.Controls.Advanced
- GradientEditorVixen.Ui.Controls.Advanced
- GradientEditorTestsVixen.Ui.Controls.Advanced.Tests