1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the examples of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
42 import QtQuick.Particles 2.0
48 property int activeSuns: 0
49 property int centerOffset: 72
51 height: 480; width: 360
56 onClicked: window.focus = false;
59 //This is the message box that pops up when there's an error
64 anchors.centerIn: parent
65 width: dialogText.width + 6; height: dialogText.height + 6
67 color: 'lightsteelblue'
68 z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones.
71 dialogText.text = str;
83 NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 }
84 PauseAnimation { duration: 5000 }
85 NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 }
91 anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right}
98 anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter }
100 GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" }
101 GradientStop { id: gradientStopB; position: 1.0; color: "#437284" }
105 // stars (when there's no sun)
112 source: "content/images/star.png"
120 emitRate: parent.width / 50
129 z: 2 // just above the sun so that the sun can set behind it
130 anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom }
132 GradientStop { position: 0.0; color: "ForestGreen" }
133 GradientStop { position: 1.0; color: "DarkGreen" }
137 SystemPalette { id: activePalette }
143 height: centerOffset * 2
144 color: activePalette.window
145 anchors { right: parent.right; top: parent.top; left: parent.left}
148 anchors.centerIn: parent
151 Text { text: "Drag an item into the scene." }
154 width: palette.width + 10; height: palette.height + 10
155 border.color: "black"
159 anchors.centerIn: parent
163 anchors.verticalCenter: parent.verticalCenter
164 componentFile: "Sun.qml"
165 source: "content/images/sun.png"
166 image: "images/sun.png"
169 anchors.verticalCenter: parent.verticalCenter
170 componentFile: "GenericSceneItem.qml"
171 source: "content/images/moon.png"
172 image: "images/moon.png"
175 anchors.verticalCenter: parent.verticalCenter
176 componentFile: "PerspectiveItem.qml"
177 source: "content/images/tree_s.png"
178 image: "images/tree_s.png"
181 anchors.verticalCenter: parent.verticalCenter
182 componentFile: "PerspectiveItem.qml"
183 source: "content/images/rabbit_brown.png"
184 image: "images/rabbit_brown.png"
187 anchors.verticalCenter: parent.verticalCenter
188 componentFile: "PerspectiveItem.qml"
189 source: "content/images/rabbit_bw.png"
190 image: "images/rabbit_bw.png"
195 Text { text: "Active Suns: " + activeSuns }
199 //Popup toolbox down the bottom
204 height: popupColumn.height + 16
205 color: activePalette.window
207 property bool poppedUp: false
208 property int downY: window.height - (createButton.height + 16)
209 property int upY: window.height - (popupColumn.height + 16)
210 y: poppedUp ? upY : downY
211 Behavior on y { NumberAnimation {}}
216 anchors.centerIn: parent
220 height: createButton.height
222 Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter }
225 text: popupToolbox.poppedUp ? "Hide" : "Show"
226 onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp
233 Qt.createQmlObject(qmlText.text, scene, 'CustomObject');
235 dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message);
243 width: 360; height: 240
247 anchors.fill: parent; anchors.margins: 5
251 wrapMode: TextEdit.WordWrap
253 text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}"
259 //Day state, for when a sun is added to the scene
262 when: window.activeSuns > 0
264 PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" }
265 PropertyChanges { target: gradientStopB; color: "SkyBlue" }
266 PropertyChanges { target: stars; opacity: 0 }
269 //! [top-level transitions]
270 transitions: Transition {
271 PropertyAnimation { duration: 3000 }
272 ColorAnimation { duration: 3000 }
274 //! [top-level transitions]