HandleSlider.cs 5.1 KB

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