diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-01 02:45:57 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-01 02:45:57 (GMT) |
commit | b5117243a50cca51cf8f77d153f0c400084134ef (patch) | |
tree | 5f55060994d37e6d5be1e392d7592ac40af91124 /src/declarative/graphicsitems/qdeclarativepositioners.cpp | |
parent | 89a56a7ddc132ecaec23967e47a27a79a2f20f66 (diff) | |
download | Qt-b5117243a50cca51cf8f77d153f0c400084134ef.zip Qt-b5117243a50cca51cf8f77d153f0c400084134ef.tar.gz Qt-b5117243a50cca51cf8f77d153f0c400084134ef.tar.bz2 |
Set positioner size to final size, rather than some random size mid animation
Task-number: QTBUG-9559
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativepositioners.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativepositioners.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index b23b8c9..781e584 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -237,21 +237,13 @@ void QDeclarativeBasePositioner::prePositioning() positionedItems.append(*item); } } - doPositioning(); + QSizeF contentSize; + doPositioning(&contentSize); if(d->addTransition || d->moveTransition) finishApplyTransitions(); //Set implicit size to the size of its children - qreal h = 0.0f; - qreal w = 0.0f; - for (int i = 0; i < positionedItems.count(); ++i) { - const PositionedItem &posItem = positionedItems.at(i); - if (posItem.isVisible) { - h = qMax(h, posItem.item->y() + posItem.item->height()); - w = qMax(w, posItem.item->x() + posItem.item->width()); - } - } - setImplicitHeight(h); - setImplicitWidth(w); + setImplicitHeight(contentSize.height()); + setImplicitWidth(contentSize.width()); } void QDeclarativeBasePositioner::positionX(int x, const PositionedItem &target) @@ -423,7 +415,7 @@ static inline bool isInvisible(QDeclarativeItem *child) return child->opacity() == 0.0 || !child->isVisible() || !child->width() || !child->height(); } -void QDeclarativeColumn::doPositioning() +void QDeclarativeColumn::doPositioning(QSizeF *contentSize) { int voffset = 0; @@ -435,9 +427,13 @@ void QDeclarativeColumn::doPositioning() if(child.item->y() != voffset) positionY(voffset, child); + contentSize->setWidth(qMax(contentSize->width(), child.item->width())); + voffset += child.item->height(); voffset += spacing(); } + + contentSize->setHeight(voffset - spacing()); } /*! @@ -534,7 +530,7 @@ QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent) { } -void QDeclarativeRow::doPositioning() +void QDeclarativeRow::doPositioning(QSizeF *contentSize) { int hoffset = 0; @@ -546,9 +542,13 @@ void QDeclarativeRow::doPositioning() if(child.item->x() != hoffset) positionX(hoffset, child); + contentSize->setHeight(qMax(contentSize->height(), child.item->height())); + hoffset += child.item->width(); hoffset += spacing(); } + + contentSize->setWidth(hoffset - spacing()); } @@ -698,7 +698,7 @@ void QDeclarativeGrid::setRows(const int rows) emit rowsChanged(); } -void QDeclarativeGrid::doPositioning() +void QDeclarativeGrid::doPositioning(QSizeF *contentSize) { int c=_columns,r=_rows;//Actual number of rows/columns int numVisible = positionedItems.count(); @@ -745,6 +745,10 @@ void QDeclarativeGrid::doPositioning() positionX(xoffset, child); positionY(yoffset, child); } + + contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width())); + contentSize->setHeight(yoffset + maxRowHeight[curRow]); + xoffset+=maxColWidth[curCol]+spacing(); curCol++; curCol%=c; @@ -854,7 +858,7 @@ void QDeclarativeFlow::setFlow(Flow flow) } } -void QDeclarativeFlow::doPositioning() +void QDeclarativeFlow::doPositioning(QSizeF *contentSize) { Q_D(QDeclarativeFlow); @@ -886,6 +890,9 @@ void QDeclarativeFlow::doPositioning() positionY(voffset, child); } + contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width())); + contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height())); + if (d->flow == LeftToRight) { hoffset += child.item->width(); hoffset += spacing(); |