HandleSliderDisc.cs 3.7 KB

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