9#include <QNativeGestureEvent>
24 return event->type() == QEvent::NativeGesture;
29 QNativeGestureEvent *gevent =
static_cast<QNativeGestureEvent *
>(event);
30 if (gevent->gestureType() == Qt::SmartZoomNativeGesture) {
38 }
else if (gevent->gestureType() == Qt::ZoomNativeGesture &&
flags().testFlag(
ZoomEnabled)) {
42 const qreal delta = 1.0 + gevent->value();
46 if (qAbs(delta) > 1.2 || qAbs(delta) < 0.8) {
55 const qreal nextExpectedZoom =
57 if (newZoom >= nextExpectedZoom) {
60 }
else if (delta < 1.0) {
61 const qreal prevExpectedZoom =
63 if (newZoom <= prevExpectedZoom) {
74 }
else if (gevent->gestureType() == Qt::RotateNativeGesture &&
flags().testFlag(
RotationEnabled)) {
79 const qreal rotationAngle = [&]() {
94 if (gevent->gestureType() == Qt::PanNativeGesture &&
flags().testFlag(
PanEnabled)) {
95#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
110 controller->
pan(-canvasOffset);
KisCoordinatesConverter * coordinatesConverter
const KoViewConverter * viewConverter() const override
void rotateCanvas(qreal angle, const std::optional< KoViewTransformStillPoint > &stillPoint, bool isNativeGesture=false)
qreal m_nonRoundedRelativeRotation
SnappedRotationData m_rotationData
KisCanvasNavigationActionStrategyNativeGesture(Flags flags, const QPointF &startViewPos, KisCanvas2 *canvas)
void inputEvent(QEvent *event) override
bool supportsEvent(QEvent *event) const override
KoViewTransformStillPoint m_actionStillPoint
static qreal canvasRotationAngleContinuous(qreal currentRotationOffset, qreal currectCanvasRotation, SnappedRotationData &data)
static qreal canvasRotationAngleDescrete(qreal currentRotationOffset, SnappedRotationData &data)
static qreal findNextZoom(qreal currentZoom, const QVector< qreal > &zoomLevels)
qreal clampZoom(qreal zoom) const
QVector< qreal > standardZoomLevels() const
KoViewTransformStillPoint makeWidgetStillPoint(const QPointF &viewPoint) const override
Creates a still point that links the viewPoint of the widget to the corresponding point of the image.
static qreal findPrevZoom(qreal currentZoom, const QVector< qreal > &zoomLevels)
KoCanvasController * canvasController() const
virtual KoZoomState zoomState() const =0
virtual void setZoom(KoZoomMode::Mode mode, qreal zoom)=0
virtual void zoom(qreal *zoomX, qreal *zoomY) const
void zoom(qreal *zoomX, qreal *zoomY) const override
@ ZOOM_WIDTH
zoom pagewidth
static bool qFuzzyIsNull(half h)
T kisDegreesToRadians(T degrees)