Commit 6cdfad98 authored by Andrew den Exter's avatar Andrew den Exter Committed by Qt by Nokia

Update item anchors when the baseline offset changes.

Task-number: QTBUG-24303
Change-Id: I75fb8eb8afb48a3f40fa159d914ac12ab6bc9ffe
Reviewed-by: 's avatarMichael Brasser <michael.brasser@nokia.com>
parent d120c3c3
......@@ -3312,6 +3312,10 @@ void QQuickItem::setBaselineOffset(qreal offset)
anchor->updateVerticalAnchors();
}
}
if (d->_anchors && (d->_anchors->usedAnchors() & QQuickAnchors::BaselineAnchor))
QQuickAnchorsPrivate::get(d->_anchors)->updateVerticalAnchors();
emit baselineOffsetChanged(offset);
}
......
import QtQuick 2.0
Item {
width: 200
height: 200
Item {
objectName: "baselineAnchored"
width: 200
height: 10
anchors.baseline: parent.verticalCenter
}
}
......@@ -84,6 +84,7 @@ private slots:
void margins();
void marginsRTL();
void stretch();
void baselineOffset();
};
void tst_qquickanchors::basicAnchors()
......@@ -705,6 +706,29 @@ void tst_qquickanchors::stretch()
delete view;
}
void tst_qquickanchors::baselineOffset()
{
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("baselineOffset.qml"));
QScopedPointer<QObject> object(component.create());
QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
QVERIFY(item);
QQuickItem *anchoredItem = findItem<QQuickItem>(item, QLatin1String("baselineAnchored"));
QCOMPARE(anchoredItem->baselineOffset(), 0.0);
QCOMPARE(anchoredItem->y(), 100.0);
anchoredItem->setBaselineOffset(5);
QCOMPARE(anchoredItem->baselineOffset(), 5.0);
QCOMPARE(anchoredItem->y(), 95.0);
anchoredItem->setBaselineOffset(10);
QCOMPARE(anchoredItem->baselineOffset(), 10.0);
QCOMPARE(anchoredItem->y(), 90.0);
}
QTEST_MAIN(tst_qquickanchors)
#include "tst_qquickanchors.moc"
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