| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- namespace BansheeEngine
- {
- /// <summary>
- /// Allows manipulation of the platform cursor.
- /// </summary>
- public static class Cursor
- {
- /// <summary>
- /// Position of the cursor in screen coordinates.
- /// </summary>
- public static Vector2I ScreenPosition
- {
- get
- {
- Vector2I value;
- Internal_GetScreenPosition(out value);
- return value;
- }
- set
- {
- Internal_SetScreenPosition(value);
- }
- }
- /// <summary>
- /// Hides the cursor.
- /// </summary>
- public static void Hide()
- {
- Internal_Hide();
- }
- /// <summary>
- /// Shows the cursor.
- /// </summary>
- public static void Show()
- {
- Internal_Show();
- }
- /// <summary>
- /// Clips the cursor to the specified area. Enabled until <see cref="ClipDisable"/> is called.
- /// </summary>
- /// <param name="area">Area in screen space to clip the cursor to.</param>
- public static void ClipToRect(Rect2I area)
- {
- Internal_ClipToRect(area);
- }
- /// <summary>
- /// Disables cursor clipping previously enabled with <see cref="ClipToRect"/>.
- /// </summary>
- public static void ClipDisable()
- {
- Internal_ClipDisable();
- }
- /// <summary>
- /// Changes the active cursor icon.
- /// </summary>
- /// <param name="name">Name of the cursor icon, previously registered with
- /// <see cref="SetCursorIcon(string,PixelData,Vector2I)"/></param>
- public static void SetCursor(string name)
- {
- Internal_SetCursorStr(name);
- }
- /// <summary>
- /// Changes the active cursor icon.
- /// </summary>
- /// <param name="type">One of the built-in cursor types.</param>
- public static void SetCursor(CursorType type)
- {
- Internal_SetCursor(type);
- }
- /// <summary>
- /// Updates the look of a specific cursor icon.
- /// </summary>
- /// <param name="name">Name of the cursor.</param>
- /// <param name="iconData">Pixel data specifying the new look.</param>
- /// <param name="hotspot">Offset into the icon image that determines where the cursor point is.</param>
- public static void SetCursorIcon(string name, PixelData iconData, Vector2I hotspot)
- {
- Internal_SetCursorIconStr(name, iconData, hotspot);
- }
- /// <summary>
- /// Updates the look of a specific cursor icon.
- /// </summary>
- /// <param name="type">One of the built-in cursor types.</param>
- /// <param name="iconData">Pixel data specifying the new look.</param>
- /// <param name="hotspot">Offset into the icon image that determines where the cursor point is.</param>
- public static void SetCursorIcon(CursorType type, PixelData iconData, Vector2I hotspot)
- {
- Internal_SetCursorIcon(type, iconData, hotspot);
- }
- /// <summary>
- /// Removes a cursor icon.
- /// </summary>
- /// <param name="name">Name of the cursor.</param>
- public static void ClearCursorIcon(string name)
- {
- Internal_ClearCursorIconStr(name);
- }
- /// <summary>
- /// Removes a cursor icon.
- /// </summary>
- /// <param name="type">One of the built-in cursor types.</param>
- public static void ClearCursorIcon(CursorType type)
- {
- Internal_ClearCursorIcon(type);
- }
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_GetScreenPosition(out Vector2I value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetScreenPosition(Vector2I value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_Hide();
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_Show();
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_ClipToRect(Rect2I value);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_ClipDisable();
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetCursorStr(string name);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetCursor(CursorType cursor);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetCursorIconStr(string name, PixelData iconData, Vector2I hotspot);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetCursorIcon(CursorType cursor, PixelData iconData, Vector2I hotspot);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_ClearCursorIconStr(string name);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_ClearCursorIcon(CursorType cursor);
- }
- /// <summary>
- /// Built-in cursor types.
- /// </summary>
- public enum CursorType //Note: Must match C++ enum CursorType
- {
- Arrow,
- ArrowDrag,
- ArrowLeftRight,
- Wait,
- IBeam,
- SizeNESW,
- SizeNS,
- SizeNWSE,
- SizeWE,
- Deny,
- // Keep at the end
- Count
- };
- }
|