Add more SDL3-exclusive mouse cursor shapes

They just fall back on GLFW.
This commit is contained in:
PJB3005
2025-08-04 16:31:43 +02:00
parent 7a510298e1
commit 3de48d7595
5 changed files with 281 additions and 3 deletions

View File

@@ -128,6 +128,19 @@ namespace Robust.Client.Graphics.Clyde
AddStandardCursor(StandardCursorShape.Hand, CursorShape.Hand);
AddStandardCursor(StandardCursorShape.HResize, CursorShape.HResize);
AddStandardCursor(StandardCursorShape.VResize, CursorShape.VResize);
AddStandardCursor(StandardCursorShape.Progress, CursorShape.Arrow);
AddStandardCursor(StandardCursorShape.NWSEResize, CursorShape.Crosshair);
AddStandardCursor(StandardCursorShape.NESWResize, CursorShape.Crosshair);
AddStandardCursor(StandardCursorShape.Move, CursorShape.Crosshair);
AddStandardCursor(StandardCursorShape.NotAllowed, CursorShape.Arrow);
AddStandardCursor(StandardCursorShape.NWResize, CursorShape.Crosshair);
AddStandardCursor(StandardCursorShape.NResize, CursorShape.VResize);
AddStandardCursor(StandardCursorShape.NEResize, CursorShape.Crosshair);
AddStandardCursor(StandardCursorShape.EResize, CursorShape.HResize);
AddStandardCursor(StandardCursorShape.SEResize, CursorShape.Crosshair);
AddStandardCursor(StandardCursorShape.SResize, CursorShape.VResize);
AddStandardCursor(StandardCursorShape.SWResize, CursorShape.Crosshair);
AddStandardCursor(StandardCursorShape.WResize, CursorShape.HResize);
}
private sealed class CursorImpl : ICursor

View File

