Pointer events are an unified abstraction over mouse, touch, pen and
potential other yet-to-be-invented pointer-like input methods. Their goal
is to expose all such input methods under a single interface so the
application side doesn't need to explicitly make sure that it's
touch-aware or pen-aware. This abstraction is already present in HTML5,
in Qt6 and in WINAPI as well, and is also what I adopted for the new UI
library because it *just makes sense*.
Unfortunately not even SDL3 took the opportunity to introduce that and
instead added a *third* separate event type for pen input in SDL3. At
first I thought that I wouldn't introduce any extra abstractions in the
Application classes (because that's what they are designed to be, as
lightweight as possible), but midway through introducing TouchEvent
classes and fighting SDL's touch->mouse and mouse->touch compatibility
translation (yes, it's both ways, depending on the platform) I realized
that a much simpler solution that doesn't require any event translation
or the users duplicating their event handling logic for several possible
input types is to introduce a single new event type that covers all.
Which is what this commit does -- it doesn't introduce anything
touch-related so far, just creates a new PointerEvent and
PointerMoveEvent class and corresponding virtual functions. Additionally,
I took this as an opportunity to make the position floating-point, since
that's what SDL3 does now as well, and GLFW did so since ever.
Plus, the Pointer and Pointers enums are directly on the Sdl2Application
class, to allow me to *finally* introduce pointer state queries. Which
weren't possible until now, because there were mutually incompatible
MouseEvent::Button and MouseMoveEvent::Button enums and putting them on
the base class would mean one would have to be translated and the other
not. With Pointer it's translated always, because there isn't any similar
enumeration in SDL that would cover mouse, touch and pen at the same
time.
Snippets that possibly generate output for Magnum documentation
###############################################################
"Getting started" image
Displayed by the getting-started executable. Run the app and take screenshot
using Spectacle (including decorations, 880x707). Similarly for the gray
version. The resulting files should be resized to half. pngcrush to them for
smaller file sizes:
Created by Inkscape from doc/artwork/triangulate.svg and line-*.svg by
saving as Optimized SVG. On fresh installations you need the scour package
for it:
enabling all possible options in the dialog, saving
cleaning up the <svg> header (removing version, xmlns) in an editor
converting to a style="", keepingviewBox
adding class="m-image"
removing all layers that have display: none
In case of the line-quad-data-expansion*.svg and
line-quad-data-overlap-*.svg, they're all generated from
doc/artwork/line-quad-expansion.svg and doc/artwork/line-quad-overlap.svg,
each time with different layers shown.
The doc/artwork/line-quad-data-other.svg is derived from
doc/artwork/line-quad-data-neighbor.svg by removing the "neighbor" layer and
making the canvas smaller, the doc/artwork/line-quad-data.svg is then derived
from doc/artwork/line-quad-data-other.svg by removing the "other" layer and
making the canvas smaller yet again.