HandleSliderDisc.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Handle slider that returns a delta value as you drag the pointer along a disc. For intersection purposes the disc
  8. /// is internally represented by a torus.
  9. /// </summary>
  10. public sealed class HandleSliderDisc : HandleSlider
  11. {
  12. /// <summary>
  13. /// Creates a new disc handle slider.
  14. /// </summary>
  15. /// <param name="parentHandle">Handle that the slider belongs to.</param>
  16. /// <param name="normal">Normal that determines the orientation of the disc.</param>
  17. /// <param name="radius">Radius of the disc.</param>
  18. /// <param name="fixedScale">If true the handle slider will always try to maintain the same visible area in the
  19. /// viewport regardless of distance from camera.</param>
  20. /// <param name="layer">Layer that allows filtering of which sliders are interacted with from a specific camera.</param>
  21. public HandleSliderDisc(Handle parentHandle, Vector3 normal, float radius, bool fixedScale = true, UInt64 layer = 1)
  22. :base(parentHandle)
  23. {
  24. Internal_CreateInstance(this, ref normal, radius, fixedScale, layer);
  25. }
  26. /// <summary>
  27. /// Returns a delta value that is the result of dragging/sliding the pointer along the disc. This changes every
  28. /// frame and will be zero unless the slider is active.
  29. /// </summary>
  30. public Degree Delta
  31. {
  32. get
  33. {
  34. float value;
  35. Internal_GetDelta(mCachedPtr, out value);
  36. return value;
  37. }
  38. }
  39. /// <summary>
  40. /// Gets the initial angle at which the drag/slide operation started. This is only valid when the slider is active.
  41. /// </summary>
  42. public Degree StartAngle
  43. {
  44. get
  45. {
  46. float value;
  47. Internal_GetStartAngle(mCachedPtr, out value);
  48. return value;
  49. }
  50. }
  51. /// <summary>
  52. /// Enables or disables a cut-off plane that can allow the disc to be intersected with only in a 180 degree arc.
  53. /// </summary>
  54. /// <param name="angle">Angle at which to start the cut-off. Points on the dist at the specified angle and the next
  55. /// 180 degrees won't be interactable.</param>
  56. /// <param name="enabled">Should the cutoff plane be enabled or disabled.</param>
  57. public void SetCutoffPlane(Degree angle, bool enabled)
  58. {
  59. Internal_SetCutoffPlane(mCachedPtr, angle.Degrees, enabled);
  60. }
  61. [MethodImpl(MethodImplOptions.InternalCall)]
  62. private static extern void Internal_CreateInstance(HandleSliderDisc instance, ref Vector3 normal, float radius,
  63. bool fixedScale, UInt64 layer);
  64. [MethodImpl(MethodImplOptions.InternalCall)]
  65. private static extern void Internal_GetDelta(IntPtr nativeInstance, out float value);
  66. [MethodImpl(MethodImplOptions.InternalCall)]
  67. private static extern void Internal_GetStartAngle(IntPtr nativeInstance, out float value);
  68. [MethodImpl(MethodImplOptions.InternalCall)]
  69. private static extern void Internal_SetCutoffPlane(IntPtr nativeInstance, float angle, bool enabled);
  70. }
  71. }