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)
173#if QT_DEPRECATED_SINCE(6, 5)
181void QQuickPinchHandler::setMinimumRotation(
qreal minimumRotation)
197void QQuickPinchHandler::setMaximumRotation(
qreal maximumRotation)
246 m_rotationAxis.
updateValue(rot, m_rotationAxis.m_startValue + rot, delta);
340#if QT_CONFIG(gestures)
345 switch (gesture->gestureType()) {
480 const bool curActive =
active();
490 qCDebug(lcPinchHandler) <<
"activated with starting scale" << m_scaleAxis.m_startValue
491 <<
"target scale" << m_scaleAxis.m_startValue <<
"rotation" << m_rotationAxis.m_startValue
492 <<
"target pos" << m_startTargetPos;
495 qCDebug(lcPinchHandler) <<
"deactivated with scale" << m_scaleAxis.m_activeValue <<
"rotation" << m_rotationAxis.m_activeValue;
502 if (
Q_UNLIKELY(lcPinchHandler().isDebugEnabled())) {
504 qCDebug(lcPinchHandler) <<
Qt::hex <<
p.id() <<
p.sceneGrabPosition() <<
"->" <<
p.scenePosition();
508#if QT_CONFIG(gestures)
512 switch (gesture->gestureType()) {
536 const bool containsReleasedPoints =
event->isEndEvent();
539 auto ep =
event->pointById(
p.id());
545 int numberOfPointsDraggedOverThreshold = 0;
553 double accumulatedCentroidDistance = 0;
554 if (
event->isBeginEvent())
555 m_accumulatedStartCentroidDistance = 0;
557 float accumulatedMovementMagnitude = 0;
559 for (
auto &point : chosenPoints) {
560 if (!containsReleasedPoints) {
561 accumulatedDrag +=
QVector2D(point.scenePressPosition() - point.scenePosition());
595 QVector2D pressCentroidRelativePosition =
QVector2D(point.scenePosition()) - currentCentroid;
596 QVector2D currentCentroidRelativePosition =
QVector2D(point.scenePressPosition()) - pressCentroid;
597 QVector2D centroidRelativeMovement = currentCentroidRelativePosition - pressCentroidRelativePosition;
598 accumulatedMovementMagnitude += centroidRelativeMovement.
length();
600 accumulatedCentroidDistance +=
qreal(pressCentroidRelativePosition.
length());
601 if (
event->isBeginEvent())
602 m_accumulatedStartCentroidDistance +=
qreal((
QVector2D(point.scenePressPosition()) - pressCentroid).length());
607 point.setAccepted(
false);
611 if (
d->dragOverThreshold(point))
612 ++numberOfPointsDraggedOverThreshold;
615 const bool requiredNumberOfPointsDraggedOverThreshold =
626 const qreal centroidMovementDelta =
qreal((currentCentroid - pressCentroid).
length());
628 qreal distanceToCentroidDelta =
qAbs(accumulatedCentroidDistance - m_accumulatedStartCentroidDistance);
629 if (numberOfPointsDraggedOverThreshold >= 1) {
630 if (requiredNumberOfPointsDraggedOverThreshold &&
659 m_scaleAxis.
maximum() / m_scaleAxis.m_startValue);
664 if (m_rotationAxis.
enabled()) {
668 m_startAngles = std::move(newAngles);
671 if (!containsReleasedPoints)
678 const QPointF centroidParentPos =
t->parentItem()->mapFromScene(
centroid().scenePosition());
680 const QPointF centroidStartParentPos =
t->parentItem()->mapFromScene(
centroid().sceneGrabPosition());
686 t->rotation(), m_rotationAxis.
persistentValue() - m_rotationAxis.m_startValue);
716 <<
", distance" << m_startDistance <<
"->" <<
dist
717 <<
", scale" << m_scaleAxis.m_startValue <<
"->" << m_scaleAxis.m_accumulatedValue
718 <<
", rotation" << m_rotationAxis.m_startValue <<
"->" << m_rotationAxis.m_accumulatedValue
720 <<
" from " <<
event->device()->type();
742#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)
QPointF adjustedPosForTransform(const QPointF ¢roid, const QPointF &startPos, const QVector2D &activeTranslatation, qreal startScale, qreal activeScale, qreal startRotation, qreal activeRotation)
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)
FINALQPointF persistentTranslation
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)
\readonly \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()
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 lengthSquared() const noexcept
Returns the squared length of the vector from the origin.
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.
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]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent