diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-07-29 06:53:36 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-07-29 06:53:36 (GMT) |
commit | a9b507ccd9392269f1df2522306a9ece3628c6c7 (patch) | |
tree | 2746798589151551d9c99a4ce290409fbf63cb9f | |
parent | 20d9edfa3b7a8a648cfdb59a0e71525912f0a0a8 (diff) | |
parent | 26cd689a2356973020b7f4c9d86b2ee71b3ef8fe (diff) | |
download | Qt-a9b507ccd9392269f1df2522306a9ece3628c6c7.zip Qt-a9b507ccd9392269f1df2522306a9ece3628c6c7.tar.gz Qt-a9b507ccd9392269f1df2522306a9ece3628c6c7.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | demos/declarative/samegame/SameGame.qml | 13 | ||||
-rwxr-xr-x | demos/declarative/samegame/content/samegame.js | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxlayouts.cpp | 32 |
3 files changed, 27 insertions, 22 deletions
diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index 3b80692..9e1b1ae 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -9,7 +9,9 @@ Rect { Rect { id: gameCanvas property int score: 0 - z:20; y:20; width:400; height:600; color: "white"; pen.width: 1 + z:20; y:20; color: "white"; pen.width: 1 + width:parent.width - tileSize - (parent.width % tileSize); + height:parent.height - tileSize - (parent.height % tileSize); anchors.horizontalCenter: parent.horizontalCenter Image { id:background; source: "content/pics/background.png" @@ -29,13 +31,4 @@ Rect { text: "Score: " + gameCanvas.score; width:100; font.size:14 anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.right: gameCanvas.right; } - Text { - text: "Just over 300 lines of QML/JS code!" - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom; anchors.bottomMargin: 16; - opacity: SequentialAnimation{ running: true; repeat: true; - NumberAnimation { from: 0; to: 1; duration: 1000; easing: "easeInQuad" } - NumberAnimation { from: 1; to: 0; duration: 1000; easing: "easeInQuad" } - } - } } diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index a7dd82b..f04fb4c 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -21,6 +21,10 @@ function initBoard() board[i].destroy(); } + maxX = Math.floor(gameCanvas.width/tileSize); + maxY = Math.floor(gameCanvas.height/tileSize); + maxIndex = maxY*maxX; + //Initialize Board board = new Array(maxIndex); gameCanvas.score = 0; diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp index 0546845..da34b8c 100644 --- a/src/declarative/fx/qfxlayouts.cpp +++ b/src/declarative/fx/qfxlayouts.cpp @@ -354,11 +354,14 @@ void QFxBaseLayout::preLayout() d->_animated.clear(); doLayout(); //Set the layout's size to be the rect containing all children - //Also set the margin + //d->aut determines whether a dimension is sum or max + //Also sets the margin qreal width=0; qreal height=0; + qreal maxWidth=0; + qreal maxHeight=0; foreach(QFxItem *item, d->_items){ - if (item->opacity() == 0.0){ + if (item->opacity() != 0.0){ if (!d->_animated.contains(item)){ setMovingItem(item); QPointF p(item->x(), item->y()); @@ -369,6 +372,8 @@ void QFxBaseLayout::preLayout() item->setPos(p); setMovingItem(0); } + maxWidth = qMax(maxWidth, item->width()); + maxHeight = qMax(maxHeight, item->height()); width = qMax(width, item->x() + item->width()); height = qMax(height, item->y() + item->height()); } @@ -376,14 +381,19 @@ void QFxBaseLayout::preLayout() width += d->_margin; height+= d->_margin; - if (d->aut & Horizontal) - setWidth(int(width)); - else if (parentItem()) - setImplicitWidth(parentItem()->width()); - if (d->aut & Vertical) - setHeight(int(height)); - else if (parentItem()) - setImplicitHeight(parentItem()->height()); + if(d->aut & Both){ + setImplicitHeight(int(height)); + setImplicitWidth(int(width)); + }else if (d->aut & Horizontal){ + setImplicitWidth(int(width)); + setImplicitHeight(int(maxHeight)); + } else if (d->aut & Vertical){ + setImplicitHeight(int(height)); + setImplicitWidth(int(maxWidth)); + }else{ + setImplicitHeight(int(maxHeight)); + setImplicitWidth(int(maxWidth)); + } setLayoutItem(0); } @@ -656,7 +666,6 @@ void QFxVerticalLayout::doLayout() } finishApplyTransitions(); setMovingItem(this); - setHeight(voffset); setMovingItem(0); } @@ -823,7 +832,6 @@ void QFxHorizontalLayout::doLayout() hoffset += spacing(); } finishApplyTransitions(); - setWidth(hoffset); } QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridLayout,QFxGridLayout) |