GUIColorField.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. public sealed class GUIColorField : GUIElement
  7. {
  8. public delegate void OnChangedDelegate(Color newValue);
  9. public event OnChangedDelegate OnChanged;
  10. public Color Value
  11. {
  12. get
  13. {
  14. Color value;
  15. Internal_GetValue(mCachedPtr, out value);
  16. return value;
  17. }
  18. set { Internal_SetValue(mCachedPtr, value); }
  19. }
  20. public GUIColorField(GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options)
  21. {
  22. Internal_CreateInstance(this, title, titleWidth, style, options, true);
  23. }
  24. public GUIColorField(string style = "", params GUIOption[] options)
  25. {
  26. Internal_CreateInstance(this, null, 0, style, options, false);
  27. }
  28. public void SetTint(Color color)
  29. {
  30. Internal_SetTint(mCachedPtr, color);
  31. }
  32. private void DoOnChanged(Color newValue)
  33. {
  34. if (OnChanged != null)
  35. OnChanged(newValue);
  36. }
  37. private void DoOnClicked()
  38. {
  39. // TODO
  40. }
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern void Internal_CreateInstance(GUIColorField instance, GUIContent title, int titleWidth,
  43. string style, GUIOption[] options, bool withTitle);
  44. [MethodImpl(MethodImplOptions.InternalCall)]
  45. private static extern void Internal_GetValue(IntPtr nativeInstance, out Color value);
  46. [MethodImpl(MethodImplOptions.InternalCall)]
  47. private static extern void Internal_SetValue(IntPtr nativeInstance, Color value);
  48. [MethodImpl(MethodImplOptions.InternalCall)]
  49. private static extern void Internal_SetTint(IntPtr nativeInstance, Color color);
  50. }
  51. }