HandleSliderLine.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 line. For intersection purposes the line
  8. /// is internally by a capsule and a sphere at its cap (assuming this will be used for arrow-like handles).
  9. /// </summary>
  10. public sealed class HandleSliderLine : HandleSlider
  11. {
  12. /// <summary>
  13. /// Creates a new line handle slider.
  14. /// </summary>
  15. /// <param name="parentHandle">Handle that the slider belongs to.</param>
  16. /// <param name="direction">Normalized direction towards which the line is pointing.</param>
  17. /// <param name="length">Length of the line.</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 HandleSliderLine(Handle parentHandle, Vector3 direction, float length, bool fixedScale = true, UInt64 layer = 1)
  22. :base(parentHandle)
  23. {
  24. Internal_CreateInstance(this, ref direction, length, fixedScale, layer);
  25. }
  26. /// <summary>
  27. /// Returns a delta value that is the result of dragging/sliding the pointer along the line. This changes every
  28. /// frame and will be zero unless the slider is active.
  29. /// </summary>
  30. public float Delta
  31. {
  32. get
  33. {
  34. float value;
  35. Internal_GetDelta(mCachedPtr, out value);
  36. return value;
  37. }
  38. }
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern void Internal_CreateInstance(HandleSliderLine instance, ref Vector3 direction, float length,
  41. bool fixedScale, UInt64 layer);
  42. [MethodImpl(MethodImplOptions.InternalCall)]
  43. private static extern void Internal_GetDelta(IntPtr nativeInstance, out float value);
  44. }
  45. }