diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-24 08:50:22 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-24 08:53:31 +0000 |
commit | 743d0132fe006699dd33e5b4254a36f4e2ec7f9f (patch) | |
tree | 6c87a3174b94250132feac8c51e956990fa1fda1 /src/quicktemplates2/qquickdrawer.cpp | |
parent | ce87c5be886d4c24045f7bdbaaf93fda3eed366f (diff) |
QQuickDrawer: don't jump when dragging open
Typically drawer's drag margin is so small that one can barely notice
that it jumps when dragging begins. On systems with larger start drag
distance, or when drawer's drag margin is manually increased, the jump
was noticeable and disturbing.
Unfortunately several tests had to be adjusted accordingly, because
they were assuming that pressing at the edge and then dragging in the
middle would immediately snap the drawer. Now the tests are sending
a press at the edge, first moving past the start drag distance, and
then moving to the actual tested position.
Change-Id: Id8badf256fd4dd51f34db76ebe03bf6b15203cd9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdrawer.cpp')
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index 0c53093b..b5b4100d 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -425,10 +425,18 @@ bool QQuickDrawerPrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEvent *ev if (!grabber || !grabber->keepMouseGrab()) { popupItem->grabMouse(); popupItem->setKeepMouseGrab(true); - offset = qMin<qreal>(0.0, positionAt(movePoint) - position); + offset = positionAt(movePoint) - position; + + // don't jump when dragged open + if (offset > 0 && position > 0 && !popupItem->contains(popupItem->mapFromScene(movePoint))) + offset = 0; } } + // limit/reset the offset to the edge of the drawer when pushed from the outside + if (qFuzzyCompare(position, 1.0) && !popupItem->contains(popupItem->mapFromScene(movePoint))) + offset = 0; + if (popupItem->keepMouseGrab()) q->setPosition(positionAt(movePoint) - offset); event->accept(); |