HandleSlider.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Base class for all handle sliders. A handle slider is geometry that the user can interact with by selecting or
  8. /// dragging (i.e. sliding) it while in scene view. Sliders generally output a one- or multi-dimensional delta value
  9. /// that signals the drag amount (and/or direction). Handle sliders are one of the building blocks for
  10. /// <see cref="Handle"/> implementations.
  11. /// </summary>
  12. public class HandleSlider : ScriptObject
  13. {
  14. /// <summary>
  15. /// Possible states the slider can be in.
  16. /// </summary>
  17. public enum StateType
  18. {
  19. /// <summary>Slider is not being interacted with.</summary>
  20. Inactive,
  21. /// <summary>Slider is clicked on and being dragged.</summary>
  22. Active,
  23. /// <summary>Slider is being hovered over but isn't clicked on.</summary>
  24. Hover
  25. };
  26. /// <summary>
  27. /// Creates a new handle slider.
  28. /// </summary>
  29. /// <param name="parentHandle">Handle that the slider belongs to.</param>
  30. public HandleSlider(Handle parentHandle)
  31. {
  32. parentHandle.RegisterSlider(this);
  33. }
  34. /// <summary>
  35. /// World position of the slider.
  36. /// </summary>
  37. public Vector3 Position
  38. {
  39. get
  40. {
  41. Vector3 value;
  42. Internal_GetPosition(mCachedPtr, out value);
  43. return value;
  44. }
  45. set
  46. {
  47. Internal_SetPosition(mCachedPtr, value);
  48. }
  49. }
  50. /// <summary>
  51. /// World rotation of the slider.
  52. /// </summary>
  53. public Quaternion Rotation
  54. {
  55. get
  56. {
  57. Quaternion value;
  58. Internal_GetRotation(mCachedPtr, out value);
  59. return value;
  60. }
  61. set
  62. {
  63. Internal_SetRotation(mCachedPtr, value);
  64. }
  65. }
  66. /// <summary>
  67. /// Scale of the slider.
  68. /// </summary>
  69. public Vector3 Scale
  70. {
  71. get
  72. {
  73. Vector3 value;
  74. Internal_GetScale(mCachedPtr, out value);
  75. return value;
  76. }
  77. set
  78. {
  79. Internal_SetScale(mCachedPtr, value);
  80. }
  81. }
  82. /// <summary>
  83. /// State the slider is currently in.
  84. /// </summary>
  85. public StateType State
  86. {
  87. get
  88. {
  89. StateType value;
  90. Internal_GetState(mCachedPtr, out value);
  91. return value;
  92. }
  93. }
  94. /// <summary>
  95. /// Destroys the slider, removing it from the scene.
  96. /// </summary>
  97. internal void Destroy()
  98. {
  99. Internal_Destroy(mCachedPtr);
  100. }
  101. [MethodImpl(MethodImplOptions.InternalCall)]
  102. private static extern void Internal_Destroy(IntPtr nativeInstance);
  103. [MethodImpl(MethodImplOptions.InternalCall)]
  104. private static extern void Internal_GetPosition(IntPtr nativeInstance, out Vector3 value);
  105. [MethodImpl(MethodImplOptions.InternalCall)]
  106. private static extern void Internal_SetPosition(IntPtr nativeInstance, Vector3 value);
  107. [MethodImpl(MethodImplOptions.InternalCall)]
  108. private static extern void Internal_GetRotation(IntPtr nativeInstance, out Quaternion value);
  109. [MethodImpl(MethodImplOptions.InternalCall)]
  110. private static extern void Internal_SetRotation(IntPtr nativeInstance, Quaternion value);
  111. [MethodImpl(MethodImplOptions.InternalCall)]
  112. private static extern void Internal_GetScale(IntPtr nativeInstance, out Vector3 value);
  113. [MethodImpl(MethodImplOptions.InternalCall)]
  114. private static extern void Internal_SetScale(IntPtr nativeInstance, Vector3 value);
  115. [MethodImpl(MethodImplOptions.InternalCall)]
  116. private static extern void Internal_GetState(IntPtr nativeInstance, out StateType value);
  117. }
  118. }