2 * Copyright (C) 2013 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/>.
19import Ubuntu.Components 0.1
20import Ubuntu.Gestures 0.1
26 property bool available: true // can be used to disable all interactions
28 property bool teasing: false
29 property int panelWidth: units.gu(8.5)
30 property int dragAreaWidth: units.gu(1)
31 property real progress: dragArea.dragging && dragArea.touchX > panel.width ? dragArea.touchX : 0
33 readonly property bool shown: panel.x > -panel.width
35 // emitted when an application is selected
36 signal launcherApplicationSelected(string desktopFile)
38 // emitted when the apps dash should be shown because of a swipe gesture
41 // emitted when the dash icon in the launcher has been tapped
42 signal dashItemSelected()
48 dismissTimer.restart()
56 function switchToNextState(state) {
57 animateTimer.nextState = state
79 dismissTimer.restart()
84 // Because the animation on x is disabled while dragging
85 // switching state directly in the drag handlers would not animate
86 // the completion of the hide/reveal gesture. Lets update the state
87 // machine and switch to the final state in the next event loop run
91 property string nextState: ""
93 // switching to an intermediate state here to make sure all the
94 // values are restored, even if we were already in the target state
96 root.state = nextState
106 enabled: root.state == "visible"
108 anchors.rightMargin: -units.gu(2)
116 if (panel.x < -panel.width/3) {
117 root.switchToNextState("")
119 root.switchToNextState("visible")
127 left: launcherDragArea.right
130 bottom: parent.bottom
132 enabled: root.state == "visible"
142 opacity: root.state == "visible" ? 0.4 : 0
144 Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuad} }
149 objectName: "launcherPanel"
150 width: root.panelWidth
153 bottom: parent.bottom
158 property bool animate: true
160 onApplicationSelected: {
162 launcherApplicationSelected(desktopFile)
164 onDashItemSelected: {
166 root.dashItemSelected(index)
170 if (dismissTimer.running) {
171 dismissTimer.restart();
177 // Disabling animation when dragging
178 duration: dragArea.dragging || launcherDragArea.drag.active ? 0 : 300;
179 easing.type: Easing.OutCubic
184 DirectionalDragArea {
187 direction: Direction.Rightwards
189 // values to be tweaked and later removed from here and set in stone as defaults
190 // once we are confident it's all good.
191 maxDeviation: units.gu(1)
193 distanceThreshold: units.gu(3)
194 minSpeed: units.gu(5)
196 enabled: root.available && root.state !== "visible"
197 width: root.dragAreaWidth
201 if (status !== DirectionalDragArea.Recognized)
204 // When the gesture finally gets recognized, the finger will likely be
205 // reasonably far from the edge. If we made the panel immediately
206 // follow the finger position it would be visually unpleasant as it
207 // would appear right next to the user's finger out of nowhere.
208 // Instead, we make the panel go towards the user's finger in several
209 // steps. ie., in an animated way.
210 var targetPanelX = Math.min(0, touchX - panel.width)
211 var delta = targetPanelX - panel.x
212 // the trick is not to go all the way (1.0) as it would cause a sudden jump
213 panel.x += 0.4 * delta
218 if (distance > root.width / 2) {
220 root.switchToNextState("")
221 } else if (distance > panel.width/2) {
222 root.switchToNextState("visible")
224 root.switchToNextState("")
232 name: "" // hidden state. Must be the default state ("") because "when:" falls back to this.
247 when: root.teasing || teaseTimer.running
250 x: -root.panelWidth + units.gu(2)
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