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.1
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 int minimizedPanelHeight: units.gu(3)
31 property int expandedPanelHeight: units.gu(7)
32 property real openedHeight: units.gu(71)
33 readonly property real unitProgress: Math.max(0, (height - minimizedPanelHeight) / (openedHeight - minimizedPanelHeight))
34 readonly property bool fullyOpened: unitProgress >= 1
35 readonly property bool partiallyOpened: unitProgress > 0 && unitProgress < 1.0
36 readonly property bool fullyClosed: unitProgress == 0
37 property bool enableHint: true
38 property bool contentEnabled: true
39 property color panelColor: "black"
41 signal showTapped(point position)
43 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
44 // use its own values. Need to ask design about this.
45 showAnimation: StandardAnimation {
48 duration: UbuntuAnimation.BriskDuration
49 easing.type: Easing.OutCubic
52 hideAnimation: StandardAnimation {
54 to: minimizedPanelHeight
55 duration: UbuntuAnimation.BriskDuration
56 easing.type: Easing.OutCubic
59 height: minimizedPanelHeight
61 onUnitProgressChanged: d.updateState()
62 clip: root.partiallyOpened
75 objectName: "menuContent"
82 height: openedHeight - bar.height - handle.height
83 indicatorsModel: root.indicatorsModel
84 visible: root.unitProgress > 0
85 enabled: contentEnabled
86 currentMenuIndex: bar.currentItemIndex
98 active: d.activeDragHandle ? true : false
100 //small shadow gradient at bottom of menu
107 height: units.gu(0.5)
109 GradientStop { position: 0.0; color: "transparent" }
110 GradientStop { position: 1.0; color: "black" }
123 objectName: "indicatorsBar"
130 enableLateralChanges: false
132 unitProgress: root.unitProgress
134 height: expanded ? expandedPanelHeight : minimizedPanelHeight
135 Behavior on height { NumberAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing } }
141 anchors.left: bar.left
144 forceScrollingPercentage: 0.33
145 stopScrollThreshold: units.gu(0.75)
146 direction: Qt.RightToLeft
149 onScroll: bar.addScrollOffset(-scrollAmount);
155 anchors.right: bar.right
158 forceScrollingPercentage: 0.33
159 stopScrollThreshold: units.gu(0.75)
160 direction: Qt.LeftToRight
163 onScroll: bar.addScrollOffset(scrollAmount);
167 anchors.bottom: parent.bottom
168 anchors.left: parent.left
169 anchors.right: parent.right
170 height: minimizedPanelHeight
171 enabled: __showDragHandle.enabled
173 bar.selectItemAt(mouseX)
180 objectName: "showDragHandle"
181 anchors.bottom: parent.bottom
182 anchors.left: parent.left
183 anchors.right: parent.right
184 height: minimizedPanelHeight
185 direction: Direction.Downwards
186 enabled: !root.shown && root.available
187 autoCompleteDragThreshold: maxTotalDragDistance / 2
192 touchPressTime = new Date().getTime();
194 var touchReleaseTime = new Date().getTime();
195 if (touchReleaseTime - touchPressTime <= 300) {
196 root.showTapped(Qt.point(touchSceneX, touchSceneY));
200 property var touchPressTime
202 // using hint regulates minimum to hint displacement, but in fullscreen mode, we need to do it manually.
203 overrideStartValue: enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height
204 maxTotalDragDistance: openedHeight - (enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height)
205 hintDisplacement: enableHint ? expandedPanelHeight - minimizedPanelHeight + handle.height : 0
209 anchors.fill: __hideDragHandle
210 enabled: __hideDragHandle.enabled
211 onClicked: root.hide()
216 objectName: "hideDragHandle"
218 direction: Direction.Upwards
219 enabled: root.shown && root.available
220 hintDisplacement: units.gu(3)
221 autoCompleteDragThreshold: maxTotalDragDistance / 6
223 maxTotalDragDistance: openedHeight - expandedPanelHeight - handle.height
225 onTouchSceneXChanged: {
226 if (root.state === "locked") {
227 d.xDisplacementSinceLock += (touchSceneX - d.lastHideTouchSceneX)
228 d.lastHideTouchSceneX = touchSceneX;
233 PanelVelocityCalculator {
234 id: yVelocityCalculator
235 velocityThreshold: d.hasCommitted ? 0.1 : 0.3
236 trackedValue: d.activeDragHandle ? d.activeDragHandle.touchSceneY : 0
238 onVelocityAboveThresholdChanged: d.updateState()
242 target: showAnimation
244 if (showAnimation.running) {
245 root.state = "commit";
251 target: hideAnimation
253 if (hideAnimation.running) {
254 root.state = "initial";
261 property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
262 property bool hasCommitted: false
263 property real lastHideTouchSceneX: 0
264 property real xDisplacementSinceLock: 0
265 onXDisplacementSinceLockChanged: d.updateState()
267 property real rowMappedLateralPosition: {
268 if (!d.activeDragHandle) return -1;
269 return d.activeDragHandle.mapToItem(bar, d.activeDragHandle.touchX, 0).x;
272 function updateState() {
273 if (!showAnimation.running && !hideAnimation.running) {
274 if (unitProgress <= 0) {
275 root.state = "initial";
276 // lock indicator if we've been committed and aren't moving too much laterally or too fast up.
277 } else if (d.hasCommitted && (Math.abs(d.xDisplacementSinceLock) < units.gu(2) || yVelocityCalculator.velocityAboveThreshold)) {
278 root.state = "locked";
280 root.state = "reveal";
289 PropertyChanges { target: d; hasCommitted: false; restoreEntryValues: false }
295 yVelocityCalculator.reset();
296 // initial item selection
297 if (!d.hasCommitted) bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchX : -1);
298 d.hasCommitted = false;
304 // changes to lateral touch position effect which indicator is selected
305 lateralPosition: d.rowMappedLateralPosition
306 // vertical velocity determines if changes in lateral position has an effect
307 enableLateralChanges: d.activeDragHandle &&
308 !yVelocityCalculator.velocityAboveThreshold
310 // left scroll bar handling
314 if (!d.activeDragHandle) return -1;
315 var mapped = d.activeDragHandle.mapToItem(leftScroller, d.activeDragHandle.touchX, 0);
319 // right scroll bar handling
321 target: rightScroller
323 if (!d.activeDragHandle) return -1;
324 var mapped = d.activeDragHandle.mapToItem(rightScroller, d.activeDragHandle.touchX, 0);
333 d.xDisplacementSinceLock = 0;
334 d.lastHideTouchSceneX = hideDragHandle.touchSceneX;
337 PropertyChanges { target: bar; expanded: true }
342 PropertyChanges { target: bar; interactive: true }
346 lastHideTouchSceneX: 0
347 xDisplacementSinceLock: 0
348 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