Add more information for pinch gestures on mobile#15092
Open
brentfpage wants to merge 2 commits intolibsdl-org:mainfrom
Open
Add more information for pinch gestures on mobile#15092brentfpage wants to merge 2 commits intolibsdl-org:mainfrom
brentfpage wants to merge 2 commits intolibsdl-org:mainfrom
Conversation
Contributor
|
This breaks binary compatibility, because the windowID field of SDL_PinchFingerEvent changes offset. An app compiled against an older SDL would get a garbage window id if dynamically linked to an SDL library with this patch. |
Author
|
Does the newest commit fix the issue? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SDL_PinchFingerEventstruct defined in include/SDL3/SDL_events.h has been expanded to include the midpoint of the finger positions comprising the pinch gesture (focus) as well as the x and y displacements between the finger positions (span). Including this information allows a programmer to implement a zoom in response to the gesture that a.) keepsfocuscentered on the screen and that b.) zooms the y axis more rapidly if the user's fingers are more vertically aligned.SDL_SendPinchin src/events/(SDL_touch_c.h and SDL_touch.c) accommodate this newfocusandspaninformationfocusandspaninfo is forwarded on to downstream functions in addition toscale, while previously onlyscalewas forwarded. This forwarding function is specificallyonNativePinchUpdateonNativePinchUpdatetoSDL_SendPinchhas been expanded to includefocusandspanSDL_SendPinchin non-Android user interface frameworkshave been adjusted so that
event.pinch.focus_x,event.pinch.focus_y,event.pinch.span_x, andevent.pinch.span_yare set to zero bySDL_SendPinch. Existing uses of pinch events will only involveevent.pinch.scale, so these changes are non-breaking. On the other hand, it may be surprising to a programmer thatfocusandspanare zero considering that they exist. I am unfamiliar with these UI frameworks, so won't attempt to addfocusandspaninfo to theirSDL_SendPinchcalls, but some glances at these frameworks' APIs suggests this would be possible to some extent.Coordinate system transformations:
In SDLSurface.java, the Android gesture detector returns
spanandfocusinfo in screen pixel coordinates. For consistency with what is done in that same file for simple touch events, I convertspanandfocusto normalized screen coordinates before passing them on toSDL_SendPinch/onNativePinchUpdate. But, I convert them back to pixel screen coordinates inSDL_SendPinch, again to be consistent with what is done for touch events (inSDL_SendTouch)To be precise, the pinch info transformations are very nearly inverses of one another, but for reasons I'm unfamiliar with, the original conversion to normalized screen coordinates divides by (pixel_count - 1) instead of (pixel_count), while the subsequent conversion back to screen pixel coordinates multiplies by pixel_count. The final change in coordinates by a multiplicative factor pixel_count/(pixel_count - 1) is minuscule for all devices.