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)
30 property int dragAreaWidth: units.gu(1)
31 property int minimizeDistance: units.gu(26)
32 property real progress: dragArea.dragging && dragArea.touchX > panelWidth ?
33 (width * (dragArea.touchX-panelWidth) / (width - panelWidth)) : 0
35 readonly property bool shown: panel.x > -panel.width
37 // emitted when an application is selected
38 signal launcherApplicationSelected(string appId)
40 // emitted when the apps dash should be shown because of a swipe gesture
43 // emitted when the dash icon in the launcher has been tapped
44 signal dashItemSelected()
50 dismissTimer.restart()
58 function switchToNextState(state) {
59 animateTimer.nextState = state
78 if (!panel.preventHiding) {
81 dismissTimer.restart()
86 // Because the animation on x is disabled while dragging
87 // switching state directly in the drag handlers would not animate
88 // the completion of the hide/reveal gesture. Lets update the state
89 // machine and switch to the final state in the next event loop run
93 property string nextState: ""
95 // switching to an intermediate state here to make sure all the
96 // values are restored, even if we were already in the target state
98 root.state = nextState
104 enabled: root.state == "visible"
106 anchors.rightMargin: -units.gu(2)
114 if (panel.x < -panel.width/3) {
115 root.switchToNextState("")
117 root.switchToNextState("visible")
125 left: launcherDragArea.right
128 bottom: parent.bottom
130 enabled: root.state == "visible"
140 opacity: root.state == "visible" ? 0.6 : 0
142 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.BriskDuration } }
147 objectName: "launcherPanel"
148 enabled: root.available
149 width: root.panelWidth
152 bottom: parent.bottom
155 opacity: (x == -width && dragArea.status === DirectionalDragArea.WaitingForTouch) ? 0 : 1
158 property bool animate: true
160 onApplicationSelected: {
162 launcherApplicationSelected(appId)
164 onDashItemSelected: {
166 root.dashItemSelected(index)
169 onPreventHidingChanged: {
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
183 Behavior on opacity {
185 duration: UbuntuAnimation.FastDuration; easing.type: Easing.OutCubic
193 direction: Direction.Rightwards
195 enabled: root.available
196 width: root.dragAreaWidth
200 if (status !== DirectionalDragArea.Recognized || launcher.state == "visible")
203 // When the gesture finally gets recognized, the finger will likely be
204 // reasonably far from the edge. If we made the panel immediately
205 // follow the finger position it would be visually unpleasant as it
206 // would appear right next to the user's finger out of nowhere.
207 // Instead, we make the panel go towards the user's finger in several
208 // steps. ie., in an animated way.
209 var targetPanelX = Math.min(0, touchX - panel.width)
210 var delta = targetPanelX - panel.x
211 // the trick is not to go all the way (1.0) as it would cause a sudden jump
212 panel.x += 0.4 * delta
217 if (distance > panel.width / 2) {
218 root.switchToNextState("visible")
219 if (distance > minimizeDistance) {
223 root.switchToNextState("")
231 name: "" // hidden state. Must be the default state ("") because "when:" falls back to this.
246 when: teaseTimer.running
249 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