Gesture API
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
We want support for common touchpad/touchscreen gestures, like pinch-to-zoom. Here are some questions:
- should we use platform-native gesture recognizers or roll our own?
- should we require widgets to pre-register for certain gestures, or should we just send a bunch of gesture events pro-actively?
- should we swallow or delay the touch events that potentially lead to a gesture?
One additional question with implications for #1965 : can we treat the typical button-like mouse interactions in the same framework as gestures. In existing druid widgets, this is commonly handled by listening for `MouseDown`, calling `ctx.set_active`, changing the `paint` style based on `ctx.is_active` and `ctx.is_hot`, etc. If our gesture support can handle this pattern too, then we could (1) eliminate some duplication and (2) start thinking of mouse events as "low-level" events that most widgets don't need to interact with manually.
## Platform-native vs roll our own
The advantages of platform-native gestures are:
- potentially less work for the initial implementation
- has the native behavior
Advantages of roll-our-own:
- don't need to implement it on every platform
- at least on gtk and macOS, the native gestures are scoped to native widgets/`NSView`s, so it would take some effort to make them act as though they were scoped to druid widgets
- can support custom gestures
## Pre-register vs pro-actively
I think we should require pre-registration. There are lots of potential gestures, especially considering various configuration options (2-finger vs 3-finger swipe, etc). The APIs on gtk and macOS are fairly similar in this respect: you create some gesture object describing the gesture you want to recognize (`gtk::Gesture` or `NSGestureRecognizer`) and then register it with a widget.
## Swallow/delay touch events
This is configurable on macOS: I think you can change it by setting fields on the `NSGestureRecognizer`. On gtk, it appears like you just get all the events, but it does provide ways to check which events are being used for gestures so we could do our own delaying/swallowing. If we roll our own, we can do whatever we want, obviously.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the platform approaches mentioned in the issue, including gtk::Gesture and NSGestureRecognizer, with the existing MouseDown, ctx.set_active, ctx.is_active, and ctx.is_hot widget pattern. A complete result needs a settled gesture API and explicit decisions about registration, event swallowing or delay, and whether mouse interactions share that framework.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100