aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickflickablebehavior_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-09-10 15:26:56 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-09-12 18:54:12 +0200
commit3df387d63421f09533ab72e2a73fb5d259693120 (patch)
tree6de0851db68e73b442523a39054fae88ec399261 /src/quick/items/qquickflickablebehavior_p.h
parent90a706dffb944e7d18b8b199b1cea68633e2b172 (diff)
PathView: reduce velocity by linear decay model if release is delayed
That is, from the time between the last mouse move event to the mouse release, the velocity will be linearly discounted/depreciated until it reaches 0 at QML_FLICK_VELOCITY_DECAY_TIME, which is currently 50 ms. 50 ms seems like a long time if the user meant to flick and release immediately (in practice it might be more like 4 ms), and also a short time if the user meant to "dwell" before releasing. If we try to translate the fake physics to real physics, this would be approximately equivalent to saying that if you slide a flat plate on an air hockey table with one finger, and then stop suddenly, its momentum _would_ cause it to keep moving under your finger for up to 50ms (except that it doesn't, because our timeline doesn't "tick" until after the release); and yet if you hold it for longer than 50ms, it will stop right on the spot. That's not quite realistic, but feels OK for fake physics (like the rest of the physics in Qt Quick). Also add the qt.quick.pathview logging category, which will just log the velocity calculations for now (but is intended for anything else in PathView that seems worth logging later on). Task-number: QTBUG-77173 Task-number: QTBUG-59052 Change-Id: Ie86f18d3b3305874b698c848290e0fd3beda94de Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/items/qquickflickablebehavior_p.h')
-rw-r--r--src/quick/items/qquickflickablebehavior_p.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/quick/items/qquickflickablebehavior_p.h b/src/quick/items/qquickflickablebehavior_p.h
index ae7fe71359..fbce62f075 100644
--- a/src/quick/items/qquickflickablebehavior_p.h
+++ b/src/quick/items/qquickflickablebehavior_p.h
@@ -93,6 +93,11 @@
#define QML_FLICK_MULTIFLICK_THRESHOLD 1250
#endif
+// If the time (ms) between the last move and the release exceeds this, then velocity will be zero.
+#ifndef QML_FLICK_VELOCITY_DECAY_TIME
+#define QML_FLICK_VELOCITY_DECAY_TIME 50
+#endif
+
// Multiflick acceleration minimum contentSize/viewSize ratio
#ifndef QML_FLICK_MULTIFLICK_RATIO
#define QML_FLICK_MULTIFLICK_RATIO 10