2 * Copyright 2014 Canonical Ltd.
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.
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.
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/>.
16 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17 * Daniel d'Andrada <daniel.dandrada@canonical.com>
21 import Ubuntu.Components 1.1
22 import "../Components"
27 // to be read from outside
28 readonly property bool dragged: dragArea.moving
32 // to be set from outside
33 property bool interactive: true
34 property bool dropShadow: true
35 property real maximizedAppTopMargin
36 property alias swipeToCloseEnabled: dragArea.enabled
37 property bool closeable
38 property alias application: appWindow.application
39 property int orientation
42 objectName: "appWindowWithShadow"
53 source: "graphics/dropshadow2gu.sci"
54 opacity: root.dropShadow ? .3 : 0
55 Behavior on opacity { UbuntuNumberAnimation {} }
60 objectName: application ? "appWindow_" + application.appId : "appWindow_null"
63 topMargin: appWindow.fullscreen ? 0 : maximizedAppTopMargin
66 interactive: root.interactive
67 orientation: root.orientation
73 objectName: "dragArea"
76 property bool moving: false
77 property real distance: 0
79 readonly property real minSpeedToClose: units.gu(40)
85 moving = moving || Math.abs(dragValue) > units.gu(1)
98 if (!root.closeable) {
99 animation.animate("center")
103 // velocity and distance values specified by design prototype
104 if ((dragVelocity < -minSpeedToClose && distance < -units.gu(8)) || distance < -root.height / 2) {
105 animation.animate("up")
106 } else if ((dragVelocity > minSpeedToClose && distance > units.gu(8)) || distance > root.height / 2) {
107 animation.animate("down")
109 animation.animate("center")
113 UbuntuNumberAnimation {
115 objectName: "closeAnimation"
118 property bool requestClose: false
120 function animate(direction) {
121 animation.from = dragArea.distance;
124 animation.to = -root.height * 1.5;
128 animation.to = root.height * 1.5;
139 dragArea.moving = false;
143 dragArea.distance = 0;