HandleSliderLine.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. public HandleSliderLine(Handle parentHandle, Vector3 direction, float length, bool fixedScale = true)
  21. :base(parentHandle)
  22. {
  23. Internal_CreateInstance(this, direction, length, fixedScale);
  24. }
  25. /// <summary>
  26. /// Returns a delta value that is the result of dragging/sliding the pointer along the line. This changes every
  27. /// frame and will be zero unless the slider is active.
  28. /// </summary>
  29. public float Delta
  30. {
  31. get
  32. {
  33. float value;
  34. Internal_GetDelta(mCachedPtr, out value);
  35. return value;
  36. }
  37. }
  38. [MethodImpl(MethodImplOptions.InternalCall)]
  39. private static extern void Internal_CreateInstance(HandleSliderLine instance, Vector3 direction, float length, bool fixedScale);
  40. [MethodImpl(MethodImplOptions.InternalCall)]
  41. private static extern void Internal_GetDelta(IntPtr nativeInstance, out float value);
  42. }
  43. }