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/>.
18import Ubuntu.Components 1.3
19import Ubuntu.Gestures 0.1
25 property alias indicatorsModel: bar.indicatorsModel
26 property alias showDragHandle: __showDragHandle
27 property alias hideDragHandle: __hideDragHandle
28 property alias overFlowWidth: bar.overFlowWidth
29 property alias verticalVelocityThreshold: yVelocityCalculator.velocityThreshold
30 property alias currentIndicator: bar.currentIndicator
31 property int minimizedPanelHeight: units.gu(3)
32 property int expandedPanelHeight: units.gu(7)
33 property real openedHeight: units.gu(71)
34 readonly property real unitProgress: Math.max(0, (height - minimizedPanelHeight) / (openedHeight - minimizedPanelHeight))
35 readonly property bool fullyOpened: unitProgress >= 1
36 readonly property bool partiallyOpened: unitProgress > 0 && unitProgress < 1.0
37 readonly property bool fullyClosed: unitProgress == 0
38 property bool enableHint: true
39 property bool showOnClick: true
40 property color panelColor: theme.palette.normal.background
42 signal showTapped(point position)
44 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
45 // use its own values. Need to ask design about this.
46 showAnimation: SequentialAnimation {
51 duration: UbuntuAnimation.BriskDuration
52 easing.type: Easing.OutCubic
54 // set binding in case units.gu changes while menu open, so height correctly adjusted to fit
55 ScriptAction { script: root.height = Qt.binding( function(){ return root.openedHeight; } ) }
58 hideAnimation: SequentialAnimation {
62 to: minimizedPanelHeight
63 duration: UbuntuAnimation.BriskDuration
64 easing.type: Easing.OutCubic
66 // set binding in case units.gu changes while menu closed, so menu adjusts to fit
67 ScriptAction { script: root.height = Qt.binding( function(){ return root.minimizedPanelHeight; } ) }
70 height: minimizedPanelHeight
72 onUnitProgressChanged: d.updateState()
73 clip: root.partiallyOpened
87 objectName: "menuContent"
94 height: openedHeight - bar.height - handle.height
95 indicatorsModel: root.indicatorsModel
96 visible: root.unitProgress > 0
97 currentMenuIndex: bar.currentItemIndex
106 bottom: parent.bottom
109 active: d.activeDragHandle ? true : false
111 //small shadow gradient at bottom of menu
118 height: units.gu(0.5)
120 GradientStop { position: 0.0; color: "transparent" }
121 GradientStop { position: 1.0; color: theme.palette.normal.background }
134 objectName: "indicatorsBar"
141 enableLateralChanges: false
143 unitProgress: root.unitProgress
145 height: expanded ? expandedPanelHeight : minimizedPanelHeight
146 Behavior on height { NumberAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing } }
152 anchors.left: bar.left
155 forceScrollingPercentage: 0.33
156 stopScrollThreshold: units.gu(0.75)
157 direction: Qt.RightToLeft
160 onScroll: bar.addScrollOffset(-scrollAmount);
166 anchors.right: bar.right
169 forceScrollingPercentage: 0.33
170 stopScrollThreshold: units.gu(0.75)
171 direction: Qt.LeftToRight
174 onScroll: bar.addScrollOffset(scrollAmount);
178 anchors.bottom: parent.bottom
179 anchors.left: parent.left
180 anchors.right: parent.right
181 height: minimizedPanelHeight
182 enabled: __showDragHandle.enabled && showOnClick
184 bar.selectItemAt(mouseX)
191 objectName: "showDragHandle"
192 anchors.bottom: parent.bottom
193 anchors.left: parent.left
194 anchors.right: parent.right
195 height: minimizedPanelHeight
196 direction: Direction.Downwards
197 enabled: !root.shown && root.available
198 autoCompleteDragThreshold: maxTotalDragDistance / 2
203 touchPressTime = new Date().getTime();
205 var touchReleaseTime = new Date().getTime();
206 if (touchReleaseTime - touchPressTime <= 300) {
207 root.showTapped(Qt.point(touchSceneX, touchSceneY));
211 property var touchPressTime
213 // using hint regulates minimum to hint displacement, but in fullscreen mode, we need to do it manually.
214 overrideStartValue: enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height
215 maxTotalDragDistance: openedHeight - (enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height)
216 hintDisplacement: enableHint ? expandedPanelHeight - minimizedPanelHeight + handle.height : 0
220 anchors.fill: __hideDragHandle
221 enabled: __hideDragHandle.enabled
222 onClicked: root.hide()
227 objectName: "hideDragHandle"
229 direction: Direction.Upwards
230 enabled: root.shown && root.available
231 hintDisplacement: units.gu(3)
232 autoCompleteDragThreshold: maxTotalDragDistance / 6
234 maxTotalDragDistance: openedHeight - expandedPanelHeight - handle.height
236 onTouchSceneXChanged: {
237 if (root.state === "locked") {
238 d.xDisplacementSinceLock += (touchSceneX - d.lastHideTouchSceneX)
239 d.lastHideTouchSceneX = touchSceneX;
244 PanelVelocityCalculator {
245 id: yVelocityCalculator
246 velocityThreshold: d.hasCommitted ? 0.1 : 0.3
247 trackedValue: d.activeDragHandle ? d.activeDragHandle.touchSceneY : 0
249 onVelocityAboveThresholdChanged: d.updateState()
253 target: showAnimation
255 if (showAnimation.running) {
256 root.state = "commit";
262 target: hideAnimation
264 if (hideAnimation.running) {
265 root.state = "initial";
272 property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
273 property bool hasCommitted: false
274 property real lastHideTouchSceneX: 0
275 property real xDisplacementSinceLock: 0
276 onXDisplacementSinceLockChanged: d.updateState()
278 property real rowMappedLateralPosition: {
279 if (!d.activeDragHandle) return -1;
280 return d.activeDragHandle.mapToItem(bar, d.activeDragHandle.touchX, 0).x;
283 function updateState() {
284 if (!showAnimation.running && !hideAnimation.running && d.activeDragHandle) {
285 if (unitProgress <= 0) {
286 root.state = "initial";
287 // lock indicator if we've been committed and aren't moving too much laterally or too fast up.
288 } else if (d.hasCommitted && (Math.abs(d.xDisplacementSinceLock) < units.gu(2) || yVelocityCalculator.velocityAboveThreshold)) {
289 root.state = "locked";
291 root.state = "reveal";
300 PropertyChanges { target: d; hasCommitted: false; restoreEntryValues: false }
306 yVelocityCalculator.reset();
307 // initial item selection
308 if (!d.hasCommitted) bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchX : -1);
309 d.hasCommitted = false;
315 // changes to lateral touch position effect which indicator is selected
316 lateralPosition: d.rowMappedLateralPosition
317 // vertical velocity determines if changes in lateral position has an effect
318 enableLateralChanges: d.activeDragHandle &&
319 !yVelocityCalculator.velocityAboveThreshold
321 // left scroll bar handling
325 if (!d.activeDragHandle) return -1;
326 var mapped = d.activeDragHandle.mapToItem(leftScroller, d.activeDragHandle.touchX, 0);
330 // right scroll bar handling
332 target: rightScroller
334 if (!d.activeDragHandle) return -1;
335 var mapped = d.activeDragHandle.mapToItem(rightScroller, d.activeDragHandle.touchX, 0);
344 d.xDisplacementSinceLock = 0;
345 d.lastHideTouchSceneX = hideDragHandle.touchSceneX;
348 PropertyChanges { target: bar; expanded: true }
353 PropertyChanges { target: bar; interactive: true }
357 lastHideTouchSceneX: 0
358 xDisplacementSinceLock: 0
359 restoreEntryValues: false
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