Commit de4158bd authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

Adjust border rects close to screen borders so that they are visible

parent 5ff0d9b7
......@@ -179,8 +179,8 @@ void BoundingRectHighlighter::highlightAll(bool animate)
QPolygonF boundingRectInSceneSpace(item->mapToScene(itemAndChildRect));
QPolygonF boundingRectInLayerItemSpace = mapFromScene(boundingRectInSceneSpace);
QRectF bboxRect = boundingRectInLayerItemSpace.boundingRect();
QRectF edgeRect = boundingRectInLayerItemSpace.boundingRect();
QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace.boundingRect());
QRectF edgeRect = bboxRect;
edgeRect.adjust(-1, -1, 1, 1);
box->highlightPolygon->setPolygon(QPolygonF(bboxRect));
......
......@@ -94,7 +94,8 @@ void SelectionIndicator::setItems(const QList<QGraphicsObject*> &itemList)
QPolygonF boundingShapeInSceneSpace;
addBoundingRectToPolygon(item, boundingShapeInSceneSpace);
QPolygonF boundingRectInLayerItemSpace = m_layerItem->mapFromScene(boundingShapeInSceneSpace);
QRectF boundingRect = m_view->adjustToScreenBoundaries(boundingShapeInSceneSpace.boundingRect());
QPolygonF boundingRectInLayerItemSpace = m_layerItem->mapFromScene(boundingRect);
QPen pen;
pen.setColor(QColor(108, 141, 221));
......
......@@ -558,6 +558,30 @@ QString QDeclarativeDesignView::idStringForObject(QObject *obj)
return qmlDesignDebugServer()->idStringForObject(obj);
}
// adjusts bounding boxes on edges of screen to be visible
QRectF QDeclarativeDesignView::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
{
int marginFromEdge = 1;
QRectF boundingRect(boundingRectInSceneSpace);
if (qAbs(boundingRect.left()) - 1 < 2) {
boundingRect.setLeft(marginFromEdge);
}
if (boundingRect.right() >= rect().right() ) {
boundingRect.setRight(rect().right() - marginFromEdge);
}
if (qAbs(boundingRect.top()) - 1 < 2) {
boundingRect.setTop(marginFromEdge);
}
if (boundingRect.bottom() >= rect().bottom() ) {
boundingRect.setBottom(rect().bottom() - marginFromEdge);
}
return boundingRect;
}
QToolBar *QDeclarativeDesignView::toolbar() const
{
return m_toolbar;
......
......@@ -54,6 +54,7 @@ public:
QToolBar *toolbar() const;
static QString idStringForObject(QObject *obj);
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
public Q_SLOTS:
void setDesignModeBehavior(bool value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment