public unsafe void SetCursor(ICursor cursor) { if (_currentCursor == cursor) { // Nothing has to be done! return; } if (cursor == null) { _currentCursor = null; GLFW.SetCursor(_glfwWindow, null); return; } if (!(cursor is CursorImpl impl) || impl.Owner != this) { throw new ArgumentException("Cursor is not created by this clyde instance."); } if (impl.Cursor == null) { throw new ObjectDisposedException(nameof(cursor)); } _currentCursor = impl; GLFW.SetCursor(_glfwWindow, impl.Cursor); }
public ICursorImpl GetCursor(StandardCursorType cursorType) { if (!Cache.TryGetValue(cursorType, out var rv)) { rv = new CursorImpl( UnmanagedMethods.LoadCursor(IntPtr.Zero, new IntPtr(CursorTypeMapping[cursorType])), false); Cache.Add(cursorType, rv); } return(rv); }
private unsafe void FlushCursorDisposeQueue() { while (_cursorDisposeQueue.TryDequeue(out var cursor)) { var ptr = (Cursor *)cursor; if (_currentCursor != null && ptr == _currentCursor.Cursor) { // Currently active cursor getting disposed. _currentCursor = null; } GLFW.DestroyCursor(ptr); } }
private void InitCursors() { unsafe void AddStandardCursor(StandardCursorShape standardShape, CursorShape shape) { var ptr = GLFW.CreateStandardCursor(shape); var impl = new CursorImpl(this, ptr, true); _standardCursors.Add(standardShape, impl); } AddStandardCursor(StandardCursorShape.Arrow, CursorShape.Arrow); AddStandardCursor(StandardCursorShape.IBeam, CursorShape.IBeam); AddStandardCursor(StandardCursorShape.Crosshair, CursorShape.Crosshair); AddStandardCursor(StandardCursorShape.Hand, CursorShape.Hand); AddStandardCursor(StandardCursorShape.HResize, CursorShape.HResize); AddStandardCursor(StandardCursorShape.VResize, CursorShape.VResize); }