2 * Copyright (C) 2016 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/>.
18import Ubuntu.Components 1.3
19import Ubuntu.Gestures 0.1
20import Unity.Application 0.1
21import "../Components/PanelState"
26 // to be set from outside
27 property Item target // appDelegate
29 readonly property bool overlayShown: overlay.visible
35 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
37 maximumTouchPoints: minimumTouchPoints
38 releaseRejectPeriod: 500
40 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
41 touchPoints.length >= minimumTouchPoints &&
42 touchPoints.length <= maximumTouchPoints
43 onRecognizedPressChanged: {
44 if (recognizedPress && target && !target.fullscreen) {
49 readonly property bool recognizedDrag: recognizedPress && dragging
50 onRecognizedDragChanged: {
52 priv.handlePressedChanged(true, tp.x, tp.y);
53 } else if (!moveHandler.containsPress) { // prevent interfering with the central piece drag/move
54 priv.dragging = false;
58 readonly property point tp: recognizedPress ? Qt.point(touchPoints[0].x, touchPoints[0].y) : Qt.point(-1, -1)
61 priv.handlePositionChanged(tp.x, tp.y);
70 repeat: priv.dragging || (priv.resizeArea && priv.resizeArea.dragging)
75 property real distanceX
76 property real distanceY
77 property bool dragging
79 readonly property var resizeArea: root.target && root.target.resizeArea ? root.target.resizeArea : null
81 function handlePressedChanged(pressed, mouseX, mouseY) {
83 var pos = mapToItem(root.target, mouseX, mouseY);
84 priv.distanceX = pos.x;
85 priv.distanceY = pos.y;
88 priv.dragging = false;
92 function handlePositionChanged(mouseX, mouseY) {
94 var pos = mapToItem(root.target.parent, mouseX, mouseY);
95 root.target.x = Math.round(pos.x - priv.distanceX);
96 root.target.y = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
101 // the visual overlay
104 objectName: "windowControlsOverlay"
106 enabled: target && overlayTimer.running
108 opacity: enabled ? 0.95 : 0
110 Behavior on opacity {
111 UbuntuNumberAnimation {}
114 readonly property bool anyMaximized: target && (target.maximized || target.maximizedLeft || target.maximizedRight)
117 source: "graphics/arrows-centre.png"
120 sourceSize: Qt.size(width, height)
121 anchors.centerIn: parent
123 visible: target && target.width > units.gu(12) && target.height > units.gu(12)
129 visible: overlay.visible
132 cursorShape: priv.dragging ? Qt.ClosedHandCursor : (overlay.visible ? Qt.OpenHandCursor : Qt.ArrowCursor)
134 onPressedChanged: priv.handlePressedChanged(pressed, mouseX, mouseY)
135 onPositionChanged: priv.handlePositionChanged(mouseX, mouseY)
141 visible: overlay.visible
145 mouse.accepted = false;
147 propagateComposedEvents: true
151 ResizeGrip { // top left
152 anchors.horizontalCenter: parent.left
153 anchors.verticalCenter: parent.top
154 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
155 resizeTarget: priv.resizeArea
158 ResizeGrip { // top center
159 anchors.horizontalCenter: parent.horizontalCenter
160 anchors.verticalCenter: parent.top
162 visible: target && !overlay.anyMaximized && !target.maximizedVertically
163 resizeTarget: priv.resizeArea
166 ResizeGrip { // top right
167 anchors.horizontalCenter: parent.right
168 anchors.verticalCenter: parent.top
170 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
171 resizeTarget: priv.resizeArea
174 ResizeGrip { // right
175 anchors.horizontalCenter: parent.right
176 anchors.verticalCenter: parent.verticalCenter
178 visible: target && !target.maximizedRight && !target.maximized && !target.maximizedHorizontally
179 resizeTarget: priv.resizeArea
182 ResizeGrip { // bottom right
183 anchors.horizontalCenter: parent.right
184 anchors.verticalCenter: parent.bottom
185 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
186 resizeTarget: priv.resizeArea
189 ResizeGrip { // bottom center
190 anchors.horizontalCenter: parent.horizontalCenter
191 anchors.verticalCenter: parent.bottom
193 visible: target && !overlay.anyMaximized && !target.maximizedVertically
194 resizeTarget: priv.resizeArea
197 ResizeGrip { // bottom left
198 anchors.horizontalCenter: parent.left
199 anchors.verticalCenter: parent.bottom
201 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
202 resizeTarget: priv.resizeArea
206 anchors.horizontalCenter: parent.left
207 anchors.verticalCenter: parent.verticalCenter
209 visible: target && !target.maximizedLeft && !target.maximized && !target.maximizedHorizontally
210 resizeTarget: priv.resizeArea
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