on xenial help sign in
made a bit more declarative
e476045Nick Dedekind
qml/Stages/Animations/BaseSessionAnimation.qml+20−18
@@ -40,25 +40,27 @@ Item {
40 property var container
40 property var container
41 objectName: "sessionAnimation"
41 objectName: "sessionAnimation"
42
42
43− // changes applied when state changes to "in"
43+ // changes applied when state changes to "from"
44− property list<QtObject> outChanges
44+ property list<QtObject> fromChanges
45− // transition animations when changing state to "in"
45+ // transition animations when changing state to "from"
46− property list<QtObject> outAnimations
46+ property list<QtObject> fromAnimations
47
47
48− // changes applied when state changes to "out"
48+ // changes applied when state changes to "to"
49− property list<QtObject> inChanges
49+ property list<QtObject> toChanges
50− // transition animations when changing state to "out"
50+ // transition animations when changing state to "to"
51− property list<QtObject> inAnimations
51+ property list<QtObject> toAnimations
52
52
53 function start() {
53 function start() {
54− // "prep" state forces outChanges without transition animations.
54+ // "prep" state forces toChanges without transition animations.
55 state = "prep"
55 state = "prep"
56− state = "in";
56+ state = "to";
57 }
57 }
58 function end() {
58 function end() {
59− state = "out";
59+ state = "from";
60 }
60 }
61
61
62+ signal completed()
63+
62 states: [
64 states: [
63 State {
65 State {
64 name: "baseAnimation"
66 name: "baseAnimation"
@@ -68,27 +70,27 @@ Item {
68 State {
70 State {
69 name: "prep"
71 name: "prep"
70 extend: "baseAnimation"
72 extend: "baseAnimation"
71− changes: outChanges
73+ changes: fromChanges
72 },
74 },
73 State {
75 State {
74− name: "out"
76+ name: "from"
75 extend: "prep"
77 extend: "prep"
76 },
78 },
77 State {
79 State {
78 name: "in"
80 name: "in"
79 extend: "baseAnimation"
81 extend: "baseAnimation"
80− changes: inChanges
82+ changes: toChanges
81 }
83 }
82 ]
84 ]
83
85
84 transitions: [
86 transitions: [
85 Transition {
87 Transition {
86− to: "out"
88+ to: "from"
87− animations: outAnimations
89+ animations: fromAnimations
88 },
90 },
89 Transition {
91 Transition {
90− to: "in"
92+ to: "to"
91− animations: inAnimations
93+ animations: toAnimations
92 }
94 }
93 ]
95 ]
94}
96}
qml/Stages/Animations/SwipeFromBottomAnimation.qml+8−9
@@ -20,29 +20,28 @@ import Ubuntu.Components 1.1
20BaseSessionAnimation {
20BaseSessionAnimation {
21 id: animation
21 id: animation
22
22
23+ fromChanges: [
23− outChanges: [ AnchorChanges {
24+ AnchorChanges {
24 target: container;
25 target: container;
25 anchors.top: container.parent.bottom
26 anchors.top: container.parent.bottom
26− anchors.right: container.parent.right
27− anchors.left: container.parent.left
28 }
27 }
29 ]
28 ]
30− outAnimations: [
29+ fromAnimations: [
31 SequentialAnimation {
30 SequentialAnimation {
32 PropertyAction { target: container.parent; property: "clip"; value: true }
31 PropertyAction { target: container.parent; property: "clip"; value: true }
33 AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
32 AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
34 PropertyAction { target: container.parent; property: "clip"; value: false }
33 PropertyAction { target: container.parent; property: "clip"; value: false }
35− ScriptAction { script: { container.session.release(); } }
34+ ScriptAction { script: { animation.completed(); } }
36 }
35 }
37 ]
36 ]
38
37
39− inChanges: [
38+ toChanges: [
40 AnchorChanges {
39 AnchorChanges {
41 target: container;
40 target: container;
42 anchors.top: container.parent.top
41 anchors.top: container.parent.top
43− anchors.bottom: container.parent.bottom
44− } ]
42+ }
45− inAnimations: [
43+ ]
44+ toAnimations: [
46 SequentialAnimation {
45 SequentialAnimation {
47 PropertyAction { target: container.parent; property: "clip"; value: true }
46 PropertyAction { target: container.parent; property: "clip"; value: true }
48 AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
47 AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
qml/Stages/ApplicationWindow.qml+1−2
@@ -38,7 +38,7 @@ Item {
38 readonly property int applicationState: root.application ? root.application.state : -1
38 readonly property int applicationState: root.application ? root.application.state : -1
39
39
40 // Whether the Application had a surface before but lost it.
40 // Whether the Application had a surface before but lost it.
41− property bool hadSurface: false
41+ property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
42
42
43 property bool needToTakeScreenshot:
43 property bool needToTakeScreenshot:
44 sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
44 sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
@@ -112,7 +112,6 @@ Item {
112 if (sessionContainer.surface) {
112 if (sessionContainer.surface) {
113 surfaceInitTimer.start();
113 surfaceInitTimer.start();
114 } else {
114 } else {
115− d.hadSurface = true;
116 d.surfaceInitialized = false;
115 d.surfaceInitialized = false;
117 }
116 }
118 }
117 }
qml/Stages/SessionContainer.qml+55−23
@@ -54,35 +54,66 @@ Item {
54
54
55 // Only way to do recursive qml items.
55 // Only way to do recursive qml items.
56 source: Qt.resolvedUrl("SessionContainer.qml")
56 source: Qt.resolvedUrl("SessionContainer.qml")
57− onLoaded: {
57+
58− item.session = modelData;
58+ Binding {
59− item.interactive = Qt.binding(function() { return root.interactive; } );
59+ target: item; when: item
60− if (!modelData.live) {
60+ property: "interactive"; value: root.interactive
61− modelData.release();
61+ }
62− }
62+
63− if (modelData.surface) {
63+ Binding {
64− item.animateIn(swipeFromBottom);
64+ target: item; when: item
65− }
65+ property: "session"; value: modelData
66 }
66 }
67
67
68− Connections {
68+ Binding {
69− target: modelData
69+ target: item; when: item
70− onSurfaceChanged: {
70+ property: "width"; value: root.width
71− if (modelData.surface) {
72− item.animateIn();
73− }
71+ }
74− }
72+
75− onLiveChanged: {
73+ Binding {
76− if (!modelData.live) {
74+ target: item; when: item
77− item.animateOut();
75+ property: "height"; value: root.height
78− }
79− }
80 }
76 }
81 }
77 }
82 }
78 }
83
79
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+
84− function animateIn() {
115+ function animateIn(component) {
85− var animation = swipeFromBottom.createObject(root, { "container": root, });
116+ var animation = component.createObject(root, { "container": root, });
86 animation.start();
117 animation.start();
87
118
88 var tmp = d.animations;
119 var tmp = d.animations;
@@ -94,6 +125,7 @@ Item {
94 if (d.animations.length > 0) {
125 if (d.animations.length > 0) {
95 var tmp = d.animations;
126 var tmp = d.animations;
96 var popped = tmp.pop();
127 var popped = tmp.pop();
128+ popped.completed.connect(function() { root.session.release(); } );
97 popped.end();
129 popped.end();
98 d.animations = tmp;
130 d.animations = tmp;
99 }
131 }
qml/Stages/SurfaceContainer.qml+3
@@ -22,10 +22,13 @@ Item {
22 id: root
22 id: root
23 objectName: "surfaceContainer"
23 objectName: "surfaceContainer"
24 property Item surface: null
24 property Item surface: null
25+ property bool hadSurface: false
25
26
26 onSurfaceChanged: {
27 onSurfaceChanged: {
27 if (surface) {
28 if (surface) {
28 surface.parent = root;
29 surface.parent = root;
30+ } else {
31+ hadSurface = true;
29 }
32 }
30 }
33 }
31 Binding {
34 Binding {