Browse Source

Added D+D StandardCursors

pull/1417/head
boombuler 9 years ago
parent
commit
74163ff668
  1. 5
      src/Avalonia.Input/Cursors.cs
  2. 5
      src/Gtk/Avalonia.Gtk3/CursorFactory.cs
  3. 4
      src/OSX/Avalonia.MonoMac/Cursor.cs
  4. 27
      src/Windows/Avalonia.Win32/CursorFactory.cs

5
src/Avalonia.Input/Cursors.cs

@ -38,7 +38,10 @@ namespace Avalonia.Input
TopLeftCorner,
TopRightCorner,
BottomLeftCorner,
BottomRightCorner
BottomRightCorner,
DragMove,
DragCopy,
DragLink,
// Not available in GTK directly, see http://www.pixelbeat.org/programming/x_cursors/
// We might enable them later, preferably, by loading pixmax direclty from theme with fallback image

5
src/Gtk/Avalonia.Gtk3/CursorFactory.cs

@ -32,7 +32,10 @@ namespace Avalonia.Gtk3
{StandardCursorType.TopLeftCorner, CursorType.TopLeftCorner},
{StandardCursorType.TopRightCorner, CursorType.TopRightCorner},
{StandardCursorType.BottomLeftCorner, CursorType.BottomLeftCorner},
{StandardCursorType.BottomRightCorner, CursorType.BottomRightCorner}
{StandardCursorType.BottomRightCorner, CursorType.BottomRightCorner},
{StandardCursorType.DragCopy, CursorType.CenterPtr},
{StandardCursorType.DragMove, CursorType.Fleur},
{StandardCursorType.DragLink, CursorType.Cross},
};
private static readonly Dictionary<StandardCursorType, IPlatformHandle> Cache =

4
src/OSX/Avalonia.MonoMac/Cursor.cs

@ -51,6 +51,10 @@ namespace Avalonia.MonoMac
[StandardCursorType.TopSide] = NSCursor.ResizeUpCursor,
[StandardCursorType.UpArrow] = NSCursor.ResizeUpCursor,
[StandardCursorType.Wait] = NSCursor.ArrowCursor, //TODO
[StandardCursorType.DragMove] = NSCursor.DragCopyCursor, // TODO
[StandardCursorType.DragCopy] = NSCursor.DragCopyCursor,
[StandardCursorType.DragLink] = NSCursor.DragLinkCursor,
};
}

27
src/Windows/Avalonia.Win32/CursorFactory.cs

@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using Avalonia.Input;
using Avalonia.Platform;
using System.Runtime.InteropServices;
namespace Avalonia.Win32
{
@ -20,6 +21,27 @@ namespace Avalonia.Win32
{
}
static CursorFactory()
{
LoadModuleCursor(StandardCursorType.DragMove, "ole32.dll", 2);
LoadModuleCursor(StandardCursorType.DragCopy, "ole32.dll", 3);
LoadModuleCursor(StandardCursorType.DragLink, "ole32.dll", 4);
}
private static void LoadModuleCursor(StandardCursorType cursorType, string module, int id)
{
IntPtr mh = UnmanagedMethods.GetModuleHandle(module);
if (mh != IntPtr.Zero)
{
IntPtr cursor = UnmanagedMethods.LoadCursor(mh, new IntPtr(id));
if (cursor != IntPtr.Zero)
{
PlatformHandle phCursor = new PlatformHandle(cursor, PlatformConstants.CursorHandleType);
Cache.Add(cursorType, phCursor);
}
}
}
private static readonly Dictionary<StandardCursorType, int> CursorTypeMapping = new Dictionary
<StandardCursorType, int>
{
@ -47,6 +69,11 @@ namespace Avalonia.Win32
//Using SizeNorthEastSouthWest
{StandardCursorType.TopRightCorner, 32643},
{StandardCursorType.BottomLeftCorner, 32643},
// Fallback, should have been loaded from ole32.dll
{StandardCursorType.DragMove, 32516},
{StandardCursorType.DragCopy, 32516},
{StandardCursorType.DragLink, 32516},
};
private static readonly Dictionary<StandardCursorType, IPlatformHandle> Cache =

Loading…
Cancel
Save