summaryrefslogtreecommitdiffstats
path: root/examples/declarative/modelviews/parallax/qml/ParallaxView.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/modelviews/parallax/qml/ParallaxView.qml')
-rw-r--r--examples/declarative/modelviews/parallax/qml/ParallaxView.qml83
1 files changed, 83 insertions, 0 deletions
diff --git a/examples/declarative/modelviews/parallax/qml/ParallaxView.qml b/examples/declarative/modelviews/parallax/qml/ParallaxView.qml
new file mode 100644
index 0000000..e869a21
--- /dev/null
+++ b/examples/declarative/modelviews/parallax/qml/ParallaxView.qml
@@ -0,0 +1,83 @@
+import Qt 4.7
+
+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.contentX / 2
+ width: Math.max(list.contentWidth, parent.width)
+ }
+
+ ListView {
+ id: list
+
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ orientation: Qt.Horizontal
+ boundsBehavior: Flickable.DragOverBounds
+ anchors.fill: parent
+ model: VisualItemModel { id: visualModel }
+
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ snapMode: ListView.SnapOneItem
+ }
+
+ 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: Qt.Horizontal
+
+ delegate: Item {
+ width: 50; height: 50
+ id: delegateRoot
+
+ Image {
+ id: image
+ source: modelData.icon
+ smooth: true
+ scale: 0.8
+ }
+
+ MouseArea {
+ 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
+ }
+}