Skip to content

Ariadne on a touch screen: a finger's drag scrolls, and a fling glides against ui.scroll_friction - #1009

Merged
transfix merged 1 commit into
masterfrom
feat/ariadne-touch-scroll
Nov 3, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/ariadne-touch-scroll

Conversation

@transfix

@transfix transfix commented Nov 3, 2026

Copy link
Copy Markdown
Owner

On a phone, content scrolls the way a phone's lists do. A finger drags a window's content along without using the scroll bar. A finger that lifts while moving leaves the content gliding at its speed until friction stops it or it reaches an end. How much friction the glide meets is a state key in the document's tree.

What a finger does now

In touch mode, cvc::gl::TouchScroll runs every frame for every window ImGuiOverlay draws: windows, child panes, text_view:s and drop-down lists.

  • A drag scrolls. This applies when the drag starts on empty space, on text, or on a widget worked by a tap: a button, checkbox, selectable, or a text field not yet being edited. Once the drag passes ImGui's drag threshold, the content follows the finger 1:1 and the widget's press is let go, so it doesn't fire.

  • Which window scrolls. It's the innermost one under the finger that scrolls along the drag's main axis, the same window the mouse wheel would pick.

  • A fling glides. The finger's speed is measured over its last 100 ms, so a finger held still before it lifts leaves no glide. The glide's speed falls as v0 * exp(-friction * t), so it covers v0 / friction whatever the frame rate. It stops at an end. It also stops when something else moves that scroll: the wheel, the scroll bar, or a text_view following new lines.

  • A press on a gliding list stops it, and that press is not a tap on whatever the glide brought under the finger.

  • Drags that keep their old meaning:

    • sliders and drag widgets
    • a field being edited
    • title and menu bars
    • resize grips and borders
    • scroll bars and a table's column borders
    • a scene view
    • the transfer-function editor
    • any widget whose document handles on_drag:, on_drag_start: or on_drag_end:

    cvc::gl::keepTouchDrag() is how an item says it keeps its drag.

  • A mouse is unaffected: it still has the wheel and the scroll bars.

Tuning: in the state tree

These keys sit beside the UI size (cvc::gl::UiSettings). In arigl a document reaches them under its own prefix, viewers.main.ui.*.

key default
<scene>.viewers.<viewer>.ui.touch_scroll 1 0: finger drags scroll nothing
<scene>.viewers.<viewer>.ui.scroll_friction 2 per second. 2 is iOS's normal deceleration, 10 its fast one, higher stops sooner, and 0 glides to the end
  • A document can bind a slider to viewers.main.ui.scroll_friction or state-set it.
  • On a touch screen, the viewer_settings component and arigl's Controls window both show it as Scroll friction. The Controls window uses the new UiSizeControl::scroll_friction.
  • ImGuiOverlay::setScrollFriction and setTouchScrollEnabled are the C++ equivalents.

ARIADNE.md section 5.14 documents all of this.

Checked

  • New test cvcgl_imgui_touch_scroll (bare ImGui context, touches fed through ImGui's own input as the overlay feeds them). It checks:
    • the glide covers v0 / friction at 60 and 144 fps;
    • a drag from a button scrolls 1:1, and the button doesn't fire;
    • a fling at friction 8 glides a quarter as far as at 2;
    • a press stops a glide without tapping;
    • sliders, title bars, fields being edited and keepTouchDrag items keep their drags;
    • a field not yet being edited is scrolled past;
    • a child pane scrolls rather than its window;
    • touch_scroll off turns it off;
    • UiSettings seeds both keys and passes on edits made by others.
  • ariadne_runtime_test: the Controls window shows the friction slider under the UI size, and moving it writes the key.
  • ariadne_loader_test: viewer_settings binds ui.scroll_friction.
  • In emulated phone Chrome, on the stock arigl-web page with a 60-item list (390x844 at 3x, real touch events over the DevTools protocol): the page starts at friction 2, the overlay's key, and the document's slider reads it through viewers.main.ui.scroll_friction.
    • A slow 200 px drag starting on "Item 12" moved the content 190 px: the drag less the 10 px threshold. It counted no tap, and holding still before lifting left no glide.
    • A drag starting on the empty space beside the buttons scrolls too.
    • A 150 px fling glided on after release and stopped by itself. The scroll-bar thumb moved 309 px in total at friction 2 against 130 at 10, set from the Controls window's new Scroll friction row.
    • A tap still taps.
    • A tap mid-glide stopped the list where it was, with no tap counted.
    • A vertical drag starting on the Friction slider moved the slider, not the list.

…s against ui.scroll_friction

In touch mode ImGuiOverlay runs cvc::gl::TouchScroll for every window it draws. A finger
that drags across content (empty space, text, or a widget worked by a tap) scrolls the
innermost window under it that scrolls along the drag, once past the drag threshold. The
widget's press is let go, so it does not fire. A finger that lifts while moving leaves
the content gliding at its speed, measured over its last 100 ms. The glide slows as
exp(-friction * t) until it stops or meets an end, and a press on gliding content stops
it without tapping.

Drags keep their meaning on sliders, drag widgets, fields being edited, title and menu
bars, resize grips, scroll bars, table column borders, scene views, the transfer
function editor and widgets with on_drag: (keepTouchDrag).

The friction (per second, 2 by default: iOS's normal deceleration) and the on/off switch
are the state keys <scene>.viewers.<viewer>.ui.scroll_friction and .ui.touch_scroll
(UiSettings), which a document reaches as viewers.main.ui.* in arigl. On a touch screen
the viewer_settings component and arigl's Controls window (UiSizeControl::scroll_friction)
offer it as Scroll friction. ARIADNE.md section 5.14 describes it.
@transfix
transfix merged commit 4e7b917 into master Nov 3, 2026
22 of 27 checks passed
@transfix
transfix deleted the feat/ariadne-touch-scroll branch November 3, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant