-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(PointerCursor): Support for WPF & GTK
- Loading branch information
1 parent
272a487
commit eed57c3
Showing
8 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/Uno.UI.Runtime.Skia.Gtk/GTK/Extensions/CursorExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Gdk; | ||
using Windows.UI.Core; | ||
|
||
namespace Uno.UI.Runtime.Skia.GTK.Extensions | ||
{ | ||
internal static class CursorExtensions | ||
{ | ||
public static CoreCursor ToCoreCursor(this Cursor cursor) | ||
{ | ||
CoreCursorType GetCoreCursorType(CursorType? type) => | ||
type switch | ||
{ | ||
CursorType.Arrow => CoreCursorType.Arrow, | ||
CursorType.Cross => CoreCursorType.Cross, | ||
CursorType.Hand1 => CoreCursorType.Hand, | ||
CursorType.Hand2 => CoreCursorType.Hand, | ||
CursorType.QuestionArrow => CoreCursorType.Help, | ||
CursorType.Sizing => CoreCursorType.SizeAll, | ||
CursorType.Watch => CoreCursorType.Wait, | ||
_ => throw new NotImplementedException(), | ||
}; | ||
|
||
return new CoreCursor(GetCoreCursorType(cursor?.CursorType), 0); | ||
} | ||
|
||
public static Cursor ToCursor(this CoreCursor coreCursor) | ||
{ | ||
CursorType GetCursorType(CoreCursorType? coreCursorType) => | ||
coreCursorType switch | ||
{ | ||
CoreCursorType.Arrow => CursorType.Arrow, | ||
CoreCursorType.Cross => CursorType.Cross, | ||
CoreCursorType.Hand => CursorType.Hand1, | ||
CoreCursorType.Help => CursorType.QuestionArrow, | ||
CoreCursorType.SizeAll => CursorType.Sizing, | ||
CoreCursorType.Wait => CursorType.Watch, | ||
_ => CursorType.Arrow, | ||
}; | ||
|
||
return new Cursor(GetCursorType(coreCursor?.Type)); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/Uno.UI.Runtime.Skia.Wpf/WPF/Extensions/CursorExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System.Windows.Input; | ||
using Windows.UI.Core; | ||
|
||
namespace Uno.UI.Skia.Platform.Extensions | ||
{ | ||
internal static class CursorExtensions | ||
{ | ||
public static CoreCursor ToCoreCursor(this Cursor cursor) | ||
{ | ||
CoreCursorType cursorType = CoreCursorType.Arrow; | ||
if (cursor == Cursors.Wait) | ||
{ | ||
cursorType = CoreCursorType.Wait; | ||
} | ||
else if (cursor == Cursors.Hand) | ||
{ | ||
cursorType = CoreCursorType.Hand; | ||
} | ||
else if (cursor == Cursors.Cross) | ||
{ | ||
cursorType = CoreCursorType.Cross; | ||
} | ||
else if (cursor == Cursors.Help) | ||
{ | ||
cursorType = CoreCursorType.Help; | ||
} | ||
else if (cursor == Cursors.IBeam) | ||
{ | ||
cursorType = CoreCursorType.IBeam; | ||
} | ||
else if (cursor == Cursors.No) | ||
{ | ||
cursorType = CoreCursorType.UniversalNo; | ||
} | ||
else if (cursor == Cursors.UpArrow) | ||
{ | ||
cursorType = CoreCursorType.UpArrow; | ||
} | ||
else if (cursor == Cursors.SizeNESW) | ||
{ | ||
cursorType = CoreCursorType.SizeNortheastSouthwest; | ||
} | ||
else if (cursor == Cursors.SizeNS) | ||
{ | ||
cursorType = CoreCursorType.SizeNorthSouth; | ||
} | ||
else if (cursor == Cursors.SizeNWSE) | ||
{ | ||
cursorType = CoreCursorType.SizeNorthwestSoutheast; | ||
} | ||
else if (cursor == Cursors.SizeWE) | ||
{ | ||
cursorType = CoreCursorType.SizeWestEast; | ||
} | ||
return new CoreCursor(cursorType, 0); | ||
} | ||
|
||
public static Cursor ToCursor(this CoreCursor coreCursor) => | ||
coreCursor?.Type switch | ||
{ | ||
CoreCursorType.Arrow => Cursors.Arrow, | ||
CoreCursorType.Cross => Cursors.Cross, | ||
CoreCursorType.Hand => Cursors.Hand, | ||
CoreCursorType.Help => Cursors.Help, | ||
CoreCursorType.IBeam => Cursors.IBeam, | ||
CoreCursorType.SizeAll => Cursors.SizeAll, | ||
CoreCursorType.SizeNortheastSouthwest => Cursors.SizeNESW, | ||
CoreCursorType.SizeNorthSouth => Cursors.SizeNS, | ||
CoreCursorType.SizeNorthwestSoutheast => Cursors.SizeNWSE, | ||
CoreCursorType.SizeWestEast => Cursors.SizeWE, | ||
CoreCursorType.UniversalNo => Cursors.No, | ||
CoreCursorType.UpArrow => Cursors.UpArrow, | ||
CoreCursorType.Wait => Cursors.Wait, | ||
_ => Cursors.Arrow, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters