2 * Copyright (C) 2013-2015 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 1.3
20import Ubuntu.Gestures 0.1
21import Unity.Launcher 0.1
26 property bool autohideEnabled: false
27 property bool available: true // can be used to disable all interactions
28 property alias inverted: panel.inverted
29 property bool shadeBackground: true // can be used to disable background shade when launcher is visible
31 property int panelWidth: units.gu(8)
32 property int dragAreaWidth: units.gu(1)
33 property int minimizeDistance: units.gu(26)
34 property real progress: dragArea.dragging && dragArea.touchX > panelWidth ?
35 (width * (dragArea.touchX-panelWidth) / (width - panelWidth)) : 0
37 readonly property bool dragging: dragArea.dragging
38 readonly property real dragDistance: dragArea.dragging ? dragArea.touchX : 0
39 readonly property real visibleWidth: panel.width + panel.x
41 readonly property bool shown: panel.x > -panel.width
43 // emitted when an application is selected
44 signal launcherApplicationSelected(string appId)
46 // emitted when the apps dash should be shown because of a swipe gesture
49 // emitted when the dash icon in the launcher has been tapped
54 panel.dismissTimer.stop()
56 panel.dismissTimer.restart()
65 fadeOutAnimation.start();
68 function switchToNextState(state) {
69 animateTimer.nextState = state
74 if (available && !dragArea.dragging) {
75 teaseTimer.mode = "teasing"
81 if (available && root.state == "") {
82 teaseTimer.mode = "hinting"
87 function pushEdge(amount) {
88 if (root.state === "") {
89 edgeBarrier.push(amount);
95 interval: mode == "teasing" ? 200 : 300
96 property string mode: "teasing"
99 // Because the animation on x is disabled while dragging
100 // switching state directly in the drag handlers would not animate
101 // the completion of the hide/reveal gesture. Lets update the state
102 // machine and switch to the final state in the next event loop run
105 objectName: "animateTimer"
107 property string nextState: ""
109 // switching to an intermediate state here to make sure all the
110 // values are restored, even if we were already in the target state
112 root.state = nextState
117 target: LauncherModel
123 onLanguageChanged: LauncherModel.refresh()
126 SequentialAnimation {
130 animateTimer.stop(); // Don't change the state behind our back
131 panel.layer.enabled = true
134 UbuntuNumberAnimation {
137 easing.type: Easing.InQuad
142 panel.layer.enabled = false
143 panel.animate = false;
145 panel.x = -panel.width
147 panel.animate = true;
154 enabled: root.available && (root.state == "visible" || root.state == "visibleTemporary")
156 anchors.rightMargin: -units.gu(2)
164 if (panel.x < -panel.width/3) {
165 root.switchToNextState("")
167 root.switchToNextState("visible")
175 enabled: root.shadeBackground && root.state == "visible"
186 opacity: root.shadeBackground && root.state == "visible" ? 0.6 : 0
188 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.BriskDuration } }
195 enabled: root.available
196 onPassed: { root.switchToNextState("visibleTemporary"); }
197 material: Component {
203 anchors.centerIn: parent
205 GradientStop { position: 0.0; color: panel.color}
206 GradientStop { position: 1.0; color: Qt.rgba(panel.r,panel.g,panel.b,0)}
215 objectName: "launcherPanel"
216 enabled: root.available && root.state == "visible" || root.state == "visibleTemporary"
217 width: root.panelWidth
220 bottom: parent.bottom
223 visible: root.x > 0 || x > -width || dragArea.pressed
226 property var dismissTimer: Timer { interval: 500 }
228 target: panel.dismissTimer
230 if (root.autohideEnabled) {
231 if (!panel.preventHiding) {
234 panel.dismissTimer.restart()
240 property bool animate: true
242 onApplicationSelected: {
244 launcherApplicationSelected(appId)
251 onPreventHidingChanged: {
252 if (panel.dismissTimer.running) {
253 panel.dismissTimer.restart();
258 enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate;
261 easing.type: Easing.OutCubic
265 Behavior on opacity {
267 duration: UbuntuAnimation.FastDuration; easing.type: Easing.OutCubic
272 DirectionalDragArea {
274 objectName: "launcherDragArea"
276 direction: Direction.Rightwards
278 enabled: root.available
279 x: -root.x // so if launcher is adjusted relative to screen, we stay put (like tutorial does when teasing)
280 width: root.dragAreaWidth
284 if (!dragging || launcher.state == "visible")
287 panel.x = -panel.width + Math.min(Math.max(0, distance), panel.width);
292 if (distance > panel.width / 2) {
293 root.switchToNextState("visible")
294 if (distance > minimizeDistance) {
297 } else if (root.state === "") {
298 // didn't drag far enough. rollback
299 root.switchToNextState("")
307 name: "" // hidden state. Must be the default state ("") because "when:" falls back to this.
317 x: -root.x // so we never go past panelWidth, even when teased by tutorial
321 name: "visibleTemporary"
325 autohideEnabled: true
330 when: teaseTimer.running && teaseTimer.mode == "teasing"
333 x: -root.panelWidth + units.gu(2)
338 when: teaseTimer.running && teaseTimer.mode == "hinting"
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