HandleSliderLine.cs 2.4 KB

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