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 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
102 enabled: root.state == "visible"
104 anchors.rightMargin: -units.gu(2)
112 if (panel.x < -panel.width/3) {
113 root.switchToNextState("")
115 root.switchToNextState("visible")
123 left: launcherDragArea.right
126 bottom: parent.bottom
128 enabled: root.state == "visible"
138 opacity: root.state == "visible" ? 0.4 : 0
140 Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuad} }
145 objectName: "launcherPanel"
146 width: root.panelWidth
149 bottom: parent.bottom
154 property bool animate: true
156 onApplicationSelected: {
158 launcherApplicationSelected(desktopFile)
160 onDashItemSelected: {
162 root.dashItemSelected(index)
166 if (dismissTimer.running) {
167 dismissTimer.restart();
173 // Disabling animation when dragging
174 duration: dragArea.dragging || launcherDragArea.drag.active ? 0 : 300;
175 easing.type: Easing.OutCubic
183 direction: Direction.Rightwards
185 enabled: root.available && root.state !== "visible"
186 width: root.dragAreaWidth
190 if (status !== DirectionalDragArea.Recognized)
193 // When the gesture finally gets recognized, the finger will likely be
194 // reasonably far from the edge. If we made the panel immediately
195 // follow the finger position it would be visually unpleasant as it
196 // would appear right next to the user's finger out of nowhere.
197 // Instead, we make the panel go towards the user's finger in several
198 // steps. ie., in an animated way.
199 var targetPanelX = Math.min(0, touchX - panel.width)
200 var delta = targetPanelX - panel.x
201 // the trick is not to go all the way (1.0) as it would cause a sudden jump
202 panel.x += 0.4 * delta
207 if (distance > panel.width / 2) {
208 root.switchToNextState("visible")
209 if (distance > panel.width * 2) {
213 root.switchToNextState("")
221 name: "" // hidden state. Must be the default state ("") because "when:" falls back to this.
236 when: teaseTimer.running
239 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