Ejemplo n.º 1
0
        partial void Callback_OnMaxClicked()
        {
            ColorDistribution distribution = Value;

            if (DistributionType == PropertyDistributionType.RandomRange)
            {
                ColorPicker.Show(distribution.GetMaxConstant(), (success, value) =>
                {
                    if (!success)
                    {
                        return;
                    }

                    Value = new ColorDistribution(distribution.GetMinConstant(), value);
                    OnChanged?.Invoke();
                });
            }
            else if (DistributionType == PropertyDistributionType.RandomCurveRange)
            {
                GradientPicker.Show(distribution.GetMaxGradient(), (success, colorGradient) =>
                {
                    if (!success)
                    {
                        return;
                    }

                    Value = new ColorDistribution(distribution.GetMinGradient(), colorGradient);
                    OnChanged?.Invoke();
                });
            }
        }
        partial void OnMinClicked()
        {
            ColorDistribution distribution = Value;

            if (DistributionType == PropertyDistributionType.Constant ||
                DistributionType == PropertyDistributionType.RandomRange)
            {
                ColorPicker.Show(distribution.GetMinConstant(), (success, value) =>
                {
                    if (!success)
                    {
                        return;
                    }

                    if (DistributionType == PropertyDistributionType.Constant)
                    {
                        Value = new ColorDistribution(value);
                    }
                    else
                    {
                        Value = new ColorDistribution(value, distribution.GetMaxConstant());
                    }

                    OnChanged?.Invoke();
                });
            }
            else if (DistributionType == PropertyDistributionType.Curve ||
                     DistributionType == PropertyDistributionType.RandomCurveRange)
            {
                GradientPicker.Show(distribution.GetMinGradient(), (success, colorGradient) =>
                {
                    if (!success)
                    {
                        return;
                    }

                    if (DistributionType == PropertyDistributionType.Curve)
                    {
                        Value = new ColorDistribution(colorGradient);
                    }
                    else
                    {
                        Value = new ColorDistribution(colorGradient, distribution.GetMaxGradient());
                    }

                    OnChanged?.Invoke();
                });
            }
        }
            /// <summary>
            /// Handles input. Should be called by the owning window whenever a pointer is double-clicked.
            /// </summary>
            /// <param name="panelPos">Position of the pointer relative to the panel parent to this element.</param>
            /// <param name="button">Pointer button involved in the event.</param>
            internal void OnPointerDoubleClicked(Vector2I panelPos, PointerButton button)
            {
                Rect2I canvasBounds = canvas.Bounds;

                if (!canvasBounds.Contains(panelPos))
                {
                    return;
                }

                Vector2I canvasPos = panelPos - new Vector2I(canvasBounds.x, canvasBounds.y);

                int keyIdx;

                if (FindKey(canvasPos, out keyIdx))
                {
                    ColorPicker.Show(keys[keyIdx].color, false,
                                     (b, color) =>
                    {
                        if (b)
                        {
                            ColorGradientKey key = keys[keyIdx];
                            key.color            = color;
                            keys[keyIdx]         = key;

                            OnGradientModified?.Invoke(new ColorGradient(keys.ToArray()));
                            Rebuild();
                        }
                    });
                }
                else
                {
                    float time = PixelToTime(canvasPos.x);
                    if (time >= 0.0f && time <= 1.0f)
                    {
                        keys.Add(new ColorGradientKey(Color.Black, time));
                        keys.Sort((lhs, rhs) => lhs.time.CompareTo(rhs.time));

                        OnGradientModified?.Invoke(new ColorGradient(keys.ToArray()));
                    }

                    Rebuild();
                }
            }
 partial void Callback_OnClicked()
 {
     ColorPicker.Show(Value, AllowHDR, ColorPickerClosed);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Triggered by the runtime when the user clicks on the color field.
 /// </summary>
 private void Internal_DoOnClicked()
 {
     ColorPicker.Show(Value, ColorPickerClosed);
 }