While not strictly related to GUI toolkits, this does bring up a
question I have about the mouse state in SDL2.
Something that was recently brought up for both FNA and MonoGame was the
accuracy of MouseState. Basically, we still have the problem of the
mouse state only caring about the coordinates within the window, when
XNA4 can actually provide coordinates both <0 and >ClientBounds.
It looks like something similar to SDL_GetGlobalMouseState would work,
but with this call we would still need to get the mouse state relative
to the window and subtract to get XNA4 behavior… and if
SDL_GetGlobalMouseState is as inefficient as the docs note, this
probably isn’t something to use in addition to SDL_GetWindowPosition
every time the client asks for MouseState. On the other hand, something
like SDL_CaptureMouse would be pretty nice to get those negative
coordinates (for example) right away, but the rest of this call’s
behavior would make things messy really quickly…
TL;DR: Is there any use for something like SDL_GetGlobalMouseState
except that it provides the coordinates that SDL_CaptureMouse would
provide, or is this something that only weird projects like FNA would need?
-Ethan> Date: Wed, 25 Jun 2014 21:57:07 -0400
From: “Ryan C. Gordon”
To: sdl at lists.libsdl.org
Subject: [SDL] SDL-gui-backend merged…
Message-ID: <53AB7DF3.7010007 at icculus.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
The first piece of my SDL-gui-backend experiment has been merged into
the main SDL repository. I’ve been looking at what SDL needs to be
useful as a backend for GUI toolkits. This isn’t so much a question of
"how do I build a UI with SDL," but more like, “what would something
like GTK+ need to talk exclusively to SDL instead of X11?”
As a first target, we added what Unreal Engine 4’s Slate UI toolkit
would need to never talk directly to X11 on Linux, since the added
requirements were pretty modest.
Here’s the merge, modulo a few patches on top to get it to compile:
https://hg.libsdl.org/SDL/rev/dc80dc0bd22e
The documentation on the new functions are right at the top of the
patch, if you scroll down a little. All of the new stuff works on Mac,
Windows, and X11, probably isn’t relevant to iOS/Android/etc, and still
needs support for Wayland, Mir, and Haiku.
This experiment will continue. I’m not sure what else, if anything else,
will be added, yet. There’s a delicate balance to SDL, and you don’t
want to go crazy adding things like this, especially when the primary
use is games, but I’m interested in finding cases like Slate–can mostly
use SDL, just needed X11 for a few special items–and seeing if we can
make those cases more portable.
–ryan.