summaryrefslogtreecommitdiffstats
path: root/examples/declarative/parallax/qml/ParallaxView.qml
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-10-30 05:13:19 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-10-30 05:13:19 (GMT)
commitabf60e8e075ecbf2c14e84d40fecff973dd124c7 (patch)
treeaa877319fca3bd223078d0dc0f3658efef1807d6 /examples/declarative/parallax/qml/ParallaxView.qml
parentb0c858dee261dec08dacd2c74671404f3229cb31 (diff)
downloadQt-abf60e8e075ecbf2c14e84d40fecff973dd124c7.zip
Qt-abf60e8e075ecbf2c14e84d40fecff973dd124c7.tar.gz
Qt-abf60e8e075ecbf2c14e84d40fecff973dd124c7.tar.bz2
cleanup
Diffstat (limited to 'examples/declarative/parallax/qml/ParallaxView.qml')
-rw-r--r--examples/declarative/parallax/qml/ParallaxView.qml89
1 files changed, 89 insertions, 0 deletions
diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml
new file mode 100644
index 0000000..ac84b47
--- /dev/null
+++ b/examples/declarative/parallax/qml/ParallaxView.qml
@@ -0,0 +1,89 @@
+import Qt 4.6
+
+Item {
+ id: root
+
+ property alias background: background.source
+ default property alias content: visualModel.children
+ property int currentIndex: 0
+
+ Image {
+ id: background
+ fillMode: Image.TileHorizontally
+ x: -list.viewportX / 2
+ width: Math.max(list.viewportWidth, parent.width)
+ }
+
+ ListView {
+ id: list
+
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ orientation: "Horizontal"
+ overShoot: false
+ anchors.fill: parent
+ model: VisualItemModel { id: visualModel }
+
+ highlight: Rectangle { height: 1; width: 1 }
+ highlightMoveSpeed: 2000
+ preferredHighlightBegin: 0
+ preferredHighlightEnd: 0
+ highlightRangeMode: "StrictlyEnforceRange"
+
+ flickDeceleration: 1000
+ }
+
+ ListView {
+ id: selector
+
+ Rectangle {
+ color: "#60FFFFFF"
+ x: -10; y: -10; radius: 10; z: -1
+ width: parent.width + 20; height: parent.height + 20
+ }
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ height: 50
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: Math.min(count * 50, parent.width - 20)
+ interactive: width == parent.width - 20
+ orientation: "Horizontal"
+
+ delegate: Item {
+ width: 50; height: 50
+ id: delegateRoot
+
+ Image {
+ id: image
+ source: modelData.icon
+ smooth: true
+ scale: 0.8
+ transformOrigin: "Center"
+ }
+
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { root.currentIndex = index }
+ }
+
+ states: State {
+ name: "Selected"
+ when: delegateRoot.ListView.isCurrentItem == true
+ PropertyChanges {
+ target: image
+ scale: 1
+ y: -5
+ }
+ }
+ transitions: Transition {
+ NumberAnimation {
+ properties: "scale,y"
+ }
+ }
+ }
+ model: visualModel.children
+ }
+}