Unity 8
PromptSurfaceAnimations.qml
1 /*
2  * Copyright 2016 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.4
18 import Ubuntu.Components 1.3
19 
20 StateGroup {
21  id: root
22  property var container
23  property var surfaceItem
24 
25  states: [
26  State {
27  name: "blank"
28  when: !root.surfaceItem.surface
29  },
30  State {
31  name: "ready"
32  when: root.surfaceItem.surface && root.surfaceItem.live
33  },
34  State {
35  name: "zombie"
36  when: root.surfaceItem.surface && !root.surfaceItem.live
37  }
38  ]
39  transitions: [
40  Transition {
41  from: "*"; to: "zombie"
42  // Slide downwards until it's out of view, through the bottom of the window
43  SequentialAnimation {
44  // clip so we don't go out of parent's bounds during spread
45  PropertyAction { target: root.container.parent; property: "clip"; value: true }
46  UbuntuNumberAnimation { target: root.surfaceItem; property: "y"; to: root.container.height
47  duration: UbuntuAnimation.BriskDuration }
48  PropertyAction { target: root.surfaceItem; property: "visible"; value: false }
49  PropertyAction { target: container.parent; property: "clip"; value: false }
50  ScriptAction { script: {
51  // Unity.Application can't destroy a zombie MirSurface if it's still being
52  // referenced by a MirSurfaceItem.
53  root.surfaceItem.surface = null;
54  } }
55  }
56  },
57  Transition {
58  from: "*"; to: "ready"
59  // Slide upwards into view, from the bottom of the window
60  SequentialAnimation {
61  // clip so we don't go out of parent's bounds during spread
62  PropertyAction { target: root.container.parent; property: "clip"; value: true }
63  ScriptAction { script: {
64  root.surfaceItem.y = root.container.height;
65  root.surfaceItem.visible = true;
66  } }
67  UbuntuNumberAnimation {
68  target: root.surfaceItem; property: "y"; to: 0
69  duration: UbuntuAnimation.BriskDuration
70  }
71  PropertyAction { target: container.parent; property: "clip"; value: false }
72  }
73  },
74  Transition {
75  from: "*"; to: "blank"
76  ScriptAction { script: {
77  root.surfaceItem.visible = false;
78  } }
79  }
80  ]
81 }