From 01bfcfba0287fa7e9e051e2540ebbdb01fee5a9e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 28 Feb 2012 11:30:16 +1000 Subject: Move some toys back to examples tvtennis, corkboards and dynamicscene are more examples than demos. clocks and tic-tac-toe are remaining demos for now. Change-Id: I3d9501a4742349a9eb7efdad0d06aa6e7cb02c14 Reviewed-by: Michael Brasser --- examples/demos/corkboards/content/Day.qml | 153 ------------ examples/demos/corkboards/content/cork.jpg | Bin 149337 -> 0 bytes examples/demos/corkboards/content/note-yellow.png | Bin 54559 -> 0 bytes examples/demos/corkboards/content/tack.png | Bin 7282 -> 0 bytes examples/demos/corkboards/corkboards.qml | 116 --------- examples/demos/dynamicscene/content/Button.qml | 80 ------ .../dynamicscene/content/GenericSceneItem.qml | 49 ---- .../demos/dynamicscene/content/PaletteItem.qml | 59 ----- .../demos/dynamicscene/content/PerspectiveItem.qml | 65 ----- examples/demos/dynamicscene/content/Sun.qml | 78 ------ examples/demos/dynamicscene/content/images/NOTE | 1 - .../dynamicscene/content/images/face-smile.png | Bin 15408 -> 0 bytes .../demos/dynamicscene/content/images/moon.png | Bin 1757 -> 0 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 1245 -> 0 bytes .../dynamicscene/content/images/rabbit_bw.png | Bin 1759 -> 0 bytes .../demos/dynamicscene/content/images/star.png | Bin 349 -> 0 bytes examples/demos/dynamicscene/content/images/sun.png | Bin 8153 -> 0 bytes .../demos/dynamicscene/content/images/tree_s.png | Bin 3406 -> 0 bytes .../demos/dynamicscene/content/itemCreation.js | 62 ----- examples/demos/dynamicscene/dynamicscene.qml | 275 --------------------- examples/demos/tvtennis/tvtennis.qml | 109 -------- examples/qml/dynamicscene/content/Button.qml | 80 ++++++ .../qml/dynamicscene/content/GenericSceneItem.qml | 49 ++++ examples/qml/dynamicscene/content/PaletteItem.qml | 59 +++++ .../qml/dynamicscene/content/PerspectiveItem.qml | 65 +++++ examples/qml/dynamicscene/content/Sun.qml | 78 ++++++ examples/qml/dynamicscene/content/images/NOTE | 1 + .../qml/dynamicscene/content/images/face-smile.png | Bin 0 -> 15408 bytes examples/qml/dynamicscene/content/images/moon.png | Bin 0 -> 1757 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 0 -> 1245 bytes .../qml/dynamicscene/content/images/rabbit_bw.png | Bin 0 -> 1759 bytes examples/qml/dynamicscene/content/images/star.png | Bin 0 -> 349 bytes examples/qml/dynamicscene/content/images/sun.png | Bin 0 -> 8153 bytes .../qml/dynamicscene/content/images/tree_s.png | Bin 0 -> 3406 bytes examples/qml/dynamicscene/content/itemCreation.js | 62 +++++ examples/qml/dynamicscene/dynamicscene.qml | 275 +++++++++++++++++++++ examples/qtquick/animation/animation.qml | 3 + examples/qtquick/animation/behaviors/tvtennis.qml | 109 ++++++++ .../touchinteraction/flickable/content/Day.qml | 153 ++++++++++++ .../touchinteraction/flickable/content/cork.jpg | Bin 0 -> 149337 bytes .../flickable/content/note-yellow.png | Bin 0 -> 54559 bytes .../touchinteraction/flickable/content/tack.png | Bin 0 -> 7282 bytes .../touchinteraction/flickable/corkboards.qml | 116 +++++++++ 43 files changed, 1050 insertions(+), 1047 deletions(-) delete mode 100644 examples/demos/corkboards/content/Day.qml delete mode 100644 examples/demos/corkboards/content/cork.jpg delete mode 100644 examples/demos/corkboards/content/note-yellow.png delete mode 100644 examples/demos/corkboards/content/tack.png delete mode 100644 examples/demos/corkboards/corkboards.qml delete mode 100644 examples/demos/dynamicscene/content/Button.qml delete mode 100644 examples/demos/dynamicscene/content/GenericSceneItem.qml delete mode 100644 examples/demos/dynamicscene/content/PaletteItem.qml delete mode 100644 examples/demos/dynamicscene/content/PerspectiveItem.qml delete mode 100644 examples/demos/dynamicscene/content/Sun.qml delete mode 100644 examples/demos/dynamicscene/content/images/NOTE delete mode 100644 examples/demos/dynamicscene/content/images/face-smile.png delete mode 100644 examples/demos/dynamicscene/content/images/moon.png delete mode 100644 examples/demos/dynamicscene/content/images/rabbit_brown.png delete mode 100644 examples/demos/dynamicscene/content/images/rabbit_bw.png delete mode 100644 examples/demos/dynamicscene/content/images/star.png delete mode 100644 examples/demos/dynamicscene/content/images/sun.png delete mode 100644 examples/demos/dynamicscene/content/images/tree_s.png delete mode 100644 examples/demos/dynamicscene/content/itemCreation.js delete mode 100644 examples/demos/dynamicscene/dynamicscene.qml delete mode 100644 examples/demos/tvtennis/tvtennis.qml create mode 100644 examples/qml/dynamicscene/content/Button.qml create mode 100644 examples/qml/dynamicscene/content/GenericSceneItem.qml create mode 100644 examples/qml/dynamicscene/content/PaletteItem.qml create mode 100644 examples/qml/dynamicscene/content/PerspectiveItem.qml create mode 100644 examples/qml/dynamicscene/content/Sun.qml create mode 100644 examples/qml/dynamicscene/content/images/NOTE create mode 100644 examples/qml/dynamicscene/content/images/face-smile.png create mode 100644 examples/qml/dynamicscene/content/images/moon.png create mode 100644 examples/qml/dynamicscene/content/images/rabbit_brown.png create mode 100644 examples/qml/dynamicscene/content/images/rabbit_bw.png create mode 100644 examples/qml/dynamicscene/content/images/star.png create mode 100644 examples/qml/dynamicscene/content/images/sun.png create mode 100644 examples/qml/dynamicscene/content/images/tree_s.png create mode 100644 examples/qml/dynamicscene/content/itemCreation.js create mode 100644 examples/qml/dynamicscene/dynamicscene.qml create mode 100644 examples/qtquick/animation/behaviors/tvtennis.qml create mode 100644 examples/qtquick/touchinteraction/flickable/content/Day.qml create mode 100644 examples/qtquick/touchinteraction/flickable/content/cork.jpg create mode 100644 examples/qtquick/touchinteraction/flickable/content/note-yellow.png create mode 100644 examples/qtquick/touchinteraction/flickable/content/tack.png create mode 100644 examples/qtquick/touchinteraction/flickable/corkboards.qml diff --git a/examples/demos/corkboards/content/Day.qml b/examples/demos/corkboards/content/Day.qml deleted file mode 100644 index 7fe625c305..0000000000 --- a/examples/demos/corkboards/content/Day.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 - -Component { - Item { - property variant stickies - - id: page - width: ListView.view.width+40; height: ListView.view.height - - - Image { - source: "cork.jpg" - width: page.ListView.view.width - height: page.ListView.view.height - fillMode: Image.PreserveAspectCrop - clip: true - } - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - - Text { - text: name; x: 15; y: 8; height: 40; width: 370 - font.pixelSize: 18; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - - property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 - property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 - - x: randomX; y: randomY - - rotation: -flickable.horizontalVelocity / 100; - Behavior on rotation { - SpringAnimation { spring: 2.0; damping: 0.15 } - } - - Item { - id: sticky - scale: 0.7 - - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } - - TextEdit { - id: myText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - text: noteText - } - - Item { - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis - drag.minimumY: 0 - drag.maximumY: page.height - 80 - drag.minimumX: 100 - drag.maximumX: page.width - 140 - onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } - } - } - } - - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "tack.png" - scale: 0.7; transformOrigin: Item.TopLeft - } - - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } - - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } - } - } - } - } -} - - - - - - - - diff --git a/examples/demos/corkboards/content/cork.jpg b/examples/demos/corkboards/content/cork.jpg deleted file mode 100644 index 160bc002bf..0000000000 Binary files a/examples/demos/corkboards/content/cork.jpg and /dev/null differ diff --git a/examples/demos/corkboards/content/note-yellow.png b/examples/demos/corkboards/content/note-yellow.png deleted file mode 100644 index 8ddecc8b03..0000000000 Binary files a/examples/demos/corkboards/content/note-yellow.png and /dev/null differ diff --git a/examples/demos/corkboards/content/tack.png b/examples/demos/corkboards/content/tack.png deleted file mode 100644 index cef2d1cd23..0000000000 Binary files a/examples/demos/corkboards/content/tack.png and /dev/null differ diff --git a/examples/demos/corkboards/corkboards.qml b/examples/demos/corkboards/corkboards.qml deleted file mode 100644 index dc3aa6b378..0000000000 --- a/examples/demos/corkboards/corkboards.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 -import "content" - -Rectangle { - width: 800; height: 480 - color: "#464646" - - ListModel { - id: list - - ListElement { - name: "Sunday" - notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } - ] - } - - ListElement { - name: "Monday" - notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } - ] - } - - ListElement { - name: "Tuesday" - notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } - ] - } - } - - ListView { - id: flickable - - anchors.fill: parent - focus: true - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - model: list - delegate: Day { } - } -} diff --git a/examples/demos/dynamicscene/content/Button.qml b/examples/demos/dynamicscene/content/Button.qml deleted file mode 100644 index 014692274a..0000000000 --- a/examples/demos/dynamicscene/content/Button.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? activePalette.light : activePalette.button - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? activePalette.button : activePalette.dark - } - } - - SystemPalette { id: activePalette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - color: activePalette.buttonText - } -} diff --git a/examples/demos/dynamicscene/content/GenericSceneItem.qml b/examples/demos/dynamicscene/content/GenericSceneItem.qml deleted file mode 100644 index 0408aa87fb..0000000000 --- a/examples/demos/dynamicscene/content/GenericSceneItem.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 - -Image { - property bool created: false - property string image - - source: image - -} diff --git a/examples/demos/dynamicscene/content/PaletteItem.qml b/examples/demos/dynamicscene/content/PaletteItem.qml deleted file mode 100644 index e993f89989..0000000000 --- a/examples/demos/dynamicscene/content/PaletteItem.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.continueDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/demos/dynamicscene/content/PerspectiveItem.qml b/examples/demos/dynamicscene/content/PerspectiveItem.qml deleted file mode 100644 index f651369452..0000000000 --- a/examples/demos/dynamicscene/content/PerspectiveItem.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - smooth: true - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/demos/dynamicscene/content/Sun.qml b/examples/demos/dynamicscene/content/Sun.qml deleted file mode 100644 index b84516eecc..0000000000 --- a/examples/demos/dynamicscene/content/Sun.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 - -Image { - id: sun - - property bool created: false - property string image: "images/sun.png" - - source: image - - // once item is created, start moving offscreen - NumberAnimation on y { - to: (window.height / 2) + window.centerOffset - running: created - onRunningChanged: { - if (running) - duration = (window.height + window.centerOffset - sun.y) * 10; - else - state = "OffScreen" - } - } - - states: State { - name: "OffScreen" - StateChangeScript { - script: { sun.created = false; sun.destroy() } - } - } - - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - } else { - window.activeSuns--; - } - } -} diff --git a/examples/demos/dynamicscene/content/images/NOTE b/examples/demos/dynamicscene/content/images/NOTE deleted file mode 100644 index fcd87f9132..0000000000 --- a/examples/demos/dynamicscene/content/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/demos/dynamicscene/content/images/face-smile.png b/examples/demos/dynamicscene/content/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/demos/dynamicscene/content/images/face-smile.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/moon.png b/examples/demos/dynamicscene/content/images/moon.png deleted file mode 100644 index 1c0d6066a8..0000000000 Binary files a/examples/demos/dynamicscene/content/images/moon.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/rabbit_brown.png b/examples/demos/dynamicscene/content/images/rabbit_brown.png deleted file mode 100644 index ebfdeed332..0000000000 Binary files a/examples/demos/dynamicscene/content/images/rabbit_brown.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/rabbit_bw.png b/examples/demos/dynamicscene/content/images/rabbit_bw.png deleted file mode 100644 index 7bff9b92ca..0000000000 Binary files a/examples/demos/dynamicscene/content/images/rabbit_bw.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/star.png b/examples/demos/dynamicscene/content/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/demos/dynamicscene/content/images/star.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/sun.png b/examples/demos/dynamicscene/content/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/demos/dynamicscene/content/images/sun.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/tree_s.png b/examples/demos/dynamicscene/content/images/tree_s.png deleted file mode 100644 index 6eac35a729..0000000000 Binary files a/examples/demos/dynamicscene/content/images/tree_s.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/itemCreation.js b/examples/demos/dynamicscene/content/itemCreation.js deleted file mode 100644 index 40f5415f9f..0000000000 --- a/examples/demos/dynamicscene/content/itemCreation.js +++ /dev/null @@ -1,62 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(window, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); - // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(itemComponent.errorString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/demos/dynamicscene/dynamicscene.qml b/examples/demos/dynamicscene/dynamicscene.qml deleted file mode 100644 index c64df5cfc0..0000000000 --- a/examples/demos/dynamicscene/dynamicscene.qml +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: window - - property int activeSuns: 0 - property int centerOffset: 72 - - height: 480; width: 320 - - - MouseArea { - anchors.fill: parent - onClicked: window.focus = false; - } - - //This is the message box that pops up when there's an error - Rectangle { - id: dialog - - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6; height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - - Text { - id: dialogText - x: 3; y: 3 - font.pixelSize: 14 - } - - SequentialAnimation { - id: dialogAnim - NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } - PauseAnimation { duration: 5000 } - NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } - } - } - - Item { - id: scene - anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} - z: 10 - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - ParticleSystem { - id: particlesystem - anchors.fill: sky - - ImageParticle { - id: stars - source: "content/images/star.png" - groups: ["stars"] - opacity: .5 - } - - Emitter { - id: starsemitter - anchors.fill: parent - emitRate: parent.width / 50 - lifeSpan: 5000 - group: "stars" - } - } - - // ground - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - SystemPalette { id: activePalette } - - // right-hand panel - Rectangle { - id: toolbox - - height: centerOffset * 2 - color: activePalette.window - anchors { right: parent.right; top: parent.top; left: parent.left} - - Column { - anchors.centerIn: parent - spacing: 8 - - Text { text: "Drag an item into the scene." } - - Rectangle { - width: palette.width + 10; height: palette.height + 10 - border.color: "black" - - Row { - id: palette - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - source: "content/images/sun.png" - image: "images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - source: "content/images/moon.png" - image: "images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/tree_s.png" - image: "images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_brown.png" - image: "images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_bw.png" - image: "images/rabbit_bw.png" - } - } - } - - Text { text: "Active Suns: " + activeSuns } - } - } - - //Popup toolbox down the bottom - Rectangle { - id: popupToolbox - z: 1000 - width: parent.width - height: popupColumn.height + 16 - color: activePalette.window - - property bool poppedUp: false - property int downY: window.height - (createButton.height + 16) - property int upY: window.height - (popupColumn.height + 16) - y: poppedUp ? upY : downY - Behavior on y { NumberAnimation {}} - - Column { - id: popupColumn - y: 8 - anchors.centerIn: parent - spacing: 8 - - Row { - height: createButton.height - spacing: 8 - Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } - Button { - id: popupButton - text: popupToolbox.poppedUp ? "Hide" : "Show" - onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp - } - Button { - id: createButton - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - - } - - Rectangle { - width: 360; height: 240 - - TextEdit { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - font.pixelSize: 14 - selectByMouse: true - wrapMode: TextEdit.WordWrap - - text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } - PropertyChanges { target: gradientStopB; color: "SkyBlue" } - PropertyChanges { target: stars; opacity: 0 } - } - - //! [top-level transitions] - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - //! [top-level transitions] -} diff --git a/examples/demos/tvtennis/tvtennis.qml b/examples/demos/tvtennis/tvtennis.qml deleted file mode 100644 index 63866e3ce6..0000000000 --- a/examples/demos/tvtennis/tvtennis.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 2.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - id: ball - - // Add a property for the target y coordinate - property variant direction : "right" - - x: 20; width: 20; height: 20; z: 1 - color: "Lime" - - // Move the ball to the right and back to the left repeatedly - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { to: page.width - 40; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y move with a velocity of 200 - Behavior on y { SpringAnimation{ velocity: 200; } - } - - Component.onCompleted: y = page.height-10; // start the ball motion - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - y = page.height - 20; - } else if (y >= page.height - 20) { - y = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - Rectangle { - id: rightBat - color: "Lime" - x: page.width - 22; width: 20; height: 90 - y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - - // The rest, to make it look realistic, if neither ever scores... - Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } - Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } - Repeater { - model: page.height / 20 - Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } - } -} diff --git a/examples/qml/dynamicscene/content/Button.qml b/examples/qml/dynamicscene/content/Button.qml new file mode 100644 index 0000000000..014692274a --- /dev/null +++ b/examples/qml/dynamicscene/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 + +Rectangle { + id: container + + property variant text + signal clicked + + height: text.height + 10; width: text.width + 20 + border.width: 1 + radius: 4 + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button + } + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark + } + } + + SystemPalette { id: activePalette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: text + anchors.centerIn:parent + font.pointSize: 10 + text: parent.text + color: activePalette.buttonText + } +} diff --git a/examples/qml/dynamicscene/content/GenericSceneItem.qml b/examples/qml/dynamicscene/content/GenericSceneItem.qml new file mode 100644 index 0000000000..0408aa87fb --- /dev/null +++ b/examples/qml/dynamicscene/content/GenericSceneItem.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 + +Image { + property bool created: false + property string image + + source: image + +} diff --git a/examples/qml/dynamicscene/content/PaletteItem.qml b/examples/qml/dynamicscene/content/PaletteItem.qml new file mode 100644 index 0000000000..e993f89989 --- /dev/null +++ b/examples/qml/dynamicscene/content/PaletteItem.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 +import "itemCreation.js" as Code + +Image { + id: paletteItem + + property string componentFile + property string image + + source: image + + MouseArea { + anchors.fill: parent + + onPressed: Code.startDrag(mouse); + onPositionChanged: Code.continueDrag(mouse); + onReleased: Code.endDrag(mouse); + } +} diff --git a/examples/qml/dynamicscene/content/PerspectiveItem.qml b/examples/qml/dynamicscene/content/PerspectiveItem.qml new file mode 100644 index 0000000000..f651369452 --- /dev/null +++ b/examples/qml/dynamicscene/content/PerspectiveItem.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 + +Image { + id: rootItem + + property bool created: false + property string image + + property double scaledBottom: y + (height + height*scale) / 2 + property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) + + source: image + opacity: onLand ? 1 : 0.25 + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; +} diff --git a/examples/qml/dynamicscene/content/Sun.qml b/examples/qml/dynamicscene/content/Sun.qml new file mode 100644 index 0000000000..b84516eecc --- /dev/null +++ b/examples/qml/dynamicscene/content/Sun.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 + +Image { + id: sun + + property bool created: false + property string image: "images/sun.png" + + source: image + + // once item is created, start moving offscreen + NumberAnimation on y { + to: (window.height / 2) + window.centerOffset + running: created + onRunningChanged: { + if (running) + duration = (window.height + window.centerOffset - sun.y) * 10; + else + state = "OffScreen" + } + } + + states: State { + name: "OffScreen" + StateChangeScript { + script: { sun.created = false; sun.destroy() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } + } +} diff --git a/examples/qml/dynamicscene/content/images/NOTE b/examples/qml/dynamicscene/content/images/NOTE new file mode 100644 index 0000000000..fcd87f9132 --- /dev/null +++ b/examples/qml/dynamicscene/content/images/NOTE @@ -0,0 +1 @@ +Images (except star.png) are from the KDE project. diff --git a/examples/qml/dynamicscene/content/images/face-smile.png b/examples/qml/dynamicscene/content/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/face-smile.png differ diff --git a/examples/qml/dynamicscene/content/images/moon.png b/examples/qml/dynamicscene/content/images/moon.png new file mode 100644 index 0000000000..1c0d6066a8 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/moon.png differ diff --git a/examples/qml/dynamicscene/content/images/rabbit_brown.png b/examples/qml/dynamicscene/content/images/rabbit_brown.png new file mode 100644 index 0000000000..ebfdeed332 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/rabbit_brown.png differ diff --git a/examples/qml/dynamicscene/content/images/rabbit_bw.png b/examples/qml/dynamicscene/content/images/rabbit_bw.png new file mode 100644 index 0000000000..7bff9b92ca Binary files /dev/null and b/examples/qml/dynamicscene/content/images/rabbit_bw.png differ diff --git a/examples/qml/dynamicscene/content/images/star.png b/examples/qml/dynamicscene/content/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/star.png differ diff --git a/examples/qml/dynamicscene/content/images/sun.png b/examples/qml/dynamicscene/content/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/sun.png differ diff --git a/examples/qml/dynamicscene/content/images/tree_s.png b/examples/qml/dynamicscene/content/images/tree_s.png new file mode 100644 index 0000000000..6eac35a729 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/tree_s.png differ diff --git a/examples/qml/dynamicscene/content/itemCreation.js b/examples/qml/dynamicscene/content/itemCreation.js new file mode 100644 index 0000000000..40f5415f9f --- /dev/null +++ b/examples/qml/dynamicscene/content/itemCreation.js @@ -0,0 +1,62 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var posnInWindow; + +function startDrag(mouse) +{ + posnInWindow = paletteItem.mapToItem(window, 0, 0); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asynchronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) { // component has been previously loaded + createItem(); + return; + } + + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else + createItem(); +} + +function createItem() { + if (itemComponent.status == Component.Ready && draggedItem == null) { + draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); + // make sure created item is above the ground layer + } else if (itemComponent.status == Component.Error) { + draggedItem = null; + console.log("error creating component"); + console.log(itemComponent.errorString()); + } +} + +function continueDrag(mouse) +{ + if (draggedItem == null) + return; + + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; +} + +function endDrag(mouse) +{ + if (draggedItem == null) + return; + + if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + } else { + draggedItem.created = true; + draggedItem = null; + } +} + diff --git a/examples/qml/dynamicscene/dynamicscene.qml b/examples/qml/dynamicscene/dynamicscene.qml new file mode 100644 index 0000000000..c64df5cfc0 --- /dev/null +++ b/examples/qml/dynamicscene/dynamicscene.qml @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: window + + property int activeSuns: 0 + property int centerOffset: 72 + + height: 480; width: 320 + + + MouseArea { + anchors.fill: parent + onClicked: window.focus = false; + } + + //This is the message box that pops up when there's an error + Rectangle { + id: dialog + + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6; height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + + Text { + id: dialogText + x: 3; y: 3 + font.pixelSize: 14 + } + + SequentialAnimation { + id: dialogAnim + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } + } + } + + Item { + id: scene + anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} + z: 10 + } + + // sky + Rectangle { + id: sky + anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } + } + } + + // stars (when there's no sun) + ParticleSystem { + id: particlesystem + anchors.fill: sky + + ImageParticle { + id: stars + source: "content/images/star.png" + groups: ["stars"] + opacity: .5 + } + + Emitter { + id: starsemitter + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + group: "stars" + } + } + + // ground + Rectangle { + id: ground + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + SystemPalette { id: activePalette } + + // right-hand panel + Rectangle { + id: toolbox + + height: centerOffset * 2 + color: activePalette.window + anchors { right: parent.right; top: parent.top; left: parent.left} + + Column { + anchors.centerIn: parent + spacing: 8 + + Text { text: "Drag an item into the scene." } + + Rectangle { + width: palette.width + 10; height: palette.height + 10 + border.color: "black" + + Row { + id: palette + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + source: "content/images/sun.png" + image: "images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + source: "content/images/moon.png" + image: "images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/tree_s.png" + image: "images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_brown.png" + image: "images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_bw.png" + image: "images/rabbit_bw.png" + } + } + } + + Text { text: "Active Suns: " + activeSuns } + } + } + + //Popup toolbox down the bottom + Rectangle { + id: popupToolbox + z: 1000 + width: parent.width + height: popupColumn.height + 16 + color: activePalette.window + + property bool poppedUp: false + property int downY: window.height - (createButton.height + 16) + property int upY: window.height - (popupColumn.height + 16) + y: poppedUp ? upY : downY + Behavior on y { NumberAnimation {}} + + Column { + id: popupColumn + y: 8 + anchors.centerIn: parent + spacing: 8 + + Row { + height: createButton.height + spacing: 8 + Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: popupButton + text: popupToolbox.poppedUp ? "Hide" : "Show" + onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp + } + Button { + id: createButton + text: "Create" + onClicked: { + try { + Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); + } + } + } + + } + + Rectangle { + width: 360; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + font.pixelSize: 14 + selectByMouse: true + wrapMode: TextEdit.WordWrap + + text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" + } + } + } + } + + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + //! [top-level transitions] + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + //! [top-level transitions] +} diff --git a/examples/qtquick/animation/animation.qml b/examples/qtquick/animation/animation.qml index 62a85a9cfa..bca68457d9 100644 --- a/examples/qtquick/animation/animation.qml +++ b/examples/qtquick/animation/animation.qml @@ -58,6 +58,8 @@ import "../../shared" as Examples Wiggly Text demonstrates using more complex behaviors to animate and wiggle some text around as you drag it. + Tv Tennis demonstrates using more complex behaviors to get paddles following a ball for an infinite game. + Easing Curves shows off all the easing curves available in Qt Quick animations. States demonstrates how the properties of an item can vary between states. @@ -80,6 +82,7 @@ Item { addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml")); addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml")); addExample("Wiggly Text", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml")); + addExample("Tv Tennis", "Paddles that follow a ball", Qt.resolvedUrl("behaviors/tvtennis.qml")); addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml")); addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml")); addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml")); diff --git a/examples/qtquick/animation/behaviors/tvtennis.qml b/examples/qtquick/animation/behaviors/tvtennis.qml new file mode 100644 index 0000000000..108f19a11d --- /dev/null +++ b/examples/qtquick/animation/behaviors/tvtennis.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 + +Rectangle { + id: page + width: 320; height: 480; + color: "Black" + + // Make a ball to bounce + Rectangle { + id: ball + + // Add a property for the target y coordinate + property variant direction : "right" + + x: 20; width: 20; height: 20; z: 1 + color: "Lime" + + // Move the ball to the right and back to the left repeatedly + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { to: page.width - 40; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y move with a velocity of 200 + Behavior on y { SpringAnimation{ velocity: 200; } + } + + Component.onCompleted: y = page.height-10; // start the ball motion + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + y = page.height - 20; + } else if (y >= page.height - 20) { + y = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + Rectangle { + id: rightBat + color: "Lime" + x: page.width - 22; width: 20; height: 90 + y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + + // The rest, to make it look realistic, if neither ever scores... + Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } + Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } + Repeater { + model: page.height / 20 + Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } + } +} diff --git a/examples/qtquick/touchinteraction/flickable/content/Day.qml b/examples/qtquick/touchinteraction/flickable/content/Day.qml new file mode 100644 index 0000000000..7fe625c305 --- /dev/null +++ b/examples/qtquick/touchinteraction/flickable/content/Day.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 + +Component { + Item { + property variant stickies + + id: page + width: ListView.view.width+40; height: ListView.view.height + + + Image { + source: "cork.jpg" + width: page.ListView.view.width + height: page.ListView.view.height + fillMode: Image.PreserveAspectCrop + clip: true + } + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + + Repeater { + model: notes + Item { + id: stickyPage + + property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 + property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 + + x: randomX; y: randomY + + rotation: -flickable.horizontalVelocity / 100; + Behavior on rotation { + SpringAnimation { spring: 2.0; damping: 0.15 } + } + + Item { + id: sticky + scale: 0.7 + + Image { + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + text: noteText + } + + Item { + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + + MouseArea { + id: mouse + anchors.fill: parent + drag.target: stickyPage + drag.axis: Drag.XandYAxis + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } + } + } + } + + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } + + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } + } + } + } +} + + + + + + + + diff --git a/examples/qtquick/touchinteraction/flickable/content/cork.jpg b/examples/qtquick/touchinteraction/flickable/content/cork.jpg new file mode 100644 index 0000000000..160bc002bf Binary files /dev/null and b/examples/qtquick/touchinteraction/flickable/content/cork.jpg differ diff --git a/examples/qtquick/touchinteraction/flickable/content/note-yellow.png b/examples/qtquick/touchinteraction/flickable/content/note-yellow.png new file mode 100644 index 0000000000..8ddecc8b03 Binary files /dev/null and b/examples/qtquick/touchinteraction/flickable/content/note-yellow.png differ diff --git a/examples/qtquick/touchinteraction/flickable/content/tack.png b/examples/qtquick/touchinteraction/flickable/content/tack.png new file mode 100644 index 0000000000..cef2d1cd23 Binary files /dev/null and b/examples/qtquick/touchinteraction/flickable/content/tack.png differ diff --git a/examples/qtquick/touchinteraction/flickable/corkboards.qml b/examples/qtquick/touchinteraction/flickable/corkboards.qml new file mode 100644 index 0000000000..dc3aa6b378 --- /dev/null +++ b/examples/qtquick/touchinteraction/flickable/corkboards.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 2.0 +import "content" + +Rectangle { + width: 800; height: 480 + color: "#464646" + + ListModel { + id: list + + ListElement { + name: "Sunday" + notes: [ + ListElement { noteText: "Lunch" }, + ListElement { noteText: "Birthday Party" } + ] + } + + ListElement { + name: "Monday" + notes: [ + ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ] + } + + ListElement { + name: "Tuesday" + notes: [ + ListElement { noteText: "Walk dog" }, + ListElement { noteText: "Buy newspaper" } + ] + } + + ListElement { + name: "Wednesday" + notes: [ ListElement { noteText: "Cook dinner" } ] + } + + ListElement { + name: "Thursday" + notes: [ + ListElement { noteText: "Meeting\n5.30pm" }, + ListElement { noteText: "Weed garden" } + ] + } + + ListElement { + name: "Friday" + notes: [ + ListElement { noteText: "More work" }, + ListElement { noteText: "Grocery shopping" } + ] + } + + ListElement { + name: "Saturday" + notes: [ + ListElement { noteText: "Drink" }, + ListElement { noteText: "Download Qt\nPlay with QML" } + ] + } + } + + ListView { + id: flickable + + anchors.fill: parent + focus: true + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + model: list + delegate: Day { } + } +} -- cgit v1.2.3