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 | |
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')
3 files changed, 35 insertions, 27 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(); diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h index f38847c..c4414d1 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h @@ -90,10 +90,10 @@ Q_SIGNALS: void addChanged(); protected Q_SLOTS: - virtual void doPositioning()=0; void prePositioning(); protected: + virtual void doPositioning(QSizeF *contentSize)=0; struct PositionedItem { PositionedItem(QDeclarativeItem *i) : item(i), isNew(false), isVisible(true) {} bool operator==(const PositionedItem &other) const { return other.item == item; } @@ -116,8 +116,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeColumn : public QDeclarativeBasePositione Q_OBJECT public: QDeclarativeColumn(QDeclarativeItem *parent=0); -protected Q_SLOTS: - virtual void doPositioning(); +protected: + virtual void doPositioning(QSizeF *contentSize); private: Q_DISABLE_COPY(QDeclarativeColumn) }; @@ -127,8 +127,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner Q_OBJECT public: QDeclarativeRow(QDeclarativeItem *parent=0); -protected Q_SLOTS: - virtual void doPositioning(); +protected: + virtual void doPositioning(QSizeF *contentSize); private: Q_DISABLE_COPY(QDeclarativeRow) }; @@ -151,8 +151,8 @@ Q_SIGNALS: void rowsChanged(); void columnsChanged(); -protected Q_SLOTS: - virtual void doPositioning(); +protected: + virtual void doPositioning(QSizeF *contentSize); private: int _rows; @@ -176,8 +176,8 @@ public: Q_SIGNALS: void flowChanged(); -protected Q_SLOTS: - virtual void doPositioning(); +protected: + virtual void doPositioning(QSizeF *contentSize); protected: QDeclarativeFlow(QDeclarativeFlowPrivate &dd, QDeclarativeItem *parent); diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h index 3a1edee..7880e3e 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h @@ -73,8 +73,8 @@ class QDeclarativeBasePositionerPrivate : public QDeclarativeItemPrivate, public public: QDeclarativeBasePositionerPrivate() - : spacing(0), type(QDeclarativeBasePositioner::None), moveTransition(0), addTransition(0), - queuedPositioning(false) + : spacing(0), type(QDeclarativeBasePositioner::None) + , moveTransition(0), addTransition(0), queuedPositioning(false) { } @@ -84,6 +84,7 @@ public: } int spacing; + QDeclarativeBasePositioner::PositionerType type; QDeclarativeTransition *moveTransition; QDeclarativeTransition *addTransition; |