HandleSliderPlane.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 plane. For intersection purposes the line
  13. /// is internally by a quadrilateral (a bounded plane).
  14. /// </summary>
  15. public sealed class HandleSliderPlane : HandleSlider
  16. {
  17. /// <summary>
  18. /// Creates a new plane handle slider.
  19. /// </summary>
  20. /// <param name="parentHandle">Handle that the slider belongs to.</param>
  21. /// <param name="dir1">First direction of the plane. The x component of returned delta value will be in this
  22. /// direction. Should be perpendicular to <see cref="dir2"/>.</param>
  23. /// <param name="dir2">Second direction of the plane. The y component of returned delta value will be in this
  24. /// direction. Should be perpendicular to <see cref="dir1"/>.</param>
  25. /// <param name="length">Length of the quadrilateral in both directions.</param>
  26. /// <param name="fixedScale">If true the handle slider will always try to maintain the same visible area in the
  27. /// viewport regardless of distance from camera.</param>
  28. /// <param name="layer">Layer that allows filtering of which sliders are interacted with from a specific camera.</param>
  29. public HandleSliderPlane(Handle parentHandle, Vector3 dir1, Vector3 dir2, float length, bool fixedScale = true, UInt64 layer = 1)
  30. :base(parentHandle)
  31. {
  32. Internal_CreateInstance(this, ref dir1, ref dir2, length, fixedScale, layer);
  33. }
  34. /// <summary>
  35. /// Returns a delta value that is the result of dragging/sliding the pointer along the plane. Returned movement is
  36. /// in terms of the two directions originally provided when constructing the slider. This changes every frame and
  37. /// will be zero unless the slider is active.
  38. /// </summary>
  39. public Vector2 Delta
  40. {
  41. get
  42. {
  43. Vector2 value;
  44. Internal_GetDelta(mCachedPtr, out value);
  45. return value;
  46. }
  47. }
  48. [MethodImpl(MethodImplOptions.InternalCall)]
  49. private static extern void Internal_CreateInstance(HandleSliderPlane instance, ref Vector3 dir1, ref Vector3 dir2,
  50. float length, bool fixedScale, UInt64 layer);
  51. [MethodImpl(MethodImplOptions.InternalCall)]
  52. private static extern void Internal_GetDelta(IntPtr nativeInstance, out Vector2 value);
  53. }
  54. /** @} */
  55. }