Commit 8377eb3b authored by Marco Bubke's avatar Marco Bubke

Fix cosmetic problems with the frame boxes.

parent efa2482d
......@@ -88,7 +88,7 @@ QRectF FormEditorItem::boundingRect() const
void FormEditorItem::updateGeometry()
{
prepareGeometryChange();
m_boundingRect = qmlItemNode().instanceBoundingRect();
m_boundingRect = qmlItemNode().instanceBoundingRect().adjusted(0, 0, 1., 1.);
setTransform(qmlItemNode().instanceTransform());
setTransform(m_attentionTransform, true);
//the property for zValue is called z in QGraphicsObject
......@@ -182,7 +182,7 @@ static QRectF alignedRect(const QRectF &rect)
alignedRect.setTop(std::floor(rect.top()) + 0.5);
alignedRect.setBottom(std::floor(rect.bottom()) + 0.5);
alignedRect.setLeft(std::floor(rect.left()) + 0.5);
alignedRect.setRight(std::floor(rect.right()) + 1.5);
alignedRect.setRight(std::floor(rect.right()) + 0.5);
return alignedRect;
}
......@@ -209,7 +209,7 @@ void FormEditorItem::paintBoundingRect(QPainter *painter) const
painter->setPen(pen);
int offset = m_borderWidth / 2;
painter->drawRect(alignedRect(boundingRect().adjusted(offset, offset, -offset, -offset)));
painter->drawRect(boundingRect().adjusted(0., 0., -1., -1.));
}
void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
......
......@@ -186,8 +186,7 @@ static QPointF bottomCenter(const QRectF &rect)
void ResizeController::updatePosition()
{
QRectF originalBoundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect();
QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect().adjusted(0.49, 0.49, 0.49, 0.49);
QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect();
QPointF topLeftPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
boundingRect.topLeft()));
QPointF topRightPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
......@@ -209,14 +208,14 @@ void ResizeController::updatePosition()
m_data->topRightItem->setHandlePosition(topRightPointInLayerSpace, originalBoundingRect.topRight());
m_data->topLeftItem->setHandlePosition(topLeftPointInLayerSpace, originalBoundingRect.topLeft());
m_data->bottomLeftItem->setHandlePosition(bottomLeftPointInLayerSpace, originalBoundingRect.bottomLeft());
m_data->bottomRightItem->setHandlePosition(bottomRightPointInLayerSpace, originalBoundingRect.bottomRight());
m_data->topItem->setHandlePosition(topPointInLayerSpace, topCenter(originalBoundingRect));
m_data->leftItem->setHandlePosition(leftPointInLayerSpace, leftCenter(originalBoundingRect));
m_data->rightItem->setHandlePosition(rightPointInLayerSpace, rightCenter(originalBoundingRect));
m_data->bottomItem->setHandlePosition(bottomPointInLayerSpace, bottomCenter(originalBoundingRect));
m_data->topRightItem->setHandlePosition(topRightPointInLayerSpace, boundingRect.topRight());
m_data->topLeftItem->setHandlePosition(topLeftPointInLayerSpace, boundingRect.topLeft());
m_data->bottomLeftItem->setHandlePosition(bottomLeftPointInLayerSpace, boundingRect.bottomLeft());
m_data->bottomRightItem->setHandlePosition(bottomRightPointInLayerSpace, boundingRect.bottomRight());
m_data->topItem->setHandlePosition(topPointInLayerSpace, topCenter(boundingRect));
m_data->leftItem->setHandlePosition(leftPointInLayerSpace, leftCenter(boundingRect));
m_data->rightItem->setHandlePosition(rightPointInLayerSpace, rightCenter(boundingRect));
m_data->bottomItem->setHandlePosition(bottomPointInLayerSpace, bottomCenter(boundingRect));
}
......
......@@ -87,7 +87,7 @@ void SelectionIndicator::setItems(const QList<FormEditorItem*> &itemList)
foreach (FormEditorItem *item, itemList) {
QGraphicsPolygonItem *newSelectionIndicatorGraphicsItem = new QGraphicsPolygonItem(m_layerItem.data());
m_indicatorShapeHash.insert(item, newSelectionIndicatorGraphicsItem);
QPolygonF boundingRectInSceneSpace(item->mapToScene(item->qmlItemNode().instanceBoundingRect().adjusted(0.5, 0.5, 0.5, 0.5)));
QPolygonF boundingRectInSceneSpace(item->mapToScene(item->qmlItemNode().instanceBoundingRect()));
// alignVertices(boundingRectInSceneSpace, 0.5 / item->formEditorView()->widget()->zoomAction()->zoomLevel());
QPolygonF boundingRectInLayerItemSpace = m_layerItem->mapFromScene(boundingRectInSceneSpace);
newSelectionIndicatorGraphicsItem->setPolygon(boundingRectInLayerItemSpace);
......@@ -106,7 +106,7 @@ void SelectionIndicator::updateItems(const QList<FormEditorItem*> &itemList)
foreach (FormEditorItem *item, itemList) {
if (m_indicatorShapeHash.contains(item)) {
QGraphicsPolygonItem *indicatorGraphicsItem = m_indicatorShapeHash.value(item);
QPolygonF boundingRectInSceneSpace(item->mapToScene(item->qmlItemNode().instanceBoundingRect().adjusted(0.5, 0.5, 0.5, 0.5)));
QPolygonF boundingRectInSceneSpace(item->mapToScene(item->qmlItemNode().instanceBoundingRect()));
// alignVertices(boundingRectInSceneSpace, 0.5 / item->formEditorView()->widget()->zoomAction()->zoomLevel());
QPolygonF boundingRectInLayerItemSpace = m_layerItem->mapFromScene(boundingRectInSceneSpace);
indicatorGraphicsItem->setPolygon(boundingRectInLayerItemSpace);
......
......@@ -609,7 +609,7 @@ QList<QGraphicsItem*> Snapper::generateSnappingLines(const QList<QRectF> &boundi
foreach(const QLineF &line, lineList) {
QLineF lineInTransformationSpace = transform.map(line);
alignLine(lineInTransformationSpace);
// alignLine(lineInTransformationSpace);
QGraphicsLineItem * lineItem = new QGraphicsLineItem(lineInTransformationSpace, layerItem);
lineItem->setZValue(40);
QPen linePen;
......
......@@ -91,7 +91,7 @@ void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionL
Q_ASSERT(transformationSpaceItem);
{
QRectF containerBoundingRectInTransformationSpace = m_formEditorItem->mapRectToItem(transformationSpaceItem,
m_formEditorItem->boundingRect());
m_formEditorItem->qmlItemNode().instanceBoundingRect());
addLines(containerBoundingRectInTransformationSpace, m_formEditorItem);
containerBoundingRectInTransformationSpace.adjust(m_leftMargin, m_topMargin, -m_rightMargin, -m_rightMargin);
......@@ -103,7 +103,7 @@ void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionL
continue;
QRectF boundingRectInContainerSpace;
boundingRectInContainerSpace = item->mapRectToItem(transformationSpaceItem, item->boundingRect());
boundingRectInContainerSpace = item->mapRectToItem(transformationSpaceItem, item->qmlItemNode().instanceBoundingRect());
boundingRectInContainerSpace = boundingRectInContainerSpace.toRect(); // round to integer
......
......@@ -200,15 +200,15 @@ void QmlItemNode::paintInstance(QPainter *painter) const
void QmlItemNode::setSize(const QSizeF &size)
{
RewriterTransaction transaction = qmlModelView()->beginRewriterTransaction();
setVariantProperty("width", round(size.width(), 4));
setVariantProperty("height", round(size.height(), 4));
setVariantProperty("width", qRound(size.width()));
setVariantProperty("height", qRound(size.height()));
}
void QmlItemNode::setPosition(const QPointF &position)
{
RewriterTransaction transaction = qmlModelView()->beginRewriterTransaction();
setVariantProperty("x", round(position.x(), 4));
setVariantProperty("y", round(position.y(), 4));
setVariantProperty("x", qRound(position.x()));
setVariantProperty("y", qRound(position.y()));
}
void QmlItemNode::selectNode()
......
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