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
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
83 onWheel: wheel.accepted = true;
88 objectName: "menuContent"
95 height: openedHeight - bar.height - handle.height
96 indicatorsModel: root.indicatorsModel
97 visible: root.unitProgress > 0
98 currentMenuIndex: bar.currentItemIndex
107 bottom: parent.bottom
110 active: d.activeDragHandle ? true : false
112 //small shadow gradient at bottom of menu
119 height: units.gu(0.5)
121 GradientStop { position: 0.0; color: "transparent" }
122 GradientStop { position: 1.0; color: theme.palette.normal.background }
135 objectName: "indicatorsBar"
142 enableLateralChanges: false
144 unitProgress: root.unitProgress
146 height: expanded ? expandedPanelHeight : minimizedPanelHeight
147 Behavior on height { NumberAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing } }
153 anchors.left: bar.left
156 forceScrollingPercentage: 0.33
157 stopScrollThreshold: units.gu(0.75)
158 direction: Qt.RightToLeft
161 onScroll: bar.addScrollOffset(-scrollAmount);
167 anchors.right: bar.right
170 forceScrollingPercentage: 0.33
171 stopScrollThreshold: units.gu(0.75)
172 direction: Qt.LeftToRight
175 onScroll: bar.addScrollOffset(scrollAmount);
179 anchors.bottom: parent.bottom
180 anchors.left: parent.left
181 anchors.right: parent.right
182 height: minimizedPanelHeight
183 enabled: __showDragHandle.enabled && showOnClick
185 bar.selectItemAt(mouseX)
192 objectName: "showDragHandle"
193 anchors.bottom: parent.bottom
194 anchors.left: parent.left
195 anchors.right: parent.right
196 height: minimizedPanelHeight
197 direction: Direction.Downwards
198 enabled: !root.shown && root.available
199 autoCompleteDragThreshold: maxTotalDragDistance / 2
204 touchPressTime = new Date().getTime();
206 var touchReleaseTime = new Date().getTime();
207 if (touchReleaseTime - touchPressTime <= 300) {
212 property var touchPressTime
214 // using hint regulates minimum to hint displacement, but in fullscreen mode, we need to do it manually.
215 overrideStartValue: enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height
216 maxTotalDragDistance: openedHeight - (enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height)
217 hintDisplacement: enableHint ? expandedPanelHeight - minimizedPanelHeight + handle.height : 0
221 anchors.fill: __hideDragHandle
222 enabled: __hideDragHandle.enabled
223 onClicked: root.hide()
228 objectName: "hideDragHandle"
230 direction: Direction.Upwards
231 enabled: root.shown && root.available
232 hintDisplacement: units.gu(3)
233 autoCompleteDragThreshold: maxTotalDragDistance / 6
235 maxTotalDragDistance: openedHeight - expandedPanelHeight - handle.height
237 onTouchPositionChanged: {
238 if (root.state === "locked") {
239 d.xDisplacementSinceLock += (touchPosition.x - d.lastHideTouchX)
240 d.lastHideTouchX = touchPosition.x;
245 PanelVelocityCalculator {
246 id: yVelocityCalculator
247 velocityThreshold: d.hasCommitted ? 0.1 : 0.3
248 trackedValue: d.activeDragHandle ?
249 (Direction.isPositive(d.activeDragHandle.direction) ?
250 d.activeDragHandle.distance :
251 -d.activeDragHandle.distance)
254 onVelocityAboveThresholdChanged: d.updateState()
258 target: showAnimation
260 if (showAnimation.running) {
261 root.state = "commit";
267 target: hideAnimation
269 if (hideAnimation.running) {
270 root.state = "initial";
277 property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
278 property bool hasCommitted: false
279 property real lastHideTouchX: 0
280 property real xDisplacementSinceLock: 0
281 onXDisplacementSinceLockChanged: d.updateState()
283 property real rowMappedLateralPosition: {
284 if (!d.activeDragHandle) return -1;
285 return d.activeDragHandle.mapToItem(bar, d.activeDragHandle.touchPosition.x, 0).x;
288 function updateState() {
289 if (!showAnimation.running && !hideAnimation.running && d.activeDragHandle) {
290 if (unitProgress <= 0) {
291 root.state = "initial";
292 // lock indicator if we've been committed and aren't moving too much laterally or too fast up.
293 } else if (d.hasCommitted && (Math.abs(d.xDisplacementSinceLock) < units.gu(2) || yVelocityCalculator.velocityAboveThreshold)) {
294 root.state = "locked";
296 root.state = "reveal";
305 PropertyChanges { target: d; hasCommitted: false; restoreEntryValues: false }
311 yVelocityCalculator.reset();
312 // initial item selection
313 if (!d.hasCommitted) bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchPosition.x : -1);
314 d.hasCommitted = false;
320 // changes to lateral touch position effect which indicator is selected
321 lateralPosition: d.rowMappedLateralPosition
322 // vertical velocity determines if changes in lateral position has an effect
323 enableLateralChanges: d.activeDragHandle &&
324 !yVelocityCalculator.velocityAboveThreshold
326 // left scroll bar handling
330 if (!d.activeDragHandle) return -1;
331 var mapped = d.activeDragHandle.mapToItem(leftScroller, d.activeDragHandle.touchPosition.x, 0);
335 // right scroll bar handling
337 target: rightScroller
339 if (!d.activeDragHandle) return -1;
340 var mapped = d.activeDragHandle.mapToItem(rightScroller, d.activeDragHandle.touchPosition.x, 0);
349 d.xDisplacementSinceLock = 0;
350 d.lastHideTouchX = hideDragHandle.touchPosition.x;
353 PropertyChanges { target: bar; expanded: true }
358 PropertyChanges { target: bar; interactive: true }
363 xDisplacementSinceLock: 0
364 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