GUIColorField.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. using bs;
  6. namespace bs.Editor
  7. {
  8. public partial class GUIColorField
  9. {
  10. /// <summary>
  11. /// Triggered when the color in the field changes.
  12. /// </summary>
  13. public event Action<Color> OnChanged;
  14. /// <summary>
  15. /// Triggered when the user closes the color picker window.
  16. /// </summary>
  17. /// <param name="selected">True if the user confirms color selection, false if he cancels.</param>
  18. /// <param name="color">Newly selected color.</param>
  19. private void ColorPickerClosed(bool selected, Color color)
  20. {
  21. if (!selected)
  22. return;
  23. if (Value != color)
  24. {
  25. Value = color;
  26. OnChanged?.Invoke(color);
  27. }
  28. }
  29. partial void Callback_OnClicked()
  30. {
  31. ColorPicker.Show(Value, AllowHDR, ColorPickerClosed);
  32. }
  33. }
  34. }