SceneHandles.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Handles rendering and interaction with scene handles for the specified camera.
  8. /// </summary>
  9. internal sealed class SceneHandles : ScriptObject
  10. {
  11. /// <summary>
  12. /// Creates a new scene handle manager.
  13. /// </summary>
  14. /// <param name="parent">Editor window in which the scene handles are displayed.</param>
  15. /// <param name="sceneCamera">Camera through which the scene handles are displayed.</param>
  16. internal SceneHandles(EditorWindow parent, Camera sceneCamera)
  17. {
  18. Internal_Create(this, parent.GetCachedPtr(), sceneCamera.Native.GetCachedPtr());
  19. }
  20. /// <summary>
  21. /// Updates active handles by moving them as a result of any input.
  22. /// </summary>
  23. /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
  24. /// <param name="inputDelta">Movement of the pointer since last frame.</param>
  25. internal void UpdateInput(Vector2I pointerPos, Vector2I inputDelta)
  26. {
  27. Internal_UpdateInput(mCachedPtr, ref pointerPos, ref inputDelta);
  28. }
  29. /// <summary>
  30. /// Draws the handles onto the target camera.
  31. /// </summary>
  32. internal void Draw()
  33. {
  34. Internal_Draw(mCachedPtr);
  35. }
  36. /// <summary>
  37. /// Selects a handle under the pointer position.
  38. /// </summary>
  39. /// <param name="pointerPos">Position of the pointer relative to the target camera's viewport.</param>
  40. internal void TrySelect(Vector2I pointerPos)
  41. {
  42. Internal_TrySelect(mCachedPtr, ref pointerPos);
  43. }
  44. /// <summary>
  45. /// Checks is any handle currently active.
  46. /// </summary>
  47. /// <returns>True if a handle is active.</returns>
  48. internal bool IsActive()
  49. {
  50. return Internal_IsActive(mCachedPtr);
  51. }
  52. /// <summary>
  53. /// Deselects any currently active handles.
  54. /// </summary>
  55. internal void ClearSelection()
  56. {
  57. Internal_ClearSelection(mCachedPtr);
  58. }
  59. [MethodImpl(MethodImplOptions.InternalCall)]
  60. private static extern void Internal_Create(SceneHandles managedInstance, IntPtr parentWindow, IntPtr camera);
  61. [MethodImpl(MethodImplOptions.InternalCall)]
  62. private static extern void Internal_UpdateInput(IntPtr thisPtr, ref Vector2I pointerPos, ref Vector2I inputDelta);
  63. [MethodImpl(MethodImplOptions.InternalCall)]
  64. private static extern void Internal_Draw(IntPtr thisPtr);
  65. [MethodImpl(MethodImplOptions.InternalCall)]
  66. private static extern void Internal_TrySelect(IntPtr thisPtr, ref Vector2I pointerPos);
  67. [MethodImpl(MethodImplOptions.InternalCall)]
  68. private static extern bool Internal_IsActive(IntPtr thisPtr);
  69. [MethodImpl(MethodImplOptions.InternalCall)]
  70. private static extern void Internal_ClearSelection(IntPtr thisPtr);
  71. }
  72. }