In development. It changes without notice.
Topic
Buttons & Gestures
The gestures every screen and both dial styles rely on, over the input sources.
A hold, a tap and a double tap of a button (HoldButton), the gestures of a finger, a list that scrolls with a drag and goes on after a flick, the repeat of a held key, and the rule that a control answers a touch only once it has been shown. The sources are in Input Sources & the Wake Rule.
Files | |
| file | src/ |
| A drawn touch control that acts on its SECOND tap. Pure, host-testable. | |
| file | src/ |
| Hold-button helper: press → hold (with progress) → fire / tap / double-tap. | |
| file | src/ |
| Pure, host-testable touch-gesture state machine. | |
| file | src/ |
| What a touch gesture means to a scrolling list. Pure, host-testable. | |
| file | src/ |
| Phone-like scrolling for a touch list: follow the finger, fling, settle. | |
| file | src/ |
| Hands a gesture recognizer every reading of a pointer's poll, once. | |
| file | src/ |
| Auto-repeat of a held touch control. Pure, host-testable. | |
| file | src/ |
| Drops what was touched before a surface was on the glass. | |
Enumerations | |
| enum class | kleidos:: |
| What one tap on an armed button did. More about kleidos:: | |
| enum class | kleidos:: |
| Discrete gesture emitted when a contact sequence resolves. More about kleidos:: | |
| enum class | kleidos:: |
| What a resolved gesture asks a list to do. More about kleidos:: | |
Functions | |
| constexpr int16_t | kleidos:: |
| Rows a vertical drag scrolls a list: the content follows the finger. | |
| constexpr TouchListHit | kleidos:: |
| Resolve one gesture against one list. | |
| constexpr TouchListWindow | kleidos:: |
Scroll a list's window by rows and keep the selection in sight. | |
| TouchListStep | kleidos:: |
| One frame of a touch list host: the scroller first, then a tap. | |
| template<typename Take> | |
| void | kleidos:: |
Hand take this tick's samples of pointer, oldest first. | |
Variables | |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| Interval between repeats while a hold is young, in ms (8 steps a second). | |
| constexpr uint32_t | kleidos:: |
| Interval between repeats once the hold has lasted long, in ms (~24 a second). | |
| constexpr uint32_t | kleidos:: |
| How long a hold lasts before it repeats at the fast interval, in ms. | |
Enumeration Type Documentation
ArmedTap #
What one tap on an armed button did.
| Enumerator | |
|---|---|
| None | Ignored: a bounce inside kArmMinGapMs; still armed. |
| Armed | The button is now armed (it was resting, or its arm had lapsed). |
| Fired | The confirming tap: act now. The button rests again. |
TouchGesture #
Discrete gesture emitted when a contact sequence resolves.
| Enumerator | |
|---|---|
| None | No gesture resolved on this sample. |
| Tap | Short contact with little travel (select / press). |
| LongPress | Fired once, while still held, after the hold threshold. |
| LongPressRelease | Release following a TouchGesture:: |
| SwipeUp | Dominant upward travel (scroll list up). |
| SwipeDown | Dominant downward travel (scroll list down). |
| SwipeLeft | Dominant leftward travel (next tab). |
| SwipeRight | Dominant rightward travel (previous tab). |
TouchListAction #
What a resolved gesture asks a list to do.
| Enumerator | |
|---|---|
| None | Nothing to do (no gesture, or it landed outside the list). |
| Select | Move the selection to TouchListHit:: |
| Activate | Open / commit TouchListHit:: |
| Scroll | Move the window by TouchListHit:: |
Function Documentation
feedTouchSamples() #
Hand take this tick's samples of pointer, oldest first.
Every reading of a poll not fed before, or else one sample of the pointer's level at nowMs.
- Template Parameters
-
Name Meaning Take A callable taking a TouchSample and returning falseto stop the feed (the rest of the poll's readings are dropped).
- Parameters
-
Name Direction Meaning pointer in The pointer. cursor in, out The screen's cursor: which poll it has taken. nowMs in Current millis32()reading, for the level sample.take in What each sample goes to.
resolveTouchList() #
Resolve one gesture against one list.
Side-effect free and total: every input maps to an action, and anything that cannot be resolved maps to TouchListAction:: rather than to a guess. A swipe is answered before any hit test, so a flick that ends on a row can never open it.
- Parameters
-
Name Direction Meaning ev in The gesture the recognizer resolved this frame. g in Geometry the renderer used for the same frame.
- Returns
- The intent, and the row it refers to.
scrollTouchList() #
Scroll a list's window by rows and keep the selection in sight.
The window moves; the selection does not, unless the window left it behind, in which case it lands on the nearest visible row (the first when the window moved past it, the last when it moved above it). A list that fits never scrolls. The window is clamped to [0, count - visible], so a flick past an end settles there instead of wrapping.
Store the returned top as the list's window: the shared reconcile (ui::) then keeps it, because the selection is inside it.
- Parameters
-
Name Direction Meaning rows in Rows to scroll (the rowsof a ui::TouchListHit). scrollTop in The window's first row before the scroll. selected in The selection before the scroll. count in Rows the list holds. visible in Rows one windowful holds.
- Returns
- The new window top and selection.
stepTouchList() #
One frame of a touch list host: the scroller first, then a tap.
A drag moves the window under the finger and is never a tap; a release flings and settles. A tap then takes the shared list grammar (resolveTouchList) against view's window: a row selects (and the window follows the selection again), the selected row activates, a tap on the peek sliver glides a windowful on. Call it every frame.
- Parameters
-
Name Direction Meaning scroller in, out The host's scroller. gestures in The host's recognizer, after this frame's sample. ev in What the recognizer resolved on this sample. nowMs in Monotonic time of the sample. geom in The list (its scrollTopis ignored:view'sis used).view in, out The window the host draws.
- Returns
- The tap's outcome and whether the window moved.
touchScrollRows() #
Rows a vertical drag scrolls a list: the content follows the finger.
A drag of dy pixels moves the list by the nearest whole number of rows, at least one, so a short flick still scrolls. Dragging up (negative dy) brings later rows into view.
- Parameters
-
Name Direction Meaning dy in Vertical travel of the drag (positive = finger moved down). rowH in One row's height in px.
- Returns
- Signed rows: positive shows later rows, negative earlier ones; 0 for no travel.
Variable Documentation
kArmMinGapMs #
Earliest a confirming tap may follow the arming one, in ms. Closer than this it is the same contact bouncing, not a decision; it matches the multi-tap window the button boards use to tell a double tap from two.
kArmWindowMs #
How long an armed button waits for its confirming tap, in ms, before it rests again on its own.