Debian Codegraph @

tests/manual/pointer/content/LeftDrawer.qml

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2019 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the manual tests of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 import QtQuick 2.14
29 import Qt.labs.animation 1.0
30 import QtGraphicalEffects 1.14
31
32 Item {
33 id: root
34 objectName: "LeftHandlerDrawer"
35 width: 100
36 height: 400
37 property real stickout: 4
38 property real xOpen: rect.radius * -2
39 property real xClosed: stickout - width
40 x: xClosed
41 y: 10
42
43 function close() {
44 openCloseAnimation.to = xClosed
45 openCloseAnimation.start()
46 }
47 function open() {
48 openCloseAnimation.to = xOpen
49 openCloseAnimation.start()
50 }
51
52 DragHandler {
53 id: dragHandler
54 yAxis.enabled: false
55 xAxis.minimum: -1000
56 margin: 20
57 onActiveChanged:
58 if (!active) {
59 if (xbr.returnToBounds())
60 return;
61 if (translation.x > 0)
62 open()
63 if (translation.x < 0)
64 close()
65 }
66 }
67
68 BoundaryRule on x {
69 id: xbr
70 minimum: xClosed
71 maximum: xOpen
72 minimumOvershoot: rect.radius
73 maximumOvershoot: rect.radius
74 }
75
76 NumberAnimation on x {
77 id: openCloseAnimation
78 duration: 300
79 easing { type: Easing.OutBounce; overshoot: 5 }
80 }
81
82 RectangularGlow {
83 id: effect
84 anchors.fill: parent
85 glowRadius: dragHandler.margin
86 spread: 0.2
87 color: "cyan"
88 cornerRadius: rect.radius + glowRadius
89 }
90
91 Rectangle {
92 id: rect
93 anchors.fill: parent
94 anchors.margins: 3
95 color: "#333"
96 border.color: "cyan"
97 border.width: 2
98 radius: 10
99 antialiasing: true
100 }
101 }