@@ -0,0 +1,95 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+*/
16+
17+import QtQuick 2.0
18+
19+Item {
20+ id: container
21+ property Item surface: null
22+ property string animation
23+ property bool show: false
24+
25+ onSurfaceChanged: {
26+ if (surface) {
27+ surface.parent = container;
28+ surface.anchors.fill = container;
29+ surface.z = 1;
30+ }
31+ }
32+
33+ Repeater {
34+ model: container.surface ? container.surface.childSurfaces : 0
35+
36+ delegate: Loader {
37+ z: 2
38+ anchors.fill: surface
39+
40+ // Only way to do recursive qml items.
41+ source: Qt.resolvedUrl("SurfaceContainer.qml")
42+ onLoaded: {
43+ item.parent = container.surface;
44+ item.surface = modelData;
45+ item.animation = "overlaySwipeBottom"
46+ item.show = true;
47+ }
48+ }
49+ }
50+
51+ states: [
52+ State {
53+ name: "baseAnimation"
54+ PropertyChanges { target: surface; anchors.fill: undefined }
55+ },
56+
57+ State {
58+ name: "overlaySwipeBottom-out"
59+ extend: "baseAnimation"
60+ when: surface && animation === "overlaySwipeBottom" && !show
61+ AnchorChanges { target: surface; anchors.top: surface.parent.bottom }
62+ },
63+ State {
64+ name: "overlaySwipeBottom-in"
65+ extend: "baseAnimation"
66+ when: surface && animation === "overlaySwipeBottom" && show
67+ AnchorChanges { target: surface; anchors.top: surface.parent.top }
68+ }
69+
70+ // TODO: more animations!
71+ // Surface needs to stick around so that we can dimiss them with animation.
72+ ]
73+
74+ transitions: [
75+ Transition {
76+ from: "overlaySwipeBottom-out"
77+ to: "overlaySwipeBottom-in"
78+ SequentialAnimation {
79+ PropertyAction { target: surface.parent; property: "clip"; value: true}
80+ AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
81+ PropertyAction { target: surface.parent; property: "clip"; value: false}
82+ }
83+ },
84+ Transition {
85+ from: "overlaySwipeBottom-in"
86+ to: "overlaySwipeBottom-out"
87+ SequentialAnimation {
88+ PropertyAction { target: surface.parent; property: "clip"; value: true}
89+ AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
90+ PropertyAction { target: surface; property: "visible"; value: false}
91+ PropertyAction { target: surface.parent; property: "clip"; value: false}
92+ }
93+ }
94+ ]
95+}