on xenial help sign in
made a bit more declarative
commite4760452f21b541efe47fb1ee51d243ab460c3eb authorNick Dedekind <nick.dedekind@canonical.com> dateMon 1 Sep 2014, 11:43 (12 years ago) parent0a79d51
5 files changed+87−52
qml/Stages/Animations/BaseSessionAnimation.qml+20−18 qml/Stages/Animations/SwipeFromBottomAnimation.qml+8−9 qml/Stages/ApplicationWindow.qml+1−2 qml/Stages/SessionContainer.qml+55−23 qml/Stages/SurfaceContainer.qml+3
qml/Stages/Animations/BaseSessionAnimation.qml+20−18
@@ -40,25 +40,27 @@ Item {
4040 property var container
4141 objectName: "sessionAnimation"
4242
43− // changes applied when state changes to "in"
44− property list<QtObject> outChanges
45− // transition animations when changing state to "in"
46− property list<QtObject> outAnimations
43+ // changes applied when state changes to "from"
44+ property list<QtObject> fromChanges
45+ // transition animations when changing state to "from"
46+ property list<QtObject> fromAnimations
4747
48− // changes applied when state changes to "out"
49− property list<QtObject> inChanges
50− // transition animations when changing state to "out"
51− property list<QtObject> inAnimations
48+ // changes applied when state changes to "to"
49+ property list<QtObject> toChanges
50+ // transition animations when changing state to "to"
51+ property list<QtObject> toAnimations
5252
5353 function start() {
54− // "prep" state forces outChanges without transition animations.
54+ // "prep" state forces toChanges without transition animations.
5555 state = "prep"
56− state = "in";
56+ state = "to";
5757 }
5858 function end() {
59− state = "out";
59+ state = "from";
6060 }
6161
62+ signal completed()
63+
6264 states: [
6365 State {
6466 name: "baseAnimation"
@@ -68,27 +70,27 @@ Item {
6870 State {
6971 name: "prep"
7072 extend: "baseAnimation"
71− changes: outChanges
73+ changes: fromChanges
7274 },
7375 State {
74− name: "out"
76+ name: "from"
7577 extend: "prep"
7678 },
7779 State {
7880 name: "in"
7981 extend: "baseAnimation"
80− changes: inChanges
82+ changes: toChanges
8183 }
8284 ]
8385
8486 transitions: [
8587 Transition {
86− to: "out"
87− animations: outAnimations
88+ to: "from"
89+ animations: fromAnimations
8890 },
8991 Transition {
90− to: "in"
91− animations: inAnimations
92+ to: "to"
93+ animations: toAnimations
9294 }
9395 ]
9496}
qml/Stages/Animations/SwipeFromBottomAnimation.qml+8−9
@@ -20,29 +20,28 @@ import Ubuntu.Components 1.1
2020BaseSessionAnimation {
2121 id: animation
2222
23− outChanges: [ AnchorChanges {
23+ fromChanges: [
24+ AnchorChanges {
2425 target: container;
2526 anchors.top: container.parent.bottom
26− anchors.right: container.parent.right
27− anchors.left: container.parent.left
2827 }
2928 ]
30− outAnimations: [
29+ fromAnimations: [
3130 SequentialAnimation {
3231 PropertyAction { target: container.parent; property: "clip"; value: true }
3332 AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
3433 PropertyAction { target: container.parent; property: "clip"; value: false }
35− ScriptAction { script: { container.session.release(); } }
34+ ScriptAction { script: { animation.completed(); } }
3635 }
3736 ]
3837
39− inChanges: [
38+ toChanges: [
4039 AnchorChanges {
4140 target: container;
4241 anchors.top: container.parent.top
43− anchors.bottom: container.parent.bottom
44− } ]
45− inAnimations: [
42+ }
43+ ]
44+ toAnimations: [
4645 SequentialAnimation {
4746 PropertyAction { target: container.parent; property: "clip"; value: true }
4847 AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
qml/Stages/ApplicationWindow.qml+1−2
@@ -38,7 +38,7 @@ Item {
3838 readonly property int applicationState: root.application ? root.application.state : -1
3939
4040 // Whether the Application had a surface before but lost it.
41− property bool hadSurface: false
41+ property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
4242
4343 property bool needToTakeScreenshot:
4444 sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
@@ -112,7 +112,6 @@ Item {
112112 if (sessionContainer.surface) {
113113 surfaceInitTimer.start();
114114 } else {
115− d.hadSurface = true;
116115 d.surfaceInitialized = false;
117116 }
118117 }
qml/Stages/SessionContainer.qml+55−23
@@ -54,35 +54,66 @@ Item {
5454
5555 // Only way to do recursive qml items.
5656 source: Qt.resolvedUrl("SessionContainer.qml")
57− onLoaded: {
58− item.session = modelData;
59− item.interactive = Qt.binding(function() { return root.interactive; } );
60− if (!modelData.live) {
61− modelData.release();
62− }
63− if (modelData.surface) {
64− item.animateIn(swipeFromBottom);
65− }
57+
58+ Binding {
59+ target: item; when: item
60+ property: "interactive"; value: root.interactive
61+ }
62+
63+ Binding {
64+ target: item; when: item
65+ property: "session"; value: modelData
6666 }
6767
68− Connections {
69− target: modelData
70− onSurfaceChanged: {
71− if (modelData.surface) {
72− item.animateIn();
73− }
74− }
75− onLiveChanged: {
76− if (!modelData.live) {
77− item.animateOut();
78− }
79− }
68+ Binding {
69+ target: item; when: item
70+ property: "width"; value: root.width
71+ }
72+
73+ Binding {
74+ target: item; when: item
75+ property: "height"; value: root.height
8076 }
8177 }
8278 }
8379
84− function animateIn() {
85− var animation = swipeFromBottom.createObject(root, { "container": root, });
80+ states: [
81+ State {
82+ name: "rootSession"
83+ when: root.session && !root.session.parentSession
84+ },
85+
86+ State {
87+ name: "childSession"
88+ when: root.session && root.session.parentSession !== null && root.session.live
89+ && !root.session.surface
90+ },
91+
92+ State {
93+ name: "childSessionReady"
94+ when: root.session && root.session.parentSession !== null && root.session.live
95+ && root.session.surface !== null
96+ },
97+
98+ State {
99+ name: "childSessionZombie"
100+ when: root.session && root.session.parentSession !== null && !root.session.live
101+ }
102+ ]
103+
104+ transitions: [
105+ Transition {
106+ to: "childSessionReady"
107+ ScriptAction { script: { if (!surfaceContainer.hadSurface) { animateIn(swipeFromBottom); } } }
108+ },
109+ Transition {
110+ to: "childSessionZombie"
111+ ScriptAction { script: { animateOut(); } }
112+ }
113+ ]
114+
115+ function animateIn(component) {
116+ var animation = component.createObject(root, { "container": root, });
86117 animation.start();
87118
88119 var tmp = d.animations;
@@ -94,6 +125,7 @@ Item {
94125 if (d.animations.length > 0) {
95126 var tmp = d.animations;
96127 var popped = tmp.pop();
128+ popped.completed.connect(function() { root.session.release(); } );
97129 popped.end();
98130 d.animations = tmp;
99131 }
qml/Stages/SurfaceContainer.qml+3
@@ -22,10 +22,13 @@ Item {
2222 id: root
2323 objectName: "surfaceContainer"
2424 property Item surface: null
25+ property bool hadSurface: false
2526
2627 onSurfaceChanged: {
2728 if (surface) {
2829 surface.parent = root;
30+ } else {
31+ hadSurface = true;
2932 }
3033 }
3134 Binding {