summaryrefslogtreecommitdiffstats
path: root/examples/declarative/dynamic
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-14 01:32:57 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-16 23:42:12 (GMT)
commit82d0b03c4f81c2832975d548917c03dbaddeee72 (patch)
treecb2d7ae0c7c8c5870f4c9439453c938a9423afad /examples/declarative/dynamic
parent0aca20bf669ef7e7702ee96d0d0676392cfd1b72 (diff)
downloadQt-82d0b03c4f81c2832975d548917c03dbaddeee72.zip
Qt-82d0b03c4f81c2832975d548917c03dbaddeee72.tar.gz
Qt-82d0b03c4f81c2832975d548917c03dbaddeee72.tar.bz2
Restructure the examples. They are now organized into various
subdirectories to make it easier to locate examples for certain features (e.g. animation) and to distinguish between different types of examples (e.g. very basic examples vs complex demo-like examples).
Diffstat (limited to 'examples/declarative/dynamic')
-rw-r--r--examples/declarative/dynamic/dynamic.qml176
-rw-r--r--examples/declarative/dynamic/dynamic.qmlproject16
-rw-r--r--examples/declarative/dynamic/images/NOTE1
-rw-r--r--examples/declarative/dynamic/images/face-smile.pngbin15408 -> 0 bytes
-rw-r--r--examples/declarative/dynamic/images/moon.pngbin1757 -> 0 bytes
-rw-r--r--examples/declarative/dynamic/images/rabbit_brown.pngbin1245 -> 0 bytes
-rw-r--r--examples/declarative/dynamic/images/rabbit_bw.pngbin1759 -> 0 bytes
-rw-r--r--examples/declarative/dynamic/images/star.pngbin349 -> 0 bytes
-rw-r--r--examples/declarative/dynamic/images/sun.pngbin8153 -> 0 bytes
-rw-r--r--examples/declarative/dynamic/images/tree_s.pngbin3406 -> 0 bytes
-rw-r--r--examples/declarative/dynamic/qml/Button.qml40
-rw-r--r--examples/declarative/dynamic/qml/PaletteItem.qml19
-rw-r--r--examples/declarative/dynamic/qml/PerspectiveItem.qml25
-rw-r--r--examples/declarative/dynamic/qml/Sun.qml38
-rw-r--r--examples/declarative/dynamic/qml/itemCreation.js65
15 files changed, 0 insertions, 380 deletions
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
deleted file mode 100644
index 52c7c1e..0000000
--- a/examples/declarative/dynamic/dynamic.qml
+++ /dev/null
@@ -1,176 +0,0 @@
-import Qt 4.7
-import Qt.labs.particles 1.0
-import "qml"
-
-Item {
- id: window
-
- property int activeSuns: 0
-
- //This is a desktop-sized example
- width: 1024; height: 512
-
- //This is the message box that pops up when there's an error
- Rectangle {
- id: dialog
-
- opacity: 0
- anchors.centerIn: parent
- width: dialogText.width + 6; height: dialogText.height + 6
- border.color: 'black'
- color: 'lightsteelblue'
- z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones.
-
- function show(str){
- dialogText.text = str;
- dialogAnim.start();
- }
-
- Text {
- id: dialogText
- x: 3; y: 3
- font.pixelSize: 14
- }
-
- SequentialAnimation {
- id: dialogAnim
- NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 }
- PauseAnimation { duration: 5000 }
- NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 }
- }
- }
-
- // sky
- Rectangle {
- id: sky
- anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter }
- gradient: Gradient {
- GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" }
- GradientStop { id: gradientStopB; position: 1.0; color: "#437284" }
- }
- }
-
- // stars (when there's no sun)
- Particles {
- id: stars
- x: 0; y: 0; width: parent.width; height: parent.height / 2
- source: "images/star.png"
- angleDeviation: 360
- velocity: 0; velocityDeviation: 0
- count: parent.width / 10
- fadeInDuration: 2800
- opacity: 1
- }
-
- // ground
- Rectangle {
- id: ground
- z: 2 // just above the sun so that the sun can set behind it
- anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom }
- gradient: Gradient {
- GradientStop { position: 0.0; color: "ForestGreen" }
- GradientStop { position: 1.0; color: "DarkGreen" }
- }
- }
-
- SystemPalette { id: activePalette }
-
- // right-hand panel
- Rectangle {
- id: toolbox
-
- width: 480
- color: activePalette.window
- anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
-
- Column {
- anchors.centerIn: parent
- spacing: 8
-
- Text { text: "Drag an item into the scene." }
-
- Rectangle {
- width: childrenRect.width + 10; height: childrenRect.height + 10
- border.color: "black"
-
- Row {
- anchors.centerIn: parent
- spacing: 8
-
- PaletteItem {
- anchors.verticalCenter: parent.verticalCenter
- componentFile: "Sun.qml"
- image: "../images/sun.png"
- }
- PaletteItem {
- anchors.verticalCenter: parent.verticalCenter
- componentFile: "GenericSceneItem.qml"
- image: "../images/moon.png"
- }
- PaletteItem {
- anchors.verticalCenter: parent.verticalCenter
- componentFile: "PerspectiveItem.qml"
- image: "../images/tree_s.png"
- }
- PaletteItem {
- anchors.verticalCenter: parent.verticalCenter
- componentFile: "PerspectiveItem.qml"
- image: "../images/rabbit_brown.png"
- }
- PaletteItem {
- anchors.verticalCenter: parent.verticalCenter
- componentFile: "PerspectiveItem.qml"
- image: "../images/rabbit_bw.png"
- }
- }
- }
-
- Text { text: "Active Suns: " + activeSuns }
-
- Rectangle { width: parent.width; height: 1; color: "black" }
-
- Text { text: "Arbitrary QML:" }
-
- Rectangle {
- width: 460; height: 240
-
- TextEdit {
- id: qmlText
- anchors.fill: parent; anchors.margins: 5
- readOnly: false
- focusOnPress: true
- font.pixelSize: 14
-
- text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}"
- }
- }
-
- Button {
- text: "Create"
- onClicked: {
- try {
- Qt.createQmlObject(qmlText.text, window, 'CustomObject');
- } catch(err) {
- dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message);
- }
- }
- }
- }
- }
-
- //Day state, for when a sun is added to the scene
- states: State {
- name: "Day"
- when: window.activeSuns > 0
-
- PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" }
- PropertyChanges { target: gradientStopB; color: "SkyBlue" }
- PropertyChanges { target: stars; opacity: 0 }
- }
-
- transitions: Transition {
- PropertyAnimation { duration: 3000 }
- ColorAnimation { duration: 3000 }
- }
-
-}
diff --git a/examples/declarative/dynamic/dynamic.qmlproject b/examples/declarative/dynamic/dynamic.qmlproject
deleted file mode 100644
index d4909f8..0000000
--- a/examples/declarative/dynamic/dynamic.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.0
-
-Project {
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
- /* List of plugin directories passed to QML runtime */
- // importPaths: [ " ../exampleplugin " ]
-}
diff --git a/examples/declarative/dynamic/images/NOTE b/examples/declarative/dynamic/images/NOTE
deleted file mode 100644
index fcd87f9..0000000
--- a/examples/declarative/dynamic/images/NOTE
+++ /dev/null
@@ -1 +0,0 @@
-Images (except star.png) are from the KDE project.
diff --git a/examples/declarative/dynamic/images/face-smile.png b/examples/declarative/dynamic/images/face-smile.png
deleted file mode 100644
index 3d66d72..0000000
--- a/examples/declarative/dynamic/images/face-smile.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/dynamic/images/moon.png b/examples/declarative/dynamic/images/moon.png
deleted file mode 100644
index 1c0d606..0000000
--- a/examples/declarative/dynamic/images/moon.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/dynamic/images/rabbit_brown.png b/examples/declarative/dynamic/images/rabbit_brown.png
deleted file mode 100644
index ebfdeed..0000000
--- a/examples/declarative/dynamic/images/rabbit_brown.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/dynamic/images/rabbit_bw.png b/examples/declarative/dynamic/images/rabbit_bw.png
deleted file mode 100644
index 7bff9b9..0000000
--- a/examples/declarative/dynamic/images/rabbit_bw.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/dynamic/images/star.png b/examples/declarative/dynamic/images/star.png
deleted file mode 100644
index 27ef924..0000000
--- a/examples/declarative/dynamic/images/star.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/dynamic/images/sun.png b/examples/declarative/dynamic/images/sun.png
deleted file mode 100644
index 7713ca5..0000000
--- a/examples/declarative/dynamic/images/sun.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/dynamic/images/tree_s.png b/examples/declarative/dynamic/images/tree_s.png
deleted file mode 100644
index 6eac35a..0000000
--- a/examples/declarative/dynamic/images/tree_s.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml
deleted file mode 100644
index 963a850..0000000
--- a/examples/declarative/dynamic/qml/Button.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-import Qt 4.7
-
-Rectangle {
- id: container
-
- property variant text
- signal clicked
-
- height: text.height + 10; width: text.width + 20
- border.width: 1
- radius: 4
- smooth: true
-
- gradient: Gradient {
- GradientStop {
- position: 0.0
- color: !mouseArea.pressed ? activePalette.light : activePalette.button
- }
- GradientStop {
- position: 1.0
- color: !mouseArea.pressed ? activePalette.button : activePalette.dark
- }
- }
-
- SystemPalette { id: activePalette }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: container.clicked()
- }
-
- Text {
- id: text
- anchors.centerIn:parent
- font.pointSize: 10
- text: parent.text
- color: activePalette.buttonText
- }
-}
diff --git a/examples/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml
deleted file mode 100644
index dcb5cc3..0000000
--- a/examples/declarative/dynamic/qml/PaletteItem.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import Qt 4.7
-import "itemCreation.js" as Code
-
-Image {
- id: paletteItem
-
- property string componentFile
- property string image
-
- source: image
-
- MouseArea {
- anchors.fill: parent
-
- onPressed: Code.startDrag(mouse);
- onPositionChanged: Code.continueDrag(mouse);
- onReleased: Code.endDrag(mouse);
- }
-}
diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml
deleted file mode 100644
index c04d3dc..0000000
--- a/examples/declarative/dynamic/qml/PerspectiveItem.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-import Qt 4.7
-
-Image {
- id: rootItem
-
- property bool created: false
- property string image
-
- property double scaledBottom: y + (height + height*scale) / 2
- property bool onLand: scaledBottom > window.height / 2
-
- source: image
- opacity: onLand ? 1 : 0.25
- scale: Math.max((y + height - 250) * 0.01, 0.3)
- smooth: true
-
- onCreatedChanged: {
- if (created && !onLand)
- rootItem.destroy();
- else
- z = scaledBottom;
- }
-
- onYChanged: z = scaledBottom;
-}
diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml
deleted file mode 100644
index 43dcb9a..0000000
--- a/examples/declarative/dynamic/qml/Sun.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import Qt 4.7
-
-Image {
- id: sun
-
- property bool created: false
- property string image: "../images/sun.png"
-
- source: image
-
- // once item is created, start moving offscreen
- NumberAnimation on y {
- to: window.height / 2
- running: created
- onRunningChanged: {
- if (running)
- duration = (window.height - sun.y) * 10;
- else
- state = "OffScreen"
- }
- }
-
- states: State {
- name: "OffScreen"
- StateChangeScript {
- script: { sun.created = false; sun.destroy() }
- }
- }
-
- onCreatedChanged: {
- if (created) {
- sun.z = 1; // above the sky but below the ground layer
- window.activeSuns++;
- } else {
- window.activeSuns--;
- }
- }
-}
diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js
deleted file mode 100644
index 59750f3..0000000
--- a/examples/declarative/dynamic/qml/itemCreation.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var itemComponent = null;
-var draggedItem = null;
-var startingMouse;
-var posnInWindow;
-
-function startDrag(mouse)
-{
- posnInWindow = paletteItem.mapToItem(null, 0, 0);
- startingMouse = { x: mouse.x, y: mouse.y }
- loadComponent();
-}
-
-//Creation is split into two functions due to an asynchronous wait while
-//possible external files are loaded.
-
-function loadComponent() {
- if (itemComponent != null) { // component has been previously loaded
- createItem();
- return;
- }
-
- itemComponent = Qt.createComponent(paletteItem.componentFile);
- if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately
- component.statusChanged.connect(createItem);
- else
- createItem();
-}
-
-function createItem() {
- if (itemComponent.status == Component.Ready && draggedItem == null) {
- draggedItem = itemComponent.createObject(window);
- draggedItem.image = paletteItem.image;
- draggedItem.x = posnInWindow.x;
- draggedItem.y = posnInWindow.y;
- draggedItem.z = 3; // make sure created item is above the ground layer
- } else if (itemComponent.status == Component.Error) {
- draggedItem = null;
- console.log("error creating component");
- console.log(component.errorsString());
- }
-}
-
-function continueDrag(mouse)
-{
- if (draggedItem == null)
- return;
-
- draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x;
- draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y;
-}
-
-function endDrag(mouse)
-{
- if (draggedItem == null)
- return;
-
- if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox
- draggedItem.destroy();
- draggedItem = null;
- } else {
- draggedItem.created = true;
- draggedItem = null;
- }
-}
-