Better layouting behavior when window is removed.
[profile/ivi/qtwayland.git] / examples / qml-compositor / qml / QmlCompositor / Window.qml
1 /****************************************************************************
2 **
3 ** This file is part of QtCompositor**
4 **
5 ** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
6 ** All rights reserved.
7 **
8 ** Contact:  Nokia Corporation qt-info@nokia.com
9 **
10 ** You may use this file under the terms of the BSD license as follows:
11 **
12 ** Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
14 ** met:
15 **
16 ** Redistributions of source code must retain the above copyright
17 ** notice, this list of conditions and the following disclaimer.
18 **
19 ** Redistributions in binary form must reproduce the above copyright
20 ** notice, this list of conditions and the following disclaimer in the
21 ** documentation and/or other materials provided with the distribution.
22 **
23 ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the
24 ** names of its contributors may be used to endorse or promote products
25 ** derived from this software without specific prior written permission.
26 **
27 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 **
39 ****************************************************************************/
40
41 import QtQuick 2.0
42
43 Rectangle {
44     id: container
45
46     x: -400;
47     y: 0;
48     opacity: 0
49
50     property variant child: null;
51     property bool animationsEnabled: false;
52     property int index;
53
54     Behavior on x {
55         enabled: container.animationsEnabled;
56         NumberAnimation { easing.type: Easing.InCubic; duration: 200; }
57     }
58
59     Behavior on y {
60         enabled: container.animationsEnabled;
61         NumberAnimation { easing.type: Easing.InQuad; duration: 200; }
62     }
63
64     Behavior on scale {
65         enabled: container.animationsEnabled;
66         NumberAnimation { easing.type: Easing.InQuad; duration: 200; }
67     }
68
69     Behavior on opacity {
70         enabled: true;
71         NumberAnimation { easing.type: Easing.Linear; duration: 250; }
72     }
73
74     MouseArea {
75         anchors.fill: { if (child == null) parent; else child; }
76         z: 1
77         enabled: { if (child == null) true; else !child.focus; }
78         onClicked: {
79             child.takeFocus();
80         }
81     }
82
83     ShaderEffect {
84         source: child
85         anchors.fill: child
86         opacity: { if (child && child.focus) 0.0; else 0.9; }
87         z: 1
88
89         Behavior on opacity {
90             enabled: true;
91             NumberAnimation { easing.type: Easing.Linear; duration: 200; }
92         }
93     }
94 }