Skip to content

Commit

Permalink
Merge branch 'bugfixes' of github.com:pencil2d/pencil
Browse files Browse the repository at this point in the history
  • Loading branch information
scribblemaniac committed Jun 18, 2019
2 parents e4f722a + d1d2921 commit b1e6171
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions core_lib/src/interface/scribblearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ QPointF ScribbleArea::whichAnchorPoint(QPointF anchorPoint)
return anchorPoint;
}

void ScribbleArea::adjustSelection(float offsetX, float offsetY, qreal rotatedAngle)
void ScribbleArea::adjustSelection(float offsetX, float offsetY, qreal rotationOffset)
{
QRectF& transformedSelection = myTransformedSelection;

Expand Down Expand Up @@ -1552,8 +1552,10 @@ void ScribbleArea::adjustSelection(float offsetX, float offsetY, qreal rotatedAn
{
myTempTransformedSelection =
transformedSelection; // @ necessary?
myRotatedAngle = (currentTool()->getCurrentPixel().x() -
currentTool()->getLastPressPixel().x()) + rotatedAngle;
QPointF curPoint = currentTool()->getCurrentPoint();
QPointF anchorPoint = transformedSelection.center();
myRotatedAngle = ( atan2( curPoint.y() - anchorPoint.y(), curPoint.x() - anchorPoint.x() ) ) * 180.0 / M_PI - rotationOffset;
qDebug() << curPoint << anchorPoint << myRotatedAngle << rotationOffset;
break;
}
default:
Expand Down
3 changes: 2 additions & 1 deletion core_lib/src/interface/scribblearea.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ScribbleArea : public QWidget

void deleteSelection();
void setSelection(QRectF rect);
void adjustSelection(float offsetX, float offsetY, qreal rotatedAngle);
void adjustSelection(float offsetX, float offsetY, qreal rotationOffset);
void applySelectionChanges();
void displaySelectionProperties();
void resetSelectionProperties();
Expand All @@ -86,6 +86,7 @@ class ScribbleArea : public QWidget
QRectF myTransformedSelection;
QRectF myTempTransformedSelection;
qreal myRotatedAngle = 0.0;
qreal mRotationOffset = 0.0;
QList<int> mClosestCurves;

bool isLayerPaintable() const;
Expand Down
7 changes: 6 additions & 1 deletion core_lib/src/tool/movetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ void MoveTool::beginInteraction(Qt::KeyboardModifiers keyMod, Layer* layer)
}

mScribbleArea->findMoveModeOfCornerInRange();
mScribbleArea->myRotatedAngle = mRotatedAngle;

if (keyMod != Qt::ShiftModifier)
{
Expand All @@ -173,6 +172,12 @@ void MoveTool::beginInteraction(Qt::KeyboardModifiers keyMod, Layer* layer)
{
createVectorSelection(keyMod, layer);
}

if(mScribbleArea->getMoveMode() == MoveMode::ROTATION) {
QPointF curPoint = getCurrentPoint();
QPointF anchorPoint = selectionRect.center();
mRotatedAngle = ( atan2( curPoint.y() - anchorPoint.y(), curPoint.x() - anchorPoint.x() ) ) * 180.0 / M_PI;
}
}

bool MoveTool::shouldDeselect()
Expand Down

0 comments on commit b1e6171

Please sign in to comment.