summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-26 09:14:31 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-26 09:14:31 (GMT)
commit65c44a439ab1e21dbcf59e01cefabb35c9c21d72 (patch)
treeab461fa2f8fe151aa88dceea52be3cd267380c2b
parentdb3b330d85b7d28dbdc9dd3aabb7f345c60537b8 (diff)
downloadQt-65c44a439ab1e21dbcf59e01cefabb35c9c21d72.zip
Qt-65c44a439ab1e21dbcf59e01cefabb35c9c21d72.tar.gz
Qt-65c44a439ab1e21dbcf59e01cefabb35c9c21d72.tar.bz2
parallax example
-rw-r--r--examples/declarative/parallax/ParallaxView.qml41
-rw-r--r--examples/declarative/parallax/Smiley.qml47
-rw-r--r--examples/declarative/parallax/parallax.qml46
-rw-r--r--examples/declarative/parallax/pics/background.jpgbin0 -> 209814 bytes
-rw-r--r--examples/declarative/parallax/pics/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/parallax/pics/shadow.pngbin0 -> 425 bytes
6 files changed, 134 insertions, 0 deletions
diff --git a/examples/declarative/parallax/ParallaxView.qml b/examples/declarative/parallax/ParallaxView.qml
new file mode 100644
index 0000000..4ddab00
--- /dev/null
+++ b/examples/declarative/parallax/ParallaxView.qml
@@ -0,0 +1,41 @@
+import Qt 4.6
+
+Item {
+ property alias background: background.source
+
+ Image {
+ id: background
+ fillMode: Image.TileHorizontally
+ x: -list.viewportX / 2
+ width: Math.max(list.viewportWidth, parent.width)
+ }
+
+ /*
+ default property alias content: visualModel.children
+ ListView {
+ id: list
+ orientation: "Horizontal"
+ overShoot: false
+ anchors.fill: parent
+ model: VisualItemModel { id: visualModel }
+
+ highlight: Item { height: 1; width: 1}
+ preferredHighlightBegin: 0
+ preferredHighlightEnd: 1
+ strictlyEnforceHighlightRange: true
+ }
+ */
+
+ default property alias content: flickArea.data
+ Flickable {
+ id: list
+ anchors.fill: parent
+ overShoot: false
+ viewportWidth: flickArea.width
+
+ Item {
+ id: flickArea
+ width: childrenRect.width
+ }
+ }
+}
diff --git a/examples/declarative/parallax/Smiley.qml b/examples/declarative/parallax/Smiley.qml
new file mode 100644
index 0000000..db87412
--- /dev/null
+++ b/examples/declarative/parallax/Smiley.qml
@@ -0,0 +1,47 @@
+import Qt 4.6
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ // The shadow for the smiley face
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "pics/shadow.png"; y: smiley.minHeight + 58
+ transformOrigin: Item.Center
+
+ // The scale property depends on the y position of the smiley face.
+ scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ }
+
+ Image {
+ id: smiley
+ property int maxHeight: window.height / 3
+ property int minHeight: 2 * window.height / 3
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "pics/face-smile.png"; y: minHeight
+
+ // Animate the y property. Setting repeat to true makes the
+ // animation repeat indefinitely, otherwise it would only run once.
+ y: SequentialAnimation {
+ running: true; repeat: true
+
+ // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function
+ NumberAnimation {
+ from: smiley.minHeight; to: smiley.maxHeight
+ easing: "easeOutExpo"; duration: 300
+ }
+
+ // Then move back to minHeight in 1 second, using the easeOutBounce easing function
+ NumberAnimation {
+ from: smiley.maxHeight; to: smiley.minHeight
+ easing: "easeOutBounce"; duration: 1000
+ }
+
+ // Then pause for 500ms
+ PauseAnimation { duration: 500 }
+ }
+ }
+}
+
diff --git a/examples/declarative/parallax/parallax.qml b/examples/declarative/parallax/parallax.qml
new file mode 100644
index 0000000..9adcfd7
--- /dev/null
+++ b/examples/declarative/parallax/parallax.qml
@@ -0,0 +1,46 @@
+import Qt 4.6
+import "../clock"
+
+Rectangle {
+ width: 320
+ height: 480
+
+ ParallaxView {
+ anchors.fill: parent
+ background: "pics/background.jpg"
+
+ Row {
+ Item {
+ width: 320
+ height: 480
+
+ Clock {
+ anchors.centerIn: parent
+ }
+ }
+
+ Item {
+ width: 320
+ height: 480
+
+ Smiley {}
+ }
+
+ Item {
+ width: 320
+ height: 480
+
+ Loader {
+ anchors.centerIn: parent
+ width: 300; height: 460
+ clip: true
+ resizeMode: Loader.SizeItemToLoader
+
+ source: "../../../demos/declarative/samegame/samegame.qml"
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/examples/declarative/parallax/pics/background.jpg b/examples/declarative/parallax/pics/background.jpg
new file mode 100644
index 0000000..61cca2f
--- /dev/null
+++ b/examples/declarative/parallax/pics/background.jpg
Binary files differ
diff --git a/examples/declarative/parallax/pics/face-smile.png b/examples/declarative/parallax/pics/face-smile.png
new file mode 100644
index 0000000..3d66d72
--- /dev/null
+++ b/examples/declarative/parallax/pics/face-smile.png
Binary files differ
diff --git a/examples/declarative/parallax/pics/shadow.png b/examples/declarative/parallax/pics/shadow.png
new file mode 100644
index 0000000..8270565
--- /dev/null
+++ b/examples/declarative/parallax/pics/shadow.png
Binary files differ