libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.6k stars 1.78k forks source link

[SDL3, API break] Maybe use CSS vocabulary for cursor names? #9079

Closed smcv closed 4 months ago

smcv commented 7 months ago

Follow-up for #8939.

On #8939, I wrote:

I think "move" is actually wrong for SIZEALL: what SDL wants is an equivalent of Windows IDC_SIZEALL, but the CSS move is documented to be a drag-and-drop cursor, more like copy

... but then https://developer.mozilla.org/en-US/docs/Web/CSS/cursor shows it as a 4-pointed arrow that doesn't share its visual metaphor with copy or alias, GNOME's Adwaita theme matches that, and the only actual user of the SDL SIZEALL cursor that I can find in Debian, https://codesearch.debian.net/show?file=cdogs-sdl_1.5.0%2Bdfsg-1%2Fsrc%2Fcdogsed%2Fcdogsed.c&line=740, seems to expect it to be the equivalent of CSS grabbing (a hand with closed fingers holding onto the dragged object). tableflip

Is it too late to change the SDL3 version of SDLSystemCursor so that it lines up 1:1 with the CSS vocabulary, which is the closest thing we have to a cross-platform list of cursors? And then UIs that want to represent "user is holding and dragging a thing" could use SDL_SYSTEM_CURSOR_GRABBING?

This would mean there's no obvious mapping for Windows IDC_SIZEALL, but it's not obvious to me how you would even want to use "resize in all four directions" in a UI, given that the mouse cursor only has 2 degrees of freedom?

icculus commented 7 months ago

I'm fine with this if @slouken is too.

For sdl2-compat, we would continue to treat it as the wild west, and when you ask for SIZEALL, you get SDL3's new SDL_SYSTEM_CURSOR_GRABBING.

but it's not obvious to me how you would even want to use "resize in all four directions" in a UI,

This is probably why cdogs_sdl is using this for "grabbing"...despite the SIZEALL name, it usually won't make sense for resizing something, but it makes some sense for "any direction you want to move this thing you are dragging is valid."

icculus commented 7 months ago

Also, if we do this, do we want to pull in GRAB (open hand) and GRABBING (closed hand), and maybe ZOOM_IN and ZOOM_OUT? Those are also listed as CSS cursors, but I don't know what macOS/win32/etc offer in their system icons vs what the browser is providing, to make these worthwhile.

(other ones, like COPY and ALIAS and CELL and such, are probably a bridge too far.)

smcv commented 7 months ago

It doesn't necessarily have to be the entire CSS vocabulary, what I'm mainly interested in is a policy that "each enum value corresponds to something in CSS" (and therefore if people want extra cursors that exist in CSS, they can ask for them, but if they want extra cursors that don't exist in CSS, the answer is much more likely to be no).

Those are also listed as CSS cursors, but I don't know what macOS/win32/etc offer in their system icons vs what the browser is providing

Chromium seems to use IDC_ constants on Windows: https://sources.debian.org/src/chromium/121.0.6167.160-1/ui/base/win/win_cursor_factory.cc/?hl=109#L109

and seems to use system cursors on macOS too: https://sources.debian.org/src/chromium/121.0.6167.160-1/ui/base/cocoa/cursor_utils.mm/

icculus commented 4 months ago

(This doesn't need an sdl2-compat update, as the enum values and meanings of the existing cursors haven't changed, just their names.)