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
22import Unity.Launcher 0.1
27 property bool available: true // can be used to disable all interactions
29 property bool teasing: false
30 property int panelWidth: units.gu(8.5)
31 property int dragAreaWidth: units.gu(1)
32 property real progress: dragArea.dragging && dragArea.touchX > panel.width ? dragArea.touchX : 0
34 readonly property bool shown: panel.x > -panel.width
36 // emitted when an application is selected
37 signal launcherApplicationSelected(string desktopFile)
39 // emitted when the apps dash should be shown because of a swipe gesture
42 // emitted when the dash icon in the launcher has been tapped
43 signal dashItemSelected()
49 dismissTimer.restart()
57 function switchToNextState(state) {
58 animateTimer.nextState = state
80 dismissTimer.restart()
85 // Because the animation on x is disabled while dragging
86 // switching state directly in the drag handlers would not animate
87 // the completion of the hide/reveal gesture. Lets update the state
88 // machine and switch to the final state in the next event loop run
92 property string nextState: ""
94 // switching to an intermediate state here to make sure all the
95 // values are restored, even if we were already in the target state
97 root.state = nextState
103 enabled: root.state == "visible"
105 anchors.rightMargin: -units.gu(2)
113 if (panel.x < -panel.width/3) {
114 root.switchToNextState("")
116 root.switchToNextState("visible")
124 left: launcherDragArea.right
127 bottom: parent.bottom
129 enabled: root.state == "visible"
139 opacity: root.state == "visible" ? 0.4 : 0
141 Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuad} }
146 objectName: "launcherPanel"
147 width: root.panelWidth
150 bottom: parent.bottom
155 property bool animate: true
157 onApplicationSelected: {
159 launcherApplicationSelected(desktopFile)
161 onDashItemSelected: {
163 root.dashItemSelected(index)
167 if (dismissTimer.running) {
168 dismissTimer.restart();
174 // Disabling animation when dragging
175 duration: dragArea.dragging || launcherDragArea.drag.active ? 0 : 300;
176 easing.type: Easing.OutCubic
181 DirectionalDragArea {
184 direction: Direction.Rightwards
186 // values to be tweaked and later removed from here and set in stone as defaults
187 // once we are confident it's all good.
188 maxDeviation: units.gu(1)
190 distanceThreshold: units.gu(3)
191 minSpeed: units.gu(5)
193 enabled: root.available && root.state !== "visible"
194 width: root.dragAreaWidth
198 if (status !== DirectionalDragArea.Recognized)
201 // When the gesture finally gets recognized, the finger will likely be
202 // reasonably far from the edge. If we made the panel immediately
203 // follow the finger position it would be visually unpleasant as it
204 // would appear right next to the user's finger out of nowhere.
205 // Instead, we make the panel go towards the user's finger in several
206 // steps. ie., in an animated way.
207 var targetPanelX = Math.min(0, touchX - panel.width)
208 var delta = targetPanelX - panel.x
209 // the trick is not to go all the way (1.0) as it would cause a sudden jump
210 panel.x += 0.4 * delta
215 if (distance > panel.width / 2) {
216 root.switchToNextState("visible")
217 if (distance > panel.width * 2) {
221 root.switchToNextState("")
229 name: "" // hidden state. Must be the default state ("") because "when:" falls back to this.
244 when: root.teasing || teaseTimer.running
247 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