HandleSliderDisc.cs 3.6 KB

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