on xenial help sign in
Child surface support
commit46981c237dc5dc650245d358ae4863afd5df9a3f authorNick Dedekind <nicholas.dedekind@gmail.com> dateFri 18 Jul 2014, 17:40 (12 years ago) parentbb2aa24
3 files changed+100−6
data/unity8.conf+3 qml/Stages/SpreadDelegate.qml+2−6 qml/Stages/SurfaceContainer.qml+95
data/unity8.conf+3
@@ -44,6 +44,8 @@ pre-start script
4444 rm "$MIR_SERVER_FILE"
4545 fi
4646
47+ initctl set-env --global MIR_SERVER_PROMPT_FILE=1
48+
4749 initctl emit scope-ui-starting
4850 initctl emit --no-wait indicator-services-start
4951end script
@@ -53,4 +55,5 @@ exec ${BINARY:-unity8} $ARGS
5355post-stop script
5456 initctl set-env --global MIR_SOCKET=$UNITY_MIR_SOCKET
5557 initctl unset-env --global UNITY_MIR_SOCKET
58+ initctl unset-env --global MIR_SERVER_PROMPT_FILE
5659end script
qml/Stages/SpreadDelegate.qml+2−6
@@ -35,10 +35,10 @@ Item {
3535 signal clicked()
3636 signal closed()
3737
38− Item {
38+ SurfaceContainer {
3939 id: surfaceContainer
4040 anchors.fill: parent
41− readonly property var surface: model.surface
41+ surface: model.surface
4242 property bool appHasCreatedASurface: false
4343
4444 onSurfaceChanged: {
@@ -47,11 +47,7 @@ Item {
4747 surface.visible = false; // hide until splash screen removed
4848 appHasCreatedASurface = true;
4949 }
50−
51− surface.parent = surfaceContainer;
52− surface.anchors.fill = surfaceContainer;
5350 surfaceContainer.checkFullscreen(surface);
54− surface.z = 1;
5551 }
5652 }
5753
qml/Stages/SurfaceContainer.qmlnew file+95
@@ -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+}