HandleSliderPlane.cs 2.6 KB

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