HandleSliderLine.cs 2.4 KB

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