Improve EnsureVisibleWithDelay feature.
Margins should to be scaled according to scene scale factor. --HG-- branch : develop
This commit is contained in:
parent
09f3ba234c
commit
f16d26b659
|
@ -478,7 +478,9 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(scene());
|
||||
SCASSERT(currentScene)
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10),
|
||||
const qreal scale = SceneScale(scene());
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale, 10/scale,
|
||||
10/scale),
|
||||
VMainGraphicsView::scrollDelay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -638,7 +638,9 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(scene());
|
||||
SCASSERT(currentScene)
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10),
|
||||
const qreal scale = SceneScale(scene());
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale, 10/scale,
|
||||
10/scale),
|
||||
VMainGraphicsView::scrollDelay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,8 +195,9 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co
|
|||
{
|
||||
if (VMainGraphicsView *view = qobject_cast<VMainGraphicsView *>(viewList.at(0)))
|
||||
{
|
||||
const int xmargin = 50;
|
||||
const int ymargin = 50;
|
||||
const qreal scale = SceneScale(scene());
|
||||
const int xmargin = qCeil(50/scale);
|
||||
const int ymargin = qCeil(50/scale);
|
||||
|
||||
const QRectF viewRect = VMainGraphicsView::SceneVisibleArea(view);
|
||||
const QRectF itemRect = mapToScene(boundingRect()).boundingRect();
|
||||
|
@ -213,7 +214,8 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co
|
|||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(scene());
|
||||
SCASSERT(currentScene)
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10),
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale,
|
||||
10/scale, 10/scale),
|
||||
VMainGraphicsView::scrollDelay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1030,8 +1030,9 @@ QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change
|
|||
{
|
||||
if (VMainGraphicsView *view = qobject_cast<VMainGraphicsView *>(viewList.at(0)))
|
||||
{
|
||||
const int xmargin = 50;
|
||||
const int ymargin = 50;
|
||||
const qreal scale = SceneScale(scene());
|
||||
const int xmargin = qCeil(50/scale);
|
||||
const int ymargin = qCeil(50/scale);
|
||||
|
||||
const QRectF viewRect = VMainGraphicsView::SceneVisibleArea(view);
|
||||
const QRectF itemRect = mapToScene(boundingRect()|childrenBoundingRect()).boundingRect();
|
||||
|
@ -1048,7 +1049,8 @@ QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change
|
|||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(scene());
|
||||
SCASSERT(currentScene);
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10),
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale,
|
||||
10/scale, 10/scale),
|
||||
VMainGraphicsView::scrollDelay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,11 +178,12 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
|
|||
{
|
||||
if (VMainGraphicsView *view = qobject_cast<VMainGraphicsView *>(viewList.at(0)))
|
||||
{
|
||||
const int xmargin = 50;
|
||||
const int ymargin = 50;
|
||||
const qreal scale = SceneScale(scene());
|
||||
const int xmargin = qCeil(50/scale);
|
||||
const int ymargin = qCeil(50/scale);
|
||||
|
||||
const QRectF viewRect = VMainGraphicsView::SceneVisibleArea(view);
|
||||
const QRectF itemRect = mapToScene(boundingRect()).boundingRect();
|
||||
const QRectF itemRect = sceneBoundingRect();
|
||||
|
||||
// If item's rect is bigger than view's rect ensureVisible works very unstable.
|
||||
if (itemRect.height() + 2*ymargin < viewRect.height() &&
|
||||
|
@ -196,8 +197,10 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
|
|||
// Ensure visible only small rect around a cursor
|
||||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(scene());
|
||||
SCASSERT(currentScene)
|
||||
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10),
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale,
|
||||
cursorPosition.y()-5/scale, 10/scale, 10/scale),
|
||||
VMainGraphicsView::scrollDelay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "vmaingraphicsview.h"
|
||||
#include "global.h"
|
||||
#include "vscenepoint.h"
|
||||
#include "../vmisc/vmath.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -161,15 +162,9 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
|
|||
{
|
||||
if (VMainGraphicsView *view = qobject_cast<VMainGraphicsView *>(viewList.at(0)))
|
||||
{
|
||||
int xmargin = 50;
|
||||
int ymargin = 50;
|
||||
|
||||
const int scale = qRound(SceneScale(scene()));
|
||||
if (scale > 1)
|
||||
{
|
||||
xmargin /= scale;
|
||||
ymargin /= scale;
|
||||
}
|
||||
const qreal scale = SceneScale(scene());
|
||||
int xmargin = qCeil(50/scale);
|
||||
int ymargin = qCeil(50/scale);
|
||||
|
||||
const QRectF viewRect = VMainGraphicsView::SceneVisibleArea(view);
|
||||
const QRectF itemRect = mapToScene(boundingRect()).boundingRect();
|
||||
|
@ -187,7 +182,8 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
|
|||
SCASSERT(currentScene)
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10),
|
||||
view->EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale,
|
||||
10/scale, 10/scale),
|
||||
VMainGraphicsView::scrollDelay);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user