MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ColorSelector

Class ColorSelector

Source/Editor/GUI/Dialogs/ColorSelector.cs:13–278  ·  view source on GitHub ↗

Color selecting control.

Source from the content-addressed store, hash-verified

11 /// </summary>
12 /// <seealso cref="FlaxEngine.GUI.ContainerControl" />
13 public class ColorSelector : ContainerControl
14 {
15 private const String GrayedOutParamName = "GrayedOut";
16
17 /// <summary>
18 /// Offset value applied to mouse cursor position when the user lets go of wheel or sliders.
19 /// </summary>
20 protected const float MouseCursorOffset = 6.0f;
21
22 /// <summary>
23 /// The color.
24 /// </summary>
25 protected Color _color;
26
27 /// <summary>
28 /// The wheel rectangle.
29 /// </summary>
30 protected Rectangle _wheelRect;
31
32 private readonly MaterialBase _hsWheelMaterial;
33 private bool _isMouseDownWheel;
34
35 private Rectangle wheelDragRect
36 {
37 get
38 {
39 var hsv = _color.ToHSV();
40 float hAngle = hsv.X * Mathf.DegreesToRadians;
41 float hRadius = hsv.Y * _wheelRect.Width * 0.5f;
42 var hsPos = new Float2(hRadius * Mathf.Cos(hAngle), -hRadius * Mathf.Sin(hAngle));
43 float wheelBoxSize = IsSliding ? 9.0f : 5.0f;
44 return new Rectangle(hsPos - (wheelBoxSize * 0.5f) + _wheelRect.Center, new Float2(wheelBoxSize));
45 }
46 }
47
48 /// <summary>
49 /// Occurs when selected color gets changed.
50 /// </summary>
51 public event Action<Color> ColorChanged;
52
53 /// <summary>
54 /// Gets or sets the color.
55 /// </summary>
56 public Color Color
57 {
58 get => _color;
59 set
60 {
61 if (_color != value)
62 {
63 _color = value;
64 ColorChanged?.Invoke(_color);
65 }
66 }
67 }
68
69 /// <summary>
70 /// Gets a value indicating whether user is using a wheel.

Callers

nothing calls this directly

Calls 3

ToHSVMethod · 0.45
CosMethod · 0.45
SinMethod · 0.45

Tested by

no test coverage detected