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/>.
18import Ubuntu.Components 0.1
20import "../Components/ListItems"
25 rotation: inverted ? 180 : 0
28 property bool inverted: true
29 property bool dragging: false
30 property bool moving: launcherListView.moving || launcherListView.flicking
31 property int dragPosition: 0
32 property int highlightIndex: -1
34 signal applicationSelected(string desktopFile)
35 signal dashItemSelected(int index)
37 onDragPositionChanged: {
38 var effectiveDragPosition = root.inverted ? launcherListView.height - dragPosition : dragPosition - mainColumn.anchors.margins
40 var hiddenContentHeight = launcherListView.contentHeight - launcherListView.height
41 // Shortening scrollable height because the first/last item needs to be fully expanded before reaching the top/bottom
42 var scrollableHeight = launcherListView.height - (launcherListView.itemSize + launcherColumn.spacing) *2
43 // As we shortened the scrollableHeight, lets move everything down by the itemSize
44 var shortenedEffectiveDragPosition = effectiveDragPosition - launcherListView.itemSize - launcherColumn.spacing
45 var newContentY = shortenedEffectiveDragPosition * hiddenContentHeight / scrollableHeight
47 // limit top/bottom to prevent overshooting
48 launcherListView.contentY = Math.min(hiddenContentHeight, Math.max(0, newContentY));
50 // Now calculate the current index:
51 // > the current mouse position + the hidden/scolled content on top is the mouse position in the averall view
52 // > adjust that removing all the margins
53 // > divide by itemSize to get index
54 highlightIndex = (effectiveDragPosition + launcherListView.contentY - mainColumn.anchors.margins*3 - launcherColumn.spacing/2) / (launcherListView.itemSize + launcherColumn.spacing)
59 source: "graphics/launcher_bg.sci"
67 topMargin: units.gu(0.5)
68 bottomMargin: units.gu(1)
69 leftMargin: units.gu(0.5)
70 rightMargin: units.gu(0.5)
72 spacing: units.gu(0.5)
78 onClicked: root.dashItemSelected(0)
81 objectName: "dashItem"
84 anchors.centerIn: parent
85 source: "graphics/home.png"
92 margins: -mainColumn.anchors.leftMargin
94 rotation: root.rotation
98 anchors.left: parent.left
99 anchors.right: parent.right
100 height: parent.height - dashItem.height - parent.spacing*2
104 anchors.topMargin: -itemSize
105 anchors.bottomMargin: -itemSize
107 bottomMargin: itemSize
108 height: parent.height - dashItem.height - parent.spacing*2
110 cacheBuffer: itemSize * 3
111 snapMode: ListView.SnapToItem
112 highlightRangeMode: ListView.ApplyRange
113 preferredHighlightBegin: (height - itemSize) / 2
114 preferredHighlightEnd: (height + itemSize) / 2
116 // The height of the area where icons start getting folded
117 property int foldingAreaHeight: itemSize * 0.75
118 property int itemSize: width
120 Component.onCompleted: {
121 // This is needed because snapping would partially fold
122 // the first item on initialisation. This can only be
123 // overridden by mouse interactions - which is what flick()
124 // simulates. Setting contentY to 0 would not work because
126 flick(0, units.gu(20))
129 delegate: LauncherDelegate {
131 objectName: "launcherDelegate" + index
132 width: launcherListView.itemSize
133 height: launcherListView.itemSize
135 inverted: root.inverted
136 highlighted: root.dragging && index === root.highlightIndex
142 root.applicationSelected(launcherModel.get(index).desktopFile);
152 topMargin: launcherListView.topMargin
154 height: launcherListView.itemSize
155 enabled: launcherListView.contentY > -launcherListView.topMargin
156 onClicked: launcherListView.flick(0, units.gu(40))
160 id: bottomFoldingArea
164 bottom: parent.bottom
165 bottomMargin: launcherListView.bottomMargin
167 height: launcherListView.itemSize
168 enabled: launcherListView.contentHeight - launcherListView.height - launcherListView.contentY > -launcherListView.bottomMargin
169 onClicked: launcherListView.flick(0, -units.gu(40))
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