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
24 property alias indicatorsModel: bar.indicatorsModel
25 property alias showDragHandle: __showDragHandle
26 property alias hideDragHandle: __hideDragHandle
27 property alias overFlowWidth: bar.overFlowWidth
28 property alias verticalVelocityThreashold: yVelocityCalculator.velocityThreashold
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
38 property bool enableHint: true
39 property bool contentEnabled: true
40 property color panelColor: "black"
42 signal showTapped(point position)
45 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
46 // use its own values. Need to ask design about this.
47 showAnimation: StandardAnimation {
50 duration: UbuntuAnimation.BriskDuration
51 easing.type: Easing.OutCubic
54 hideAnimation: StandardAnimation {
56 to: minimizedPanelHeight
57 duration: UbuntuAnimation.BriskDuration
58 easing.type: Easing.OutCubic
61 height: minimizedPanelHeight
63 var revealProgress = root.height - minimizedPanelHeight;
65 if (!showAnimation.running && !hideAnimation.running) {
66 if (revealProgress <= 0) {
67 root.state = "initial";
69 root.state = "reveal";
73 clip: root.partiallyOpened
82 objectName: "menuContent"
89 height: openedHeight - bar.height - handle.height
90 indicatorsModel: root.indicatorsModel
91 visible: root.unitProgress > 0
92 enabled: contentEnabled
100 bottom: parent.bottom
103 active: d.activeDragHandle ? true : false
105 //small shadow gradient at bottom of menu
112 height: units.gu(0.5)
114 GradientStop { position: 0.0; color: "transparent" }
115 GradientStop { position: 1.0; color: "black" }
128 objectName: "indicatorsBar"
135 enableLateralChanges: false
137 unitProgress: root.unitProgress
139 height: expanded ? expandedPanelHeight : minimizedPanelHeight
140 Behavior on height { NumberAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing } }
146 anchors.left: bar.left
149 forceScrollingPercentage: 0.33
150 stopScrollThreshold: units.gu(0.75)
151 direction: Qt.RightToLeft
154 onScroll: bar.addScrollOffset(-scrollAmount);
160 anchors.right: bar.right
163 forceScrollingPercentage: 0.33
164 stopScrollThreshold: units.gu(0.75)
165 direction: Qt.LeftToRight
168 onScroll: bar.addScrollOffset(scrollAmount);
173 anchors.bottom: parent.bottom
174 anchors.left: parent.left
175 anchors.right: parent.right
176 height: minimizedPanelHeight
177 direction: Direction.Downwards
178 enabled: !root.shown && root.available
179 autoCompleteDragThreshold: maxTotalDragDistance / 2
181 distanceThreshold: minimizedPanelHeight
182 onTapped: showTapped(Qt.point(touchSceneX, touchSceneY));
184 // using hint regulates minimum to hint displacement, but in fullscreen mode, we need to do it manually.
185 overrideStartValue: enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height
186 maxTotalDragDistance: openedHeight - (enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height)
187 hintDisplacement: enableHint ? expandedPanelHeight - minimizedPanelHeight + handle.height : 0
193 direction: Direction.Upwards
194 enabled: root.shown && root.available
195 hintDisplacement: units.gu(3)
196 autoCompleteDragThreshold: maxTotalDragDistance / 6
198 maxTotalDragDistance: openedHeight - expandedPanelHeight - handle.height
202 PanelVelocityCalculator {
203 id: yVelocityCalculator
204 velocityThreashold: 0.5
205 trackedValue: d.activeDragHandle ? d.activeDragHandle.touchSceneY : 0
207 onVelocityThreasholdTriggered: bar.updateItemFromLateralPosition(bar.lateralPosition);
211 target: showAnimation
213 if (showAnimation.running) {
214 root.state = "commit";
215 bar.alignIndicatorsToLeft();
221 target: hideAnimation
223 if (hideAnimation.running) {
224 root.state = "initial";
231 onCurrentMenuIndexChanged: {
232 var oldActive = d.enableIndexChangeSignal;
233 if (!oldActive) return;
234 d.enableIndexChangeSignal = false;
236 bar.setCurrentItemIndex(content.currentMenuIndex);
238 d.enableIndexChangeSignal = oldActive;
244 onCurrentItemIndexChanged: {
245 var oldActive = d.enableIndexChangeSignal;
246 if (!oldActive) return;
247 d.enableIndexChangeSignal = false;
249 content.setCurrentMenuIndex(bar.currentItemIndex);
251 d.enableIndexChangeSignal = oldActive;
257 property bool enableIndexChangeSignal: true
258 property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
260 property real rowMappedLateralPosition: {
261 if (!d.activeDragHandle) return -1;
262 if (!d.activeDragHandle.dragging) return -1;
263 return d.activeDragHandle.mapToItem(bar, d.activeDragHandle.touchX, 0).x;
275 yVelocityCalculator.reset();
276 // initial item selection
277 bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchX : -1);
283 // changes to lateral touch position effect which indicator is selected
284 lateralPosition: d.rowMappedLateralPosition
285 // vertical velocity determines if changes in lateral position has an effect
286 enableLateralChanges: {
287 if (!d.activeDragHandle) return false;
288 if (!d.activeDragHandle.dragging) return false;
290 return !yVelocityCalculator.stopLateralChanges;
293 // left scroll bar handling
297 if (!d.activeDragHandle) return -1;
298 if (!d.activeDragHandle.dragging) return -1;
300 var mapped = d.activeDragHandle.mapToItem(leftScroller, d.activeDragHandle.touchX, 0);
304 // right scroll bar handling
306 target: rightScroller
308 if (!d.activeDragHandle) return -1;
309 if (!d.activeDragHandle.dragging) return -1;
311 var mapped = d.activeDragHandle.mapToItem(rightScroller, d.activeDragHandle.touchX, 0);
318 PropertyChanges { target: bar; expanded: true }
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