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
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Shapes
Rectangle {
id: point1
color: "red"
border.width: 1
border.color: "black"
opacity: 0.3
width: 20
height: 20
visible: !theMouseArea.pressed
property real cx: 400
property real cy: 800
property point pt: Qt.point(cx, cy)
DragHandler {
id: handler
xAxis.minimum: -controlPanel.pathMargin
yAxis.minimum: -controlPanel.pathMargin
xAxis.onActiveValueChanged: {
cx = (x + width/2) / controlPanel.scale
controlPanel.updatePath()
}
yAxis.onActiveValueChanged: {
cy = (y + height/2) / controlPanel.scale
controlPanel.updatePath()
}
}
Component.onCompleted: {
x = cx * controlPanel.scale - width/2
y = cy * controlPanel.scale - height/2
}
Connections {
target: controlPanel
function onScaleChanged() {
x = cx * controlPanel.scale - width/2
y = cy * controlPanel.scale - height/2
}
}
}
|