Browse Source

add full osx implementation for custom cursors.

pull/4887/head
Dan Walmsley 5 years ago
parent
commit
e90fe543f0
  1. 18
      src/Avalonia.Native/Cursor.cs
  2. 1
      src/Avalonia.Native/avn.idl

18
src/Avalonia.Native/Cursor.cs

@ -1,4 +1,5 @@
using System;
using System.IO;
using Avalonia.Input;
using Avalonia.Platform;
using Avalonia.Native.Interop;
@ -39,9 +40,22 @@ namespace Avalonia.Native
return new AvaloniaNativeCursor( cursor );
}
public ICursorImpl CreateCursor(IBitmapImpl cursor, PixelPoint hotSpot)
public unsafe ICursorImpl CreateCursor(IBitmapImpl cursor, PixelPoint hotSpot)
{
throw new NotImplementedException();
using(var ms = new MemoryStream())
{
cursor.Save(ms);
var imageData = ms.ToArray();
fixed(void* ptr = imageData)
{
var avnCursor = _native.CreateCustomCursor(ptr, new IntPtr(imageData.Length),
new AvnPixelSize { Width = hotSpot.X, Height = hotSpot.Y });
return new AvaloniaNativeCursor(avnCursor);
}
}
}
}
}

1
src/Avalonia.Native/avn.idl

@ -619,6 +619,7 @@ interface IAvnCursor : IUnknown
interface IAvnCursorFactory : IUnknown
{
HRESULT GetCursor(AvnStandardCursorType cursorType, IAvnCursor** retOut);
HRESULT CreateCustomCursor (void* bitmapData, size_t length, AvnPixelSize hotPixel, IAvnCursor** retOut);
}
[uuid(60452465-8616-40af-bc00-042e69828ce7)]

Loading…
Cancel
Save