Commit 0fcc6afd authored by Marco Bubke's avatar Marco Bubke Committed by Thomas Hartmann

QmlDesigner: Split between bounding rectangle and painted bounding rectangle

In qml the interactive bounding rectangle is always
QRectF(0, 0, width, height). The painted bounding rectangle can differ from
this logical one. This change is much more near to the qml description.

Change-Id: I139cb70512fa1ed003b28ca2ae512f4e33e915e5
Reviewed-on: http://codereview.qt.nokia.com/812Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 415680d6
......@@ -90,9 +90,6 @@ QmlGraphicsItemNodeInstance::Pointer QmlGraphicsItemNodeInstance::create(QObject
instance->setHasContent(anyItemHasContent(qmlGraphicsItem));
qmlGraphicsItem->setFlag(QGraphicsItem::ItemHasNoContents, false);
if (qmlGraphicsItem->inherits("QDeclarativeText"))
instance->setResizable(false);
static_cast<QDeclarativeParserStatus*>(qmlGraphicsItem)->classBegin();
instance->populateResetValueHash();
......@@ -107,93 +104,11 @@ bool QmlGraphicsItemNodeInstance::isQmlGraphicsItem() const
QSizeF QmlGraphicsItemNodeInstance::size() const
{
if (isValid()) {
double implicitWidth = qmlGraphicsItem()->implicitWidth();
if (!m_hasWidth
&& implicitWidth // WORKAROUND
&& qmlGraphicsItem()->width() <= 0
&& implicitWidth != qmlGraphicsItem()->width()
&& !hasBindingForProperty("width")) {
qmlGraphicsItem()->blockSignals(true);
qmlGraphicsItem()->setWidth(implicitWidth);
qmlGraphicsItem()->blockSignals(false);
}
double implicitHeight = qmlGraphicsItem()->implicitHeight();
if (!m_hasHeight
&& implicitWidth // WORKAROUND
&& qmlGraphicsItem()->height() <= 0
&& implicitHeight != qmlGraphicsItem()->height()
&& !hasBindingForProperty("height")) {
qmlGraphicsItem()->blockSignals(true);
qmlGraphicsItem()->setHeight(implicitHeight);
qmlGraphicsItem()->blockSignals(false);
}
}
if (isRootNodeInstance()) {
if (!m_hasWidth) {
qmlGraphicsItem()->blockSignals(true);
if (qmlGraphicsItem()->width() < 10.)
qmlGraphicsItem()->setWidth(100.);
qmlGraphicsItem()->blockSignals(false);
}
if (!m_hasHeight) {
qmlGraphicsItem()->blockSignals(true);
if (qmlGraphicsItem()->height() < 10.)
qmlGraphicsItem()->setHeight(100.);
qmlGraphicsItem()->blockSignals(false);
}
}
return QSizeF(qmlGraphicsItem()->width(), qmlGraphicsItem()->height());
}
QRectF QmlGraphicsItemNodeInstance::boundingRect() const
{
if (isValid()) {
double implicitWidth = qmlGraphicsItem()->implicitWidth();
if (!m_hasWidth
&& implicitWidth // WORKAROUND
&& qmlGraphicsItem()->width() <= 0
&& implicitWidth != qmlGraphicsItem()->width()
&& !hasBindingForProperty("width")) {
qmlGraphicsItem()->blockSignals(true);
qmlGraphicsItem()->setWidth(implicitWidth);
qmlGraphicsItem()->blockSignals(false);
}
double implicitHeight = qmlGraphicsItem()->implicitHeight();
if (!m_hasHeight
&& implicitWidth // WORKAROUND
&& qmlGraphicsItem()->height() <= 0
&& implicitHeight != qmlGraphicsItem()->height()
&& !hasBindingForProperty("height")) {
qmlGraphicsItem()->blockSignals(true);
qmlGraphicsItem()->setHeight(implicitHeight);
qmlGraphicsItem()->blockSignals(false);
}
}
if (isRootNodeInstance()) {
if (!m_hasWidth) {
qmlGraphicsItem()->blockSignals(true);
if (qmlGraphicsItem()->width() < 10.)
qmlGraphicsItem()->setWidth(100.);
qmlGraphicsItem()->blockSignals(false);
}
if (!m_hasHeight) {
qmlGraphicsItem()->blockSignals(true);
if (qmlGraphicsItem()->height() < 10.)
qmlGraphicsItem()->setHeight(100.);
qmlGraphicsItem()->blockSignals(false);
}
}
if (qmlGraphicsItem())
return qmlGraphicsItem()->boundingRect();
......
......@@ -99,7 +99,7 @@ QRectF FormEditorItem::boundingRect() const
void FormEditorItem::updateGeometry()
{
prepareGeometryChange();
m_boundingRect = qmlItemNode().instanceBoundingRect().adjusted(0, 0, 1., 1.);
m_boundingRect = qmlItemNode().instancePaintedBoundingRect().adjusted(0, 0, 1., 1.);
setTransform(qmlItemNode().instanceTransform());
setTransform(m_attentionTransform, true);
//the property for zValue is called z in QGraphicsObject
......
......@@ -518,21 +518,19 @@ bool ResizeManipulator::isActive() const
void ResizeManipulator::setSize(QmlItemNode itemNode, const QSizeF &size)
{
int penWidth = (itemNode.instancePenWidth() / 2) * 2;
if (!itemNode.hasBindingProperty("width"))
itemNode.setVariantProperty("width", qRound(size.width()) - penWidth);
itemNode.setVariantProperty("width", qRound(size.width()));
if (!itemNode.hasBindingProperty("height"))
itemNode.setVariantProperty("height", qRound(size.height()) - penWidth);
itemNode.setVariantProperty("height", qRound(size.height()));
}
void ResizeManipulator::setPosition(QmlItemNode itemNode, const QPointF &position)
{
if (!itemNode.hasBindingProperty("x"))
itemNode.setVariantProperty("x", qRound(position.x()) + (itemNode.instancePenWidth() / 2));
itemNode.setVariantProperty("x", qRound(position.x()));
if (!itemNode.hasBindingProperty("y"))
itemNode.setVariantProperty("y", qRound(position.y()) + (itemNode.instancePenWidth() / 2));
itemNode.setVariantProperty("y", qRound(position.y()));
}
}
......@@ -76,6 +76,7 @@ public:
bool instanceIsInPositioner() const;
QRectF instanceBoundingRect() const;
QRectF instancePaintedBoundingRect() const;
QTransform instanceTransform() const;
QTransform instanceSceneTransform() const;
QPointF instancePosition() const;
......
......@@ -220,6 +220,11 @@ bool QmlItemNode::instanceIsInPositioner() const
}
QRectF QmlItemNode::instanceBoundingRect() const
{
return QRectF(QPointF(0, 0), nodeInstance().size());
}
QRectF QmlItemNode::instancePaintedBoundingRect() const
{
return nodeInstance().boundingRect();
}
......
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