2
0

HandleSliderDisc.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. public HandleSliderDisc(Handle parentHandle, Vector3 normal, float radius, bool fixedScale = true)
  21. :base(parentHandle)
  22. {
  23. Internal_CreateInstance(this, normal, radius, fixedScale);
  24. }
  25. /// <summary>
  26. /// Returns a delta value that is the result of dragging/sliding the pointer along the disc. This changes every
  27. /// frame and will be zero unless the slider is active.
  28. /// </summary>
  29. public Degree Delta
  30. {
  31. get
  32. {
  33. float value;
  34. Internal_GetDelta(mCachedPtr, out value);
  35. return value;
  36. }
  37. }
  38. /// <summary>
  39. /// Gets the initial angle at which the drag/slide operation started. This is only valid when the slider is active.
  40. /// </summary>
  41. public Degree StartAngle
  42. {
  43. get
  44. {
  45. float value;
  46. Internal_GetStartAngle(mCachedPtr, out value);
  47. return value;
  48. }
  49. }
  50. /// <summary>
  51. /// Enables or disables a cut-off plane that can allow the disc to be intersected with only in a 180 degree arc.
  52. /// </summary>
  53. /// <param name="angle">Angle at which to start the cut-off. Points on the dist at the specified angle and the next
  54. /// 180 degrees won't be interactable.</param>
  55. /// <param name="enabled">Should the cutoff plane be enabled or disabled.</param>
  56. public void SetCutoffPlane(Degree angle, bool enabled)
  57. {
  58. Internal_SetCutoffPlane(mCachedPtr, angle.Degrees, enabled);
  59. }
  60. [MethodImpl(MethodImplOptions.InternalCall)]
  61. private static extern void Internal_CreateInstance(HandleSliderDisc instance, Vector3 normal, float radius, bool fixedScale);
  62. [MethodImpl(MethodImplOptions.InternalCall)]
  63. private static extern void Internal_GetDelta(IntPtr nativeInstance, out float value);
  64. [MethodImpl(MethodImplOptions.InternalCall)]
  65. private static extern void Internal_GetStartAngle(IntPtr nativeInstance, out float value);
  66. [MethodImpl(MethodImplOptions.InternalCall)]
  67. private static extern void Internal_SetCutoffPlane(IntPtr nativeInstance, float angle, bool enabled);
  68. }
  69. }