Commit 9aa2c52
applib/menu_layer: touch scrolling and tap activation
Make MenuLayer a Tier-1 touch widget: finger scrolling with live content
offset, and one-step tap activation, on top of the recognizer stack.
MenuLayer carries an 8-byte intrusive registry node (padding shrunk 40->32 so
the struct size is unchanged on every board, guarded by a static assert). It
registers in menu_layer_init and deregisters in menu_layer_deinit; the legacy
2.x path is not registered and falls back to the button bridge. Deinit clears
the gesture target before cancelling, so a widget torn down mid-gesture under a
live window cannot leave the gesture state pointing at freed memory; double
deinit and re-init without deinit are safe.
A pan drives the content offset live (base captured at Started, throttled),
clamped so short content and centre-focused menus cannot scroll into garbage;
the selection index is frozen during the pan (cell height depends on it) and
only changes on liftoff. Liftoff, tap and cancel all run the full
selection_will_change contract and honour every outcome: a veto keeps the old
selection and does nothing, a redirected index selects without activating, and
the requested index selects (tap activates only when the final selection is the
tapped row). This veto is the deliberate fix for the upstream tap that could
select a row the buttons cannot reach. A right swipe activates; a left swipe
emulates BACK.
The tap point arrives in screen coordinates, so it is mapped through the scroll
layer's global frame before hitting the content; without that a menu inset
below the status bar mis-hits every row by the inset height.
Hit-testing rewritten from the reference implementation, extended to run the
selection_will_change veto the reference omitted.
Ref: #1773
Co-authored-by: tsutomu1984-hub <307831185+tsutomu1984-hub@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Vlad Zaytsev <git@vvzvlad.xyz>1 parent 10faf26 commit 9aa2c52
6 files changed
Lines changed: 1403 additions & 5 deletions
0 commit comments