1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import Qt.labs.animation
Item {
id: root
objectName: "LeftHandlerDrawer"
width: 100
height: 400
property real stickout: 4
property real xOpen: rect.radius * -2
property real xClosed: stickout - width
x: xClosed
y: 10
function close() {
openCloseAnimation.to = xClosed
openCloseAnimation.start()
}
function open() {
openCloseAnimation.to = xOpen
openCloseAnimation.start()
}
DragHandler {
id: dragHandler
yAxis.enabled: false
xAxis.minimum: -1000
margin: 20
onActiveChanged:
if (!active) {
if (xbr.returnToBounds())
return;
if (activeTranslation.x > 0)
open()
if (activeTranslation.x < 0)
close()
}
}
BoundaryRule on x {
id: xbr
minimum: xClosed
maximum: xOpen
minimumOvershoot: rect.radius
maximumOvershoot: rect.radius
}
NumberAnimation on x {
id: openCloseAnimation
duration: 300
easing { type: Easing.OutBounce; overshoot: 5 }
}
// TODO this was supposed to be RectangularGlow but we lost QtGraphicalEffects in Qt 6
Rectangle {
id: effect
anchors.fill: parent
border.width: dragHandler.margin
border.color: "cyan"
opacity: 0.2
radius: rect.radius + dragHandler.margin
}
Rectangle {
id: rect
anchors.fill: parent
anchors.margins: 3
color: "#333"
border.color: "cyan"
border.width: 2
radius: 10
antialiasing: true
}
}
|