HandleSliderPlane.cs 2.8 KB

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