Repository navigation
Ariadne on a touch screen: a finger's drag scrolls, and a fling glides against ui.scroll_friction - #1009
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::TouchScrollruns every frame for every windowImGuiOverlaydraws: 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 coversv0 / frictionwhatever the frame rate. It stops at an end. It also stops when something else moves that scroll: the wheel, the scroll bar, or atext_viewfollowing 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:
on_drag:,on_drag_start:oron_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.*.<scene>.viewers.<viewer>.ui.touch_scroll10: finger drags scroll nothing<scene>.viewers.<viewer>.ui.scroll_friction2viewers.main.ui.scroll_frictionorstate-setit.viewer_settingscomponent and arigl's Controls window both show it as Scroll friction. The Controls window uses the newUiSizeControl::scroll_friction.ImGuiOverlay::setScrollFrictionandsetTouchScrollEnabledare the C++ equivalents.ARIADNE.md section 5.14 documents all of this.
Checked
cvcgl_imgui_touch_scroll(bare ImGui context, touches fed through ImGui's own input as the overlay feeds them). It checks:v0 / frictionat 60 and 144 fps;keepTouchDragitems keep their drags;touch_scrolloff turns it off;UiSettingsseeds 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_settingsbindsui.scroll_friction.viewers.main.ui.scroll_friction.