on xenial help sign in
Surface animation on remove
commit241ac4187eaa4324dd2916a7ccdb2448fff42635 authorNick Dedekind <nicholas.dedekind@gmail.com> dateThu 28 Aug 2014, 18:07 (12 years ago) parent40ab519
7 files changed+89−119
qml/Stages/Animations/DarkenAndFadeInAnimation.qml−48 qml/Stages/Animations/SwipeFromBottomAnimation.qml+3−2 qml/Stages/Animations/SwipeUpAnimation.qml−49 qml/Stages/SurfaceContainer.qml+24−5 tests/qmltests/Stages/RecursingChildSessionControl.qml+46−12 tests/qmltests/Stages/tst_SessionContainer.qml+3−3 tests/qmltests/Stages/tst_SurfaceContainer.qml+13
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 @@
1515 */
1616
1717import QtQuick 2.0
18+import Ubuntu.Components 1.1
1819
1920BaseSessionAnimation {
2021 id: animation
@@ -23,7 +24,7 @@ BaseSessionAnimation {
2324 outAnimations: [
2425 SequentialAnimation {
2526 PropertyAction { target: sessionContainer; property: "clip"; value: true }
26− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
27+ AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
2728 PropertyAction { target: surfaceContainer; property: "visible"; value: !sessionContainer.removing }
2829 PropertyAction { target: sessionContainer; property: "clip"; value: false }
2930 ScriptAction { script: { if (sessionContainer.removing) sessionContainer.session.release(); } }
@@ -41,7 +42,7 @@ BaseSessionAnimation {
4142 inAnimations: [
4243 SequentialAnimation {
4344 PropertyAction { target: sessionContainer; property: "clip"; value: true }
44− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
45+ AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
4546 PropertyAction { target: sessionContainer; property: "clip"; value: false }
4647 }
4748 ]
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 @@
1515*/
1616
1717import QtQuick 2.0
18+import Ubuntu.Components 1.1
1819import "Animations"
1920
2021Item {
2122 id: root
2223 objectName: "surfaceContainer"
2324 property Item surface: null
25+ property bool surfaceRemoved: false
2426
2527 onSurfaceChanged: {
2628 if (surface) {
29+ surfaceRemoved = false;
30+ surface.removed.connect(onRemoved);
2731 surface.parent = root;
2832 surface.z = 1;
2933 }
@@ -33,10 +37,25 @@ Item {
3337 property: "anchors.fill"; value: root
3438 }
3539
36− Connections {
37− target: surface
38− onRemoved: {
39− surface.release();
40− }
40+ function onRemoved() {
41+ surfaceRemoved = true;
4142 }
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+ ]
4261}
tests/qmltests/Stages/RecursingChildSessionControl.qml+46−12
@@ -28,7 +28,12 @@ ColumnLayout {
2828
2929 property var screenshotIds: [ "gallery", "map", "facebook", "camera", "browser", "music", "twitter"]
3030
31+ onSessionChanged: {
32+ if (!session) surfaceCheckbox.checked = false;
33+ }
34+
3135 Column {
36+ id: column
3237 Layout.fillWidth: true
3338 visible: repeater.count
3439 spacing: units.gu(1)
@@ -42,8 +47,8 @@ ColumnLayout {
4247 width: 1
4348 }
4449 anchors {
45− left: parent.left
46− right: parent.right
50+ left: column.left
51+ right: column.right
4752 leftMargin: units.gu(1)
4853 rightMargin: units.gu(1)
4954 }
@@ -73,23 +78,53 @@ ColumnLayout {
7378 }
7479 }
7580
76− Item {
81+ ColumnLayout {
7782 Layout.fillWidth: true
78− Layout.preferredHeight: buttonLayout.height + units.gu(1)
83+ spacing: units.gu(1)
7984
8085 RowLayout {
81− id: buttonLayout
82− anchors {
83− top: parent.top; topMargin: units.gu(0.5)
84− left: parent.left; leftMargin: units.gu(1)
86+ Layout.fillWidth: true
87+
88+ CheckBox {
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+ }
85106 }
86107
108+ Label {
109+ text: "surface"
110+ anchors.verticalCenter: parent.verticalCenter
111+ }
112+ }
113+
114+ RowLayout {
115+ id: buttonLayout
116+
87117 Button {
88118 enabled: root.session
89119 text: removable ? "Remove" : "Release"
90120 onClicked: {
91− if (removable) root.session.removed();
92− else root.session.release();
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 {
126+ root.session.release();
127+ }
93128 }
94129 }
95130
@@ -97,8 +132,7 @@ ColumnLayout {
97132 enabled: root.session !== null
98133 text: "Add Child"
99134 onClicked: {
100− var screenshot = Math.round(Math.random() * screenshotIds.length);
101− console.log(screenshot)
135+ var screenshot = Math.round(Math.random()*100 % (screenshotIds.length-1));
102136 var session = ApplicationTest.addChildSession(root.session, root.screenshotIds[screenshot]);
103137 }
104138 }
tests/qmltests/Stages/tst_SessionContainer.qml+3−3
@@ -80,8 +80,8 @@ Rectangle {
8080
8181 if (checked) {
8282 var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
83− fakeSession.createSurface();
8483 sessionContainerLoader.item.session = fakeSession;
84+ fakeSession.createSurface();
8585 } else {
8686 sessionContainerLoader.item.session.release();
8787 }
@@ -163,7 +163,7 @@ Rectangle {
163163 sessions[i].release();
164164 tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, i);
165165 }
166− tryCompare(sessionSpy, "count", data.count)
166+ tryCompare(sessionSpy, "count", data.count);
167167 }
168168
169169 function test_nestedChildSessions_data() {
@@ -200,7 +200,7 @@ Rectangle {
200200 }
201201
202202 tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, 0);
203− tryCompare(sessionSpy, "count", data.depth)
203+ tryCompare(sessionSpy, "count", data.depth);
204204 }
205205 }
206206}
tests/qmltests/Stages/tst_SurfaceContainer.qml+13
@@ -123,5 +123,18 @@ Rectangle {
123123 compare(fakeSurface.width, surfaceContainerLoader.item.width);
124124 compare(fakeSurface.height, surfaceContainerLoader.item.height);
125125 }
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+ }
126139 }
127140}