rotation undo fixed, cleanup.

presentation
JJones780 7 years ago
parent 41591de6dc
commit cc3e766529
  1. 11
      src/control/tools/EditSelection.cpp
  2. 9
      src/control/tools/EditSelectionContents.cpp
  3. 1
      src/control/tools/EditSelectionContents.h

@ -474,10 +474,7 @@ void EditSelection::mouseMove(double mouseX, double mouseY)
XOJ_CHECK_TYPE(EditSelection); XOJ_CHECK_TYPE(EditSelection);
double zoom = this->view->getXournal()->getZoom(); 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) if (this->mouseDownType == CURSOR_SELECTION_MOVE)
{ {
this->x = mouseX/zoom - this->relMousePosX; this->x = mouseX/zoom - this->relMousePosX;
@ -626,11 +623,7 @@ void EditSelection::mouseMove(double mouseX, double mouseY)
this->height = minSize; this->height = minSize;
} }
//Calculate new clip region delta due to rotation: // 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.
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);
} }

@ -41,6 +41,7 @@ EditSelectionContents::EditSelectionContents(double x, double y, double width, d
this->relativeX = -9999999999; this->relativeX = -9999999999;
this->relativeY = -9999999999; this->relativeY = -9999999999;
this->rotation = 0; this->rotation = 0;
this->lastRotation = 0;
this->lastX = this->originalX = x; this->lastX = this->originalX = x;
this->lastY = this->originalY = y; this->lastY = this->originalY = y;
@ -475,12 +476,13 @@ void EditSelectionContents::updateContent(double x, double y, double rotation, d
undo->addUndoAction(moveUndo); undo->addUndoAction(moveUndo);
} }
else if (rotate) else if (type == CURSOR_SELECTION_ROTATE)
{ {
RotateUndoAction* rotateUndo = new RotateUndoAction(this->sourcePage, &this->selected, x, 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); undo->addUndoAction(rotateUndo);
this->rotation = 0; // reset rotation for next usage this->rotation = 0; // reset rotation for next usage
this->lastRotation = rotation; // undo one rotation at a time.
} }
if (scale) if (scale)
{ {
@ -512,8 +514,9 @@ void EditSelectionContents::updateContent(double x, double y, double rotation, d
break; 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); undo->addUndoAction(scaleUndo);
} }
this->lastX = x; this->lastX = x;

@ -162,6 +162,7 @@ private:
* The given rotation. Original rotation should always be zero (double) * The given rotation. Original rotation should always be zero (double)
*/ */
double rotation = 0; double rotation = 0;
double lastRotation = 0; // for undoing multiple rotations during one selection edit.
/** /**
* The offset to the original selection * The offset to the original selection

Loading…
Cancel
Save