diff options
Diffstat (limited to 'examples')
109 files changed, 5428 insertions, 285 deletions
diff --git a/examples/declarative/canvas/motionchart/motionchart.qml b/examples/declarative/canvas/motionchart/motionchart.qml new file mode 100644 index 0000000000..974690e3fc --- /dev/null +++ b/examples/declarative/canvas/motionchart/motionchart.qml @@ -0,0 +1,140 @@ +import QtQuick 2.0 + +Canvas { + id:motionChart + width:1300 + height: 700 + property int progress:-1 + property variant applesFrom: [1000, 300]; + property variant applesTo:[1200, 400]; + property variant orangesFrom: [1150, 200]; + property variant orangesTo:[250, 550]; + property variant bananasFrom: [300, 250]; + property variant bananasTo:[788, 617]; + + property date startDate:new Date (1988,0,1) + property date endDate:new Date (1989,6,1) + property variant title:["Fruit", "Sales", "Expenses", "Location"]; + property bool clearTrace:true + Text {id:appleText; text:"Apples"; font.bold:true; font.pixelSize:12; opacity:0} + Text {id:orangeText; text:"Oranges"; font.bold:true; font.pixelSize:12; opacity:0} + Text {id:bananaText; text:"Bananas"; font.bold:true; font.pixelSize:12; opacity:0} + + Text {id:sales; text: "700 Sales"; x:15; y:15;font.bold:true; font.pixelSize:15; opacity:0} + Text {id:expenses; text: "Expenses 1300"; x:1170; y:670;font.bold:true; font.pixelSize:15; opacity:0} + Timer { + id:timer + interval: 1; running: true; repeat: true + onTriggered: { + if (motionChart.progress == -1) { + motionChart.setup(); + running = false; + } + motionChart.draw(); + } + } + + MouseArea { + anchors.fill: parent + onPressed : { + motionChart.progress = 0; + setup(); + timer.running = true; + motionChart.clearTrace = true; + } + onDoubleClicked : { + motionChart.progress = 0; + setup(); + timer.running = true; + motionChart.clearTrace = false; + } + } + + + function setup() { + var ctx = motionChart.getContext("2d"); + ctx.globalCompositeOperation = "source-over"; + ctx.clearRect(0, 0, motionChart.width, motionChart.height); + + ctx.strokeColor = Qt.rgba(133, 133, 133,1); + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(10,690); + ctx.lineTo(10, 5); + ctx.moveTo(10,690); + ctx.lineTo(1295, 690); + + for ( var i = 0; i < 10; i++) { + ctx.moveTo(10, i*70); + ctx.lineTo(15, i*70); + ctx.moveTo(i*130, 690); + ctx.lineTo(i*130, 685); + } + + ctx.stroke(); + sales.opacity =1; + expenses.opacity = 1; + appleText.opacity = 1; + orangeText.opacity = 1; + bananaText.opacity = 1; + } + + function draw() { + var totalDays = Math.ceil((endDate.getTime()-startDate.getTime())/(1000*60*60*24)); + if (motionChart.progress >= totalDays) { + timer.running = false; + return; + } + var apples = []; + apples[0] = applesFrom[0] + ((applesTo[0] - applesFrom[0]) * (motionChart.progress/totalDays)); + apples[1] = applesFrom[1] + ((applesTo[1] - applesFrom[1]) * (motionChart.progress/totalDays)); + + var oranges = []; + oranges[0] = orangesFrom[0] + ((orangesTo[0] - orangesFrom[0]) * (motionChart.progress/totalDays)); + oranges[1] = orangesFrom[1] + ((orangesTo[1] - orangesFrom[1]) * (motionChart.progress/totalDays)); + + var bananas = []; + bananas[0] = bananasFrom[0] + ((bananasTo[0] - bananasFrom[0]) * (motionChart.progress/totalDays)); + bananas[1] = bananasFrom[1] + ((bananasTo[1] - bananasFrom[1]) * (motionChart.progress/totalDays)); + + var ctx = motionChart.getContext("2d"); + ctx.globalCompositeOperation = "source-over"; + + if (motionChart.clearTrace) + ctx.clearRect(15, 15, motionChart.width - 15, motionChart.height - 30); + + + //apples + ctx.fillColor = Qt.rgba(0,255,0,1); + + ctx.beginPath(); + ctx.arc( apples[0] , 700 - apples[1] , 20 , 0 , Math.PI * 2 , true ); + //ctx.closePath(); + ctx.fill(); + ctx.fillRect(apples[0], 700 - apples[1], 28, 28); + appleText.x = apples[0]; + appleText.y = 700 - apples[1] - 30; + //oranges + ctx.fillColor = Qt.rgba(0,0,255,1); + ctx.beginPath(); + ctx.arc( oranges[0], 700 - oranges[1] , 20 , 0 , Math.PI * 2 , true ); + ctx.closePath(); + ctx.fill(); + ctx.fillRect(oranges[0], 700 - oranges[1], 28, 28); + orangeText.x = oranges[0]; + orangeText.y = 700 - oranges[1] - 30; + + //bananas + ctx.fillColor = Qt.rgba(255,0,0,1); + ctx.beginPath(); + ctx.arc( bananas[0] , 700 - bananas[1] , 20 , 0 , Math.PI * 2 , true ); + ctx.closePath(); + ctx.fill(); + ctx.fillRect(bananas[0], 700 - bananas[1], 28, 28); + bananaText.x = bananas[0]; + bananaText.y = 700 - bananas[1] - 30; + + ctx.sync(); + motionChart.progress ++; + } +} diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro index 927294ade6..cbeb7e9e26 100644 --- a/examples/declarative/declarative.pro +++ b/examples/declarative/declarative.pro @@ -4,7 +4,8 @@ TEMPLATE = subdirs SUBDIRS = \ cppextensions \ modelviews \ - tutorials + tutorials \ + painteditem # plugins uses a 'Time' class that conflicts with symbian e32std.h also defining a class of the same name symbian:SUBDIRS -= plugins diff --git a/examples/declarative/modelviews/webview/webview.qmlproject b/examples/declarative/inputmethods/inputmethods.qmlproject index d4909f8685..d4909f8685 100644 --- a/examples/declarative/modelviews/webview/webview.qmlproject +++ b/examples/declarative/inputmethods/inputmethods.qmlproject diff --git a/examples/declarative/inputmethods/spellcheck/Key.qml b/examples/declarative/inputmethods/spellcheck/Key.qml new file mode 100644 index 0000000000..c95a3f0b2c --- /dev/null +++ b/examples/declarative/inputmethods/spellcheck/Key.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 + +Rectangle { + property string text + property string displayText + property alias font: keyText.font + property int key: 0 + + id: root + radius: 2 + + width: 28 + height: 28 + + gradient: Gradient { + GradientStop { position: 0.0; color: "darkgrey" } + GradientStop { position: 1.0; color: "grey" } + } + + Text { + id: keyText + + anchors.fill: parent + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + font.pixelSize: 18 + font.capitalization: keyboard.shift && displayText == "" ? Font.AllUppercase : Font.MixedCase + + text: root.displayText != "" ? root.displayText : root.text + + style: !mouseArea.pressed ? Text.Raised : Text.Normal + color: "white" + styleColor: "grey" + } + + MouseArea { + id: mouseArea + + anchors.fill: parent + onPressed: keyboard.keyPress(key, text) + onReleased: keyboard.keyRelease(key, text) + } +} diff --git a/examples/declarative/inputmethods/spellcheck/Keyboard.qml b/examples/declarative/inputmethods/spellcheck/Keyboard.qml new file mode 100644 index 0000000000..533762e7ba --- /dev/null +++ b/examples/declarative/inputmethods/spellcheck/Keyboard.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.inputcontext 1.0 as InputContext + + +Rectangle { + id: keyboard + + radius: 5 + height: 122 + width: 324 + + property bool shift: false + + gradient: Gradient { + GradientStop { position: 0.0; color: "lightgrey" } + GradientStop { position: 1.0; color: "white" } + } + + Column { + anchors.left: parent.left; anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + spacing: 2 + + Row { + spacing: 2 + anchors.horizontalCenter: parent.horizontalCenter + + Key { key: Qt.Key_Q; text: "q"; } + Key { key: Qt.Key_W; text: "w"; } + Key { key: Qt.Key_E; text: "e"; } + Key { key: Qt.Key_R; text: "r"; } + Key { key: Qt.Key_T; text: "t"; } + Key { key: Qt.Key_Y; text: "y"; } + Key { key: Qt.Key_U; text: "u"; } + Key { key: Qt.Key_I; text: "i"; } + Key { key: Qt.Key_O; text: "o"; } + Key { key: Qt.Key_P; text: "p"; } + } + Row { + spacing: 2 + anchors.horizontalCenter: parent.horizontalCenter + + Key { key: Qt.Key_A; text: "a"; } + Key { key: Qt.Key_S; text: "s"; } + Key { key: Qt.Key_D; text: "d"; } + Key { key: Qt.Key_F; text: "f"; } + Key { key: Qt.Key_G; text: "g"; } + Key { key: Qt.Key_H; text: "h"; } + Key { key: Qt.Key_J; text: "j"; } + Key { key: Qt.Key_K; text: "k"; } + Key { key: Qt.Key_L; text: "l"; } + } + Row { + spacing: 2 + anchors.horizontalCenter: parent.horizontalCenter + + Key { key: Qt.Key_Shift; displayText: "shift"; width: 50 } + Key { key: Qt.Key_Z; text: "z"; } + Key { key: Qt.Key_X; text: "x"; } + Key { key: Qt.Key_C; text: "c"; } + Key { key: Qt.Key_V; text: "v"; } + Key { key: Qt.Key_B; text: "b"; } + Key { key: Qt.Key_N; text: "n"; } + Key { key: Qt.Key_M; text: "m"; } + Key { key: Qt.Key_Comma; text: ","; } + Key { key: Qt.Key_Period; text: "."; } + } + + Row { + spacing: 2 + anchors.horizontalCenter: parent.horizontalCenter + + Key { key: Qt.Key_Enter; text: "\n"; displayText: "enter"; width: 90 } + Key { key: Qt.Key_Space; text: " "; displayText: "space"; width: 138} + Key { key: Qt.Key_Backspace; displayText: "backspace"; width: 90 } + } + } + + function keyPress(key, text) + { + if (key == Qt.Key_Shift) + keyboard.shift = !keyboard.shift + else if (keyboard.shift) + InputContext.sendKeyPress(key, text.toUpperCase(), Qt.ShiftModifier) + else + InputContext.sendKeyPress(key, text) + } + + function keyRelease(key, text) + { + if (key != Qt.Key_Shift) { + if (keyboard.shift) { + InputContext.sendKeyRelease(key, text.toUpperCase(), Qt.ShiftModifier) + keyboard.shift = false + } else { + InputContext.sendKeyRelease(key, text) + } + } + } +} diff --git a/examples/declarative/modelviews/webview/alerts.qml b/examples/declarative/inputmethods/spellcheck/WordSuggestions.qml index 5acf0e0980..5c4e9cb4a2 100644 --- a/examples/declarative/modelviews/webview/alerts.qml +++ b/examples/declarative/inputmethods/spellcheck/WordSuggestions.qml @@ -38,64 +38,63 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtWebKit 1.0 +import QtQuick 2.0 +import Qt.labs.inputcontext 1.0 as InputContext -WebView { - id: webView - width: 200 - height: 150 - url: "alerts.html" - - onAlert: popup.show(message) +ListView { + property int globalX: InputContext.microFocus.x + ((InputContext.microFocus.width - width) / 2) + property int globalY: InputContext.microFocus.y + InputContext.microFocus.height - Rectangle { - id: popup + x: parent.mapToItem(null, globalX, globalY).x + y: parent.mapToItem(null, globalX, globalY).y - color: "red" - border.color: "black"; border.width: 2 - radius: 4 + visible: suggestionModel.count > 0 - y: parent.height // off "screen" - anchors.horizontalCenter: parent.horizontalCenter - width: label.width + 5 - height: label.height + 5 + width: 200 + height: 70 - opacity: 0 + InputContext.KeyFilter { + onPressed: event.accepted = filterKeyPress(event.key, event.text) + } - function show(text) { - label.text = text - popup.state = "visible" - timer.start() - } - states: State { - name: "visible" - PropertyChanges { target: popup; opacity: 1 } - PropertyChanges { target: popup; y: (webView.height-popup.height)/2 } + InputContext.MouseHandler { + onPressed: { + if (cursor < 0 || cursor >= InputContext.preeditText.length) + InputContext.commit() } + } - transitions: [ - Transition { from: ""; PropertyAnimation { properties: "opacity,y"; duration: 65 } }, - Transition { from: "visible"; PropertyAnimation { properties: "opacity,y"; duration: 500 } } - ] + model: XmlListModel { + id: suggestionModel - Timer { - id: timer - interval: 1000 + query: "/query/results/s:suggestion" + namespaceDeclarations: "declare namespace s=\"http://www.inktomi.com/\";" + source: InputContext.preeditText.length > 4 ? "http://query.yahooapis.com/v1/public/yql?q=select * from search.spelling where query=\"" + InputContext.preeditText + "\"" : "" - onTriggered: popup.state = "" - } + XmlRole { name: "suggestion"; query: "string()" } + } + + delegate: Rectangle { + radius: 2 + color: "lightsteelblue" + + anchors.horizontalCenter: parent.horizontalCenter + + width: suggestionText.implicitWidth + 2 + height: suggestionText.implicitHeight + 2 Text { - id: label - anchors.centerIn: parent - width: webView.width *0.75 - - color: "white" - font.pixelSize: 20 - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - smooth: true + id: suggestionText + + font: InputContext.font + text: suggestion + + anchors.fill: parent + anchors.margins: 1 + } + MouseArea { + anchors.fill: parent + onClicked: InputContext.commit(suggestion) } } } diff --git a/examples/declarative/inputmethods/spellcheck/spellcheck.qml b/examples/declarative/inputmethods/spellcheck/spellcheck.qml new file mode 100644 index 0000000000..57e81451a6 --- /dev/null +++ b/examples/declarative/inputmethods/spellcheck/spellcheck.qml @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.inputcontext 1.0 as InputContext + +Item { + width: 360 + height: 240 + + function filterKeyPress(key, text) + { + switch (key) { + case Qt.Key_Enter: + case Qt.Key_Return: + case Qt.Key_Space: + case Qt.Key_Tab: + if (InputContext.preeditText != "") + InputContext.commit(); + break; + case Qt.Key_Backspace: + if (InputContext.preeditText != "") { + InputContext.preeditText = InputContext.preeditText.substr(0, InputContext.preeditText.length - 1); + return true; + } + break; + default: + if (text != "") { + InputContext.preeditText += text + return true; + } else if (InputContext.preeditText != "") { + InputContext.commit(); + } + break; + } + return false; + } + + Rectangle { + anchors.left: parent.left; anchors.top: parent.top; anchors.right: parent.right; + anchors.bottom: keyboard.top + anchors.margins: 2 + + border.width: 1 + radius: 2 + + TextEdit { + id: textEdit + + wrapMode: TextEdit.WordWrap + + anchors.fill: parent + anchors.margins: 2 + } + + MouseArea { + anchors.fill: textEdit + + onPressed: { + mouse.accepted = false + var position = textEdit.positionAt(mouse.x, mouse.y); + if (position != textEdit.cursorPosition) { + InputContext.commit() + textEdit.cursorPosition = textEdit.positionAt(mouse.x, mouse.y) + textEdit.selectWord() + var word = textEdit.selectedText + if (word != "") { + InputContext.commit(""); + InputContext.preeditText = word; + } + } + } + } + } + + WordSuggestions {} + + Keyboard { + id: keyboard + anchors.horizontalCenter: parent.horizontalCenter + + y: parent.height + + states: [ + State { + name: "visible" + PropertyChanges { target: keyboard; y: parent.height - height } + when: InputContext.softwareInputPanelVisible + }, + State { + name: "hidden" + PropertyChanges { target: keyboard; y: parent.height } + when: !InputContext.softwareInputPanelVisible + } + ] + transitions: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.InOutQuad; duration: 100 } + } + } +} diff --git a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml index f3894fb24d..224d38b057 100644 --- a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml +++ b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml @@ -86,7 +86,7 @@ FocusScope { hoverEnabled: true onClicked: { - GridView.view.currentIndex = index + container.GridView.view.currentIndex = index container.forceActiveFocus() } } diff --git a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml index 88c362495a..8f9d022971 100644 --- a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml +++ b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml @@ -68,7 +68,7 @@ Item { hoverEnabled: true onClicked: { - ListView.view.currentIndex = index + container.ListView.view.currentIndex = index container.forceActiveFocus() } } diff --git a/examples/declarative/modelviews/webview/newwindows/qml/alerts.html b/examples/declarative/modelviews/webview/newwindows/qml/alerts.html deleted file mode 100644 index 82caddf7fb..0000000000 --- a/examples/declarative/modelviews/webview/newwindows/qml/alerts.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body onclick="alert('This is an alert')"> -<p>This is a web page. It fires an alert when clicked. -</body> -</html> diff --git a/examples/declarative/modelviews/webview/newwindows/qml/content/Mapping/map.html b/examples/declarative/modelviews/webview/newwindows/qml/content/Mapping/map.html deleted file mode 100644 index a98da5430f..0000000000 --- a/examples/declarative/modelviews/webview/newwindows/qml/content/Mapping/map.html +++ /dev/null @@ -1,60 +0,0 @@ -<html> -<head> -<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> -<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> -<script type="text/javascript"> - var geocoder - var map - function goToLatLng(latlng,bounds) { - if (map) { - map.setCenter(latlng) - map.fitBounds(bounds) - } else { - var myOptions = { - zoom: 8, - center: latlng, - mapTypeId: google.maps.MapTypeId.ROADMAP - }; - map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); - } - } - function initialize() { - geocoder = new google.maps.Geocoder(); - if (window.qml.address) { - goToAddress() - } else { - goToLatLng(new google.maps.LatLng(window.qml.lat,window.qml.lng)); - } - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition(function(position) { - initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); - window.qml.lat = initialLocation.lat; - window.qml.lng = initialLocation.lng; - goToLatLng(initialLocation); - }); - } - } - function goToAddress() { - if (geocoder) { - var req = { - address: window.qml.address, - } - if (map) - req.bounds = map.getBounds() - window.qml.status = "Loading"; - geocoder.geocode(req, function(results, status) { - if (status == google.maps.GeocoderStatus.OK) { - window.qml.status = "Ready"; - goToLatLng(results[0].geometry.location,results[0].geometry.bounds); - } else { - window.qml.status = "Error"; - } - }); - } - } -</script> -</head> -<body onload="initialize()" leftmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px"> - <div id="map_canvas" style="width:100%; height:100%"></div> -</body> -</html> diff --git a/examples/declarative/modelviews/webview/newwindows/qml/content/pics/cancel.png b/examples/declarative/modelviews/webview/newwindows/qml/content/pics/cancel.png Binary files differdeleted file mode 100644 index ecc95331f2..0000000000 --- a/examples/declarative/modelviews/webview/newwindows/qml/content/pics/cancel.png +++ /dev/null diff --git a/examples/declarative/modelviews/webview/newwindows/qml/content/pics/ok.png b/examples/declarative/modelviews/webview/newwindows/qml/content/pics/ok.png Binary files differdeleted file mode 100644 index 5795f04fbf..0000000000 --- a/examples/declarative/modelviews/webview/newwindows/qml/content/pics/ok.png +++ /dev/null diff --git a/examples/declarative/modelviews/webview/newwindows/qml/newwindows.html b/examples/declarative/modelviews/webview/newwindows/qml/newwindows.html deleted file mode 100644 index f169599387..0000000000 --- a/examples/declarative/modelviews/webview/newwindows/qml/newwindows.html +++ /dev/null @@ -1,3 +0,0 @@ -<h1>Multiple windows...</h1> - -<a target="_blank" href="newwindows.html">Popup!</a> diff --git a/examples/declarative/painteditem/painteditem.pro b/examples/declarative/painteditem/painteditem.pro new file mode 100644 index 0000000000..e3afd6b0f0 --- /dev/null +++ b/examples/declarative/painteditem/painteditem.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + smile \ + textballoons diff --git a/examples/declarative/painteditem/smile/main.cpp b/examples/declarative/painteditem/smile/main.cpp new file mode 100644 index 0000000000..e26c1b47e7 --- /dev/null +++ b/examples/declarative/painteditem/smile/main.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#include <QtGui/qapplication.h> +#include <QtDeclarative/qdeclarative.h> +#include <QtDeclarative/qsgview.h> +#include <QtDeclarative/qsgpainteditem.h> + +class MyPaintItem : public QSGPaintedItem +{ + Q_OBJECT +public: + MyPaintItem() : QSGPaintedItem() + { + setAntialiasing(true); + } + + virtual void paint(QPainter *p) + { + QRectF rect(0, 0, width(), height()); + rect.adjust(10, 10, -10, -10); + p->setPen(QPen(Qt::black, 20)); + p->setBrush(Qt::yellow); + p->drawEllipse(rect); + p->setPen(Qt::black); + p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); + p->drawText(rect, Qt::AlignCenter, QLatin1String(":-)")); + } +}; + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterType<MyPaintItem>("MyModule", 1, 0, "MyPaintItem"); + + QGLFormat f = QGLFormat::defaultFormat(); + f.setSampleBuffers(true); + QSGView view(f); + view.setResizeMode(QSGView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("smile.qml")); + view.show(); + view.raise(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/declarative/painteditem/smile/smile.pro b/examples/declarative/painteditem/smile/smile.pro new file mode 100644 index 0000000000..5d7b9df074 --- /dev/null +++ b/examples/declarative/painteditem/smile/smile.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +TARGET = painteditem + +QT += declarative + +macx: CONFIG -= app_bundle + +SOURCES += main.cpp + +CONFIG += console + +symbian { + TARGET.EPOCHEAPSIZE = 0x20000 0x5000000 +} diff --git a/examples/declarative/modelviews/webview/inlinehtml.qml b/examples/declarative/painteditem/smile/smile.qml index 1b0c15e1f3..bc4bd2664b 100644 --- a/examples/declarative/modelviews/webview/inlinehtml.qml +++ b/examples/declarative/painteditem/smile/smile.qml @@ -38,18 +38,20 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtWebKit 1.0 +import QtQuick 2.0 +import MyModule 1.0 -// Inline HTML with loose formatting can be -// set on the html property. -WebView { - html:"\ - <body> - <table border=1> - <tr><th><th>One<th>Two<th>Three - <tr><th>1<td>X<td>1<td>X - <tr><th>2<td>0<td>X<td>0 - <tr><th>3<td>X<td>1<td>X - </table>" +Rectangle { + width: 480 + height: 480 + gradient: Gradient { + GradientStop { position: 0.0; color: "#00249a" } + GradientStop { position: 0.7; color: "#ffd94f" } + GradientStop { position: 1.0; color: "#ffa322" } + } + MyPaintItem { + anchors.fill: parent + anchors.margins: 10 + smooth: true + } } diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h new file mode 100644 index 0000000000..a0cac07110 --- /dev/null +++ b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDeclarativeExtensionPlugin> + +#include "../textballoon.h" + +class TextBalloonPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + qmlRegisterType<TextBalloon>(uri, 1, 0, "TextBalloon"); + } +}; + +Q_EXPORT_PLUGIN2(qmltextballoonplugin, TextBalloonPlugin); diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir new file mode 100644 index 0000000000..e8a08ae9d3 --- /dev/null +++ b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir @@ -0,0 +1 @@ +plugin qmltextballoonplugin diff --git a/examples/declarative/painteditem/textballoons/textballoon.cpp b/examples/declarative/painteditem/textballoons/textballoon.cpp new file mode 100644 index 0000000000..0fc56c7a74 --- /dev/null +++ b/examples/declarative/painteditem/textballoons/textballoon.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "textballoon.h" + +//! [0] +TextBalloon::TextBalloon(QSGItem *parent) + : QSGPaintedItem(parent) + , rightAligned(false) +{ +} +//! [0] + +//! [1] +void TextBalloon::paint(QPainter *painter) +{ + QBrush brush(QColor("#007430")); + + painter->setBrush(brush); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + + painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); + + if (rightAligned) + { + const QPointF points[3] = { + QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), + QPointF(boundingRect().width() - 20.0, boundingRect().height()), + QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } + else + { + const QPointF points[3] = { + QPointF(10.0, boundingRect().height() - 10.0), + QPointF(20.0, boundingRect().height()), + QPointF(30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } +} +//! [1] + +bool TextBalloon::isRightAligned() +{ + return this->rightAligned; +} + +void TextBalloon::setRightAligned(bool rightAligned) +{ + this->rightAligned = rightAligned; +} diff --git a/examples/declarative/painteditem/textballoons/textballoon.h b/examples/declarative/painteditem/textballoons/textballoon.h new file mode 100644 index 0000000000..1b630f4011 --- /dev/null +++ b/examples/declarative/painteditem/textballoons/textballoon.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTBALLOON_H +#define TEXTBALLOON_H + +#include <QtDeclarative> + +//! [0] +class TextBalloon : public QSGPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) + + public: + TextBalloon(QSGItem *parent = 0); + void paint(QPainter *painter); + + bool isRightAligned(); + void setRightAligned(bool rightAligned); + + private: + bool rightAligned; + + signals: + void rightAlignedChanged(); +}; +//! [0] + +#endif diff --git a/examples/declarative/painteditem/textballoons/textballoons.pro b/examples/declarative/painteditem/textballoons/textballoons.pro new file mode 100644 index 0000000000..3148fd20e6 --- /dev/null +++ b/examples/declarative/painteditem/textballoons/textballoons.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative + +TARGET = qmltextballoonplugin + +HEADERS += TextBalloonPlugin/plugin.h \ + textballoon.h + +SOURCES += textballoon.cpp + +DESTDIR = TextBalloonPlugin + +qdeclarativesources.files += \ + TextBalloonPlugin/qmldir + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin + +sources.files = textballoons.qml +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin + +INSTALLS = qdeclarativesources sources target diff --git a/examples/declarative/painteditem/textballoons/textballoons.qml b/examples/declarative/painteditem/textballoons/textballoons.qml new file mode 100644 index 0000000000..b786a2c601 --- /dev/null +++ b/examples/declarative/painteditem/textballoons/textballoons.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import TextBalloonPlugin 1.0 + +Item { + height: 480 + width: 640 + + //! [0] + ListModel { + id: balloonModel + ListElement { + balloonWidth: 200 + } + ListElement { + balloonWidth: 350 + } + } + + ListView { + anchors.bottom: controls.top + anchors.bottomMargin: 2 + anchors.top: parent.top + id: balloonView + delegate: TextBalloon { + anchors.right: index % 2 == 0 ? undefined : parent.right + height: 60 + rightAligned: index % 2 == 0 ? false : true + width: balloonWidth + } + model: balloonModel + spacing: 5 + width: parent.width + } + //! [0] + + //! [1] + Rectangle { + id: controls + + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 1 + anchors.right: parent.right + border.width: 2 + color: "white" + height: parent.height * 0.15 + + Text { + anchors.centerIn: parent + text: "Add another balloon" + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: { + balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)}) + balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) + } + onEntered: { + parent.color = "#8ac953" + } + onExited: { + parent.color = "white" + } + } + } + //! [1] +} diff --git a/examples/declarative/particles/allsmiles/content/particle.png b/examples/declarative/particles/allsmiles/content/particle.png Binary files differnew file mode 100644 index 0000000000..5c83896d22 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/particle.png diff --git a/examples/declarative/particles/allsmiles/content/singlesmile.png b/examples/declarative/particles/allsmiles/content/singlesmile.png Binary files differnew file mode 100644 index 0000000000..4087fa6b7f --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/singlesmile.png diff --git a/examples/declarative/particles/allsmiles/content/sizeInOut.png b/examples/declarative/particles/allsmiles/content/sizeInOut.png Binary files differnew file mode 100644 index 0000000000..0a306ea21a --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/sizeInOut.png diff --git a/examples/declarative/particles/allsmiles/content/smileMask.png b/examples/declarative/particles/allsmiles/content/smileMask.png Binary files differnew file mode 100644 index 0000000000..65a0143e9e --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/smileMask.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacesprite.png b/examples/declarative/particles/allsmiles/content/squarefacesprite.png Binary files differnew file mode 100644 index 0000000000..f9a5d5fcce --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacesprite.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacesprite2.png b/examples/declarative/particles/allsmiles/content/squarefacesprite2.png Binary files differnew file mode 100644 index 0000000000..7106a520a4 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacesprite2.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacesprite3.png b/examples/declarative/particles/allsmiles/content/squarefacesprite3.png Binary files differnew file mode 100644 index 0000000000..f4e6f26856 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacesprite3.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacesprite4.png b/examples/declarative/particles/allsmiles/content/squarefacesprite4.png Binary files differnew file mode 100644 index 0000000000..1e094eed4a --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacesprite4.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacesprite5.png b/examples/declarative/particles/allsmiles/content/squarefacesprite5.png Binary files differnew file mode 100644 index 0000000000..1cfc5c7f8c --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacesprite5.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacesprite6.png b/examples/declarative/particles/allsmiles/content/squarefacesprite6.png Binary files differnew file mode 100644 index 0000000000..b040139a9e --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacesprite6.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacesprite7.png b/examples/declarative/particles/allsmiles/content/squarefacesprite7.png Binary files differnew file mode 100644 index 0000000000..b1e5e4e339 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacesprite7.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacespriteX.png b/examples/declarative/particles/allsmiles/content/squarefacespriteX.png Binary files differnew file mode 100644 index 0000000000..93a0181dd0 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacespriteX.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacespriteXX.png b/examples/declarative/particles/allsmiles/content/squarefacespriteXX.png Binary files differnew file mode 100644 index 0000000000..3159efe246 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacespriteXX.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacewhite.png b/examples/declarative/particles/allsmiles/content/squarefacewhite.png Binary files differnew file mode 100644 index 0000000000..02259c5762 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacewhite.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacewhiteX.png b/examples/declarative/particles/allsmiles/content/squarefacewhiteX.png Binary files differnew file mode 100644 index 0000000000..59af205c6b --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacewhiteX.png diff --git a/examples/declarative/particles/allsmiles/content/squarefacewhiteXX.png b/examples/declarative/particles/allsmiles/content/squarefacewhiteXX.png Binary files differnew file mode 100644 index 0000000000..b0f15c6785 --- /dev/null +++ b/examples/declarative/particles/allsmiles/content/squarefacewhiteXX.png diff --git a/examples/declarative/particles/allsmiles/smile.qml b/examples/declarative/particles/allsmiles/smile.qml new file mode 100644 index 0000000000..e37e8fa98e --- /dev/null +++ b/examples/declarative/particles/allsmiles/smile.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + color: "white" + width: 310 + height: 300 + ParticleSystem{ id: sys } + Picture{ + system: sys + anchors.fill: parent + image: "content/singlesmile.png" + onceOff: true + } + ColoredParticle{ + system: sys + image: "content/particle.png" + color: "black" + alpha: 0.4 + sizeTable: "content/sizeInOut.png" + } + TrailEmitter{ + id: emitter + system: sys + emitting: false + particleDuration: 4000 + maxParticles: 1200 + anchors.fill: parent + particleSize: 32 + speed: PointVector{ xVariation: 12; yVariation: 12 } + } + MouseArea{ + anchors.fill: parent + onClicked: emitter.burst(1200); + } +} + diff --git a/examples/declarative/particles/allsmiles/smilefactory.qml b/examples/declarative/particles/allsmiles/smilefactory.qml new file mode 100644 index 0000000000..47becb50fe --- /dev/null +++ b/examples/declarative/particles/allsmiles/smilefactory.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + color: "goldenrod" + width: 400 + height: 400 + ParticleSystem{id:sys} + DeformableParticle{ + system: sys + particles: ["goingLeft", "goingRight"] + image: "content/singlesmile.png" + rotation: 90 + rotationSpeed: 90 + autoRotation: true + } + DeformableParticle{ + system: sys + particles: ["goingDown"] + image: "content/squarefacespriteXX.png" + rotation: 180 + yVector: PointVector{ y: 0.5; yVariation: 0.25; xVariation: 0.25; } + } + Timer{ + running: true + repeat: false + interval: 100 + onTriggered: emitA.emitting = true; + } + Timer{ + running: true + repeat: false + interval: 4200 + onTriggered: emitB.emitting = true; + } + Timer{ + running: true + repeat: false + interval: 8400 + onTriggered: emitC.emitting = true; + } + TrailEmitter{ + id: emitA + x: 0 + y: 120 + system: sys + emitting: false + particle: "goingRight" + speed: PointVector{ x: 100 } + particleDuration: 4000 + particlesPerSecond: 2 + particleSize: 32 + } + TrailEmitter{ + id: emitB + x: 400 + y: 240 + system: sys + emitting: false + particle: "goingLeft" + speed: PointVector{ x: -100 } + particleDuration: 4000 + particlesPerSecond: 2 + particleSize: 32 + } + TrailEmitter{ + id: emitC + x: 0 + y: 360 + system: sys + emitting: false + particle: "goingDown" + speed: PointVector{ x: 100 } + particleDuration: 4000 + particlesPerSecond: 2 + particleSize: 32 + } +} diff --git a/examples/declarative/particles/allsmiles/spriteparticles.qml b/examples/declarative/particles/allsmiles/spriteparticles.qml new file mode 100644 index 0000000000..4bcb7081b8 --- /dev/null +++ b/examples/declarative/particles/allsmiles/spriteparticles.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + color: "goldenrod" + width: 400 + height: 400 + ColoredParticle{ + id: test + particles: ["Test"] + image: "content/particle.png" + system: sys + z: 2 + anchors.fill: parent + color: "#336666CC" + colorVariation: 0.0 + } + SpriteParticle{ + id: single + particles: ["Face"] + system: sys + z: 2 + anchors.fill: parent + Sprite{ + source: "content/squarefacesprite.png" + frames: 6 + duration: 120 + } + } + Mask{ + id: mask + source: "content/smileMask.png" + } + TrailEmitter{ + system: sys + particle: "Test" + anchors.fill: parent + id: particles2 + particlesPerSecond: 6000 + particleDuration: 720 + emitting: true + particleSize: 10 + shape: mask + } + TrailEmitter{ + system: sys + particle: "Face" + anchors.fill: parent + id: particles + particlesPerSecond: 60 + particleDuration: 1440 + emitting: true + speed: PointVector{xVariation: 10; yVariation: 10;} + particleSize: 30 + particleSizeVariation: 10 + shape: mask + } + ParticleSystem{ + id: sys + anchors.fill: parent + } + +} diff --git a/examples/declarative/particles/allsmiles/spritestateparticles.qml b/examples/declarative/particles/allsmiles/spritestateparticles.qml new file mode 100644 index 0000000000..6a61487a89 --- /dev/null +++ b/examples/declarative/particles/allsmiles/spritestateparticles.qml @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + color: "goldenrod" + width: 800 + height: 800 + id: root + SpriteImage{ + sprites: [Sprite{ + name: "happy" + source: "content/squarefacesprite2.png" + frames: 6 + duration: 120 + to: {"silly": 0.4, "sad": 0.2, "cyclops":0.1, "boggled":0.3, "dying":0.0} + }, Sprite{ + name: "silly" + source: "content/squarefacesprite.png" + frames: 6 + duration: 120 + to: {"love": 0.4, "happy": 0.1, "evil": 0.2, "cyclops":0.1, "boggled":0.2} + }, Sprite{ + name: "sad" + source: "content/squarefacesprite3.png" + frames: 6 + duration: 120 + to: {"love" : 0.2, "evil": 0.2, "silly": 0.2, "cyclops":0.2, "boggled":0.2} + }, Sprite{ + name: "cyclops" + source: "content/squarefacesprite4.png" + frames: 6 + duration: 120 + to: {"love": 0.1, "evil": 0.1, "silly":0.1, "boggled":0.1, "cyclops" : 1.0} + }, Sprite{ + name: "evil" + source: "content/squarefacesprite5.png" + frames: 6 + duration: 120 + to: {"happy": 1.0} + }, Sprite{ + name: "love" + source: "content/squarefacesprite6.png" + frames: 6 + duration: 120 + to: {"sad": 0.6, "evil":0.4, "boggled":0.2} + }, Sprite{ + name: "boggled" + source: "content/squarefacesprite7.png" + frames: 6 + duration: 120 + to: {"love" : 0.2, "evil": 0.2, "silly": 0.2, "cyclops":0.1, "sad":0.2} + }, Sprite{ + name: "dying" + source: "content/squarefacespriteX.png" + frames: 4 + duration: 120 + to: {"dead":1.0} + }, Sprite{ + name: "dead" + source: "content/squarefacespriteXX.png" + frames: 1 + duration: 10000 + }] + + width: 100 + height: 100 + x: 20 + y: 20 + z:4 + } + ParticleSystem{ id: sys } + SpriteParticle{ + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite{ + name: "happy" + source: "content/squarefacesprite2.png" + frames: 6 + duration: 120 + to: {"silly": 0.4, "sad": 0.2, "cyclops":0.1, "boggled":0.3, "dying":0.0} + }, Sprite{ + name: "silly" + source: "content/squarefacesprite.png" + frames: 6 + duration: 120 + to: {"love": 0.4, "happy": 0.1, "evil": 0.2, "cyclops":0.1, "boggled":0.2} + }, Sprite{ + name: "sad" + source: "content/squarefacesprite3.png" + frames: 6 + duration: 120 + to: {"love" : 0.2, "evil": 0.2, "silly": 0.2, "cyclops":0.2, "boggled":0.2} + }, Sprite{ + name: "cyclops" + source: "content/squarefacesprite4.png" + frames: 6 + duration: 120 + to: {"love": 0.1, "evil": 0.1, "silly":0.1, "boggled":0.1, "cyclops" : 1.0} + }, Sprite{ + name: "evil" + source: "content/squarefacesprite5.png" + frames: 6 + duration: 120 + to: {"happy": 1.0} + }, Sprite{ + name: "love" + source: "content/squarefacesprite6.png" + frames: 6 + duration: 120 + to: {"sad": 0.6, "evil":0.4, "boggled":0.2} + }, Sprite{ + name: "boggled" + source: "content/squarefacesprite7.png" + frames: 6 + duration: 120 + to: {"love" : 0.2, "evil": 0.2, "silly": 0.2, "cyclops":0.1, "sad":0.2} + }, Sprite{ + name: "dying" + source: "content/squarefacespriteX.png" + frames: 4 + duration: 120 + to: {"dead":1.0} + }, Sprite{ + name: "dead" + source: "content/squarefacespriteXX.png" + frames: 1 + duration: 10000 + }] + } + TrailEmitter{ + system: sys + particlesPerSecond: 16 + particleDuration: 10000 + emitting: true + speed: AngleVector{angle: 90; magnitude: 60; angleVariation: 5} + acceleration: PointVector{ y: 10 } + particleSize: 30 + particleSizeVariation: 10 + width: parent.width + height: 100 + } + SpriteGoal{ + system: sys + width: root.width; + height: root.height/2; + y: root.height/2; + goalState:"dead" + } +} diff --git a/examples/declarative/particles/allsmiles/spritevariedparticles.qml b/examples/declarative/particles/allsmiles/spritevariedparticles.qml new file mode 100644 index 0000000000..c1b773093f --- /dev/null +++ b/examples/declarative/particles/allsmiles/spritevariedparticles.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + color: "goldenrod" + width: 800 + height: 800 + ParticleSystem{ id: sys } + SpriteParticle{ + system: sys + anchors.fill: parent + sprites: [Sprite{ + name: "initial" + source: "content/squarefacesprite.png" + frames: 6 + duration: 0 + to: {"happy":0.2, "silly":0.2, "sad":0.2, "cyclops":0.1, "evil":0.1, "love":0.1, "boggled":0.1} + }, Sprite{ + name: "silly" + source: "content/squarefacesprite.png" + frames: 6 + duration: 120 + }, Sprite{ + name: "happy" + source: "content/squarefacesprite2.png" + frames: 6 + duration: 120 + }, Sprite{ + name: "sad" + source: "content/squarefacesprite3.png" + frames: 6 + duration: 120 + }, Sprite{ + name: "cyclops" + source: "content/squarefacesprite4.png" + frames: 6 + duration: 120 + }, Sprite{ + name: "evil" + source: "content/squarefacesprite5.png" + frames: 6 + duration: 120 + }, Sprite{ + name: "love" + source: "content/squarefacesprite6.png" + frames: 6 + duration: 120 + }, Sprite{ + name: "boggled" + source: "content/squarefacesprite7.png" + frames: 6 + duration: 120 + }] + } + TrailEmitter{ + id: particleEmitter + system: sys + width: parent.width + particlesPerSecond: 16 + particleDuration: 8000 + emitting: true + speed: AngleVector{angle: 90; magnitude: 300; magnitudeVariation: 100; angleVariation: 5} + acceleration: PointVector{ y: 10 } + particleSize: 30 + particleSizeVariation: 10 + } + Binding{ + target: particleEmitter + property: "y" + value: ma.mouseY + when: ma.mouseX !=0 || ma.mouseY!=0 + } + MouseArea{ + id: ma + anchors.fill: parent + } +} diff --git a/examples/declarative/modelviews/webview/autosize.qml b/examples/declarative/particles/allsmiles/ultraparticles.qml index d7d6764659..85bbdbacd8 100644 --- a/examples/declarative/modelviews/webview/autosize.qml +++ b/examples/declarative/particles/allsmiles/ultraparticles.qml @@ -38,69 +38,72 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtWebKit 1.0 +import QtQuick 2.0 +import Qt.labs.particles 2.0 -// The WebView size is determined by the width, height, -// preferredWidth, and preferredHeight properties. -Rectangle { - id: rect - width: 200 - height: layout.height - - Column { - id: layout - spacing: 2 - - WebView { - html: "No width defined." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - - WebView { - width: rect.width - html: "The width is full." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - - WebView { - width: rect.width/2 - html: "The width is half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - width: rect.width/2 - html: "The_width_is_half." // not wrapped - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - - WebView { - preferredWidth: rect.width/2 - html: "The preferredWidth is half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - preferredWidth: rect.width/2 - html: "The_preferredWidth_is_half." // not wrapped - Rectangle { - color: "#10000000" - anchors.fill: parent +Rectangle{ + color: "white" + width: 640 + height: 480 + ParticleSystem{ + id: sys + } + UltraParticle{ + sprites: [ + Sprite{ + name: "licking" + source: "content/squarefacewhite.png" + frames: 6 + duration: 120 + to: {"dying":1, "licking":5} + }, + Sprite{ + name: "dying" + source: "content/squarefacewhiteX.png" + frames: 4 + duration: 120 + to: {"dead":1} + }, + Sprite{ + name: "dead" + source: "content/squarefacewhiteXX.png" + frames: 1 + duration: 120 } - } + ] + colorVariation: 0.5 + rotationSpeedVariation: 360 + system: sys + colorTable: "../trails/content/colortable.png" + } + Friction{ + factor: 0.1 + system: sys + } + TrailEmitter{ + system: sys + anchors.centerIn: parent + id: particles + particlesPerSecond: 200 + particleDuration: 6000 + emitting: true + speed: AngleVector{angleVariation: 360; magnitude: 80; magnitudeVariation: 40} + particleSize: 40 + particleEndSize: 80 + } + Text{ + x: 16 + y: 16 + text: "QML..." + style: Text.Outline; styleColor: "#AAAAAA" + font.pixelSize: 32 + } + Text{ + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: 16 + text: "... can you be trusted with the power?" + style: Text.Outline; styleColor: "#AAAAAA" + font.pixelSize: 32 } } diff --git a/examples/declarative/particles/asteroid/asteroid.qml b/examples/declarative/particles/asteroid/asteroid.qml new file mode 100644 index 0000000000..b5b4f672c2 --- /dev/null +++ b/examples/declarative/particles/asteroid/asteroid.qml @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 Qt.labs.particles 2.0 +import Qt.labs.particles 2.0 as Qlp +import QtQuick 2.0 + +Item { + id: root + width: 360 + height: 540 + MouseArea{ + id: ma + anchors.fill: parent + } + + ParticleSystem { id: sys } + Image { + source: "content/finalfrontier.png" + transformOrigin: Item.Center + anchors.centerIn: parent + smooth: true + NumberAnimation on rotation { + from: 0 + to: 360 + duration: 200000 + loops: Animation.Infinite + } + + } + ColoredParticle { + system: sys + particles: ["starfield"] + image: "content/star.png" + colorVariation: 0.3 + color: "white" + } + TrailEmitter { + id: starField + system: sys + particle: "starfield" + + particlesPerSecond: 80 + particleDuration: 2500 + + anchors.centerIn: parent + + //acceleration: AngleVector{angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed? + acceleration: PointVector{ xVariation: 200; yVariation: 200; } + + particleSize: 0 + particleEndSize: 80 + particleSizeVariation: 10 + } + TrailEmitter{ + system: sys + particle: "meteor" + particlesPerSecond: 12 + particleDuration: 5000 + emitting: true + acceleration: PointVector{ xVariation: 80; yVariation: 80; } + particleSize: 15 + particleEndSize: 300 + anchors.centerIn: parent + } + SpriteParticle{ + system: sys + particles: ["meteor"] + sprites:[Sprite{ + id: spinState + name: "spinning" + source: "content/meteor.png" + frames: 35 + duration: 40 + speedModifiesDuration: -0.1 + to: {"explode":0, "spinning":1} + },Sprite{ + name: "explode" + source: "content/_explo.png" + frames: 22 + duration: 40 + speedModifiesDuration: -0.1 + to: {"nullFrame":1} + },Sprite{//Not sure if this is needed, but seemed easiest + name: "nullFrame" + source: "content/nullRock.png" + frames: 1 + duration: 1000 + } + ] + } + SpriteGoal{ + particles: ["meteor"] + system: sys + goalState: "explode" + jump: true + anchors.centerIn: holder//A bug in affectors currently isn't compensating for relative x,y. when that's fixed this can just anchors.fill: rocketShip + width: 60 + height: 60 + } + Image { + id: rocketShip + source: "content/rocket.png" + smooth: true + anchors.centerIn: holder + rotation: (circle.percent+0.25) * 360 + z: 2 + } + Item { + id: holder + x: circle.x - Math.sin(circle.percent * 6.28316530714)*200 + y: circle.y + Math.cos(circle.percent * 6.28316530714)*200 + z: 1 + } + + Item { + id: circle + x: root.width / 1.2 + y: root.height / 1.7 + property real percent: 0 + + SequentialAnimation on percent { + id: circleAnim1 + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 4000 + from: 1 + to: 0 + } + + } + } + ColoredParticle{ + z:0 + system: sys + particles: ["exhaust"] + image: "content/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + TrailEmitter{ + id: trailsNormal2 + system: sys + particle: "exhaust" + + particlesPerSecond: 300 + particleDuration: 500 + + y: holder.y + x: holder.x + + speed: PointVector{ xVariation: 40; yVariation: 40; } + speedFromMovement: 16 + + acceleration: PointVector{ xVariation: 10; yVariation: 10; } + + particleSize: 4 + particleSizeVariation: 4 + } +} diff --git a/examples/declarative/particles/asteroid/blackhole.qml b/examples/declarative/particles/asteroid/blackhole.qml new file mode 100644 index 0000000000..68d5835880 --- /dev/null +++ b/examples/declarative/particles/asteroid/blackhole.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + id: root + width: 360 + height: 540 + color: "black" + property bool spacePressed: false + focus: true + Image{ + source: "content/finalfrontier.png" + anchors.centerIn:parent + } + Keys.onPressed: { + if (event.key == Qt.Key_Space) { + spacePressed = true; + event.accepted = true; + } + } + Keys.onReleased: { + if (event.key == Qt.Key_Space) { + spacePressed = false; + event.accepted = true; + } + } + + TrailEmitter{ + particle: "stars" + system: particles + particlesPerSecond: 40 + particleDuration: 4000 + emitting: true + particleSize: 30 + particleSizeVariation: 10 + speed: PointVector{ x: 220; xVariation: 40 } + height: parent.height + } + TrailEmitter{ + particle: "roids" + system: particles + particlesPerSecond: 10 + particleDuration: 4000 + emitting: true + particleSize: 30 + particleSizeVariation: 10 + speed: PointVector{ x: 220; xVariation: 40 } + height: parent.height + } + ParticleSystem{ + id: particles + anchors.fill: parent + } + ColoredParticle{ + id: stars + particles: ["stars"] + system: particles + image: "content/star.png" + color: "white" + colorVariation: 0.1 + } + SpriteParticle{ + id: roids + particles: ["roids"] + system: particles + sprites: Sprite{ + id: spinState + name: "spinning" + source: "content/meteor.png" + frames: 35 + duration: 60 + speedModifiesDuration: -0.1 + } + } + ColoredParticle{ + id: shot + particles: ["shot"] + system: particles + image: "content/star.png" + + color: "#0FF06600" + colorVariation: 0.3 + } + ColoredParticle{ + id: engine + particles: ["engine"] + system: particles + image: "content/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + GravitationalSingularity{ + id: gs; x: root.width/2; y: root.height/2; strength: 4000000; + system: particles + } + Kill{ + system: particles + x: gs.x - 8; + y: gs.y - 8; + width: 16 + height: 16 + } + Image{ + source:"content/rocket2.png" + id: ship + width: 45 + height: 22 + MouseArea{ + id: ma + anchors.fill: parent; + drag.axis: Drag.XandYAxis + drag.target: ship + } + TrailEmitter{ + particle: "engine" + system: particles + particlesPerSecond: 200 + particleDuration: 1000 + emitting: true + particleSize: 10 + particleEndSize: 4 + particleSizeVariation: 4 + speed: PointVector{ x: -128; xVariation: 32 } + height: parent.height + width: 20 + } + TrailEmitter{ + particle: "shot" + system: particles + particlesPerSecond: 32 + particleDuration: 2000 + emitting: spacePressed + particleSize: 40 + speed: PointVector{ x: 256; } + x: parent.width + y: parent.height/2 + } + } + Text{ + color: "white" + anchors.bottom: parent.bottom + text:"Drag the ship, Spacebar to fire." + } +} + diff --git a/examples/declarative/particles/asteroid/content/_explo.png b/examples/declarative/particles/asteroid/content/_explo.png Binary files differnew file mode 100644 index 0000000000..4297245d49 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/_explo.png diff --git a/examples/declarative/particles/asteroid/content/finalfrontier.png b/examples/declarative/particles/asteroid/content/finalfrontier.png Binary files differnew file mode 100644 index 0000000000..2ba1815230 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/finalfrontier.png diff --git a/examples/declarative/particles/asteroid/content/meteor.png b/examples/declarative/particles/asteroid/content/meteor.png Binary files differnew file mode 100644 index 0000000000..e8c368aea7 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/meteor.png diff --git a/examples/declarative/particles/asteroid/content/meteor_explo.png b/examples/declarative/particles/asteroid/content/meteor_explo.png Binary files differnew file mode 100644 index 0000000000..e659bfe2cf --- /dev/null +++ b/examples/declarative/particles/asteroid/content/meteor_explo.png diff --git a/examples/declarative/particles/asteroid/content/meteors.png b/examples/declarative/particles/asteroid/content/meteors.png Binary files differnew file mode 100644 index 0000000000..bada8a1407 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/meteors.png diff --git a/examples/declarative/particles/asteroid/content/nullRock.png b/examples/declarative/particles/asteroid/content/nullRock.png Binary files differnew file mode 100644 index 0000000000..4076327a1a --- /dev/null +++ b/examples/declarative/particles/asteroid/content/nullRock.png diff --git a/examples/declarative/particles/asteroid/content/particle4.png b/examples/declarative/particles/asteroid/content/particle4.png Binary files differnew file mode 100644 index 0000000000..bc95b703c1 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/particle4.png diff --git a/examples/declarative/particles/asteroid/content/rocket.png b/examples/declarative/particles/asteroid/content/rocket.png Binary files differnew file mode 100644 index 0000000000..a171610b03 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/rocket.png diff --git a/examples/declarative/particles/asteroid/content/rocket2.png b/examples/declarative/particles/asteroid/content/rocket2.png Binary files differnew file mode 100644 index 0000000000..7110f8fdc6 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/rocket2.png diff --git a/examples/declarative/particles/asteroid/content/star.png b/examples/declarative/particles/asteroid/content/star.png Binary files differnew file mode 100644 index 0000000000..0d592cfa87 --- /dev/null +++ b/examples/declarative/particles/asteroid/content/star.png diff --git a/examples/declarative/particles/modelparticles/bubbles.qml b/examples/declarative/particles/modelparticles/bubbles.qml new file mode 100644 index 0000000000..80d03a9ea7 --- /dev/null +++ b/examples/declarative/particles/modelparticles/bubbles.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 +import "../../modelviews/listview/content" as OtherDemo +import "content/script.js" as Script +import "content" +//Needs OtherDemo to be updated to QtQuick 2.0 + +Item{ + id: root + width: 400 + height: 400 + Rectangle{ + anchors.fill: parent + color: "lightsteelblue" + } + ParticleSystem{ + id: sys; + } + TrailEmitter{ + system: sys + particle: "A" + width: parent.width/2 + x: parent.width/4 + y:parent.height + speed: PointVector{ y: -64; yVariation: 16 } + particlesPerSecond: 1 + particleDuration: 8000 + } + Drift{ + system: sys + xDrift: 200 + } + DataParticle{ + id: mp + z: 0 + system: sys + particles: ["A"] + model: OtherDemo.RecipesModel{} + delegate: ExpandingDelegate{} + } +} diff --git a/examples/declarative/particles/modelparticles/content/Delegate.qml b/examples/declarative/particles/modelparticles/content/Delegate.qml new file mode 100644 index 0000000000..ae1dffb63b --- /dev/null +++ b/examples/declarative/particles/modelparticles/content/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/declarative/particles/modelparticles/content/Delegate2.qml b/examples/declarative/particles/modelparticles/content/Delegate2.qml new file mode 100644 index 0000000000..a05fa348b9 --- /dev/null +++ b/examples/declarative/particles/modelparticles/content/Delegate2.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 + +//![0] +Package { + Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } + Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' + + Rectangle { + id: wrapper + width: w; height: h; + color: col + rotation: Math.random()*360 + Behavior on rotation{RotationAnimation{}} + + states: State{ + name: "gridded" + when: root.inGrid + PropertyChanges{ + target: wrapper + rotation: 0 + } + ParentChange{ + target: wrapper + parent: gridDelegate + x:0 + y:0 + } + } + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} +//![0] diff --git a/examples/declarative/particles/modelparticles/content/ExpandingDelegate.qml b/examples/declarative/particles/modelparticles/content/ExpandingDelegate.qml new file mode 100644 index 0000000000..e6fcb6dcf7 --- /dev/null +++ b/examples/declarative/particles/modelparticles/content/ExpandingDelegate.qml @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import "../../../modelviews/listview/content" + +// This example illustrates expanding a list item to show a more detailed view. + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + //this bit changed for aesthetics + width: 70 + height: 70 + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + Image{ + anchors.fill:parent + anchors.margins: -32 + source: "bubble.png" + } + + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: "../../modelviews/listview/" + picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "../../modelviews/listview/" + "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "../../modelviews/listview/" + "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible + PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + //PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + //The only strictly necessary particle specific lines + to: "Details" + reversible: true + ScriptAction{script:{ + if(state == "Details") + mp.freeze(index); + else + mp.unfreeze(index); + } + } + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } + } + } + } + } diff --git a/examples/declarative/modelviews/webview/newwindows.qml b/examples/declarative/particles/modelparticles/content/RssModel.qml index 07954f4a96..603a157de5 100644 --- a/examples/declarative/modelviews/webview/newwindows.qml +++ b/examples/declarative/particles/modelparticles/content/RssModel.qml @@ -38,34 +38,16 @@ ** ****************************************************************************/ -// Demonstrates opening new WebViews from HTML -// -// Note that to open windows from JavaScript, you will need to -// allow it on WebView with settings.javascriptCanOpenWindows: true - import QtQuick 1.0 -import QtWebKit 1.0 - -Grid { - columns: 3 - id: pages - height: 300; width: 600 - Component { - id: webViewPage - Rectangle { - width: webView.width - height: webView.height - border.color: "gray" +XmlListModel { + property string tags : "" - WebView { - id: webView - newWindowComponent: webViewPage - newWindowParent: pages - url: "newwindows.html" - } - } - } + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - Loader { sourceComponent: webViewPage } + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } } diff --git a/examples/declarative/particles/modelparticles/content/bubble.png b/examples/declarative/particles/modelparticles/content/bubble.png Binary files differnew file mode 100644 index 0000000000..c7f479e9e3 --- /dev/null +++ b/examples/declarative/particles/modelparticles/content/bubble.png diff --git a/examples/declarative/particles/modelparticles/content/script.js b/examples/declarative/particles/modelparticles/content/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/declarative/particles/modelparticles/content/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/declarative/particles/modelparticles/gridsplosion.qml b/examples/declarative/particles/modelparticles/gridsplosion.qml new file mode 100644 index 0000000000..d45ef392e0 --- /dev/null +++ b/examples/declarative/particles/modelparticles/gridsplosion.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 +import "content" + +Item{ + id: root + width: 240 + height: 240 + property bool inGrid: false + ParticleSystem{ id: sys } + TrailEmitter{ + system: sys + id: burster; + emitting: false + particlesPerSecond: 1000 + particleDuration: 500 + speed: PointVector{xVariation: 400; yVariation: 400} + anchors.centerIn: parent + Timer{ + interval: 1000 + running: true + repeat: false + onTriggered: burster.pulse(0.1); + } + Timer{ + interval: 2000 + running: true + repeat: false + onTriggered: {inGrid = true;}// sys.running = false;} + } + } + ColoredParticle{ + system: sys + image: "../trails/content/particle.png" + color: "black" + colorVariation: 0.0 + } + GridView{ id: grid; cellWidth: 40; cellHeight: 40 + model: theModel.parts.grid + width: 120 + height: 120 + } + DataParticle{ + system: sys + model: theModel.parts.particles + } + Friction{ + system: sys + factor: 1 + } + Stasis{ + system: sys + targetLife: 400 + } + VisualDataModel{ + id: theModel + delegate: Delegate2{} + model: ListModel{ + ListElement{ + w: 40 + h: 20 + col: "forestgreen" + } + ListElement{ + w: 20 + h: 40 + col: "salmon" + } + ListElement{ + w: 20 + h: 20 + col: "lightsteelblue" + } + ListElement{ + w: 40 + h: 40 + col: "goldenrod" + } + ListElement{ + w: 40 + h: 20 + col: "forestgreen" + } + ListElement{ + w: 20 + h: 40 + col: "salmon" + } + ListElement{ + w: 20 + h: 20 + col: "lightsteelblue" + } + ListElement{ + w: 40 + h: 40 + col: "goldenrod" + } + ListElement{ + w: 0 + h: 0 + col: "white"//Hack because add isn't working well with old stuff + } + } + } +} diff --git a/examples/declarative/particles/modelparticles/package.qml b/examples/declarative/particles/modelparticles/package.qml new file mode 100644 index 0000000000..d5c104b480 --- /dev/null +++ b/examples/declarative/particles/modelparticles/package.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 +import "content" + +Rectangle { + color: "white" + width: 400 + height: 200 + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + VisualDataModel { + id: visualModel + delegate: Delegate {} + model: myModel + } + + ListView { + width: 200; height:200 + model: visualModel.parts.list + } + DataParticle{ + x: 200; width: 200; height:200 + model: visualModel.parts.grid + system: sys + clip: true; + } + //![0] + ParticleSystem{ + id: sys + anchors.fill: parent + } + TrailEmitter{ + system: sys + width: 100 + x: 50 + speed: PointVector{ y: 40 } + particleDuration: 5000 + particlesPerSecond: 1.6 + } +} diff --git a/examples/declarative/particles/modelparticles/stream.qml b/examples/declarative/particles/modelparticles/stream.qml new file mode 100644 index 0000000000..0ad807bc7b --- /dev/null +++ b/examples/declarative/particles/modelparticles/stream.qml @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 +import "content/script.js" as Script +import "content" + +Item{ + id: root + width: 640 + height: 480 + Rectangle{ + anchors.fill: parent + color: "black" + z: -1 + } + Item{ + id: loading + Behavior on opacity{NumberAnimation{}} + anchors.fill: parent + Text{ + anchors.centerIn: parent + text: "Loading" + color: "white" + } + } + ParticleSystem{ + id: sys; + running: true + overwrite: false + startTime: 12000//Doesn't actually work with the loading time though... + } + TrailEmitter{ + id: emitter + system: sys + height: parent.height - 132/2 + x: -132/2 + y: 132/2 + speed: PointVector{ x: 32; xVariation: 8 } + particlesPerSecond: 0.5 + particleDuration: 120000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) + particle: "photos" + } + Kill{ + system: sys + x: parent.width + 132/2 + height: parent.height + width: 1000 + } + ColoredParticle{ + system: sys + particles: ["fireworks"] + image: "../trails/content/star.png" + color: "lightsteelblue" + alpha: 0 + colorVariation: 0 + z: 1000 + } + ItemParticle{ + id: mp + z: 0 + system: sys + fade: false + particles: ["photos"] + } + Component{ + id: alertDelegate + Rectangle{ + width: 132 + height: 132 + NumberAnimation on scale{ + running: true + loops: 1 + from: 0.2 + to: 1 + } + Image{ + source: "../asteroid/content/rocket.png" + anchors.centerIn: parent + } + Text{ + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: "A new ship has arrived!" + } + } + } + property Item alertItem; + function alert(){ + resetter.active = false + force.active = true; + alertItem = alertDelegate.createObject(root); + alertItem.x = root.width/2 - alertItem.width/2 + alertItem.y = root.height/2 - alertItem.height/2 + spawnFireworks.pulse(0.2); + stopAlert.start(); + } + focus: true + Keys.onSpacePressed: alert(); + Timer{ + id: stopAlert + running: false + repeat: false + interval: 800 + onTriggered: { + force.active = false + resetter.active = true; + mp.take(alertItem, true); + centerEmitter.burst(1); + } + } + Attractor{ + id: force + system: sys + x: root.width/2 + y: root.height/2 + strength: -30000 + active: false + anchors.centerIn: parent + width: parent.width/2 + height: parent.height/2 + particles:["photos"] + } + Reset{ + id: resetter + system: sys + particles:["photos"] + } + TrailEmitter{ + id: centerEmitter + speed: PointVector{ x: 32; xVariation: 8;} + particlesPerSecond: 0.5 + particleDuration: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) + maxParticles: 20 + particle: "photos" + system: sys + anchors.centerIn: parent + emitting: false + + //TODO: Zoom in effect + } + TrailEmitter{ + id: spawnFireworks + particle: "fireworks" + system: sys + maxParticles: 400 + particlesPerSecond: 400 + particleDuration: 2800 + x: parent.width/2 + y: parent.height/2 - 64 + width: 8 + height: 8 + emitting: false + particleSize: 32 + particleEndSize: 8 + speed: AngleVector{ magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } + acceleration: PointVector{ y: 160 } + } + Item{ x: -1000; y: -1000 //offscreen + Repeater{//Load them here, add to system on completed + model: theModel + delegate: theDelegate + } + } + RssModel{id: theModel; tags:"particle,particles"} + Component { + id: theDelegate + Rectangle { + id: container + border.width: 2 + property real myRand: Math.random();//'depth' + z: Math.floor(myRand * 100) + scale: (myRand + 1.0)/2; + //TODO: Darken based on 'depth' + width: 132 + height: 132 + //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity); + ItemParticle.onDetached: mp.take(container);//respawns + function manage() + { + if(state == "selected"){ + // console.log("Taking " + index); + mp.freeze(container); + }else{ + // console.log("Returning " +index); + mp.unfreeze(container); + } + } + Image{ + id: img + anchors.centerIn: parent + smooth: true; source: "http://" + Script.getImagePath(content); cache: true + fillMode: Image.PreserveAspectFit; + width: parent.width-4; height: parent.height-4 + onStatusChanged: if(img.status == Image.Ready){ + container.opacity = 0; + loading.opacity = 0; + mp.take(container); + } + } + Text{ + anchors.bottom: parent.bottom + width: parent.width + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + text: title + color: "black" + } + MouseArea{ + anchors.fill: parent + onClicked: container.state == "selected" ? container.state = "" : container.state = "selected" + } + states: State{ + name: "selected" + ParentChange{ + target: container + parent: root + x: 0 + y: 0 + } + PropertyChanges{ + target: container + width: root.width + height: root.height + z: 101 + opacity: 1 + rotation: 0 + } + } + transitions: Transition{ + to: "selected" + reversible: true + SequentialAnimation{ + ScriptAction{script: container.manage();} + ParallelAnimation{ + ParentAnimation{NumberAnimation{ properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly + NumberAnimation{ properties: "width, height, z, rotation" } + } + } + } + } + } +} diff --git a/examples/declarative/particles/snow/content/flake-01.png b/examples/declarative/particles/snow/content/flake-01.png Binary files differnew file mode 100644 index 0000000000..490887a82f --- /dev/null +++ b/examples/declarative/particles/snow/content/flake-01.png diff --git a/examples/declarative/modelviews/webview/content/Mapping/Map.qml b/examples/declarative/particles/snow/snow.qml index e88ce8b25c..25d2e1468b 100644 --- a/examples/declarative/modelviews/webview/content/Mapping/Map.qml +++ b/examples/declarative/particles/snow/snow.qml @@ -38,36 +38,38 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtWebKit 1.0 +import QtQuick 2.0 +import Qt.labs.particles 2.0 -Item { - id: page - - property real latitude: -34.397 - property real longitude: 150.644 - property string address: "" - property alias status: js.status - - WebView { - id: map - anchors.fill: parent - url: "map.html" - pressGrabTime: 0 - javaScriptWindowObjects: QtObject { - id: js - WebView.windowObjectName: "qml" - property real lat: page.latitude - property real lng: page.longitude - property string address: page.address - property string status: "Loading" - - onAddressChanged: { - if (map.url != "" && map.progress == 1) - map.evaluateJavaScript("goToAddress()") - } +Rectangle{ + width: 360 + height: 540 + ParticleSystem { id: particles } + SpriteParticle { + system: particles + Sprite{ + name: "snow" + source: "content/flake-01.png" + frames: 51 + duration: 40 } - - onLoadFinished: { evaluateJavaScript("goToAddress()"); } + } + Wander { + system: particles + anchors.fill: parent + xVariance: 40; + pace: 40; + } + TrailEmitter { + system: particles + particlesPerSecond: 20 + particleDuration: 7000 + emitting: true + speed: PointVector{ y:80; yVariation: 40; } + acceleration: PointVector{ y: 4 } + particleSize: 20 + particleSizeVariation: 10 + width: parent.width + height: 100 } } diff --git a/examples/declarative/particles/snow/snow2.qml b/examples/declarative/particles/snow/snow2.qml new file mode 100644 index 0000000000..c016ba2934 --- /dev/null +++ b/examples/declarative/particles/snow/snow2.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + width: 360 + height: 540 + ParticleSystem{ id: particles } + SpriteParticle{ + system: particles + Sprite{ + name: "snow" + source: "content/flake-01.png" + frames: 51 + duration: 40 + } + } + Drift{ + system: particles + anchors.fill: parent + xDrift: 400; + } + TrailEmitter{ + system: particles + particlesPerSecond: 20 + particleDuration: 7000 + emitting: true + speed: PointVector{ y:80; yVariation: 40; } + acceleration: PointVector{ y: 4 } + particleSize: 20 + particleSizeVariation: 10 + width: parent.width + height: 100 + } +} diff --git a/examples/declarative/particles/snow/snow3.qml b/examples/declarative/particles/snow/snow3.qml new file mode 100644 index 0000000000..080bc4d1af --- /dev/null +++ b/examples/declarative/particles/snow/snow3.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + width: 360 + height: 540 + id: root + ParticleSystem{ id: particles } + SpriteParticle{ + system: particles + sprites: Sprite{ + name: "snow" + source: "content/flake-01.png" + frames: 51 + duration: 40 + } + } + Drift{ + system: particles + anchors.fill: parent + xDrift: 200 + } + SpeedLimit{ + system: particles + anchors.fill: parent + speedLimit: 100 + } + TrailEmitter{ + system: particles + particlesPerSecond: 20 + particleDuration: 7000 + emitting: true + speed: PointVector{ y:80; yVariation: 40; } + acceleration: PointVector{ y: 4 } + particleSize: 20 + particleSizeVariation: 10 + width: parent.width + height: 40 + } +} diff --git a/examples/declarative/particles/spaceexplorer/content/helpers.js b/examples/declarative/particles/spaceexplorer/content/helpers.js new file mode 100644 index 0000000000..c38c4c0eed --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/helpers.js @@ -0,0 +1,8 @@ +function intersects(item, x, y, e){ + return x+e >= item.x && x-e <= item.x + item.width && y+e >= item.y && y-e <= item.y + item.height; +} + +function direction(x1, y1, x2, y2){ + return Math.atan2(y2-y1, x2-x1) * (180/Math.PI); +} + diff --git a/examples/declarative/particles/spaceexplorer/content/particle4.png b/examples/declarative/particles/spaceexplorer/content/particle4.png Binary files differnew file mode 100644 index 0000000000..bc95b703c1 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/particle4.png diff --git a/examples/declarative/particles/spaceexplorer/content/powerupScore.png b/examples/declarative/particles/spaceexplorer/content/powerupScore.png Binary files differnew file mode 100644 index 0000000000..e8c368aea7 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/powerupScore.png diff --git a/examples/declarative/particles/spaceexplorer/content/powerupScore_gone.png b/examples/declarative/particles/spaceexplorer/content/powerupScore_gone.png Binary files differnew file mode 100644 index 0000000000..4076327a1a --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/powerupScore_gone.png diff --git a/examples/declarative/particles/spaceexplorer/content/powerupScore_got.png b/examples/declarative/particles/spaceexplorer/content/powerupScore_got.png Binary files differnew file mode 100644 index 0000000000..4297245d49 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/powerupScore_got.png diff --git a/examples/declarative/particles/spaceexplorer/content/rocket.png b/examples/declarative/particles/spaceexplorer/content/rocket.png Binary files differnew file mode 100644 index 0000000000..a171610b03 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/rocket.png diff --git a/examples/declarative/particles/spaceexplorer/content/rocket2.png b/examples/declarative/particles/spaceexplorer/content/rocket2.png Binary files differnew file mode 100644 index 0000000000..7110f8fdc6 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/rocket2.png diff --git a/examples/declarative/particles/spaceexplorer/content/rocketEye.png b/examples/declarative/particles/spaceexplorer/content/rocketEye.png Binary files differnew file mode 100644 index 0000000000..20005937d2 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/rocketEye.png diff --git a/examples/declarative/particles/spaceexplorer/content/star.png b/examples/declarative/particles/spaceexplorer/content/star.png Binary files differnew file mode 100644 index 0000000000..0d592cfa87 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/content/star.png diff --git a/examples/declarative/particles/spaceexplorer/spaceexplorer.qml b/examples/declarative/particles/spaceexplorer/spaceexplorer.qml new file mode 100644 index 0000000000..091ca0a8b5 --- /dev/null +++ b/examples/declarative/particles/spaceexplorer/spaceexplorer.qml @@ -0,0 +1,412 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 +import "content/helpers.js" as Helpers + +Rectangle{ + id: root + width: 360 + height: 540 + color: "black" + Image{ + anchors.centerIn: parent + source: "../asteroid/content/finalfrontier.png" + } + property bool spacePressed: false + property int holeSize: 4 + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_Space) { + spacePressed = true; + event.accepted = true; + } + } + Keys.onReleased: { + if (event.key == Qt.Key_Space) { + spacePressed = false; + event.accepted = true; + } + } + + function fakeMove(){ + fakeMoving = rocket.x < 80 || rocket.x+rocket.width-root.width > -80 || rocket.y < 80 || rocket.y+rocket.height-root.height > -80; + if(fakeMoving) + fakeMovementDir = Helpers.direction(root.width/2, root.height/2, rocket.x, rocket.y) + 180; + } + property bool fakeMoving: false + property real fakeMovementDir: 0 + + TrailEmitter{ + particle: "stars2" + system: background + particlesPerSecond: 60 + particleDuration: 4000 + emitting: true + particleSize: 10 + particleSizeVariation: 10 + anchors.fill: parent + } + ParticleSystem{ id: background } + ColoredParticle{ + particles: ["stars2"] + system: background + anchors.fill: parent + image: "content/star.png" + color: "white" + colorVariation: 0.1 + } + Gravity{ + system: background + anchors.fill: parent + acceleration: fakeMoving?10:0 + angle: fakeMovementDir + } + Text{ + color: "white" + anchors.bottom: parent.bottom + anchors.right: parent.right + text:"Drag the ship, but don't hit a black hole!" + font.pixelSize: 10 + } + Text{ + color: "white" + font.pixelSize: 36 + anchors.centerIn: parent + text: "GAME OVER" + opacity: gameOver ? 1 : 0 + Behavior on opacity{NumberAnimation{}} + } + Text{ + color: "white" + font.pixelSize: 18 + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 8 + text: "Score: " + score + } + Image{ + source: "content/star.png" + width: 40 + height: 40 + anchors.right: parent.right + anchors.top: parent.top + MouseArea{ + anchors.fill: parent + anchors.margins: -20 + onClicked: shoot = !shoot + } + } + property int score: 0 + property bool gameOver: false + property bool shoot: true + property int maxLives: 3 + property int lives: maxLives + property bool alive: !Helpers.intersects(rocket, gs1.x, gs1.y, holeSize) && !Helpers.intersects(rocket, gs2.x, gs2.y, holeSize) && !Helpers.intersects(rocket, gs3.x, gs3.y, holeSize) && !Helpers.intersects(rocket, gs4.x, gs4.y, holeSize); + onAliveChanged: if(!alive){ + lives -= 1; + if(lives == -1){ + console.log("game over"); + gameOver = true; + } + } + Row{ + Repeater{ + model: maxLives + delegate: Image{ + opacity: index < lives ? 1 : 0 + Behavior on opacity{NumberAnimation{}} + source: "content/rocket.png" + } + } + } + + property real courseDur: 10000 + property real vorteX: width/4 + property real vorteY: height/4 + Behavior on vorteX{NumberAnimation{duration: courseDur}} + Behavior on vorteY{NumberAnimation{duration: courseDur}} + property real vorteX2: width/4 + property real vorteY2: 3*height/4 + Behavior on vorteX2{NumberAnimation{duration: courseDur}} + Behavior on vorteY2{NumberAnimation{duration: courseDur}} + property real vorteX3: 3*width/4 + property real vorteY3: height/4 + Behavior on vorteX3{NumberAnimation{duration: courseDur}} + Behavior on vorteY3{NumberAnimation{duration: courseDur}} + property real vorteX4: 3*width/4 + property real vorteY4: 3*height/4 + Behavior on vorteX4{NumberAnimation{duration: courseDur}} + Behavior on vorteY4{NumberAnimation{duration: courseDur}} + Timer{ + id: vorTimer + interval: courseDur + running: true + repeat: true + triggeredOnStart: true + onTriggered: { + vorteX = Math.random() * width * 2 - width * 0.5; + vorteY = Math.random() * height * 2 - height * 0.5; + vorteX2 = Math.random() * width * 2 - width * 0.5; + vorteY2 = Math.random() * height * 2 - height * 0.5; + vorteX3 = Math.random() * width * 2 - width * 0.5; + vorteY3 = Math.random() * height * 2 - height * 0.5; + vorteX4 = Math.random() * width * 2 - width * 0.5; + vorteY4 = Math.random() * height * 2 - height * 0.5; + } + } + + + + ParticleSystem{ id: foreground } + ColoredParticle{ + particles: ["stars"] + anchors.fill: parent + system: foreground + image: "content/star.png" + color: "white" + colorVariation: 0.1 + } + ColoredParticle{ + particles: ["shot"] + anchors.fill: parent + system: foreground + image: "content/star.png" + + color: "orange" + colorVariation: 0.3 + } + ColoredParticle{ + id: engine + particles: ["engine"] + anchors.fill: parent + system: foreground + image: "content/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + SpriteParticle{ + particles: ["powerups"] + anchors.fill: parent + system: foreground + Sprite{ + name: "norm" + source: "content/powerupScore.png" + frames: 35 + duration: 40 + to: {"norm":1, "got":0} + } + Sprite{ + name: "got" + source: "content/powerupScore_got.png" + frames: 22 + duration: 40 + to: {"null":1} + } + Sprite{ + name: "null" + source: "content/powerupScore_gone.png" + frames: 1 + duration: 1000 + } + } + SpriteGoal{ + x: rocket.x - 30 + y: rocket.y - 30 + width: 60 + height: 60 + goalState: "got" + jump: true + onAffected: if(!gameOver) score += 1000 + system: foreground + } + GravitationalSingularity{ + id: gs1; x: vorteX; y: vorteY; strength: 800000; + system: foreground + } + Kill{ + x: gs1.x - holeSize; + y: gs1.y - holeSize; + width: holeSize * 2 + height: holeSize * 2 + system: foreground + } + + GravitationalSingularity{ + id: gs2; x: vorteX2; y: vorteY2; strength: 800000; + system: foreground + } + Kill{ + x: gs2.x - holeSize; + y: gs2.y - holeSize; + width: holeSize * 2 + height: holeSize * 2 + system: foreground + } + + GravitationalSingularity{ + id: gs3; x: vorteX3; y: vorteY3; strength: 800000; + system: foreground + } + Kill{ + x: gs3.x - holeSize; + y: gs3.y - holeSize; + width: holeSize * 2 + height: holeSize * 2 + system: foreground + } + GravitationalSingularity{ + id: gs4; x: vorteX4; y: vorteY4; strength: 800000; + system: foreground + } + Kill{ + x: gs4.x - holeSize; + y: gs4.y - holeSize; + width: holeSize * 2 + height: holeSize * 2 + system: foreground + } + TrailEmitter{ + particle: "powerups" + system: foreground + particlesPerSecond: 1 + particleDuration: 6000 + emitting: !gameOver + particleSize: 60 + particleSizeVariation: 10 + anchors.fill: parent + } + TrailEmitter{ + particle: "stars" + system: foreground + particlesPerSecond: 40 + particleDuration: 4000 + emitting: !gameOver + particleSize: 30 + particleSizeVariation: 10 + anchors.fill: parent + } + SpriteImage{ + id: rocket + //Sprites or children for default? + Sprite{ + name: "normal" + source: "content/rocket2.png" + frames: 1 + duration: 1000 + to: {"normal": 0.9, "winking" : 0.1} + } + Sprite{ + name: "winking" + source: "content/rocketEye.png" + frames: 10 + duration: 40 + to: {"normal" : 1} + } + x: root.width/2 + y: root.height/2 + property int lx: 0 + property int ly: 0 + property int lastX: 0 + property int lastY: 0 + width: 45 + height: 22 + onXChanged:{ lastX = lx; lx = x; fakeMove()} + onYChanged:{ lastY = ly; ly = y; fakeMove()} + rotation: Helpers.direction(lastX, lastY, x, y) + data:[ + MouseArea{ + id: ma + anchors.fill: parent; + drag.axis: Drag.XandYAxis + drag.target: rocket + }, + TrailEmitter{ + system: foreground + particle: "engine" + particlesPerSecond: 100 + particleDuration: 1000 + emitting: !gameOver + particleSize: 10 + particleEndSize: 4 + particleSizeVariation: 4 + speed: PointVector{ + x: -128 * Math.cos(rocket.rotation * (Math.PI / 180)) + y: -128 * Math.sin(rocket.rotation * (Math.PI / 180)) + } + anchors.verticalCenter: parent.verticalCenter + height: 4 + width: 4 + + }, + TrailEmitter{ + system: foreground + particle: "shot" + particlesPerSecond: 16 + particleDuration: 1600 + emitting: !gameOver && shoot + particleSize: 40 + speed: PointVector{ + x: 256 * Math.cos(rocket.rotation * (Math.PI / 180)) + y: 256 * Math.sin(rocket.rotation * (Math.PI / 180)) + } + x: parent.width - 4 + y: parent.height/2 + } + ] + } +} + diff --git a/examples/declarative/modelviews/webview/googlemaps.qml b/examples/declarative/particles/trails/content/PetsModel.qml index 85641f4171..d7375a73af 100644 --- a/examples/declarative/modelviews/webview/googlemaps.qml +++ b/examples/declarative/particles/trails/content/PetsModel.qml @@ -38,46 +38,61 @@ ** ****************************************************************************/ -// This example demonstrates how Web services such as Google Maps can be -// abstracted as QML types. Here we have a "Mapping" module with a "Map" -// type. The Map type has an address property. Setting that property moves -// the map. The underlying implementation uses WebView and the Google Maps -// API, but users from QML don't need to understand the implementation in -// order to create a Map. - import QtQuick 1.0 -import QtWebKit 1.0 -import "content/Mapping" - -Map { - id: map - width: 300 - height: 300 - address: "Paris" - - Rectangle { - x: 70 - width: input.width + 20 - height: input.height + 4 - anchors.bottom: parent.bottom; anchors.bottomMargin: 5 - radius: 5 - opacity: map.status == "Ready" ? 1 : 0 - TextInput { - id: input - text: map.address - anchors.centerIn: parent - Keys.onReturnPressed: map.address = input.text - } +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" } - - Text { - id: loading - anchors.centerIn: parent - text: map.status == "Error" ? "Error" : "Loading" - opacity: map.status == "Ready" ? 0 : 1 - font.pixelSize: 30 - - Behavior on opacity { NumberAnimation{} } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" } } diff --git a/examples/declarative/particles/trails/content/candle.png b/examples/declarative/particles/trails/content/candle.png Binary files differnew file mode 100644 index 0000000000..8fa3193719 --- /dev/null +++ b/examples/declarative/particles/trails/content/candle.png diff --git a/examples/declarative/particles/trails/content/colortable.png b/examples/declarative/particles/trails/content/colortable.png Binary files differnew file mode 100644 index 0000000000..a62ceeb4a0 --- /dev/null +++ b/examples/declarative/particles/trails/content/colortable.png diff --git a/examples/declarative/particles/trails/content/particle.png b/examples/declarative/particles/trails/content/particle.png Binary files differnew file mode 100644 index 0000000000..5c83896d22 --- /dev/null +++ b/examples/declarative/particles/trails/content/particle.png diff --git a/examples/declarative/particles/trails/content/particle2.png b/examples/declarative/particles/trails/content/particle2.png Binary files differnew file mode 100644 index 0000000000..36349c6c6e --- /dev/null +++ b/examples/declarative/particles/trails/content/particle2.png diff --git a/examples/declarative/particles/trails/content/particle3.png b/examples/declarative/particles/trails/content/particle3.png Binary files differnew file mode 100644 index 0000000000..905d8f37b8 --- /dev/null +++ b/examples/declarative/particles/trails/content/particle3.png diff --git a/examples/declarative/particles/trails/content/particleA.png b/examples/declarative/particles/trails/content/particleA.png Binary files differnew file mode 100644 index 0000000000..c63acdee1f --- /dev/null +++ b/examples/declarative/particles/trails/content/particleA.png diff --git a/examples/declarative/particles/trails/content/portal_bg.png b/examples/declarative/particles/trails/content/portal_bg.png Binary files differnew file mode 100644 index 0000000000..3c59eeabb9 --- /dev/null +++ b/examples/declarative/particles/trails/content/portal_bg.png diff --git a/examples/declarative/particles/trails/content/sparkleSize.png b/examples/declarative/particles/trails/content/sparkleSize.png Binary files differnew file mode 100644 index 0000000000..752056541b --- /dev/null +++ b/examples/declarative/particles/trails/content/sparkleSize.png diff --git a/examples/declarative/particles/trails/content/star.png b/examples/declarative/particles/trails/content/star.png Binary files differnew file mode 100644 index 0000000000..0d592cfa87 --- /dev/null +++ b/examples/declarative/particles/trails/content/star.png diff --git a/examples/declarative/particles/trails/dynamicemitters.qml b/examples/declarative/particles/trails/dynamicemitters.qml new file mode 100644 index 0000000000..8ea0272d94 --- /dev/null +++ b/examples/declarative/particles/trails/dynamicemitters.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem{ + id: sys + } + ColoredParticle{ + system: sys + image: "content/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + } + Component{ + id: emitterComp + TrailEmitter{ + id: container + TrailEmitter{ + id: emitMore + system: sys + emitting: true + particlesPerSecond: 128 + particleDuration: 600 + particleSize: 16 + particleEndSize: 8 + speed: AngleVector{angleVariation:360; magnitude: 60} + } + + property int life: 2600 + property real targetX: 0 + property real targetY: 0 + function go(){ + xAnim.start(); + yAnim.start(); + container.emitting = true + } + system: sys + emitting: true + particlesPerSecond: 64 + particleDuration: 600 + particleSize: 24 + particleEndSize: 8 + NumberAnimation on x{ + id: xAnim; + to: targetX + duration: life + running: false + } + NumberAnimation on y{ + id: yAnim; + to: targetY + duration: life + running: false + } + Timer{ + interval: life + running: true + onTriggered: container.destroy(); + } + } + } + MouseArea{ + anchors.fill: parent + onClicked:{ + for(var i=0; i<16; i++){ + var obj = emitterComp.createObject(root); + obj.x = mouse.x + obj.y = mouse.y + obj.targetX = Math.random() * 640 + obj.targetY = Math.random() * 480 + obj.life = Math.round(Math.random() * 2400) + 200 + obj.go(); + } + } + } +} diff --git a/examples/declarative/particles/trails/fireballs.qml b/examples/declarative/particles/trails/fireballs.qml new file mode 100644 index 0000000000..116a2334dc --- /dev/null +++ b/examples/declarative/particles/trails/fireballs.qml @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem{ + id: particles + } + + /* + ColoredParticle{ + id: fireball + anchors.fill: parent + particles: ["E"] + system: particles + image: "content/particleA.png" + colorVariation: 0.2 + color: "#00ff400f" + } + */ + ColoredParticle{ + id: smoke + system: particles + anchors.fill: parent + particles: ["A", "B"] + image: "content/particle.png" + colorVariation: 0 + color: "#00111111" + } + ColoredParticle{ + id: flame + anchors.fill: parent + system: particles + particles: ["C", "D"] + image: "content/particle.png" + colorVariation: 0.1 + color: "#00ff400f" + } + TrailEmitter{ + id: fire + system: particles + particle: "C" + + y: parent.height + width: parent.width + + particlesPerSecond: 350 + particleDuration: 3500 + + acceleration: PointVector{ y: -17; xVariation: 3 } + speed: PointVector{xVariation: 3} + + particleSize: 24 + particleSizeVariation: 8 + particleEndSize: 4 + } + FollowEmitter{ + id: fireSmoke + particle: "B" + system: particles + follow: "C" + width: root.width + height: root.height - 68 + + particlesPerParticlePerSecond: 1 + particleDuration: 2000 + + speed: PointVector{y:-17*6; yVariation: -17; xVariation: 3} + acceleration: PointVector{xVariation: 3} + + particleSize: 36 + particleSizeVariation: 8 + particleEndSize: 16 + } + FollowEmitter{ + id: fireballFlame + anchors.fill: parent + system: particles + particle: "D" + follow: "E" + + particlesPerParticlePerSecond: 120 + particleDuration: 180 + emissionWidth: 8 + emissionHeight: 8 + + particleSize: 16 + particleSizeVariation: 4 + particleEndSize: 4 + } + + FollowEmitter{ + id: fireballSmoke + anchors.fill: parent + system: particles + particle: "A" + follow: "E" + + particlesPerParticlePerSecond: 128 + particleDuration: 2400 + emissionWidth: 16 + emissionHeight: 16 + + speed: PointVector{yVariation: 16; xVariation: 16} + acceleration: PointVector{y: -16} + + particleSize: 24 + particleSizeVariation: 8 + particleEndSize: 8 + } + TrailEmitter{ + id: balls + system: particles + particle: "E" + + y: parent.height + width: parent.width + + particlesPerSecond: 2 + particleDuration: 7000 + + speed: PointVector{y:-17*4*2; xVariation: 6*6} + acceleration: PointVector{y: 17*2; xVariation: 6*6} + + particleSize: 12 + particleSizeVariation: 4 + } + +} + diff --git a/examples/declarative/particles/trails/layered.qml b/examples/declarative/particles/trails/layered.qml new file mode 100644 index 0000000000..38eb8e67dc --- /dev/null +++ b/examples/declarative/particles/trails/layered.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + id: root + width: 360 + height: 600 + color: "darkblue" + property bool cloneMode: false + MouseArea{ + anchors.fill: parent + onClicked: cloneMode = !cloneMode; + } + ParticleSystem{ + id: sys + startTime: 4000 + } + TrailEmitter{ + system: sys + y:root.height + 20 + width: root.width + particlesPerSecond: 200 + particleDuration: 4000 + speed: PointVector{ y: -120; } + } + SpriteParticle{ + system: sys + visible: !cloneMode + Sprite{ + source: "content/particle2.png" + } + } + SpriteParticle{ + system: sys + visible: cloneMode + z: 0 + Sprite{ + source: "content/particle3.png" + } + } + SpriteParticle{ + system: sys + clip: true + visible: cloneMode + y: 120 + height: 240 + width: root.width + z: 1 + Sprite{ + source: "content/particle.png" + } + } +} diff --git a/examples/declarative/particles/trails/list.qml b/examples/declarative/particles/trails/list.qml new file mode 100644 index 0000000000..2ab579f126 --- /dev/null +++ b/examples/declarative/particles/trails/list.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + Particles. + +import QtQuick 2.0 +import Qt.labs.particles 2.0 +import "content" + +Rectangle { + width: 200; height: 300 + color: "black" + ParticleSystem{ id: particles } + ColoredParticle{ + anchors.fill: parent + system: particles + z: 10 + image: "content/star.png" + color: "white" + colorVariation: 0.0 + } + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: 55 + Column { + Text { text: 'Name: ' + name; color: "white" } + Text { text: 'Type: ' + type; color: "white" } + Text { text: 'Age: ' + age; color: "white" } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + width: 200; height: 50 + color: "#333366" + y: listView.currentItem.y; + //Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } + Behavior on y { NumberAnimation {id: anim} } + TrailEmitter{ + anchors.fill: parent + system: particles; + emitting: anim.running + particlesPerSecond: 600 + particleDuration: 600 + particleSize: 16 + particleEndSize: 8 + } + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: PetsModel {} + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + } +} diff --git a/examples/declarative/particles/trails/overburst.qml b/examples/declarative/particles/trails/overburst.qml new file mode 100644 index 0000000000..6ca15972a4 --- /dev/null +++ b/examples/declarative/particles/trails/overburst.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + color: "black" + width: 360 + height: 540 + ParticleSystem{ id: sys } + ColoredParticle{ + system: sys + id: cp + image: "content/particle.png" + colorVariation: 0.4 + color: "#000000FF" + } + TrailEmitter{ + //burst on click + id: bursty + system: sys + emitting: ma.pressed + x: ma.mouseX + y: ma.mouseY + particlesPerSecond: 16000 + particleDuration: 1000 + maxParticles: 4000 + acceleration: AngleVector{angleVariation: 360; magnitude: 360; } + particleSize: 8 + particleEndSize: 16 + particleSizeVariation: 4 + } + MouseArea{ + anchors.fill: parent + id: ma + } + MouseArea{ + width: 100 + height: 100 + onClicked: sys.overwrite = !sys.overwrite + id: ma2 + Rectangle{ + anchors.fill: parent + color: "lightsteelblue" + } + } +} diff --git a/examples/declarative/particles/trails/portal.qml b/examples/declarative/particles/trails/portal.qml new file mode 100644 index 0000000000..dba2e59513 --- /dev/null +++ b/examples/declarative/particles/trails/portal.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + id: root + width: 360 + height: 540 + color: "black" + Image{ + anchors.fill: parent + source: "content/portal_bg.png" + } + ParticleSystem{ + id: particles + startTime: 2000 + } + ColoredParticle{ + particles: ["center","edge"] + anchors.fill: parent + system: particles + image: "content/particle.png" + colorVariation: 0.1 + color: "#009999FF" + } + TrailEmitter{ + anchors.fill: parent + particle: "center" + system: particles + particlesPerSecond: 200 + particleDuration: 2000 + emitting: true + particleSize: 20 + particleSizeVariation: 2 + particleEndSize: 0 + shape: Ellipse{fill: false} + speed: DirectedVector{ + targetX: root.width/2 + targetY: root.height/2 + proportionalMagnitude: true + magnitude: 0.5 + } + } + TrailEmitter{ + anchors.fill: parent + particle: "edge" + system: particles + particlesPerSecond: 4000 + particleDuration: 2000 + emitting: true + particleSize: 20 + particleSizeVariation: 2 + particleEndSize: 0 + shape: Ellipse{fill: false} + speed: DirectedVector{ + targetX: root.width/2 + targetY: root.height/2 + proportionalMagnitude: true + magnitude: 0.1 + magnitudeVariation: 0.1 + } + acceleration: DirectedVector{ + targetX: root.width/2 + targetY: root.height/2 + targetVariation: 200 + proportionalMagnitude: true + magnitude: 0.1 + magnitudeVariation: 0.1 + } + } +} diff --git a/examples/declarative/particles/trails/rainbow.qml b/examples/declarative/particles/trails/rainbow.qml new file mode 100644 index 0000000000..6c64929668 --- /dev/null +++ b/examples/declarative/particles/trails/rainbow.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 Qt.labs.particles 2.0 +import QtQuick 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem{ id: particles } + ColoredParticle{ + system: particles + colorVariation: 0.5 + alpha: 0 + + image: "content/particle.png" + colorTable: "content/colortable.png" + sizeTable: "content/colortable.png" + } + TrailEmitter{ + system: particles + particlesPerSecond: 500 + particleDuration: 2000 + + y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 + x: root.width / 2 + Math.cos(t) * root.width * 0.3 + property real t; + + NumberAnimation on t { + from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite + } + + speedFromMovement: 20 + + speed: PointVector{ xVariation: 5; yVariation: 5;} + acceleration: PointVector{ xVariation: 5; yVariation: 5;} + + particleSize: 16 + //particleEndSize: 8 + //particleSizeVariation: 8 + } +} diff --git a/examples/declarative/particles/trails/shimmer.qml b/examples/declarative/particles/trails/shimmer.qml new file mode 100644 index 0000000000..06f599d97a --- /dev/null +++ b/examples/declarative/particles/trails/shimmer.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + width: 360 + height: 540 + color: "black" + MouseArea{ + anchors.fill: parent + onClicked: particles.running = !particles.running + } + ParticleSystem{ + id: particles + running: false + } + ColoredParticle{ + anchors.fill: parent + system: particles + image: "content/star.png" + sizeTable: "content/sparkleSize.png" + alpha: 0 + colorVariation: 0.6 + } + TrailEmitter{ + anchors.fill: parent + system: particles + particlesPerSecond: 2000 + particleDuration: 2000 + emitting: true + particleSize: 30 + particleSizeVariation: 10 + } +} diff --git a/examples/declarative/particles/trails/swarm.qml b/examples/declarative/particles/trails/swarm.qml new file mode 100644 index 0000000000..083f9e816d --- /dev/null +++ b/examples/declarative/particles/trails/swarm.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 as QLP + +Rectangle{ + width: 200 + height: 200 + color: "black" + QLP.ParticleSystem{ id: ps } + QLP.ColoredParticle{ + system: ps + particles: ["star1","star2"] + anchors.fill: parent + clip: true + image: "content/star.png" + } + QLP.Swarm{ + system: ps + leaders: ["star2"]; + anchors.fill: parent + strength: 128 + } + QLP.TrailEmitter{ + anchors.fill: parent + system: ps + particle: "star1" + particlesPerSecond: 100 + particleDuration: 2000 + } + QLP.TrailEmitter{ + anchors.fill: parent + system: ps + particle: "star2" + particlesPerSecond: 0.4 + particleDuration: 10000 + particleSize: 64 + particleEndSize: 32 + } +} diff --git a/examples/declarative/particles/trails/trails.qml b/examples/declarative/particles/trails/trails.qml new file mode 100644 index 0000000000..58d369c8d5 --- /dev/null +++ b/examples/declarative/particles/trails/trails.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + color: "black" + width: 360 + height: 540 + ParticleSystem{ id: sys } + ColoredParticle{ + system: sys + id: cp + image: "content/particle.png" + color: "#00FFFFFF" + colorVariation: 0.4 + } + TrailEmitter{ + //burst on click + id: bursty + system: sys + emitting: false + particlesPerSecond: 2000 + particleDuration: 500 + acceleration: AngleVector{ angle: 90; angleVariation: 360; magnitude: 640; } + particleSize: 8 + particleEndSize: 16 + particleSizeVariation: 4 + } + TrailEmitter{ + system: sys + speedFromMovement: 4.0 + emitting: ma.pressed + x: ma.mouseX + y: ma.mouseY + particlesPerSecond: 400 + particleDuration: 2000 + acceleration: AngleVector{ angle: 90; angleVariation: 22; magnitude: 32; } + particleSize: 8 + particleEndSize: 16 + particleSizeVariation: 8 + } + MouseArea{ + id: ma + anchors.fill: parent + onPressed: {bursty.x = mouse.x; bursty.y = mouse.y; bursty.pulse(0.1);}//uses both for comparison + onReleased: {bursty.x = mouse.x; bursty.y = mouse.y; bursty.burst(200);} + } +} diff --git a/examples/declarative/particles/trails/turbulence.qml b/examples/declarative/particles/trails/turbulence.qml new file mode 100644 index 0000000000..7da50464c2 --- /dev/null +++ b/examples/declarative/particles/trails/turbulence.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle{ + width: 360 + height: 540 + color: "#222222" + id: root + Image{ + source: "content/candle.png" + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottomMargin: -8 + anchors.horizontalCenterOffset: 2 + } + ParticleSystem{ + id: ps + } + Turbulence{ + system: ps + height: (parent.height / 2) + width: parent.width / 2 + x: parent. width / 4 + anchors.fill: parent + strength: 16 + frequency: 64 + gridSize: 16 + } + ColoredParticle{ + particles: ["smoke"] + system: ps + image: "content/particle.png" + color: "#11111111" + colorVariation: 0 + } + ColoredParticle{ + particles: ["flame"] + system: ps + image: "content/particle.png" + color: "#11ff400f" + colorVariation: 0.1 + } + TrailEmitter{ + anchors.centerIn: parent + system: ps + particle: "flame" + + particlesPerSecond: 120 + particleDuration: 1200 + particleSize: 20 + particleEndSize: 10 + particleSizeVariation: 10 + acceleration: PointVector{ y: -40 } + speed: AngleVector{ angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 } + } + FollowEmitter{ + id: smoke1 + width: root.width + height: 232 + system: ps + particle: "smoke" + follow: "flame" + + particlesPerParticlePerSecond: 4 + particleDuration: 2400 + particleDurationVariation: 400 + particleSize: 16 + particleEndSize: 8 + particleSizeVariation: 8 + acceleration: PointVector{ y: -40 } + speed: AngleVector{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 } + } + FollowEmitter{ + id: smoke2 + width: root.width + height: 232 + system: ps + particle: "smoke" + follow: "flame" + + particlesPerParticlePerSecond: 1 + particleDuration: 2400 + particleSize: 36 + particleEndSize: 24 + particleSizeVariation: 8 + acceleration: PointVector{ y: -40 } + speed: AngleVector{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 } + } +} diff --git a/examples/declarative/particles/trails/velocityfrommotion.qml b/examples/declarative/particles/trails/velocityfrommotion.qml new file mode 100644 index 0000000000..3692410853 --- /dev/null +++ b/examples/declarative/particles/trails/velocityfrommotion.qml @@ -0,0 +1,327 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 2.0 +import Qt.labs.particles 2.0 + +Rectangle { + + id: root + + height: 540 + width: 360 + + gradient: Gradient { + GradientStop { position: 0; color: "#000020" } + GradientStop { position: 1; color: "#000000" } + } + + MouseArea { + id: mouseArea + anchors.fill: root + +/* + onPressed: stopAndStart() + onReleased: stopAndStart() + function stopAndStart() { + trailsNormal.emitting = false; + trailsNormal.emitting = true; + trailsStars.emitting = false; + trailsStars.emitting = true; + trailsNormal2.emitting = false; + trailsNormal2.emitting = true; + trailsStars2.emitting = false; + trailsStars2.emitting = true; + print("stop and start") + } +*/ + } + + ParticleSystem{ id: sys1 } + ColoredParticle{ + system: sys1 + image: "content/particle.png" + color: "cyan" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "cyan" + to: "magenta" + duration: 1000 + } + ColorAnimation { + from: "magenta" + to: "blue" + duration: 2000 + } + ColorAnimation { + from: "blue" + to: "violet" + duration: 2000 + } + ColorAnimation { + from: "violet" + to: "cyan" + duration: 2000 + } + } + colorVariation: 0.3 + } + TrailEmitter{ + id: trailsNormal + system: sys1 + + particlesPerSecond: 500 + particleDuration: 2000 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle.cx + + speed: PointVector{xVariation: 4; yVariation: 4;} + acceleration: PointVector{xVariation: 10; yVariation: 10;} + speedFromMovement: 8 + + particleSize: 8 + particleSizeVariation: 4 + } + ParticleSystem { id: sys2 } + ColoredParticle{ + color: "cyan" + system: sys2 + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "magenta" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "magenta" + duration: 2000 + } + } + colorVariation: 0.5 + image: "content/star.png" + } + TrailEmitter{ + id: trailsStars + system: sys2 + + particlesPerSecond: 100 + particleDuration: 2200 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle.cx + + speed: PointVector{xVariation: 4; yVariation: 4;} + acceleration: PointVector{xVariation: 10; yVariation: 10;} + speedFromMovement: 8 + + particleSize: 22 + particleSizeVariation: 4 + } + ParticleSystem { id: sys3; } + ColoredParticle{ + image: "content/particle.png" + system: sys3 + color: "orange" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "green" + duration: 2000 + } + ColorAnimation { + from: "green" + to: "red" + duration: 2000 + } + } + + colorVariation: 0.2 + + } + TrailEmitter{ + id: trailsNormal2 + system: sys3 + + particlesPerSecond: 300 + particleDuration: 2000 + + y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx + + speedFromMovement: 16 + + speed: PointVector{xVariation: 4; yVariation: 4;} + acceleration: PointVector{xVariation: 10; yVariation: 10;} + + particleSize: 12 + particleSizeVariation: 4 + } + ParticleSystem { id: sys4; } + ColoredParticle{ + system: sys4 + image: "content/star.png" + color: "green" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "green" + to: "red" + duration: 2000 + } + ColorAnimation { + from: "red" + to: "green" + duration: 2000 + } + } + + colorVariation: 0.5 + } + TrailEmitter{ + id: trailsStars2 + system: sys4 + + particlesPerSecond: 50 + particleDuration: 2200 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx + + speedFromMovement: 16 + speed: PointVector{xVariation: 2; yVariation: 2;} + acceleration: PointVector{xVariation: 10; yVariation: 10;} + + particleSize: 22 + particleSizeVariation: 4 + } + + + + color: "white" + + Item { + id: circle + //anchors.fill: parent + property real radius: 0 + property real dx: root.width / 2 + property real dy: root.height / 2 + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 1000 + from: 1 + to: 0 + loops: 8 + } + NumberAnimation { + duration: 1000 + from: 0 + to: 1 + loops: 8 + } + + } + + SequentialAnimation on radius { + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 4000 + from: 0 + to: 100 + } + NumberAnimation { + duration: 4000 + from: 100 + to: 0 + } + } + } + + Item { + id: circle3 + property real radius: 100 + property real dx: root.width / 2 + property real dy: root.height / 2 + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { from: 0.0; to: 1 ; duration: 10000; } + } + } + + Item { + id: circle2 + property real radius: 30 + property real dx: circle3.cx + property real dy: circle3.cy + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { from: 0.0; to: 1 ; duration: 1000; } + } + } + +} diff --git a/examples/examples.pro b/examples/examples.pro index 09881f1a9c..2ee93a92db 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs SUBDIRS += declarative +contains(QT_CONFIG, qmltest): SUBDIRS += qmltest diff --git a/examples/qmltest/qmltest.pro b/examples/qmltest/qmltest.pro new file mode 100644 index 0000000000..40d964c20a --- /dev/null +++ b/examples/qmltest/qmltest.pro @@ -0,0 +1,4 @@ +TEMPLATE=app +TARGET=tst_qmltestexample +CONFIG += qmltestcase +SOURCES += tst_qmltest.cpp diff --git a/examples/qmltest/tst_basic.qml b/examples/qmltest/tst_basic.qml new file mode 100644 index 0000000000..48aac141a2 --- /dev/null +++ b/examples/qmltest/tst_basic.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + name: "BasicTests" + + function test_pass() { + compare(2 + 2, 4, "2 + 2") + } + + function test_fail() { + compare(2 + 2, 5, "2 + 2") + } + + function test_skip() { + skip("skipping") + } + + function test_expecting() { + expectFail("", "this is the fail we wanted") + verify(false) + } + + function test_table_data() { + return [ + {tag: "2 + 2 = 4", a: 2, b: 2, answer: 4 }, + {tag: "2 + 6 = 8", a: 2, b: 6, answer: 8 }, + {tag: "2 + 2 = 5", a: 2, b: 2, answer: 5 }, // fail + ] + } + + function test_table(data) { + compare(data.a + data.b, data.answer) + } +} diff --git a/examples/qmltest/tst_item.qml b/examples/qmltest/tst_item.qml new file mode 100644 index 0000000000..4247834565 --- /dev/null +++ b/examples/qmltest/tst_item.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + id: foo + width: 640; height: 480 + color: "cyan" + + TestCase { + name: "ItemTests" + id: test1 + + function test_color() { + compare(foo.color, "#00ffff") + } + } +} diff --git a/examples/qmltest/tst_qmltest.cpp b/examples/qmltest/tst_qmltest.cpp new file mode 100644 index 0000000000..4f6eb4d1b9 --- /dev/null +++ b/examples/qmltest/tst_qmltest.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(qmltest) |