Kleidos API Search

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.

See also
Input Sources & the Wake Rule, User Interface

Files

file src/ui/input/armed_button.h
A drawn touch control that acts on its SECOND tap. Pure, host-testable.
file src/ui/input/hold_button.h
Hold-button helper: press → hold (with progress) → fire / tap / double-tap.
file src/ui/input/touch_gesture_recognizer.h
Pure, host-testable touch-gesture state machine.
file src/ui/input/touch_list_nav.h
What a touch gesture means to a scrolling list. Pure, host-testable.
file src/ui/input/touch_list_scroller.h
Phone-like scrolling for a touch list: follow the finger, fling, settle.
file src/ui/input/touch_reading_feed.h
Hands a gesture recognizer every reading of a pointer's poll, once.
file src/ui/input/touch_repeat.h
Auto-repeat of a held touch control. Pure, host-testable.
file src/ui/input/touch_shown_gate.h
Drops what was touched before a surface was on the glass.

Classes

class kleidos::ui::ArmedButton
Arm state of one drawn touch control that fires on its second tap. More about kleidos::ui::ArmedButton
struct kleidos::HoldButton
Frame-driven hold/tap/double-tap detector for a single ButtonInput. More about kleidos::HoldButton
struct kleidos::ui::TouchSample
One raw touch reading fed to the recognizer each tick. More about kleidos::ui::TouchSample
struct kleidos::ui::TouchGestureConfig
Recognition tunables. More about kleidos::ui::TouchGestureConfig
struct kleidos::ui::TouchGestureEvent
Resolved gesture plus the point it acts on. More about kleidos::ui::TouchGestureEvent
class kleidos::ui::TouchGestureRecognizer
Stateful touch-gesture recognizer (one active contact at a time). More about kleidos::ui::TouchGestureRecognizer
struct kleidos::ui::TouchListHit
One resolved intent, and the row it refers to. More about kleidos::ui::TouchListHit
struct kleidos::ui::TouchListGeom
The list as its renderer laid it out this frame. More about kleidos::ui::TouchListGeom
struct kleidos::ui::TouchListWindow
Where a list's window and selection sit after a scroll. More about kleidos::ui::TouchListWindow
struct kleidos::ui::TouchScrollGeometry
The list a scroller moves: its row pitch, its rows and one windowful. More about kleidos::ui::TouchScrollGeometry
class kleidos::ui::TouchListScroller
Drag, fling and settle state of one touch list. More about kleidos::ui::TouchListScroller
struct kleidos::ui::TouchListView
The window a scrolling touch list draws, kept by its host. More about kleidos::ui::TouchListView
struct kleidos::ui::TouchListStep
What one frame of a scrolling touch list did. More about kleidos::ui::TouchListStep
struct kleidos::ui::TouchFeedCursor
Which poll of a pointer a screen has taken the readings of. More about kleidos::ui::TouchFeedCursor
class kleidos::ui::TouchRepeat
The repeat schedule of one held control. More about kleidos::ui::TouchRepeat
class kleidos::ui::TouchShownGate
Keeps contacts made before a surface was shown from reaching it. More about kleidos::ui::TouchShownGate

Enumerations

enum class kleidos::ui::ArmedTap : uint8_t { kleidos::ui::ArmedTap::None , kleidos::ui::ArmedTap::Armed , kleidos::ui::ArmedTap::Fired }
What one tap on an armed button did. More about kleidos::ui::ArmedTap
enum class kleidos::ui::TouchGesture : uint8_t { kleidos::ui::TouchGesture::None, kleidos::ui::TouchGesture::Tap, kleidos::ui::TouchGesture::LongPress, kleidos::ui::TouchGesture::LongPressRelease, kleidos::ui::TouchGesture::SwipeUp, kleidos::ui::TouchGesture::SwipeDown, kleidos::ui::TouchGesture::SwipeLeft, kleidos::ui::TouchGesture::SwipeRight }
Discrete gesture emitted when a contact sequence resolves. More about kleidos::ui::TouchGesture
enum class kleidos::ui::TouchListAction : uint8_t { kleidos::ui::TouchListAction::None , kleidos::ui::TouchListAction::Select , kleidos::ui::TouchListAction::Activate , kleidos::ui::TouchListAction::Scroll }
What a resolved gesture asks a list to do. More about kleidos::ui::TouchListAction

Functions

