diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2011-08-10 13:51:32 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-10 07:34:18 +0200 |
commit | 2601011f1c0168f080c488be09c888042812f7cb (patch) | |
tree | 0750fe5651ded96b5a473acd067b2156e0c77dee /tests | |
parent | 108c94807a22740d0ecae369846063b4596d3788 (diff) |
Add support for individual row and column spacing to Grid object.
Add rowSpacing and columnSpacing properties to QML Grid object. If
these are specified, use them when laying out the grid. If they are
not specified, default to using the spacing property that was
previously used, so it is backwards compatible.
Task-number: QTBUG-11876
Change-Id: I5c809e89fe124d8d5ea1667b273f19e2c37ff18a
Reviewed-on: http://codereview.qt.nokia.com/2797
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml | 43 | ||||
-rw-r--r-- | tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp | 34 |
2 files changed, 77 insertions, 0 deletions
diff --git a/tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml b/tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml new file mode 100644 index 0000000000..49bbd337e7 --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + columns: 3 + spacing: 4 + rowSpacing: 7 + columnSpacing: 11 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp index 3b2a504ff4..497f511335 100644 --- a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp +++ b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp @@ -76,6 +76,7 @@ private slots: void test_grid_topToBottom(); void test_grid_rightToLeft(); void test_grid_spacing(); + void test_grid_row_column_spacing(); void test_grid_animated(); void test_grid_animated_rightToLeft(); void test_grid_zero_columns(); @@ -622,6 +623,39 @@ void tst_qsgpositioners::test_grid_spacing() delete canvas; } +void tst_qsgpositioners::test_grid_row_column_spacing() +{ + QSGView *canvas = createView(SRCDIR "/data/grid-row-column-spacing.qml"); + + QSGRectangle *one = canvas->rootObject()->findChild<QSGRectangle*>("one"); + QVERIFY(one != 0); + QSGRectangle *two = canvas->rootObject()->findChild<QSGRectangle*>("two"); + QVERIFY(two != 0); + QSGRectangle *three = canvas->rootObject()->findChild<QSGRectangle*>("three"); + QVERIFY(three != 0); + QSGRectangle *four = canvas->rootObject()->findChild<QSGRectangle*>("four"); + QVERIFY(four != 0); + QSGRectangle *five = canvas->rootObject()->findChild<QSGRectangle*>("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 61.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 92.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 57.0); + QCOMPARE(five->x(), 61.0); + QCOMPARE(five->y(), 57.0); + + QSGItem *grid = canvas->rootObject()->findChild<QSGItem*>("grid"); + QCOMPARE(grid->width(), 142.0); + QCOMPARE(grid->height(), 107.0); + + delete canvas; +} + void tst_qsgpositioners::test_grid_animated() { QSGView *canvas = createView(SRCDIR "/data/grid-animated.qml"); |