From 47479c0e969a3b3d220c77b8bb7cb8f2d58c07ae Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 24 Apr 2017 08:51:47 +0200 Subject: DragHandler: allow parent to be different from target The most obvious way to implement a Slider is to allow dragging the knob - as on a real-world physical sliding potentiometer. But to make it easier on a touchscreen, it should be possible to touch anywhere along the slider's travel, as on a QtQuick.Controls 2 Slider. For that purpose, we need to respond to events within the bounds of one Item while actually dragging a different Item (the knob). It's similar to the way that PinchHandler can handle pinch gestures within one Item while transforming another (which may be too small to get both fingers inside). Change-Id: Iac9a5f11a7a45e22d93fe52bf62d157c48d72d3d Reviewed-by: Shawn Rutledge --- src/quick/handlers/qquickdraghandler_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/quick/handlers/qquickdraghandler_p.h') diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h index a75ea6f2c7..54fef697f7 100644 --- a/src/quick/handlers/qquickdraghandler_p.h +++ b/src/quick/handlers/qquickdraghandler_p.h @@ -112,14 +112,16 @@ Q_SIGNALS: protected: bool wantsEventPoint(QQuickEventPoint *point) override; + void onActiveChanged() override; void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) override; private: void ungrab(); void enforceAxisConstraints(QPointF *localPos); + void initializeTargetStartPos(QQuickEventPoint *point); private: - QPointF m_startPos; + QPointF m_targetStartPos; QPointF m_translation; QQuickDragAxis m_xAxis; QQuickDragAxis m_yAxis; -- cgit v1.2.3