2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
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/>.
16 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
20import Ubuntu.Components 1.1
25 anchors.margins: -resizeHandleWidth
27 // The target item managed by this. Must be a parent or a sibling
28 // The area will anchor to it and manage move and resize events
29 property var target: null
30 property int resizeHandleWidth: 0
31 property int minWidth: 0
32 property int minHeight: 0
36 readonly property int windowWidth: root.width - root.resizeHandleWidth * 2
37 readonly property int windowHeight: root.height - resizeHandleWidth * 2
39 property var startPoint
40 property int startWidth
41 property int startHeight
43 property bool resizeTop: false
44 property bool resizeBottom: false
45 property bool resizeLeft: false
46 property bool resizeRight: false
51 priv.startPoint = mapToItem(null, Qt.point(mouse.x, mouse.y)).x;
52 priv.startWidth = root.width;
53 priv.startHeight = root.height;
54 priv.resizeTop = mouseY < root.resizeHandleWidth;
55 priv.resizeBottom = mouseY > (root.height - root.resizeHandleWidth);
56 priv.resizeLeft = mouseX < root.resizeHandleWidth;
57 priv.resizeRight = mouseX > (root.width - root.resizeHandleWidth);
61 var currentPoint = mapToItem(null, Qt.point(mouse.x, mouse.y)).x;
62 var mouseDiff = Qt.point(currentPoint.x - priv.startPoint.x, currentPoint.y - priv.startPoint.y);
63 var moveDiff = Qt.point(0, 0);
64 var sizeDiff = Qt.point(0, 0);
65 if (priv.resizeTop || priv.resizeBottom || priv.resizeLeft || priv.resizeRight) {
67 moveDiff.y += mouseDiff.y;
68 sizeDiff.y += -mouseDiff.y;
69 } else if (priv.resizeBottom) {
70 sizeDiff.y += mouse.y - priv.startPoint.y;
71 priv.startPoint.y = mouse.y
73 if (priv.resizeLeft) {
74 moveDiff.x += mouseDiff.x;
75 sizeDiff.x += -mouseDiff.x;
76 } else if (priv.resizeRight) {
77 sizeDiff.x += mouse.x - priv.startPoint.x;
78 priv.startPoint.x = mouse.x
80 if (priv.windowWidth + sizeDiff.x < root.minWidth) {
81 sizeDiff.x = root.minWidth - priv.windowWidth;
82 moveDiff.x = moveDiff.x == 0 ? 0 : -sizeDiff.x;
84 if (priv.windowHeight + sizeDiff.y < root.minHeight) {
85 sizeDiff.y = root.minHeight - priv.windowHeight;
86 moveDiff.y = moveDiff.y == 0 ? 0 : -sizeDiff.y;
89 target.x += moveDiff.x;
90 target.y += moveDiff.y;
91 target.width += sizeDiff.x;
92 target.height += sizeDiff.y;
94 target.x += mouseDiff.x;
95 target.y += mouseDiff.y;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list