From 414b91ab7f11efaf89afb237d682507caec05eff Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 25 Jul 2011 17:13:18 +1000 Subject: [PATCH] Use visible only, and not opacity, in positioners Task-number: QTBUG-12940 Change-Id: Id637bbd7c30aea8bc23c2aeaccfb069a8de7955f Reviewed-on: http://codereview.qt.nokia.com/2082 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- src/declarative/items/qsgpositioners.cpp | 5 +- .../qsgpositioners/data/grid-animated.qml | 2 +- .../qsgpositioners/data/horizontal-animated.qml | 2 +- .../qsgpositioners/data/vertical-animated.qml | 2 +- .../qsgpositioners/tst_qsgpositioners.cpp | 46 +++++++++---------- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/declarative/items/qsgpositioners.cpp b/src/declarative/items/qsgpositioners.cpp index f5eab39..3f6b24a 100644 --- a/src/declarative/items/qsgpositioners.cpp +++ b/src/declarative/items/qsgpositioners.cpp @@ -57,7 +57,6 @@ static const QSGItemPrivate::ChangeTypes watchedChanges = QSGItemPrivate::Geometry | QSGItemPrivate::SiblingOrder | QSGItemPrivate::Visibility - | QSGItemPrivate::Opacity | QSGItemPrivate::Destroyed; void QSGBasePositionerPrivate::watchChanges(QSGItem *other) @@ -195,13 +194,13 @@ void QSGBasePositioner::prePositioning() positionedItems.append(posItem); item = &positionedItems[positionedItems.count()-1]; item->isNew = true; - if (child->opacity() <= 0.0 || !childPrivate->explicitVisible || !child->width() || !child->height()) + if (!childPrivate->explicitVisible || !child->width() || !child->height()) item->isVisible = false; } else { item = &oldItems[wIdx]; // Items are only omitted from positioning if they are explicitly hidden // i.e. their positioning is not affected if an ancestor is hidden. - if (child->opacity() <= 0.0 || !childPrivate->explicitVisible || !child->width() || !child->height()) { + if (!childPrivate->explicitVisible || !child->width() || !child->height()) { item->isVisible = false; } else if (!item->isVisible) { item->isVisible = true; diff --git a/tests/auto/declarative/qsgpositioners/data/grid-animated.qml b/tests/auto/declarative/qsgpositioners/data/grid-animated.qml index 56e8f26..b8ee8f9 100644 --- a/tests/auto/declarative/qsgpositioners/data/grid-animated.qml +++ b/tests/auto/declarative/qsgpositioners/data/grid-animated.qml @@ -31,7 +31,7 @@ Item { objectName: "two" x: -100 y: -100 - opacity: 0 + visible: false color: "green" width: 50 height: 50 diff --git a/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml b/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml index d19cc46..b9b8591 100644 --- a/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml +++ b/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml @@ -29,7 +29,7 @@ Item { objectName: "two" color: "blue" x: -100; - opacity: 0 + visible: false width: 50 height: 50 } diff --git a/tests/auto/declarative/qsgpositioners/data/vertical-animated.qml b/tests/auto/declarative/qsgpositioners/data/vertical-animated.qml index 69f1b7e..ecf593c 100644 --- a/tests/auto/declarative/qsgpositioners/data/vertical-animated.qml +++ b/tests/auto/declarative/qsgpositioners/data/vertical-animated.qml @@ -26,7 +26,7 @@ Item { objectName: "two" color: "blue" y: -100 - opacity: 0 + visible: false width: 50 height: 50 } diff --git a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp index 788c072..21b0ea1 100644 --- a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp +++ b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp @@ -251,19 +251,17 @@ void tst_qsgpositioners::test_horizontal_animated() QTRY_COMPARE(one->x(), 0.0); QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->isVisible(), false); QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet QTRY_COMPARE(two->y(), 0.0); QTRY_COMPARE(three->x(), 50.0); QTRY_COMPARE(three->y(), 0.0); //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); - - // New size should be immediate - QCOMPARE(row->width(), 150.0); - QCOMPARE(row->height(), 50.0); + two->setVisible(true); + QTRY_COMPARE(two->isVisible(), true); + QTRY_COMPARE(row->width(), 150.0); + QTRY_COMPARE(row->height(), 50.0); QTest::qWait(0);//Let the animation start QCOMPARE(two->x(), -100.0); @@ -305,19 +303,19 @@ void tst_qsgpositioners::test_horizontal_animated_rightToLeft() QTRY_COMPARE(one->x(), 50.0); QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->isVisible(), false); QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet QTRY_COMPARE(two->y(), 0.0); QTRY_COMPARE(three->x(), 0.0); QTRY_COMPARE(three->y(), 0.0); //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); + two->setVisible(true); + QTRY_COMPARE(two->isVisible(), true); - // New size should be immediate - QCOMPARE(row->width(), 150.0); - QCOMPARE(row->height(), 50.0); + // New size should propagate after visible change + QTRY_COMPARE(row->width(), 150.0); + QTRY_COMPARE(row->height(), 50.0); QTest::qWait(0);//Let the animation start QCOMPARE(one->x(), 50.0); @@ -411,17 +409,17 @@ void tst_qsgpositioners::test_vertical_animated() QTRY_COMPARE(one->y(), 0.0); QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->isVisible(), false); QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet QTRY_COMPARE(two->x(), 0.0); QTRY_COMPARE(three->y(), 50.0); QTRY_COMPARE(three->x(), 0.0); //Add 'two' - two->setOpacity(1.0); - QTRY_COMPARE(two->opacity(), 1.0); - QCOMPARE(column->height(), 150.0); - QCOMPARE(column->width(), 50.0); + two->setVisible(true); + QTRY_COMPARE(two->isVisible(), true); + QTRY_COMPARE(column->height(), 150.0); + QTRY_COMPARE(column->width(), 50.0); QTest::qWait(0);//Let the animation start QCOMPARE(two->y(), -100.0); QCOMPARE(three->y(), 50.0); @@ -624,7 +622,7 @@ void tst_qsgpositioners::test_grid_animated() QTRY_COMPARE(one->y(), 0.0); QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->isVisible(), false); QTRY_COMPARE(two->y(), -100.0); QTRY_COMPARE(two->x(), -100.0); QTRY_COMPARE(three->y(), 0.0); @@ -635,8 +633,8 @@ void tst_qsgpositioners::test_grid_animated() QTRY_COMPARE(five->x(), 0.0); //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); + two->setVisible(true); + QCOMPARE(two->isVisible(), true); QCOMPARE(grid->width(), 150.0); QCOMPARE(grid->height(), 100.0); QTest::qWait(0);//Let the animation start @@ -707,7 +705,7 @@ void tst_qsgpositioners::test_grid_animated_rightToLeft() QTRY_COMPARE(one->y(), 0.0); QTRY_COMPARE(one->x(), 100.0); - QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->isVisible(), false); QTRY_COMPARE(two->y(), -100.0); QTRY_COMPARE(two->x(), -100.0); QTRY_COMPARE(three->y(), 0.0); @@ -718,8 +716,8 @@ void tst_qsgpositioners::test_grid_animated_rightToLeft() QTRY_COMPARE(five->x(), 100.0); //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); + two->setVisible(true); + QCOMPARE(two->isVisible(), true); QCOMPARE(grid->width(), 150.0); QCOMPARE(grid->height(), 100.0); QTest::qWait(0);//Let the animation start -- 1.7.2.5