5#include <QtQml/qqmlinfo.h>
6#include <QtQuick/qquickwindow.h>
7#include <private/qsgadaptationlayer_p.h>
8#include <private/qquickitem_p.h>
9#include <private/qguiapplication_p.h>
10#include <private/qquickmultipointhandler_p_p.h>
11#include <private/qquickwindow_p.h>
15#include <qpa/qplatformnativeinterface.h>
69#if QT_DEPRECATED_SINCE(6, 5)
77void QQuickPinchHandler::setMinimumScale(
qreal minimumScale)
93void QQuickPinchHandler::setMaximumScale(
qreal maximumScale)
172#if QT_DEPRECATED_SINCE(6, 5)
180void QQuickPinchHandler::setMinimumRotation(
qreal minimumRotation)
196void QQuickPinchHandler::setMaximumRotation(
qreal maximumRotation)
245 m_rotationAxis.
updateValue(rot, m_rotationAxis.m_startValue + rot, delta);
338#if QT_CONFIG(gestures)
343 switch (gesture->gestureType()) {
478 const bool curActive =
active();
488 qCDebug(lcPinchHandler) <<
"activated with starting scale" << m_scaleAxis.m_startValue
489 <<
"rotation" << m_rotationAxis.m_startValue
490 <<
"target pos" << m_startTargetPos;
493 qCDebug(lcPinchHandler) <<
"deactivated with scale" << m_scaleAxis.m_activeValue <<
"rotation" << m_rotationAxis.m_activeValue;
500 if (
Q_UNLIKELY(lcPinchHandler().isDebugEnabled())) {
502 qCDebug(lcPinchHandler) <<
Qt::hex <<
p.id() <<
p.sceneGrabPosition() <<
"->" <<
p.scenePosition();
506#if QT_CONFIG(gestures)
510 switch (gesture->gestureType()) {
534 const bool containsReleasedPoints =
event->isEndEvent();
535 QVector<QEventPoint> chosenPoints;
537 auto ep =
event->pointById(
p.id());
543 int numberOfPointsDraggedOverThreshold = 0;
551 double accumulatedCentroidDistance = 0;
552 if (
event->isBeginEvent())
553 m_accumulatedStartCentroidDistance = 0;
555 float accumulatedMovementMagnitude = 0;
557 for (
auto &point : chosenPoints) {
558 if (!containsReleasedPoints) {
559 accumulatedDrag +=
QVector2D(point.scenePressPosition() - point.scenePosition());
593 QVector2D pressCentroidRelativePosition =
QVector2D(point.scenePosition()) - currentCentroid;
594 QVector2D currentCentroidRelativePosition =
QVector2D(point.scenePressPosition()) - pressCentroid;
595 QVector2D centroidRelativeMovement = currentCentroidRelativePosition - pressCentroidRelativePosition;
596 accumulatedMovementMagnitude += centroidRelativeMovement.
length();
598 accumulatedCentroidDistance +=
qreal(pressCentroidRelativePosition.length());
599 if (
event->isBeginEvent())
600 m_accumulatedStartCentroidDistance +=
qreal((
QVector2D(point.scenePressPosition()) - pressCentroid).length());
605 point.setAccepted(
false);
609 if (
d->dragOverThreshold(point))
610 ++numberOfPointsDraggedOverThreshold;
613 const bool requiredNumberOfPointsDraggedOverThreshold =
624 const qreal centroidMovementDelta =
qreal((currentCentroid - pressCentroid).
length());
626 qreal distanceToCentroidDelta =
qAbs(accumulatedCentroidDistance - m_accumulatedStartCentroidDistance);
627 if (numberOfPointsDraggedOverThreshold >= 1) {
628 if (requiredNumberOfPointsDraggedOverThreshold &&
629 avgDrag.lengthSquared() >= dragThresholdSquared && accumulatedMovementMagnitude <
dragThreshold) {
657 m_scaleAxis.
maximum() / m_scaleAxis.m_startValue);
662 if (m_rotationAxis.
enabled()) {
663 QVector<PointData> newAngles =
angles(
centroid().scenePosition());
666 m_startAngles = std::move(newAngles);
669 if (!containsReleasedPoints)
676 const QPointF centroidParentPos =
t->parentItem()->mapFromScene(
centroid().scenePosition());
678 const QPointF centroidStartParentPos =
t->parentItem()->mapFromScene(
centroid().sceneGrabPosition());
684 t->rotation(), m_rotationAxis.
persistentValue() - m_rotationAxis.m_startValue);
714 <<
", distance" << m_startDistance <<
"->" <<
dist
715 <<
", scale" << m_scaleAxis.m_startValue <<
"->" << m_scaleAxis.m_accumulatedValue
716 <<
", rotation" << m_rotationAxis.m_startValue <<
"->" << m_rotationAxis.m_accumulatedValue
718 <<
" from " <<
event->device()->type();
740#include "moc_qquickpinchhandler_p.cpp"
qsizetype size() const noexcept
The QNativeGestureEvent class contains parameters that describe a gesture event. \inmodule QtGui.
\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.
A base class for pointer events.
void onActiveChanged(bool active, qreal initActiveValue)
void updateValue(qreal activeValue, qreal accumulatedValue, qreal delta=0)
qreal persistentValue() const
void setMinimum(qreal minimum)
void setMaximum(qreal maximum)
QPointF scenePressPosition
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void handlePointerEventImpl(QPointerEvent *event) override
This function can be overridden to implement whatever behavior a specific subclass is intended to hav...
QQuickHandlerPoint & mutableCentroid()
Returns a modifiable reference to the point that will be returned by the \l centroid property.
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
qreal averageTouchPointDistance(const QPointF &ref)
QQuickHandlerPoint centroid
void acceptPoints(const QVector< QEventPoint > &points)
QVector< PointData > angles(const QPointF &ref) const
bool grabPoints(QPointerEvent *event, const QVector< QEventPoint > &points)
static qreal averageAngleDelta(const QVector< PointData > &old, const QVector< PointData > &newAngles)
void rotationChanged(qreal delta)
void minimumScaleChanged()
void setPersistentScale(qreal scale)
\qmlsignal QtQuick::PinchHandler::scaleChanged(qreal delta)
void scaleChanged(qreal delta)
void maximumRotationChanged()
void setActiveScale(qreal scale)
\readonly \qmlproperty real QtQuick::PinchHandler::activeScale
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 handlePointerEventImpl(QPointerEvent *event) override
This function can be overridden to implement whatever behavior a specific subclass is intended to hav...
QPointF activeTranslation
void onActiveChanged() override
\qmlpropertygroup QtQuick::PinchHandler::xAxis \qmlproperty real QtQuick::PinchHandler::xAxis....
void setPersistentRotation(qreal rot)
\qmlproperty real QtQuick::PinchHandler::persistentRotation
void setPersistentTranslation(const QPointF &trans)
\qmlsignal QtQuick::PinchHandler::translationChanged(QVector2D delta)
void setActiveRotation(qreal rot)
\qmlsignal QtQuick::PinchHandler::rotationChanged(qreal delta)
void translationChanged(QVector2D delta)
void minimumRotationChanged()
QPointF persistentTranslation
void maximumScaleChanged()
Qt::MouseButtons acceptedButtons
bool parentContains(const QEventPoint &point) const
Returns true if margin() > 0 and point is within the margin beyond QQuickItem::boundingRect(),...
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.
void setActive(bool active)
The QVector2D class represents a vector or vertex in 2D space.
float length() const noexcept
Returns the length of the vector from the origin.
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 float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr T qAbs(const T &t)
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLenum GLenum GLenum scale
std::uniform_real_distribution dist(1, 2.5)
[2]