on xenial help sign in
more work on the right edge gesture
commit4f0238221c0a3a4285444731eb998be1bdf54304 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 3 Aug 2016, 16:04 (10 years ago) parent102b9a7
2 files changed+77−67
qml/Stages/DesktopStage.qml+14−51 qml/Stages/Spread/StagedRightEdgeMaths.qml+63−16
qml/Stages/DesktopStage.qml+14−51
@@ -302,6 +302,7 @@ AbstractStage {
302302 },
303303 State {
304304 name: "sidestagedrightedge"; when: rightEdgeDragArea.dragging && root.mode == "stagedWithSideStage"
305+ PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
305306 },
306307 State {
307308 name: "windowedrightedge"; when: rightEdgeDragArea.dragging && root.mode == "windowed"
@@ -312,7 +313,7 @@ AbstractStage {
312313 State {
313314 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
314315 PropertyChanges { target: triGestureArea; enabled: true }
315− PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate ? 3 : 2 }
316+ PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
316317 PropertyChanges { target: sideStage; visible: true }
317318 },
318319 State {
@@ -473,6 +474,7 @@ AbstractStage {
473474 delegate: FocusScope {
474475 id: appDelegate
475476 objectName: "appDelegate_" + model.id
477+ property int itemIndex: index // We need this from outside the repeater
476478 // z might be overriden in some cases by effects, but we need z ordering
477479 // to calculate occlusion detection
478480 property int normalZ: topLevelSurfaceList.count - index
@@ -789,26 +791,13 @@ AbstractStage {
789791
790792 StagedRightEdgeMaths {
791793 id: stagedRightEdgeMaths
792− itemIndex: index
793− sceneWidth: appContainer.width - root.leftMargin
794− sceneHeight: appContainer.height
795− progress: 0
796− targetHeight: spreadMaths.stackHeight
797− targetX: spreadMaths.targetX
798− startY: appDelegate.fullscreen ? 0 : PanelState.panelHeight
799− targetY: spreadMaths.targetY
800− targetAngle: spreadMaths.targetAngle
801− targetScale: spreadMaths.targetScale
802− }
803−
804− SideStagedRightEdgeMaths {
805− id: sideStagedRightEdgeMaths
806794 sceneWidth: appContainer.width - root.leftMargin
807795 sceneHeight: appContainer.height
808796 isMainStageApp: priv.mainStageDelegate == appDelegate
809797 isSideStageApp: priv.sideStageDelegate == appDelegate
810798 sideStageWidth: sideStage.width
811799 itemIndex: index
800+ nextInStack: priv.nextInStack
812801 progress: 0
813802 targetHeight: spreadMaths.stackHeight
814803 targetX: spreadMaths.targetX
@@ -849,56 +838,29 @@ AbstractStage {
849838 PropertyChanges { target: dragArea; enabled: true }
850839 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
851840 },
852−// State {
853−// name: "stagedrightedge";
854−// when: root.state == "stagedrightedge" || rightEdgeFocusAnimation.running || hidingAnimation.running
855−// PropertyChanges {
856−// target: stagedRightEdgeMaths
857−// progress: rightEdgeDragArea.progress
858−// }
859−// PropertyChanges {
860−// target: appDelegate
861−// y: stagedRightEdgeMaths.animatedY
862−// x: stagedRightEdgeMaths.animatedX
863−// z: index +1
864−// height: stagedRightEdgeMaths.animatedHeight
865−// requestedWidth: decoratedWindow.oldRequestedWidth
866−// requestedHeight: decoratedWindow.oldRequestedHeight
867−// visible: stagedRightEdgeMaths.itemVisible
868−// }
869−// PropertyChanges {
870−// target: decoratedWindow;
871−// hasDecoration: false
872−// angle: stagedRightEdgeMaths.animatedAngle
873−// itemScale: stagedRightEdgeMaths.animatedScale
874−// scaleToPreviewSize: spreadItem.stackHeight
875−// scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
876−// shadowOpacity: 0.3
877−// }
878−// },
879841 State {
880− name: "sidestagedrightedge"
842+ name: "stagedrightedge"
881843 when: root.state == "sidestagedrightedge" || root.state == "stagedrightedge" || rightEdgeFocusAnimation.running || hidingAnimation.running
882844 PropertyChanges {
883− target: sideStagedRightEdgeMaths
845+ target: stagedRightEdgeMaths
884846 progress: rightEdgeDragArea.progress
885847 }
886848 PropertyChanges {
887849 target: appDelegate
888− x: sideStagedRightEdgeMaths.animatedX
889− y: sideStagedRightEdgeMaths.animatedY
850+ x: stagedRightEdgeMaths.animatedX
851+ y: stagedRightEdgeMaths.animatedY
890852 z: index +1
891− height: sideStagedRightEdgeMaths.animatedHeight
853+ height: stagedRightEdgeMaths.animatedHeight
892854 requestedWidth: decoratedWindow.oldRequestedWidth
893855 requestedHeight: decoratedWindow.oldRequestedHeight
894856 }
895857 PropertyChanges {
896858 target: decoratedWindow
897859 hasDecoration: false
898− angle: sideStagedRightEdgeMaths.animatedAngle
899− itemScale: sideStagedRightEdgeMaths.animatedScale
860+ angle: stagedRightEdgeMaths.animatedAngle
861+ itemScale: stagedRightEdgeMaths.animatedScale
900862 scaleToPreviewSize: spreadItem.stackHeight
901− scaleToPreviewProgress: sideStagedRightEdgeMaths.scaleToPreviewProgress
863+ scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
902864 shadowOpacity: .3
903865 }
904866 },
@@ -1345,8 +1307,9 @@ AbstractStage {
13451307 priv.goneToSpread = true;
13461308 } else {
13471309 if (appRepeater.count > 1) {
1310+ print("playing focus animation for", priv.nextInStack)
13481311 appRepeater.itemAt(0).playHidingAnimation()
1349− appRepeater.itemAt(1).playFocusAnimation()
1312+ appRepeater.itemAt(priv.nextInStack).playFocusAnimation()
13501313 } else {
13511314 appRepeater.itemAt(0).playFocusAnimation();
13521315 }
qml/Stages/Spread/StagedRightEdgeMaths.qml+63−16
@@ -1,5 +1,6 @@
11import QtQuick 2.4
22import Ubuntu.Components 1.3
3+import Unity.Application 0.1
34import "MathUtils.js" as MathUtils
45
56QtObject {
@@ -9,6 +10,7 @@ QtObject {
910 property int itemIndex: 0
1011 property real progress: 0
1112 property int sceneWidth: 0
13+ property int sideStageWidth: 0
1214 property int sceneHeight: 0
1315 property int targetX: 0
1416 property int startY: 0
@@ -19,14 +21,17 @@ QtObject {
1921 property real startScale: 1.3
2022 property real targetScale: 0
2123
22− onProgressChanged: if (itemIndex == 0) { print("progress", progress) }
24+ property bool isMainStageApp: false
25+ property bool isSideStageApp: false
26+ property int nextInStack: 0
27+
28+
29+// onProgressChanged: if (itemIndex == 0) { print("progress", progress) }
2330
2431 // Config
2532 property real breakPoint: 0.4
2633 property int tileDistance: units.gu(10)
2734
28−
29−
3035 // Output
3136
3237 readonly property real scaleToPreviewProgress: {
@@ -42,29 +47,71 @@ QtObject {
4247 }
4348
4449 readonly property int animatedX: {
45− if (itemIndex == 0) {
46− return root.targetX * root.progress
50+ var stageCount = (priv.mainStageDelegate ? 1 : 0) + (priv.sideStageDelegate ? 1 : 0)
51+ var nextStage = appRepeater.itemAt(nextInStack).stage;
52+
53+ var startX = 0;
54+ if (isMainStageApp) {
55+ startX = 0;
56+ } else if (isSideStageApp) {
57+ startX = sceneWidth - sideStageWidth;
58+ } else if (itemIndex == nextInStack && itemIndex < 2 && priv.sideStageDelegate && nextStage == ApplicationInfoInterface.MainStage) {
59+ startX = sceneWidth - sideStageWidth;
60+ } else {
61+ startX = sceneWidth + Math.max(0, itemIndex - stageCount - 1) * tileDistance;
4762 }
48− var startX = sceneWidth //+ (itemIndex - 1) * tileDistance
49− if (itemIndex == 1) {
50− if (root.progress < breakPoint) {
51− return MathUtils.linearAnimation(0, breakPoint, startX, startX / 2 + (itemIndex - 1) * tileDistance, progress)
63+
64+ if (itemIndex == nextInStack) {
65+ if (progress < breakPoint) {
66+ return MathUtils.linearAnimation(0, breakPoint, startX, sceneWidth / 2, progress)
5267 }
53− return MathUtils.linearAnimation(breakPoint, 1, startX / 2 + (itemIndex - 1) * tileDistance, targetX, progress)
68+ return MathUtils.linearAnimation(breakPoint, 1, sceneWidth / 2, targetX, progress)
5469 }
70+
5571 if (progress < breakPoint) {
56− return startX
72+ return startX;
5773 }
58− return MathUtils.linearAnimation(breakPoint, 1, startX + (itemIndex - 1) * tileDistance, targetX, progress)
74+
75+ return MathUtils.linearAnimation(breakPoint, 1, startX, targetX, progress)
76+
5977 }
6078
6179 readonly property int animatedY: progress < breakPoint ? startY : MathUtils.linearAnimation(breakPoint, 1, startY, targetY, progress)
6280
63− readonly property real animatedAngle: itemIndex == 0 ? MathUtils.linearAnimation(0, 1, 0, targetAngle, progress)
64− : Math.max(MathUtils.linearAnimation(0, breakPoint, startAngle, targetAngle, progress), targetAngle)
81+ readonly property real animatedAngle: {
82+ var startAngle = 0;
83+ if (isMainStageApp) {
84+ startAngle = 0;
85+ } else if (isSideStageApp) {
86+ startAngle = 0;
87+ } else {
88+ startAngle = root.startAngle;
89+ }
6590
66− readonly property real animatedScale: itemIndex == 0 ? MathUtils.linearAnimation(0, 1, 1, targetScale, progress)
67− : MathUtils.linearAnimation(0, 1, startScale, targetScale, progress)
91+ return MathUtils.linearAnimation(0, 1, startAngle, targetAngle, progress);
92+ }
93+
94+ readonly property real animatedScale: {
95+ var startScale = 1;
96+ if (isMainStageApp) {
97+ startScale = 1;
98+ } else if (isSideStageApp) {
99+ startScale = 1;
100+ } else {
101+ startScale = root.startScale;
102+ }
103+
104+// print("main stage delegate:", priv.mainStageDelegate, "side delegate", priv.sideStageDelegate, "this", appDelegate, "scale:", startScale)
105+// return startScale;
106+ if (itemIndex == nextInStack) {
107+ return MathUtils.linearAnimation(0, 1, startScale, targetScale, progress)
108+ }
109+ if (progress < breakPoint) {
110+ return startScale;
111+ }
112+
113+ return MathUtils.linearAnimation(breakPoint, 1, startScale, targetScale, progress)
114+ }
68115
69116 readonly property bool itemVisible: true //animatedX < sceneWidth
70117}