GUIColorGradientField.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using bs;
  3. namespace bs.Editor
  4. {
  5. partial class GUIColorGradientField
  6. {
  7. /// <summary>
  8. /// Triggered when the gradient in the field changes.
  9. /// </summary>
  10. public event Action<ColorGradient> OnChanged;
  11. /// <summary>
  12. /// Callback triggered when the user clicks on the GUI element.
  13. /// </summary>
  14. partial void Callback_OnClicked()
  15. {
  16. GradientPicker.Show(Value, (success, colorGradient) =>
  17. {
  18. if (!success)
  19. return;
  20. Value = colorGradient;
  21. OnChanged?.Invoke(colorGradient);
  22. });
  23. }
  24. }
  25. partial class GUIColorGradientHDRField
  26. {
  27. /// <summary>
  28. /// Triggered when the gradient in the field changes.
  29. /// </summary>
  30. public event Action<ColorGradientHDR> OnChanged;
  31. /// <summary>
  32. /// Callback triggered when the user clicks on the GUI element.
  33. /// </summary>
  34. partial void Callback_OnClicked()
  35. {
  36. // Note: Should allow HDR color gradient
  37. ColorGradient gradient = new ColorGradient(Value.GetKeys());
  38. GradientPicker.Show(gradient, (success, colorGradient) =>
  39. {
  40. if (!success)
  41. return;
  42. Value = new ColorGradientHDR(colorGradient.GetKeys());
  43. OnChanged?.Invoke(Value);
  44. });
  45. }
  46. }
  47. }