diff options
author | A-Team <ateam@pad.test.qt.nokia.com> | 2010-10-14 22:00:12 (GMT) |
---|---|---|
committer | A-Team <ateam@pad.test.qt.nokia.com> | 2010-10-14 22:00:12 (GMT) |
commit | ca7a96943c122b8371caf98dc92f7e6644de1814 (patch) | |
tree | 4aaed5a7e0401455090ea0d92dd1ff26d86f09f7 /examples | |
parent | f103ad276181090da8c70bd29f4474ea7657e03f (diff) | |
parent | 9358d77fc1de64d2a8a06bfa4095dcde9f9b009b (diff) | |
download | Qt-ca7a96943c122b8371caf98dc92f7e6644de1814.zip Qt-ca7a96943c122b8371caf98dc92f7e6644de1814.tar.gz Qt-ca7a96943c122b8371caf98dc92f7e6644de1814.tar.bz2 |
Merge branch '4.7-upstream' into 4.7-doc
Diffstat (limited to 'examples')
-rw-r--r-- | examples/declarative/animation/behaviors/wigglytext.qml | 108 | ||||
-rwxr-xr-x | examples/declarative/tutorials/samegame/samegame4/content/samegame.js | 2 |
2 files changed, 109 insertions, 1 deletions
diff --git a/examples/declarative/animation/behaviors/wigglytext.qml b/examples/declarative/animation/behaviors/wigglytext.qml new file mode 100644 index 0000000..6cd93ab --- /dev/null +++ b/examples/declarative/animation/behaviors/wigglytext.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Rectangle { + id: container + + property string text: "Drag this text..." + property bool animated: true + + width: 640; height: 480; color: "#474747"; focus: true + + Keys.onPressed: { + if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) + container.remove() + else if (event.text != "") { + container.append(event.text) + } + } + + function append(text) { + container.animated = false + var lastLetter = container.children[container.children.length - 1] + var newLetter = letterComponent.createObject(container) + newLetter.text = text + newLetter.follow = lastLetter + container.animated = true + } + + function remove() { + if (container.children.length) + container.children[container.children.length - 1].destroy() + } + + function doLayout() { + var follow = null + for (var i = 0; i < container.text.length; ++i) { + var newLetter = letterComponent.createObject(container) + newLetter.text = container.text[i] + newLetter.follow = follow + follow = newLetter + } + } + + Component { + id: letterComponent + Text { + id: letter + property variant follow + + x: follow ? follow.x + follow.width : container.width / 3 + y: follow ? follow.y : container.height / 2 + + font.pixelSize: 40; font.bold: true + color: "#999999"; styleColor: "#222222"; style: Text.Raised + + MouseArea { + anchors.fill: parent + drag.target: letter; drag.axis: Drag.XandYAxis + onPressed: letter.color = "#dddddd" + onReleased: letter.color = "#999999" + } + + Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + } + } + + Component.onCompleted: doLayout() +} diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js index 79ff0c1..ccc3f9d 100755 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js @@ -145,7 +145,7 @@ function shuffleDown() { obj = board[index(column, row)]; if (obj == null) continue; - obj.x = (fallDist - column) * gameCanvas.blockSize; + obj.x = (column - fallDist) * gameCanvas.blockSize; board[index(column - fallDist, row)] = obj; board[index(column, row)] = null; } |