Skip to content

Commit

Permalink
fix: auto scroll when moving pattern piece is now independent from th…
Browse files Browse the repository at this point in the history
…e piece's size
  • Loading branch information
Onetchou authored and DSCaskey committed Jul 25, 2024
1 parent e91b1e1 commit e27901a
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/libs/vtools/tools/pattern_piece_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,21 +1050,12 @@ QVariant PatternPieceTool::itemChange(QGraphicsItem::GraphicsItemChange change,
const QRectF viewRect = VMainGraphicsView::SceneVisibleArea(view);
const QRectF itemRect = mapToScene(boundingRect()|childrenBoundingRect()).boundingRect();

// If item's rect is bigger than view's rect ensureVisible works very unstable.
if (itemRect.height() + 2*ymargin < viewRect.height() &&
itemRect.width() + 2*xmargin < viewRect.width())
{
view->ensureVisible(itemRect, xmargin, ymargin);
}
else
{
// Ensure visible only small rect around a cursor
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(scene());
SCASSERT(currentScene);
const QPointF cursorPosition = currentScene->getScenePos();
view->ensureVisible(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale,
10/scale, 10/scale));
}
// Ensure visible only small rect around a cursor
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(scene());
SCASSERT(currentScene);
const QPointF cursorPosition = currentScene->getScenePos();
view->ensureVisible(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale,
10/scale, 10/scale));
}
}

Expand Down

0 comments on commit e27901a

Please sign in to comment.