HandleSlider.cs 5.0 KB

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