on xenial help sign in
Surface animation on remove
241ac41Nick Dedekind
qml/Stages/Animations/DarkenAndFadeInAnimation.qmldeleted−48
@@ -1,48 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 1.1
19−
20−BaseSessionAnimation {
21− id: animation
22−
23− property Rectangle darkenItem: Rectangle {
24− parent: animation.session.parent
25− anchors.fill: parent
26− color: Qt.rgba(0,0,0,0.0)
27− }
28−
29− outChanges: [ PropertyChanges { target: animation.session; opacity: 0.0 } ]
30− outAnimations: [
31− SequentialAnimation {
32− UbuntuNumberAnimation { target: animation.session; property: "opacity"; duration: UbuntuAnimation.FastDuration }
33− ColorAnimation { target: darkenItem; duration: UbuntuAnimation.FastDuration }
34− ScriptAction { script: { if (animation.parent.removing) animation.surface.release(); } }
35− }
36− ]
37−
38− inChanges: [
39− PropertyChanges { target: darkenItem; color: Qt.rgba(0,0,0,0.7) },
40− PropertyChanges { target: animation.session; opacity: 1.0 }
41− ]
42− inAnimations: [
43− SequentialAnimation {
44− ColorAnimation { target: darkenItem; duration: UbuntuAnimation.FastDuration }
45− UbuntuNumberAnimation { target: animation.session; property: "opacity"; duration: UbuntuAnimation.FastDuration }
46− }
47− ]
48−}
qml/Stages/Animations/SwipeFromBottomAnimation.qml+3−2
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import Ubuntu.Components 1.1
18
19
19BaseSessionAnimation {
20BaseSessionAnimation {
20 id: animation
21 id: animation
@@ -23,7 +24,7 @@ BaseSessionAnimation {
23 outAnimations: [
24 outAnimations: [
24 SequentialAnimation {
25 SequentialAnimation {
25 PropertyAction { target: sessionContainer; property: "clip"; value: true }
26 PropertyAction { target: sessionContainer; property: "clip"; value: true }
26− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
27+ AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
27 PropertyAction { target: surfaceContainer; property: "visible"; value: !sessionContainer.removing }
28 PropertyAction { target: surfaceContainer; property: "visible"; value: !sessionContainer.removing }
28 PropertyAction { target: sessionContainer; property: "clip"; value: false }
29 PropertyAction { target: sessionContainer; property: "clip"; value: false }
29 ScriptAction { script: { if (sessionContainer.removing) sessionContainer.session.release(); } }
30 ScriptAction { script: { if (sessionContainer.removing) sessionContainer.session.release(); } }
@@ -41,7 +42,7 @@ BaseSessionAnimation {
41 inAnimations: [
42 inAnimations: [
42 SequentialAnimation {
43 SequentialAnimation {
43 PropertyAction { target: sessionContainer; property: "clip"; value: true }
44 PropertyAction { target: sessionContainer; property: "clip"; value: true }
44− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
45+ AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
45 PropertyAction { target: sessionContainer; property: "clip"; value: false }
46 PropertyAction { target: sessionContainer; property: "clip"; value: false }
46 }
47 }
47 ]
48 ]
qml/Stages/Animations/SwipeUpAnimation.qmldeleted−49
@@ -1,49 +0,0 @@
1−/*
2− * Copyright (C) 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 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 General Public License for more details.
12− *
13− * You should have received a copy of the GNU 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−BaseSessionAnimation {
20− id: animation
21−
22− outAnimations: [
23− SequentialAnimation {
24− PropertyAction { target: animation.parent; property: "clip"; value: true }
25− PropertyAction { target: animation.session; property: "visible"; value: true }
26− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
27− PropertyAction { target: animation.parent; property: "clip"; value: false }
28− ScriptAction { script: { if (animation.parent.removing) animation.session.release(); } }
29− }
30− ]
31−
32− inChanges: [
33− AnchorChanges {
34− target: animation.session;
35− anchors.top: undefined
36− anchors.right: undefined
37− anchors.bottom: animation.parent.top
38− anchors.left: undefined
39− }
40− ]
41− inAnimations: [
42− SequentialAnimation {
43− PropertyAction { target: animation.parent; property: "clip"; value: true }
44− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
45− PropertyAction { target: animation.session; property: "visible"; value: false}
46− PropertyAction { target: animation.parent; property: "clip"; value: false }
47− }
48− ]
49−}
qml/Stages/SurfaceContainer.qml+24−5
@@ -15,15 +15,19 @@
15*/
15*/
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import Ubuntu.Components 1.1
18import "Animations"
19import "Animations"
19
20
20Item {
21Item {
21 id: root
22 id: root
22 objectName: "surfaceContainer"
23 objectName: "surfaceContainer"
23 property Item surface: null
24 property Item surface: null
25+ property bool surfaceRemoved: false
24
26
25 onSurfaceChanged: {
27 onSurfaceChanged: {
26 if (surface) {
28 if (surface) {
29+ surfaceRemoved = false;
30+ surface.removed.connect(onRemoved);
27 surface.parent = root;
31 surface.parent = root;
28 surface.z = 1;
32 surface.z = 1;
29 }
33 }
@@ -33,10 +37,25 @@ Item {
33 property: "anchors.fill"; value: root
37 property: "anchors.fill"; value: root
34 }
38 }
35
39
36− Connections {
37− target: surface
38− onRemoved: {
40+ function onRemoved() {
39− surface.release();
41+ surfaceRemoved = true;
40− }
41 }
42 }
43+
44+ states: [
45+ State {
46+ name: "removed"
47+ when: surfaceRemoved
48+ }
49+ ]
50+ transitions: [
51+ Transition {
52+ from: ""; to: "removed"
53+ SequentialAnimation {
54+ UbuntuNumberAnimation { target: surface; property: "opacity"; to: 0.0
55+ duration: UbuntuAnimation.BriskDuration }
56+ PropertyAction { target: surface; property: "visible"; value: false }
57+ ScriptAction { script: { if (root.surface) { root.surface.release(); } } }
58+ }
59+ }
60+ ]
42}
61}
tests/qmltests/Stages/RecursingChildSessionControl.qml+46−12
@@ -28,7 +28,12 @@ ColumnLayout {
28
28
29 property var screenshotIds: [ "gallery", "map", "facebook", "camera", "browser", "music", "twitter"]
29 property var screenshotIds: [ "gallery", "map", "facebook", "camera", "browser", "music", "twitter"]
30
30
31+ onSessionChanged: {
32+ if (!session) surfaceCheckbox.checked = false;
33+ }
34+
31 Column {
35 Column {
36+ id: column
32 Layout.fillWidth: true
37 Layout.fillWidth: true
33 visible: repeater.count
38 visible: repeater.count
34 spacing: units.gu(1)
39 spacing: units.gu(1)
@@ -42,8 +47,8 @@ ColumnLayout {
42 width: 1
47 width: 1
43 }
48 }
44 anchors {
49 anchors {
45− left: parent.left
50+ left: column.left
46− right: parent.right
51+ right: column.right
47 leftMargin: units.gu(1)
52 leftMargin: units.gu(1)
48 rightMargin: units.gu(1)
53 rightMargin: units.gu(1)
49 }
54 }
@@ -73,23 +78,53 @@ ColumnLayout {
73 }
78 }
74 }
79 }
75
80
76− Item {
81+ ColumnLayout {
77 Layout.fillWidth: true
82 Layout.fillWidth: true
78− Layout.preferredHeight: buttonLayout.height + units.gu(1)
83+ spacing: units.gu(1)
79
84
80 RowLayout {
85 RowLayout {
81− id: buttonLayout
86+ Layout.fillWidth: true
82− anchors {
87+
83− top: parent.top; topMargin: units.gu(0.5)
88+ CheckBox {
84− left: parent.left; leftMargin: units.gu(1)
89+ id: surfaceCheckbox;
90+ checked: false;
91+ enabled: root.session
92+ onClicked: {
93+ if (checked) {
94+ root.session.createSurface();
95+ } else if (root.session.surface) {
96+ root.session.surface.removed();
97+ }
98+ }
99+
100+ Connections {
101+ target: root.session ? root.session : null
102+ onSurfaceChanged: {
103+ surfaceCheckbox.checked = root.session.surface !== null
104+ }
105+ }
85 }
106 }
86
107
108+ Label {
109+ text: "surface"
110+ anchors.verticalCenter: parent.verticalCenter
111+ }
112+ }
113+
114+ RowLayout {
115+ id: buttonLayout
116+
87 Button {
117 Button {
88 enabled: root.session
118 enabled: root.session
89 text: removable ? "Remove" : "Release"
119 text: removable ? "Remove" : "Release"
90 onClicked: {
120 onClicked: {
91− if (removable) root.session.removed();
121+ if (removable) {
122+ // release the surface first. simulates mir app closing
123+ if (root.session.surface) root.session.surface.removed();
124+ root.session.removed();
125+ } else {
92− else root.session.release();
126+ root.session.release();
127+ }
93 }
128 }
94 }
129 }
95
130
@@ -97,8 +132,7 @@ ColumnLayout {
97 enabled: root.session !== null
132 enabled: root.session !== null
98 text: "Add Child"
133 text: "Add Child"
99 onClicked: {
134 onClicked: {
100− var screenshot = Math.round(Math.random() * screenshotIds.length);
135+ var screenshot = Math.round(Math.random()*100 % (screenshotIds.length-1));
101− console.log(screenshot)
102 var session = ApplicationTest.addChildSession(root.session, root.screenshotIds[screenshot]);
136 var session = ApplicationTest.addChildSession(root.session, root.screenshotIds[screenshot]);
103 }
137 }
104 }
138 }
tests/qmltests/Stages/tst_SessionContainer.qml+3−3
@@ -80,8 +80,8 @@ Rectangle {
80
80
81 if (checked) {
81 if (checked) {
82 var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
82 var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
83− fakeSession.createSurface();
84 sessionContainerLoader.item.session = fakeSession;
83 sessionContainerLoader.item.session = fakeSession;
84+ fakeSession.createSurface();
85 } else {
85 } else {
86 sessionContainerLoader.item.session.release();
86 sessionContainerLoader.item.session.release();
87 }
87 }
@@ -163,7 +163,7 @@ Rectangle {
163 sessions[i].release();
163 sessions[i].release();
164 tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, i);
164 tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, i);
165 }
165 }
166− tryCompare(sessionSpy, "count", data.count)
166+ tryCompare(sessionSpy, "count", data.count);
167 }
167 }
168
168
169 function test_nestedChildSessions_data() {
169 function test_nestedChildSessions_data() {
@@ -200,7 +200,7 @@ Rectangle {
200 }
200 }
201
201
202 tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, 0);
202 tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, 0);
203− tryCompare(sessionSpy, "count", data.depth)
203+ tryCompare(sessionSpy, "count", data.depth);
204 }
204 }
205 }
205 }
206}
206}
tests/qmltests/Stages/tst_SurfaceContainer.qml+13
@@ -123,5 +123,18 @@ Rectangle {
123 compare(fakeSurface.width, surfaceContainerLoader.item.width);
123 compare(fakeSurface.width, surfaceContainerLoader.item.width);
124 compare(fakeSurface.height, surfaceContainerLoader.item.height);
124 compare(fakeSurface.height, surfaceContainerLoader.item.height);
125 }
125 }
126+
127+ function test_delayRelease() {
128+ surfaceCheckbox.checked = true;
129+ var surfaceContainer = surfaceContainerLoader.item;
130+
131+ verify(surfaceContainer.surface !== null);
132+
133+ surfaceContainer.surface.removed();
134+ // should not be immediately removed
135+ verify(surfaceContainer.surface !== null);
136+ // but should eventually
137+ tryCompare(surfaceContainer, "surface", null);
138+ }
126 }
139 }
127}
140}