Skip to content

Commit

Permalink
Add more standard cursor shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Perksey committed Apr 18, 2024
1 parent f2838a8 commit 3a9aaee
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 18 deletions.
32 changes: 31 additions & 1 deletion src/Input/Silk.NET.Input.Common/Enums/StandardCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,36 @@ public enum StandardCursor
/// <summary>
/// Vertical resize arrow cursor.
/// </summary>
VResize
VResize,

/// <summary>
/// Top-left to bottom-right diagonal resize/move arrow cursor.
/// </summary>
NwseResize,

/// <summary>
/// Top-right to bottom-left diagonal resize/move arrow cursor.
/// </summary>
NeswResize,

/// <summary>
/// Omni-directional resize/move cursor.
/// </summary>
ResizeAll,

/// <summary>
/// Operation not allowed cursor.
/// </summary>
NotAllowed,

/// <summary>
/// Hourglass/waiting cursor.
/// </summary>
Wait,

/// <summary>
/// Regular arrow but with an hourglass/waiting icon cursor.
/// </summary>
WaitArrow
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,7 @@ static Silk.NET.Input.InputWindowExtensions.ShouldLoadFirstPartyPlatforms(bool s
static Silk.NET.Input.InputWindowExtensions.TryAdd(string! assemblyName) -> bool
static Silk.NET.Input.ScrollWheel.operator !=(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.ScrollWheel.operator ==(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#nullable enable
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,7 @@ static Silk.NET.Input.InputWindowExtensions.ShouldLoadFirstPartyPlatforms(bool s
static Silk.NET.Input.InputWindowExtensions.TryAdd(string! assemblyName) -> bool
static Silk.NET.Input.ScrollWheel.operator !=(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.ScrollWheel.operator ==(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#nullable enable
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,7 @@ static Silk.NET.Input.InputWindowExtensions.ShouldLoadFirstPartyPlatforms(bool s
static Silk.NET.Input.InputWindowExtensions.TryAdd(string! assemblyName) -> bool
static Silk.NET.Input.ScrollWheel.operator !=(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.ScrollWheel.operator ==(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#nullable enable
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,7 @@ static Silk.NET.Input.InputWindowExtensions.ShouldLoadFirstPartyPlatforms(bool s
static Silk.NET.Input.InputWindowExtensions.TryAdd(string! assemblyName) -> bool
static Silk.NET.Input.ScrollWheel.operator !=(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.ScrollWheel.operator ==(Silk.NET.Input.ScrollWheel left, Silk.NET.Input.ScrollWheel right) -> bool
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#nullable enable
static Silk.NET.Input.GamepadExtensions.LeftThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.LeftThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
static Silk.NET.Input.GamepadExtensions.RightThumbstick(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Thumbstick
static Silk.NET.Input.GamepadExtensions.RightThumbstickButton(this Silk.NET.Input.IGamepad! gamepad) -> Silk.NET.Input.Button
Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
12 changes: 11 additions & 1 deletion src/Input/Silk.NET.Input.Glfw/GlfwCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ internal class GlfwCursor : ICursor, IDisposable
{StandardCursor.Hand, CursorShape.Hand},
{StandardCursor.HResize, CursorShape.HResize},
{StandardCursor.VResize, CursorShape.VResize},
{StandardCursor.ResizeAll, CursorShape.AllResize},
{StandardCursor.NeswResize, CursorShape.NeswResize},
{StandardCursor.NwseResize, CursorShape.NwseResize},
{StandardCursor.NotAllowed, CursorShape.NotAllowed}
};

private const int BytesPerCursorPixel = 4;
Expand Down Expand Up @@ -76,8 +80,8 @@ public StandardCursor StandardCursor
{
if (_standardCursor != value)
{
_standardCursor = value;
UpdateStandardCursor();
_standardCursor = value;
}
}
}
Expand Down Expand Up @@ -162,6 +166,8 @@ public bool IsSupported(CursorMode mode)
/// <inheritdoc />
public bool IsSupported(StandardCursor standardCursor)
{
GlfwProvider.GLFW.Value.GetVersion(out var major, out var minor, out _);
var is34OrLater = major > 3 || major == 3 && minor >= 4;
return standardCursor switch
{
StandardCursor.Default => true,
Expand All @@ -171,6 +177,10 @@ public bool IsSupported(StandardCursor standardCursor)
StandardCursor.Hand => true,
StandardCursor.HResize => true,
StandardCursor.VResize => true,
StandardCursor.NeswResize when is34OrLater => true,
StandardCursor.NwseResize when is34OrLater => true,
StandardCursor.ResizeAll when is34OrLater => true,
StandardCursor.NotAllowed when is34OrLater => true,
_ => false
};
}
Expand Down
6 changes: 6 additions & 0 deletions src/Input/Silk.NET.Input.Sdl/SdlCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ internal class SdlCursor : ICursor
{StandardCursor.Hand, SystemCursor.SystemCursorHand},
{StandardCursor.HResize, SystemCursor.SystemCursorSizewe},
{StandardCursor.VResize, SystemCursor.SystemCursorSizens},
{StandardCursor.NwseResize, SystemCursor.SystemCursorSizenwse},
{StandardCursor.NeswResize, SystemCursor.SystemCursorSizenesw},
{StandardCursor.ResizeAll, SystemCursor.SystemCursorSizeall},
{StandardCursor.NotAllowed, SystemCursor.SystemCursorNo},
{StandardCursor.Wait, SystemCursor.SystemCursorWait},
{StandardCursor.WaitArrow, SystemCursor.SystemCursorWaitarrow}
};

private const int BytesPerCursorPixel = 4;
Expand Down

0 comments on commit 3a9aaee

Please sign in to comment.