@@ -22,6 +22,7 @@ import "../Components"
2222import Utils 0.1
2323import Ubuntu.Gestures 0.1
2424import GlobalShortcut 1.0
25+import "Spread"
2526
2627AbstractStage {
2728 id: root
@@ -313,6 +314,12 @@ AbstractStage {
313314 ]
314315 onStateChanged: print("spread going to state:", state)
315316
317+ Spread {
318+ id: spreadItem
319+ anchors.fill: appContainer
320+ totalItemCount: appRepeater.count
321+ z: 10
322+ }
316323
317324 FocusScope {
318325 id: appContainer
@@ -689,8 +696,8 @@ AbstractStage {
689696
690697 SpreadMaths {
691698 id: spreadMaths
699+ spread: spreadItem
692700 itemIndex: index
693− totalItems: appRepeater.count
694701 flickable: floatingFlickable
695702 }
696703 StageMaths {
@@ -710,8 +717,8 @@ AbstractStage {
710717 sceneWidth: appContainer.width - root.leftMargin
711718 sceneHeight: appContainer.height
712719 progress: 0
713− targetX: spreadMaths.animatedX
714− targetAngle: spreadMaths.animatedAngle
720+ targetX: spreadMaths.targetX
721+ targetAngle: spreadMaths.targetAngle
715722 }
716723
717724// onXChanged: if (model.application.appId == "unity8-dash") print("dash moved to", x)
@@ -720,21 +727,23 @@ AbstractStage {
720727 states: [
721728 State {
722729 name: "spread"; when: root.state == "spread"
723− PropertyChanges {
724− target: appDelegate;
725− x: spreadMaths.animatedX
726− y: spreadMaths.animatedY
727− z: index
728− height: spreadMaths.tileSize + windowInfoItem.height + units.gu(2)
729− requestedWidth: decoratedWindow.oldRequestedWidth
730− requestedHeight: decoratedWindow.oldRequestedHeight
731− }
732730 PropertyChanges {
733731 target: decoratedWindow;
734732 showDecoration: false;
735− angle: spreadMaths.animatedAngle
733+ angle: spreadMaths.targetAngle
734+ itemScale: spreadMaths.scale
735+ scaleToPreviewSize: spreadItem.stackHeight
736736 scaleToPreview: true
737737 }
738+ PropertyChanges {
739+ target: appDelegate
740+ x: spreadMaths.targetX
741+ y: spreadMaths.targetY
742+ z: index
743+ height: spreadItem.spreadItemHeight
744+ requestedWidth: decoratedWindow.oldRequestedWidth
745+ requestedHeight: decoratedWindow.oldRequestedHeight
746+ }
738747 PropertyChanges { target: inputBlocker; enabled: true }
739748 PropertyChanges { target: windowInfoItem; opacity: 1 }
740749 },
@@ -840,6 +849,7 @@ AbstractStage {
840849 requestedHeight: appDelegate.windowedHeight
841850 }
842851 PropertyChanges { target: touchControls; enabled: true }
852+ PropertyChanges { target: resizeArea; enabled: true }
843853 },
844854 State {
845855 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
@@ -930,25 +940,19 @@ AbstractStage {
930940 },
931941 Transition {
932942 to: "spread"
943+ // DecoratedWindow wants the sceleToPreviewSize set before enabling scaleToPreview
944+ PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
945+ PropertyAction { target: decoratedWindow; property: "scaleToPreview" }
933946 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
934− UbuntuNumberAnimation { target: decoratedWindow; properties: "width,height,angle,baseScale"; duration: priv.animationDuration }
947+ UbuntuNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle"; duration: priv.animationDuration }
935948 },
936949 Transition {
937950 from: "spread"; to: "staged,normal"
938951 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
939− UbuntuNumberAnimation { target: decoratedWindow; properties: "angle,width,height,baseScale"; duration: priv.animationDuration }
952+ UbuntuNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle"; duration: priv.animationDuration }
940953 },
941954 Transition {
942− from: "normal"; to: "staged";
943− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
944− },
945− Transition {
946− from: "normal,spread"; to: "staged"
947− UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
948− UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
949− },
950− Transition {
951− from: "nromal,staged"; to: "stagedWithSideStage"
955+ from: "normal,staged"; to: "stagedWithSideStage"
952956 UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
953957 UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
954958 }
@@ -983,6 +987,7 @@ AbstractStage {
983987 screenWidth: appContainer.width
984988 screenHeight: appContainer.height
985989 leftMargin: root.leftMargin
990+ enabled: false
986991
987992 onPressed: {
988993 print("***** focusing because of resize area press", model.application.appId)
@@ -1047,8 +1052,8 @@ AbstractStage {
10471052 property real itemScale: 1
10481053 transform: [
10491054 Scale {
1050− origin.x: itemScaleOriginX
1051− origin.y: itemScaleOriginY
1055+ origin.x: 0
1056+ origin.y: decoratedWindow.implicitHeight / 2
10521057 xScale: decoratedWindow.itemScale
10531058 yScale: decoratedWindow.itemScale
10541059 },
@@ -1094,11 +1099,7 @@ AbstractStage {
10941099 priv.goneToSpread = false;
10951100 }
10961101 }
1097−// Rectangle {
1098−// anchors.fill: parent
1099−// color: "blue"
1100−// opacity: .4
1101−// }
1102+// Rectangle { anchors.fill: parent; color: "blue"; opacity: .4 }
11021103
11031104 WindowInfoItem {
11041105 id: windowInfoItem
@@ -1138,11 +1139,17 @@ AbstractStage {
11381139
11391140 FloatingFlickable {
11401141 id: floatingFlickable
1141− anchors.fill: parent
1142+ anchors.fill: appContainer
11421143 enabled: false
1144+ contentWidth: spreadItem.spreadTotalWidth
1145+ rightMargin: leftMargin
1146+ leftMargin: {
1147+ var stepOnXAxis = 1 / spreadItem.visibleItemCount
1148+ var distanceToIndex1 = spreadItem.curve.getYFromX(stepOnXAxis)
1149+ var middlePartDistance = spreadItem.curve.getYFromX(0.5 + stepOnXAxis/2) - spreadItem.curve.getYFromX(0.5 - stepOnXAxis/2)
1150+ return 1.2 * (middlePartDistance - distanceToIndex1) * spreadItem.spreadWidth
1151+ }
11431152
1144− property int minContentWidth: 6 * Math.min(height / 4, width / 5)
1145− contentWidth: Math.max(6, appRepeater.count) * Math.min(height / 4, width / 5)
11461153 }
11471154
11481155 PropertyAnimation {
@@ -1191,8 +1198,12 @@ AbstractStage {
11911198 if (gesturePoints[gesturePoints.length - 1] < -root.width / 2) {
11921199 priv.goneToSpread = true;
11931200 } else {
1194− appRepeater.itemAt(0).playHidingAnimation()
1195− appRepeater.itemAt(1).playFocusAnimation()
1201+ if (appRepeater.count > 1) {
1202+ appRepeater.itemAt(0).playHidingAnimation()
1203+ appRepeater.itemAt(1).playFocusAnimation()
1204+ } else {
1205+ appRepeater.itemAt(0).playFocusAnimation();
1206+ }
11961207 }
11971208
11981209// // Ok. The user released. Find out if it was a one-way movement.
@@ -1295,6 +1306,10 @@ AbstractStage {
12951306
12961307 Label {
12971308 anchors { left: parent.left; top: parent.top; margins: units.gu(4) }
1298− text: "sidestage z: " + sideStage.z
1309+ text: "spreadWidth: " + spreadItem.spreadWidth
1310+ + "\n spreadItemWidth: " + spreadItem.spreadItemWidth
1311+ + "\n flickableContentWidth: " + floatingFlickable.contentWidth
1312+ + "\n visibleItemCount: " + spreadItem.visibleItemCount
1313+ + "\n contentTopMargin: " + spreadItem.contentTopMargin
12991314 }
13001315}