2
0

Cursor.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. namespace BansheeEngine
  7. {
  8. public static class Cursor
  9. {
  10. public static Vector2I ScreenPosition
  11. {
  12. get
  13. {
  14. Vector2I value;
  15. Internal_GetScreenPosition(out value);
  16. return value;
  17. }
  18. set
  19. {
  20. Internal_SetScreenPosition(value);
  21. }
  22. }
  23. public static void Hide()
  24. {
  25. Internal_Hide();
  26. }
  27. public static void Show()
  28. {
  29. Internal_Show();
  30. }
  31. public static void ClipToRect(Rect2I area)
  32. {
  33. Internal_ClipToRect(area);
  34. }
  35. public static void ClipDisable()
  36. {
  37. Internal_ClipDisable();
  38. }
  39. public static void SetCursor(string name)
  40. {
  41. Internal_SetCursorStr(name);
  42. }
  43. public static void SetCursor(CursorType type)
  44. {
  45. Internal_SetCursor(type);
  46. }
  47. public static void SetCursorIcon(string name, PixelData iconData, Vector2I hotspot)
  48. {
  49. Internal_SetCursorIconStr(name, iconData, hotspot);
  50. }
  51. public static void SetCursorIcon(CursorType type, PixelData iconData, Vector2I hotspot)
  52. {
  53. Internal_SetCursorIcon(type, iconData, hotspot);
  54. }
  55. public static void ClearCursorIcon(string name)
  56. {
  57. Internal_ClearCursorIconStr(name);
  58. }
  59. public static void ClearCursorIcon(CursorType type)
  60. {
  61. Internal_ClearCursorIcon(type);
  62. }
  63. [MethodImpl(MethodImplOptions.InternalCall)]
  64. private static extern void Internal_GetScreenPosition(out Vector2I value);
  65. [MethodImpl(MethodImplOptions.InternalCall)]
  66. private static extern void Internal_SetScreenPosition(Vector2I value);
  67. [MethodImpl(MethodImplOptions.InternalCall)]
  68. private static extern void Internal_Hide();
  69. [MethodImpl(MethodImplOptions.InternalCall)]
  70. private static extern void Internal_Show();
  71. [MethodImpl(MethodImplOptions.InternalCall)]
  72. private static extern void Internal_ClipToRect(Rect2I value);
  73. [MethodImpl(MethodImplOptions.InternalCall)]
  74. private static extern void Internal_ClipDisable();
  75. [MethodImpl(MethodImplOptions.InternalCall)]
  76. private static extern void Internal_SetCursorStr(string name);
  77. [MethodImpl(MethodImplOptions.InternalCall)]
  78. private static extern void Internal_SetCursor(CursorType cursor);
  79. [MethodImpl(MethodImplOptions.InternalCall)]
  80. private static extern void Internal_SetCursorIconStr(string name, PixelData iconData, Vector2I hotspot);
  81. [MethodImpl(MethodImplOptions.InternalCall)]
  82. private static extern void Internal_SetCursorIcon(CursorType cursor, PixelData iconData, Vector2I hotspot);
  83. [MethodImpl(MethodImplOptions.InternalCall)]
  84. private static extern void Internal_ClearCursorIconStr(string name);
  85. [MethodImpl(MethodImplOptions.InternalCall)]
  86. private static extern void Internal_ClearCursorIcon(CursorType cursor);
  87. }
  88. // Note: Do not modify indexes, they need to match C++ enum CursorType
  89. public enum CursorType
  90. {
  91. Arrow,
  92. ArrowDrag,
  93. ArrowLeftRight,
  94. Wait,
  95. IBeam,
  96. SizeNESW,
  97. SizeNS,
  98. SizeNWSE,
  99. SizeWE,
  100. Deny,
  101. // Keep at the end
  102. Count
  103. };
  104. }