From 31f74f8355efe057ab8ab18ada9c1009218b813b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Thu, 1 Aug 2024 11:50:04 +0200 Subject: [PATCH] CommandPalette/BoundingBox: rotate changes Rotate commands should be absolute, not incremental or multiplied. --- src/core/Boxes/boundingbox.cpp | 5 +++++ src/core/Boxes/boundingbox.h | 1 + src/core/canvas.h | 3 ++- src/core/canvasselectedboxesactions.cpp | 6 ++++-- src/ui/dialogs/commandpalette.cpp | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/core/Boxes/boundingbox.cpp b/src/core/Boxes/boundingbox.cpp index bb7c9b037..a2caec407 100644 --- a/src/core/Boxes/boundingbox.cpp +++ b/src/core/Boxes/boundingbox.cpp @@ -737,6 +737,11 @@ void BoundingBox::setScale(const qreal scale) mTransformAnimator->setScale(scale, scale); } +void BoundingBox::setRotate(const qreal rot) +{ + mTransformAnimator->setRotation(rot); +} + void BoundingBox::rotateBy(const qreal rot) { mTransformAnimator->rotateRelativeToSavedValue(rot); } diff --git a/src/core/Boxes/boundingbox.h b/src/core/Boxes/boundingbox.h index 80449b601..858c61342 100644 --- a/src/core/Boxes/boundingbox.h +++ b/src/core/Boxes/boundingbox.h @@ -285,6 +285,7 @@ class CORE_EXPORT BoundingBox : public eBoxOrSound { void scale(const qreal scaleBy); void scale(const qreal scaleXBy, const qreal scaleYBy); void setScale(const qreal scale); + void setRotate(const qreal rot); void saveTransformPivotAbsPos(const QPointF &absPivot); void startPosTransform(); diff --git a/src/core/canvas.h b/src/core/canvas.h index 9a798a0f2..06cc5c5fc 100644 --- a/src/core/canvas.h +++ b/src/core/canvas.h @@ -542,7 +542,8 @@ class CORE_EXPORT Canvas : public CanvasBase void duplicateAction(); void selectAllAction(); void clearSelectionAction(); - void rotateSelectedBoxesStartAndFinish(const qreal rotBy); + void rotateSelectedBoxesStartAndFinish(const qreal rotBy, + bool inc = true); void scaleSelectedBoxesStartAndFinish(const qreal scaleBy); void moveSelectedBoxesStartAndFinish(const QPointF moveBy); diff --git a/src/core/canvasselectedboxesactions.cpp b/src/core/canvasselectedboxesactions.cpp index 22e957f83..4335ce574 100644 --- a/src/core/canvasselectedboxesactions.cpp +++ b/src/core/canvasselectedboxesactions.cpp @@ -295,11 +295,13 @@ NormalSegment Canvas::getSegment(const eMouseEvent& e) const { return NormalSegment(); } -void Canvas::rotateSelectedBoxesStartAndFinish(const qreal rotBy) { +void Canvas::rotateSelectedBoxesStartAndFinish(const qreal rotBy, + bool inc) { if(mDocument.fLocalPivot) { for(const auto &box : mSelectedBoxes) { box->startRotTransform(); - box->rotateBy(rotBy); + if (inc) { box->rotateBy(rotBy); } + else { box->setRotate(rotBy); } box->finishTransform(); } } else { diff --git a/src/ui/dialogs/commandpalette.cpp b/src/ui/dialogs/commandpalette.cpp index 0321639b1..57bfec80a 100644 --- a/src/ui/dialogs/commandpalette.cpp +++ b/src/ui/dialogs/commandpalette.cpp @@ -260,7 +260,7 @@ void CommandPalette::parseCmd(const QString &input) const auto scene = *mDocument.fActiveScene; if (!scene) { return; } qDebug() << "do rotate" << arg; - scene->rotateSelectedBoxesStartAndFinish(arg.toDouble()); + scene->rotateSelectedBoxesStartAndFinish(arg.toDouble(), false); mDocument.actionFinished(); appendHistory(input); accept();