@@ -32,6 +32,21 @@ Rectangle {
3232 property bool spreadEnabled: true // If false, animations and right edge will be disabled
3333 property real inverseProgress: 0 // This is the progress for left edge drags, in pixels.
3434 property int orientation: Qt.PortraitOrientation
35+ property QtObject applicationManager: ApplicationManager
36+ property bool focusFirstApp: true // If false, focused app will appear on right edge like other apps
37+ property bool altTabEnabled: true
38+ property real startScale: 1.1
39+ property real endScale: 0.7
40+
41+ // How far left the stage has been dragged
42+ readonly property real dragProgress: spreadRepeater.count > 0 ? -spreadRepeater.itemAt(0).xTranslate : 0
43+
44+ readonly property alias dragging: spreadDragArea.dragging
45+
46+ // Only used by the tutorial right now, when it is teasing the right edge
47+ property real dragAreaOverlap
48+
49+ signal opened()
3550
3651 color: "#111111"
3752
@@ -52,30 +67,30 @@ Rectangle {
5267 if (inverseProgress == 0 && priv.oldInverseProgress > 0) {
5368 // left edge drag released. Minimum distance is given by design.
5469 if (priv.oldInverseProgress > units.gu(22)) {
55− ApplicationManager.requestFocusApplication("unity8-dash");
70+ applicationManager.requestFocusApplication("unity8-dash");
5671 }
5772 }
5873 priv.oldInverseProgress = inverseProgress;
5974 }
6075
6176 Connections {
62− target: ApplicationManager
77+ target: applicationManager
6378
6479 onFocusRequested: {
6580 if (spreadView.phase > 0) {
6681 spreadView.snapTo(priv.indexOf(appId));
6782 } else {
68− ApplicationManager.focusApplication(appId);
83+ applicationManager.focusApplication(appId);
6984 }
7085 }
7186
7287 onApplicationAdded: {
7388 if (spreadView.phase == 2) {
74− spreadView.snapTo(ApplicationManager.count - 1);
89+ spreadView.snapTo(applicationManager.count - 1);
7590 } else {
7691 spreadView.phase = 0;
7792 spreadView.contentX = -spreadView.shift;
78− ApplicationManager.focusApplication(appId);
93+ applicationManager.focusApplication(appId);
7994 }
8095 }
8196
@@ -90,9 +105,9 @@ Rectangle {
90105 }
91106
92107 function focusTopMostApp() {
93− if (ApplicationManager.count > 0) {
94− var topmostApp = ApplicationManager.get(0);
95− ApplicationManager.focusApplication(topmostApp.appId);
108+ if (applicationManager.count > 0) {
109+ var topmostApp = applicationManager.get(0);
110+ applicationManager.focusApplication(topmostApp.appId);
96111 }
97112 }
98113 }
@@ -100,20 +115,21 @@ Rectangle {
100115 QtObject {
101116 id: priv
102117
103− property string focusedAppId: ApplicationManager.focusedApplicationId
104− property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
118+ readonly property int firstSpreadIndex: root.focusFirstApp ? 1 : 0
119+ property string focusedAppId: applicationManager.focusedApplicationId
120+ property var focusedApplication: applicationManager.findApplication(focusedAppId)
105121 property var focusedAppDelegate: null
106122
107123 property real oldInverseProgress: 0
108− property bool animateX: true
124+ property bool animateX: false
109125
110126 onFocusedAppIdChanged: focusedAppDelegate = spreadRepeater.itemAt(0);
111127
112128 onFocusedAppDelegateChanged: focusedAppDelegate.focus = true;
113129
114130 function indexOf(appId) {
115− for (var i = 0; i < ApplicationManager.count; i++) {
116− if (ApplicationManager.get(i).appId == appId) {
131+ for (var i = 0; i < applicationManager.count; i++) {
132+ if (applicationManager.get(i).appId == appId) {
117133 return i;
118134 }
119135 }
@@ -133,7 +149,7 @@ Rectangle {
133149
134150 // This indicates when the spreadView is active. That means, all the animations
135151 // are activated and tiles need to line up for the spread.
136− readonly property bool active: shiftedContentX > 0 || spreadDragArea.status === DirectionalDragArea.Recognized
152+ readonly property bool active: shiftedContentX > 0 || spreadDragArea.status === DirectionalDragArea.Recognized || !root.focusFirstApp
137153
138154 // The flickable needs to fill the screen in order to get touch events all over.
139155 // However, we don't want to the user to be able to scroll back all the way. For
@@ -199,10 +215,17 @@ Rectangle {
199215 // Add 1 pixel to make sure we definitely hit positionMarker4 even with rounding errors of the animation.
200216 snapAnimation.targetContentX = width * positionMarker4 + 1 - shift;
201217 snapAnimation.start();
218+ root.opened();
202219 }
203220 }
204221 function snapTo(index) {
205− if (ApplicationManager.count <= index) {
222+ if (!root.altTabEnabled) {
223+ // Reset to start instead
224+ snapAnimation.targetContentX = -shift;
225+ snapAnimation.start();
226+ return;
227+ }
228+ if (applicationManager.count <= index) {
206229 // In case we're trying to snap to some non existing app, lets snap back to the first one
207230 index = 0;
208231 }
@@ -217,10 +240,12 @@ Rectangle {
217240 snapAnimation.start();
218241 }
219242
220− // In case the ApplicationManager already holds an app when starting up we're missing animations
243+ // In case the applicationManager already holds an app when starting up we're missing animations
221244 // Make sure we end up in the same state
222245 Component.onCompleted: {
223246 spreadView.contentX = -spreadView.shift
247+ priv.animateX = true;
248+ snapAnimation.complete();
224249 }
225250
226251 SequentialAnimation {
@@ -237,7 +262,7 @@ Rectangle {
237262 ScriptAction {
238263 script: {
239264 if (spreadView.selectedIndex >= 0) {
240− ApplicationManager.focusApplication(ApplicationManager.get(spreadView.selectedIndex).appId);
265+ applicationManager.focusApplication(applicationManager.get(spreadView.selectedIndex).appId);
241266
242267 spreadView.selectedIndex = -1;
243268 spreadView.phase = 0;
@@ -252,7 +277,7 @@ Rectangle {
252277 // This width controls how much the spread can be flicked left/right. It's composed of:
253278 // tileDistance * app count (with a minimum of 3 apps, in order to also allow moving 1 and 2 apps a bit)
254279 // + some constant value (still scales with the screen width) which looks good and somewhat fills the screen
255− width: Math.max(3, ApplicationManager.count) * spreadView.tileDistance + (spreadView.width - spreadView.tileDistance) * 1.5
280+ width: Math.max(3, applicationManager.count) * spreadView.tileDistance + (spreadView.width - spreadView.tileDistance) * 1.5
256281 height: parent.height
257282 Behavior on width {
258283 enabled: spreadView.closingIndex >= 0
@@ -267,20 +292,22 @@ Rectangle {
267292 x: spreadView.contentX
268293
269294 onClicked: {
270− spreadView.snapTo(0);
295+ if (root.altTabEnabled) {
296+ spreadView.snapTo(0);
297+ }
271298 }
272299
273300 Repeater {
274301 id: spreadRepeater
275302 objectName: "spreadRepeater"
276− model: ApplicationManager
303+ model: applicationManager
277304 delegate: TransformedSpreadDelegate {
278305 id: appDelegate
279306 objectName: "appDelegate" + index
280307 startAngle: 45
281308 endAngle: 5
282− startScale: 1.1
283− endScale: 0.7
309+ startScale: root.startScale
310+ endScale: root.endScale
284311 startDistance: spreadView.tileDistance
285312 endDistance: units.gu(.5)
286313 width: spreadView.width
@@ -288,11 +315,12 @@ Rectangle {
288315 selected: spreadView.selectedIndex == index
289316 otherSelected: spreadView.selectedIndex >= 0 && !selected
290317 interactive: !spreadView.interactive && spreadView.phase === 0
291− && spreadView.shiftedContentX === 0 && root.interactive && index === 0
292− swipeToCloseEnabled: spreadView.interactive && !snapAnimation.running
318+ && spreadView.shiftedContentX === 0 && root.interactive && isFocused
319+ swipeToCloseEnabled: spreadView.interactive && root.interactive && !snapAnimation.running
293320 maximizedAppTopMargin: root.maximizedAppTopMargin
294321 dropShadow: spreadView.active ||
295322 (priv.focusedAppDelegate && priv.focusedAppDelegate.x !== 0)
323+ focusFirstApp: root.focusFirstApp
296324
297325 readonly property bool isDash: model.appId == "unity8-dash"
298326
@@ -300,7 +328,7 @@ Rectangle {
300328
301329 x: {
302330 // focused app is always positioned at 0 except when following left edge drag
303− if (index == 0) {
331+ if (isFocused) {
304332 if (!isDash && root.inverseProgress > 0 && spreadView.phase === 0) {
305333 return root.inverseProgress;
306334 }
@@ -311,10 +339,10 @@ Rectangle {
311339 }
312340
313341 // Otherwise line up for the spread
314− return spreadView.width + (index - 1) * spreadView.tileDistance;
342+ return spreadView.width + spreadIndex * spreadView.tileDistance;
315343 }
316344
317− application: ApplicationManager.get(index)
345+ application: applicationManager.get(index)
318346 closeable: !isDash
319347
320348 property real behavioredIndex: index
@@ -352,7 +380,7 @@ Rectangle {
352380 progress: {
353381 var tileProgress = (spreadView.shiftedContentX - behavioredIndex * spreadView.tileDistance) / spreadView.width;
354382 // Tile 1 needs to move directly from the beginning...
355− if (behavioredIndex == 1 && spreadView.phase < 2) {
383+ if (root.focusFirstApp && behavioredIndex == 1 && spreadView.phase < 2) {
356384 tileProgress += spreadView.tileDistance / spreadView.width;
357385 }
358386 // Limiting progress to ~0 and 1.7 to avoid binding calculations when tiles are not
@@ -367,7 +395,7 @@ Rectangle {
367395
368396 // This mostly is the same as progress, just adds the snapping to phase 1 for tiles 0 and 1
369397 animatedProgress: {
370− if (spreadView.phase == 0 && index < 2) {
398+ if (spreadView.phase == 0 && index <= priv.firstSpreadIndex) {
371399 if (progress < spreadView.positionMarker1) {
372400 return progress;
373401 } else if (progress < spreadView.positionMarker1 + 0.05){
@@ -392,11 +420,11 @@ Rectangle {
392420 }
393421
394422 onClicked: {
395− if (spreadView.phase == 2) {
396− if (ApplicationManager.focusedApplicationId == ApplicationManager.get(index).appId) {
423+ if (root.altTabEnabled && spreadView.phase == 2) {
424+ if (applicationManager.focusedApplicationId == applicationManager.get(index).appId) {
397425 spreadView.snapTo(index);
398426 } else {
399− ApplicationManager.requestFocusApplication(ApplicationManager.get(index).appId);
427+ applicationManager.requestFocusApplication(applicationManager.get(index).appId);
400428 }
401429 }
402430 }
@@ -411,7 +439,7 @@ Rectangle {
411439
412440 onClosed: {
413441 spreadView.closingIndex = index;
414− ApplicationManager.stopApplication(ApplicationManager.get(index).appId);
442+ applicationManager.stopApplication(applicationManager.get(index).appId);
415443 }
416444 }
417445 }
@@ -424,7 +452,7 @@ Rectangle {
424452 direction: Direction.Leftwards
425453 enabled: (spreadView.phase != 2 && root.spreadEnabled) || dragging
426454
427− anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
455+ anchors { top: parent.top; right: parent.right; bottom: parent.bottom; rightMargin: -root.dragAreaOverlap }
428456 width: root.dragAreaWidth
429457
430458 property var gesturePoints: new Array()