5#include <private/qquickwindow_p.h>
6#include <private/qquickmultipointhandler_p_p.h>
63QPointF QQuickDragHandler::targetCentroidPosition()
87 }
else if (m_pressTargetPos.
isNull()) {
88 m_pressTargetPos = targetCentroidPosition();
114 if (
mode == m_snapMode)
117 emit snapModeChanged();
123 const bool curActive =
active();
137 m_pressedInsideTarget =
false;
156#if QT_CONFIG(gestures)
170 event->setAccepted(
true);
177 accumulatedDragDelta.
setX(0);
179 accumulatedDragDelta.
setY(0);
185 qreal minAngle = 361;
186 qreal maxAngle = -361;
187 bool allOverThreshold = !
event->isEndEvent();
190 if (
event->isBeginEvent())
194 if (!allOverThreshold)
196 auto point =
event->pointById(
p.id());
198 chosenPoints << *point;
202 QVector2D accumulatedDragDelta =
QVector2D(point->scenePosition() - point->scenePressPosition());
206 if (
qAbs(accumulatedDragDelta.
x()) >
qAbs(accumulatedDragDelta.
y()))
207 accumulatedDragDelta.
setY(0);
208 accumulatedDragDelta.
setX(0);
213 if (
qAbs(accumulatedDragDelta.
y()) >
qAbs(accumulatedDragDelta.
x()))
214 accumulatedDragDelta.
setX(0);
215 accumulatedDragDelta.
setY(0);
217 qreal angle = std::atan2(accumulatedDragDelta.
y(), accumulatedDragDelta.
x()) * 180 /
M_PI;
218 bool overThreshold = d_func()->dragOverThreshold(accumulatedDragDelta);
219 qCDebug(lcDragHandler) <<
"movement" << accumulatedDragDelta <<
"angle" <<
angle <<
"of point" << point
220 <<
"pressed @" << point->scenePressPosition() <<
"over threshold?" << overThreshold;
223 if (allOverThreshold && !overThreshold)
224 allOverThreshold =
false;
226 if (
event->isBeginEvent()) {
233 m_pressTargetPos = targetCentroidPosition();
242 if (allOverThreshold) {
243 qreal angleDiff = maxAngle - minAngle;
245 angleDiff = 360 - angleDiff;
246 qCDebug(lcDragHandler) <<
"angle min" << minAngle <<
"max" << maxAngle <<
"range" << angleDiff;
252 const QPointF newTargetTopLeft = targetCentroidPosition() - m_pressTargetPos;
254 const QPointF targetXformOrigin = newTargetTopLeft + xformOrigin;
259 pos.setX(targetItemPos.
x());
261 pos.setY(targetItemPos.
y());
262 enforceAxisConstraints(&
pos);
267void QQuickDragHandler::enforceAxisConstraints(
QPointF *localPos)
294 qCDebug(lcDragHandler) <<
"translation: delta" << delta
371#include "moc_qquickdraghandler_p.cpp"
The QEventPoint class provides information about a point in a QPointerEvent.
qsizetype size() const noexcept
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
constexpr void setY(qreal y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr void setX(qreal x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
A base class for pointer events.
GrabTransition
This enum represents a transition of exclusive or passive grab from one object (possibly nullptr) to ...
static bool isTouchEvent(const QPointerEvent *ev)
static bool isMouseEvent(const QPointerEvent *ev)
void onActiveChanged(bool active, qreal initActiveValue)
void updateValue(qreal activeValue, qreal accumulatedValue, qreal delta=0)
qreal persistentValue() const
void setSnapMode(QQuickDragHandler::SnapMode mode)
void setPersistentTranslation(const QVector2D &trans)
@ SnapIfPressedOutsideTarget
QVector2D activeTranslation
void translationChanged(QVector2D delta)
void onActiveChanged() override
bool wantsPointerEvent(QPointerEvent *event) override
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
void setActiveTranslation(const QVector2D &trans)
FINALQVector2D persistentTranslation
void handlePointerEventImpl(QPointerEvent *event) override
This function can be overridden to implement whatever behavior a specific subclass is intended to hav...
void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point) override
Notification that the grab has changed in some way which is relevant to this handler.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setKeepTouchGrab(bool)
Sets whether the touch points grabbed by this item should remain exclusively with this item.
Q_INVOKABLE QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in item's coordinate system to the equivalent point within this item's coordinat...
QPointF mapFromScene(const QPointF &point) const
Maps the given point in the scene's coordinate system to the equivalent point within this item's coor...
virtual Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
QQuickItem * parentItem() const
void setKeepMouseGrab(bool)
Sets whether the mouse input should remain exclusively with this item.
bool isAncestorOf(const QQuickItem *child) const
Returns true if this item is an ancestor of child (i.e., if this item is child's parent,...
QPointF transformOriginPoint
void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point) override
Notification that the grab has changed in some way which is relevant to this handler.
void handlePointerEventImpl(QPointerEvent *event) override
This function can be overridden to implement whatever behavior a specific subclass is intended to hav...
QList< QQuickHandlerPoint > & currentPoints()
bool wantsPointerEvent(QPointerEvent *event) override
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
void onActiveChanged() override
QQuickHandlerPoint centroid
bool grabPoints(QPointerEvent *event, const QVector< QEventPoint > &points)
void moveTarget(QPointF pos)
QQuickItem * parentItem() const
\qmlproperty Item QtQuick::PointerHandler::parent
void setPassiveGrab(QPointerEvent *event, const QEventPoint &point, bool grab=true)
Acquire or give up a passive grab of the given point, according to the grab state.
QPointerEvent * currentEvent()
void setActive(bool active)
The QVector2D class represents a vector or vertex in 2D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLint GLsizei GLsizei height
static QT_BEGIN_NAMESPACE const qreal DragAngleToleranceDegrees
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent