Debian Codegraph @

modules/Lomiri/Components/Extras/qml6/PhotoEditor/CropDragArea.qml

raw
1 /*
2 * Copyright (C) 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Charles Lindsay <[email protected]>
18 */
19
20 import QtQuick 2.9
21
22 // A MouseArea meant to drag a corner/edge of a crop area.
23 MouseArea {
24 id: cropDragArea
25
26 /*!
27 */
28 signal dragged(real dx, real dy)
29 /*!
30 */
31 signal dragStarted()
32 /*!
33 */
34 signal dragCompleted()
35
36 // Since we're usually moving this area with the mouse in response to
37 // dragging, we don't need to capture the last x/y, just where it was
38 // grabbed.
39 property real grabX: -1
40 /*!
41 */
42 property real grabY: -1
43
44 onPressed: {
45 dragStarted();
46
47 grabX = mouse.x;
48 grabY = mouse.y;
49 }
50
51 onReleased: {
52 dragCompleted();
53 }
54
55 onPositionChanged: cropDragArea.dragged(mouse.x - grabX, mouse.y - grabY)
56 }