@@ -94,6 +94,19 @@ internal partial class Clyde
Add(StandardCursorShape.Hand, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_POINTER);
Add(StandardCursorShape.HResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_EW_RESIZE);
Add(StandardCursorShape.VResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NS_RESIZE);
Add(StandardCursorShape.Progress, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_PROGRESS);
Add(StandardCursorShape.NWSEResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NWSE_RESIZE);
Add(StandardCursorShape.NESWResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NESW_RESIZE);
Add(StandardCursorShape.Move, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_MOVE);
Add(StandardCursorShape.NotAllowed, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NOT_ALLOWED);
Add(StandardCursorShape.NWResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NW_RESIZE);
Add(StandardCursorShape.NResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_N_RESIZE);
Add(StandardCursorShape.NEResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NE_RESIZE);
Add(StandardCursorShape.EResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_E_RESIZE);
Add(StandardCursorShape.SEResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_SE_RESIZE);
Add(StandardCursorShape.SResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_S_RESIZE);
Add(StandardCursorShape.SWResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_SW_RESIZE);
Add(StandardCursorShape.WResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_W_RESIZE);
void Add(StandardCursorShape shape, SDL.SDL_SystemCursor sysCursor)
{

View File

@@ -15,6 +15,11 @@ namespace Robust.Client.Graphics
/// </summary>
IBeam,
/// <summary>
/// Alias for <see cref="IBeam"/>.
/// </summary>
Text = IBeam,
/// <summary>
/// The crosshair shape. Used when dragging and dropping.
/// </summary>
@@ -25,16 +30,135 @@ namespace Robust.Client.Graphics
/// </summary>
Hand,
/// <summary>
/// Alias for <see cref="Hand"/>
/// </summary>
Pointer = Hand,
/// <summary>
/// The horizontal resize shape. Used when mousing over something that can be horizontally resized.
/// </summary>
HResize,
/// <summary>
/// Alias for <see cref="EWResize"/>
/// </summary>
EWResize = HResize,
/// <summary>
/// The vertical resize shape. Used when mousing over something that can be vertically resized.
/// </summary>
VResize,
/// <summary>
/// Alias for <see cref="VResize"/>.
/// </summary>
NSResize = VResize,
/// <summary>
/// Program is busy doing something.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
Progress,
/// <summary>
/// Diagonal resize shape for northwest-southeast resizing.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
NWSEResize,
/// <summary>
/// Diagonal resize shape for northeast-southwest resizing.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
NESWResize,
/// <summary>
/// 4-way arrow move icon.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
Move,
/// <summary>
/// An action is not allowed.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
NotAllowed,
/// <summary>
/// One-directional resize to the northwest.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
NWResize,
/// <summary>
/// One-directional resize to the north.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
NResize,
/// <summary>
/// One-directional resize to the northeast.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
NEResize,
/// <summary>
/// One-directional resize to the east.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
EResize,
/// <summary>
/// One-directional resize to the southeast.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
SEResize,
/// <summary>
/// One-directional resize to the south.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
SResize,
/// <summary>
/// One-directional resize to the southwest.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
SWResize,
/// <summary>
/// One-directional resize to the west.
/// </summary>
/// <remarks>
/// This cursor is not always available and may be substituted.
/// </remarks>
WResize,
/// <summary>
/// Not a real value
/// </summary>

View File

@@ -11,14 +11,124 @@ namespace Robust.Client.UserInterface
/// <summary>
/// Default common cursor shapes available in the UI.
/// </summary>
/// <seealso cref="StandardCursorShape"/>
public enum CursorShape: byte
{
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.Arrow"/>
/// </summary>
Arrow,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.IBeam"/>
/// </summary>
IBeam,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.Text"/>
/// </summary>
Text = IBeam,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.Crosshair"/>
/// </summary>
Crosshair,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.Hand"/>
/// </summary>
Hand,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.Pointer"/>
/// </summary>
Pointer = Hand,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.HResize"/>
/// </summary>
HResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.EWResize"/>
/// </summary>
EWResize = HResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.VResize"/>
/// </summary>
VResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.NSResize"/>
/// </summary>
NSResize = VResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.Progress"/>
/// </summary>
Progress,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.NWSEResize"/>
/// </summary>
NWSEResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.NESWResize"/>
/// </summary>
NESWResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.Move"/>
/// </summary>
Move,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.NotAllowed"/>
/// </summary>
NotAllowed,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.NWResize"/>
/// </summary>
NWResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.NResize"/>
/// </summary>
NResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.NEResize"/>
/// </summary>
NEResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.EResize"/>
/// </summary>
EResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.SEResize"/>
/// </summary>
SEResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.SResize"/>
/// </summary>
SResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.SWResize"/>
/// </summary>
SWResize,
/// <summary>
/// Corresponds to <see cref="StandardCursorShape.WResize"/>
/// </summary>
WResize,
/// <summary>
/// Special cursor shape indicating that <see cref="CustomCursorShape"/> is set and being used.
/// </summary>

View File

@@ -202,7 +202,14 @@ internal partial class UserInterfaceManager
return;
}
var shape = cursorTarget.DefaultCursorShape switch
var shape = MapCursorShape(cursorTarget.DefaultCursorShape);
_clyde.SetCursor(_clyde.GetStandardCursor(shape));
}
private static StandardCursorShape MapCursorShape(Control.CursorShape shape)
{
return shape switch
{
Control.CursorShape.Arrow => StandardCursorShape.Arrow,
Control.CursorShape.IBeam => StandardCursorShape.IBeam,
@@ -210,10 +217,21 @@ internal partial class UserInterfaceManager
Control.CursorShape.Crosshair => StandardCursorShape.Crosshair,
Control.CursorShape.VResize => StandardCursorShape.VResize,
Control.CursorShape.HResize => StandardCursorShape.HResize,
Control.CursorShape.Progress => StandardCursorShape.Progress,
Control.CursorShape.NWSEResize => StandardCursorShape.NWSEResize,
Control.CursorShape.NESWResize => StandardCursorShape.NESWResize,
Control.CursorShape.Move => StandardCursorShape.Move,
Control.CursorShape.NotAllowed => StandardCursorShape.NotAllowed,
Control.CursorShape.NWResize => StandardCursorShape.NWResize,
Control.CursorShape.NResize => StandardCursorShape.NResize,
Control.CursorShape.NEResize => StandardCursorShape.NEResize,
Control.CursorShape.EResize => StandardCursorShape.EResize,
Control.CursorShape.SEResize => StandardCursorShape.SEResize,
Control.CursorShape.SResize => StandardCursorShape.SResize,
Control.CursorShape.SWResize => StandardCursorShape.SWResize,
Control.CursorShape.WResize => StandardCursorShape.WResize,
_ => StandardCursorShape.Arrow
};
_clyde.SetCursor(_clyde.GetStandardCursor(shape));
}
public void MouseWheel(MouseWheelEventArgs args)