From cc3e7665293f71ce92a0edd41be6b88f19aeb010 Mon Sep 17 00:00:00 2001 From: JJones780 Date: Sun, 28 Apr 2019 02:02:44 -0600 Subject: [PATCH] rotation undo fixed, cleanup. --- src/control/tools/EditSelection.cpp | 11 ++--------- src/control/tools/EditSelectionContents.cpp | 9 ++++++--- src/control/tools/EditSelectionContents.h | 1 + 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/control/tools/EditSelection.cpp b/src/control/tools/EditSelection.cpp index 9e892271..a28cd0e7 100644 --- a/src/control/tools/EditSelection.cpp +++ b/src/control/tools/EditSelection.cpp @@ -474,10 +474,7 @@ void EditSelection::mouseMove(double mouseX, double mouseY) XOJ_CHECK_TYPE(EditSelection); double zoom = this->view->getXournal()->getZoom(); - - g_print("%f\t%f\t%f\t%f\t%f\t\t\t",this->x,this->y,this->rotation, this->width, this->height); - - + if (this->mouseDownType == CURSOR_SELECTION_MOVE) { this->x = mouseX/zoom - this->relMousePosX; @@ -626,11 +623,7 @@ void EditSelection::mouseMove(double mouseX, double mouseY) this->height = minSize; } - //Calculate new clip region delta due to rotation: - double addW =std::abs(this->width * cos(this->rotation)) + std::abs(this->height * sin(this->rotation)) - this->width ; - double addH = std::abs(this->width * sin(this->rotation)) + std::abs(this->height * cos(this->rotation)) - this->height; - - g_print("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n",dx,dy,this->x,this->y,this->rotation, this->width, this->height,addW,addH); + // idea was to use dx and dy to accommodate scaling issues when rotated ( a bit of a hack) but we've got problems with undoScaling and everything would be better served if we re-wrote parts EditSelection and EditSelectionContents so that scaling and rotation were all based off of center coordinates instead of topLeft. Leaving for now to finish other checkins. } diff --git a/src/control/tools/EditSelectionContents.cpp b/src/control/tools/EditSelectionContents.cpp index cea775ba..3a3b7e72 100644 --- a/src/control/tools/EditSelectionContents.cpp +++ b/src/control/tools/EditSelectionContents.cpp @@ -41,6 +41,7 @@ EditSelectionContents::EditSelectionContents(double x, double y, double width, d this->relativeX = -9999999999; this->relativeY = -9999999999; this->rotation = 0; + this->lastRotation = 0; this->lastX = this->originalX = x; this->lastY = this->originalY = y; @@ -475,12 +476,13 @@ void EditSelectionContents::updateContent(double x, double y, double rotation, d undo->addUndoAction(moveUndo); } - else if (rotate) + else if (type == CURSOR_SELECTION_ROTATE) { RotateUndoAction* rotateUndo = new RotateUndoAction(this->sourcePage, &this->selected, x, - y, width / 2, height / 2, this->rotation); + y, width / 2, height / 2, rotation - this->lastRotation); undo->addUndoAction(rotateUndo); this->rotation = 0; // reset rotation for next usage + this->lastRotation = rotation; // undo one rotation at a time. } if (scale) { @@ -512,8 +514,9 @@ void EditSelectionContents::updateContent(double x, double y, double rotation, d break; } - ScaleUndoAction* scaleUndo = new ScaleUndoAction(this->sourcePage, &this->selected, px, py, fx, fy); + ScaleUndoAction* scaleUndo = new ScaleUndoAction(this->sourcePage, &this->selected, px, py, fx, fy); //this needs to be aware of the rotation... this should all be rewritten to scale and rotate from center... !!!!!!!!! TODO undo->addUndoAction(scaleUndo); + } this->lastX = x; diff --git a/src/control/tools/EditSelectionContents.h b/src/control/tools/EditSelectionContents.h index 767e3a21..1d66c6bb 100644 --- a/src/control/tools/EditSelectionContents.h +++ b/src/control/tools/EditSelectionContents.h @@ -162,6 +162,7 @@ private: * The given rotation. Original rotation should always be zero (double) */ double rotation = 0; + double lastRotation = 0; // for undoing multiple rotations during one selection edit. /** * The offset to the original selection