Lomiri
Loading...
Searching...
No Matches
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
17import QtQuick 2.12
18import Lomiri.Components 1.3
19
20StateGroup {
21 id: root
22 property var container
23 property var surfaceItem
24 property var hadSurface
25
26 states: [
27 State {
28 name: "blank"
29 when: !root.surfaceItem.surface && !root.hadSurface
30 },
31 State {
32 name: "ready"
33 when: root.surfaceItem.surface && root.surfaceItem.live
34 },
35 State {
36 name: "zombie"
37 when: root.hadSurface && !root.surfaceItem.live
38 }
39 ]
40 transitions: [
41 Transition {
42 from: "*"; to: "zombie"
43 // Slide downwards until it's out of view, through the bottom of the window
44 SequentialAnimation {
45 // clip so we don't go out of parent's bounds during spread
46 PropertyAction { target: root.container.parent; property: "clip"; value: true }
47 LomiriNumberAnimation { target: root.surfaceItem; property: "anchors.topMargin"; to: root.container.height
48 duration: LomiriAnimation.BriskDuration }
49 PropertyAction { target: root.surfaceItem; property: "visible"; value: false }
50 PropertyAction { target: container.parent; property: "clip"; value: false }
51 ScriptAction { script: {
52 // QtMir.Application can't destroy a zombie MirSurface if it's still being
53 // referenced by a MirSurfaceItem.
54 root.surfaceItem.surface = null;
55 } }
56 }
57 },
58 Transition {
59 from: "*"; to: "ready"
60 // Slide upwards into view, from the bottom of the window
61 SequentialAnimation {
62 // clip so we don't go out of parent's bounds during spread
63 PropertyAction { target: root.container.parent; property: "clip"; value: true }
64 ScriptAction { script: {
65 root.surfaceItem.visible = true;
66 } }
67 LomiriNumberAnimation {
68 target: root.surfaceItem; property: "anchors.topMargin"; from: root.container.height; to: 0
69 duration: LomiriAnimation.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}