HandleSlider2D.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. /// Constraint that determines in which direction can a HandleSlider2D be moved.
  13. /// </summary>
  14. public enum Slider2DConstraint // Note: Must match C++ enum Slider2DConstraint
  15. {
  16. /// <summary>
  17. /// Slider can be moved in both dimensions.
  18. /// </summary>
  19. None,
  20. /// <summary>
  21. /// Slider can only be moved horizontally.
  22. /// </summary>
  23. Horizontal,
  24. /// <summary>
  25. /// Slider can only be moved vertically.
  26. /// </summary>
  27. Vertical
  28. };
  29. /// <summary>
  30. /// Handle slider that is positioned in screen-space, and reports 2D movement in screen space (in pixels). When setting
  31. /// the position the Z coordinate will be ignored, and XY coordinates will be interpreted as pixels relative to the
  32. /// camera its viewed through.
  33. /// </summary>
  34. public sealed class HandleSlider2D : HandleSlider
  35. {
  36. /// <summary>
  37. /// Creates a new 2D handle slider.
  38. /// </summary>
  39. /// <param name="parentHandle">Handle that the slider belongs to.</param>
  40. /// <param name="width">Width of the area of the slider that can be interacted with, in pixels.</param>
  41. /// <param name="height">Height of the area of the slider that can be interacted with, in pixels.</param>
  42. /// <param name="layer">
  43. /// Layer that allows filtering of which sliders are interacted with from a specific camera.
  44. /// </param>
  45. /// <param name="constraint">
  46. /// Optional constraint that determines in which direction is the slider allowed to be moved in.
  47. /// </param>
  48. public HandleSlider2D(Handle parentHandle, int width, int height, Slider2DConstraint constraint, UInt64 layer = 1)
  49. :base(parentHandle)
  50. {
  51. Internal_CreateInstance(this, width, height, constraint, layer);
  52. }
  53. /// <summary>
  54. /// Returns a delta value that is the result of dragging/sliding the pointer. This changes every frame and will be
  55. /// zero unless the slider is active. The value is in screen space (pixels).
  56. /// </summary>
  57. public Vector2I Delta
  58. {
  59. get
  60. {
  61. Vector2I value;
  62. Internal_GetDelta(mCachedPtr, out value);
  63. return value;
  64. }
  65. }
  66. [MethodImpl(MethodImplOptions.InternalCall)]
  67. private static extern void Internal_CreateInstance(HandleSlider2D instance, int width, int height,
  68. Slider2DConstraint constraint, UInt64 layer);
  69. [MethodImpl(MethodImplOptions.InternalCall)]
  70. private static extern void Internal_GetDelta(IntPtr nativeInstance, out Vector2I value);
  71. }
  72. /** @} */
  73. }