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"
25 enabled: target && !target.fullscreen
27 // to be set from outside
28 property Item target // appDelegate
30 readonly property alias overlayShown: overlay.visible
36 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
38 maximumTouchPoints: minimumTouchPoints
40 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
41 touchPoints.length >= minimumTouchPoints &&
42 touchPoints.length <= maximumTouchPoints
43 onRecognizedPressChanged: {
44 if (recognizedPress) {
50 readonly property bool recognizedDrag: recognizedPress && dragging
51 onRecognizedDragChanged: {
53 priv.handlePressedChanged(true, tp.x, tp.y);
54 } else if (!moveHandler.containsPress) { // prevent interfering with the central piece drag/move
55 priv.dragging = false;
59 readonly property point tp: recognizedPress ? Qt.point(touchPoints[0].x, touchPoints[0].y) : Qt.point(-1, -1)
62 priv.handlePositionChanged(tp.x, tp.y);
71 repeat: priv.dragging || (priv.resizeArea && priv.resizeArea.dragging)
76 property real distanceX
77 property real distanceY
78 property bool dragging
80 readonly property var resizeArea: root.target && root.target.resizeArea ? root.target.resizeArea : null
82 function handlePressedChanged(pressed, mouseX, mouseY) {
84 var pos = mapToItem(root.target, mouseX, mouseY);
85 priv.distanceX = pos.x;
86 priv.distanceY = pos.y;
89 priv.dragging = false;
93 function handlePositionChanged(mouseX, mouseY) {
95 var pos = mapToItem(root.target.parent, mouseX, mouseY);
96 root.target.x = Math.round(pos.x - priv.distanceX);
97 root.target.y = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
102 // the visual overlay
105 objectName: "windowControlsOverlay"
107 enabled: overlayTimer.running
109 opacity: enabled ? 0.95 : 0
111 Behavior on opacity {
112 UbuntuNumberAnimation {}
115 readonly property bool anyMaximized: target && (target.maximized || target.maximizedLeft || target.maximizedRight)
118 source: "graphics/arrows-centre.png"
121 sourceSize: Qt.size(width, height)
122 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
144 if (gestureArea.recognizedPress || gestureArea.recognizedDrag) {
145 mouse.accepted = false;
150 mouse.accepted = root.contains(Qt.point(mouse.x, mouse.y));
152 propagateComposedEvents: true
156 ResizeGrip { // top left
157 anchors.horizontalCenter: parent.left
158 anchors.verticalCenter: parent.top
159 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
160 resizeTarget: priv.resizeArea
163 ResizeGrip { // top center
164 anchors.horizontalCenter: parent.horizontalCenter
165 anchors.verticalCenter: parent.top
167 visible: target && !overlay.anyMaximized && !target.maximizedVertically
168 resizeTarget: priv.resizeArea
171 ResizeGrip { // top right
172 anchors.horizontalCenter: parent.right
173 anchors.verticalCenter: parent.top
175 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
176 resizeTarget: priv.resizeArea
179 ResizeGrip { // right
180 anchors.horizontalCenter: parent.right
181 anchors.verticalCenter: parent.verticalCenter
183 visible: target && !target.maximizedRight && !target.maximized && !target.maximizedHorizontally
184 resizeTarget: priv.resizeArea
187 ResizeGrip { // bottom right
188 anchors.horizontalCenter: parent.right
189 anchors.verticalCenter: parent.bottom
190 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
191 resizeTarget: priv.resizeArea
194 ResizeGrip { // bottom center
195 anchors.horizontalCenter: parent.horizontalCenter
196 anchors.verticalCenter: parent.bottom
198 visible: target && !overlay.anyMaximized && !target.maximizedVertically
199 resizeTarget: priv.resizeArea
202 ResizeGrip { // bottom left
203 anchors.horizontalCenter: parent.left
204 anchors.verticalCenter: parent.bottom
206 visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
207 resizeTarget: priv.resizeArea
211 anchors.horizontalCenter: parent.left
212 anchors.verticalCenter: parent.verticalCenter
214 visible: target && !target.maximizedLeft && !target.maximized && !target.maximizedHorizontally
215 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