constexpr int16_tkleidos::ui::touchScrollRows (int16_t dy, int16_t rowH)
Rows a vertical drag scrolls a list: the content follows the finger.
constexpr TouchListHitkleidos::ui::resolveTouchList (const TouchGestureEvent &ev, const TouchListGeom &g)
Resolve one gesture against one list.
constexpr TouchListWindowkleidos::ui::scrollTouchList (int16_t rows, uint16_t scrollTop, uint16_t selected, uint16_t count, uint8_t visible)
Scroll a list's window by rows and keep the selection in sight.
TouchListStepkleidos::ui::stepTouchList (TouchListScroller &scroller, const TouchGestureRecognizer &gestures, const TouchGestureEvent &ev, uint32_t nowMs, const TouchListGeom &geom, TouchListView &view)
One frame of a touch list host: the scroller first, then a tap.
template<typename Take>
voidkleidos::ui::feedTouchSamples (const TouchInput &pointer, TouchFeedCursor &cursor, uint32_t nowMs, Take &&take)
Hand take this tick's samples of pointer, oldest first.

Variables

constexpr uint32_tkleidos::ui::kArmMinGapMs
constexpr uint32_tkleidos::ui::kArmWindowMs
constexpr uint32_tkleidos::ui::kRepeatSlowMs
Interval between repeats while a hold is young, in ms (8 steps a second).
constexpr uint32_tkleidos::ui::kRepeatFastMs
Interval between repeats once the hold has lasted long, in ms (~24 a second).
constexpr uint32_tkleidos::ui::kRepeatFastAfterMs
How long a hold lasts before it repeats at the fast interval, in ms.

Back to the top

Enumeration Type Documentation

ArmedTap #

enum class kleidos::ui::ArmedTap : uint8_t

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 #

enum class kleidos::ui::TouchGesture : uint8_t

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::LongPress.

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 #

enum class kleidos::ui::TouchListAction : uint8_t

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::index.

Activate 

Open / commit TouchListHit::index (it was selected).

Scroll 

Move the window by TouchListHit::rows (see scrollTouchList).

Back to the top

Function Documentation

feedTouchSamples() #

template<typename Take>
void kleidos::ui::feedTouchSamples(const TouchInput & pointer, TouchFeedCursor & cursor, uint32_t nowMs, Take && take)

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
NameMeaning
TakeA callable taking a TouchSample and returning false to stop the feed (the rest of the poll's readings are dropped).
Parameters
NameDirectionMeaning
pointerinThe pointer.
cursorin, outThe screen's cursor: which poll it has taken.
nowMsinCurrent millis32() reading, for the level sample.
takeinWhat each sample goes to.

resolveTouchList() #

TouchListHit kleidos::ui::resolveTouchList(const TouchGestureEvent & ev, const TouchListGeom & g)
constexpr

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::None 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
NameDirectionMeaning
evinThe gesture the recognizer resolved this frame.
ginGeometry the renderer used for the same frame.
Returns
The intent, and the row it refers to.

scrollTouchList() #

TouchListWindow kleidos::ui::scrollTouchList(int16_t rows, uint16_t scrollTop, uint16_t selected, uint16_t count, uint8_t visible)
constexpr

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::scrollWindowTop) then keeps it, because the selection is inside it.

Parameters
NameDirectionMeaning
rowsinRows to scroll (the rows of a ui::TouchListHit).
scrollTopinThe window's first row before the scroll.
selectedinThe selection before the scroll.
countinRows the list holds.
visibleinRows one windowful holds.
Returns
The new window top and selection.

stepTouchList() #

TouchListStep kleidos::ui::stepTouchList(TouchListScroller & scroller, const TouchGestureRecognizer & gestures, const TouchGestureEvent & ev, uint32_t nowMs, const TouchListGeom & geom, TouchListView & view)

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
NameDirectionMeaning
scrollerin, outThe host's scroller.
gesturesinThe host's recognizer, after this frame's sample.
evinWhat the recognizer resolved on this sample.
nowMsinMonotonic time of the sample.
geominThe list (its scrollTop is ignored: view's is used).
viewin, outThe window the host draws.
Returns
The tap's outcome and whether the window moved.

touchScrollRows() #

int16_t kleidos::ui::touchScrollRows(int16_t dy, int16_t rowH)
constexpr

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
NameDirectionMeaning
dyinVertical travel of the drag (positive = finger moved down).
rowHinOne row's height in px.
Returns
Signed rows: positive shows later rows, negative earlier ones; 0 for no travel.

Back to the top

Variable Documentation

kArmMinGapMs #

uint32_t kleidos::ui::kArmMinGapMs
inlineconstexpr

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 #

uint32_t kleidos::ui::kArmWindowMs
inlineconstexpr

How long an armed button waits for its confirming tap, in ms, before it rests again on its own.

Back to the top