@@ -23,6 +23,7 @@ import Utils 0.1
23import Ubuntu.Gestures 0.1
23import Ubuntu.Gestures 0.1
24import GlobalShortcut 1.0
24import GlobalShortcut 1.0
25import "Spread"
25import "Spread"
26+import "Spread/MathUtils.js" as MathUtils
27AbstractStage {
28AbstractStage {
@@ -288,6 +289,7 @@ AbstractStage {
288 when: !appRepeater.startingUp && root.parent
289 when: !appRepeater.startingUp && root.parent
292+ onStateChanged: print("*** Main State changed to:", state)
291 states: [
293 states: [
293 name: "spread"; when: priv.goneToSpread
295 name: "spread"; when: priv.goneToSpread
@@ -295,14 +297,14 @@ AbstractStage {
295 PropertyChanges { target: spreadItem; focus: true }
297 PropertyChanges { target: spreadItem; focus: true }
298− name: "stagedrightedge"; when: rightEdgeDragArea.dragging && root.mode == "staged"
300+ name: "stagedRightEdge"; when: rightEdgeDragArea.dragging && root.mode == "staged"
301− name: "sidestagedrightedge"; when: rightEdgeDragArea.dragging && root.mode == "stagedWithSideStage"
303+ name: "sideStagedRightEdge"; when: rightEdgeDragArea.dragging && root.mode == "stagedWithSideStage"
302 PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
304 PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
305− name: "windowedrightedge"; when: rightEdgeDragArea.dragging && root.mode == "windowed"
307+ name: "windowedRightEdge"; when: rightEdgeDragArea.dragging && root.mode == "windowed"
308 name: "staged"; when: root.mode === "staged"
310 name: "staged"; when: root.mode === "staged"
@@ -319,7 +321,7 @@ AbstractStage {
320 transitions: [
322 transitions: [
321 Transition {
323 Transition {
322− from: "stagedrightedge"; to: "spread"
324+ from: "stagedRightEdge"; to: "spread"
323 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
325 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
325 Transition {
327 Transition {
@@ -333,7 +335,6 @@ AbstractStage {
333 ScriptAction {
335 ScriptAction {
334 script: {
336 script: {
335 var item = appRepeater.itemAt(Math.max(0, spreadItem.highlightedIndex));
337 var item = appRepeater.itemAt(Math.max(0, spreadItem.highlightedIndex));
337 item.playFocusAnimation();
338 item.playFocusAnimation();
@@ -341,7 +342,7 @@ AbstractStage {
343 Transition {
344 Transition {
344− to: "stagedrightedge"
345+ to: "stagedRightEdge"
345 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
346 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
@@ -744,7 +745,7 @@ AbstractStage {
745 function playFocusAnimation() {
746 function playFocusAnimation() {
746 print("playing focus animation", state, root.mode, "app", model.application.appId)
747 print("playing focus animation", state, root.mode, "app", model.application.appId)
747− if (state == "stagedrightedge") {
748+ if (state == "stagedRightEdge") {
748 // TODO: Can we drop this if and find something that always works?
749 // TODO: Can we drop this if and find something that always works?
749 if (root.mode == "staged") {
750 if (root.mode == "staged") {
750 rightEdgeFocusAnimation.targetX = 0
751 rightEdgeFocusAnimation.targetX = 0
@@ -754,12 +755,16 @@ AbstractStage {
754 rightEdgeFocusAnimation.targetX = appDelegate.stage == ApplicationInfoInterface.SideStage ? sideStage.x : 0
755 rightEdgeFocusAnimation.targetX = appDelegate.stage == ApplicationInfoInterface.SideStage ? sideStage.x : 0
755 rightEdgeFocusAnimation.start()
756 rightEdgeFocusAnimation.start()
758+ } else if (state == "windowedRightEdge") {
758 focusAnimation.start()
761 focusAnimation.start()
761 function playHidingAnimation() {
764 function playHidingAnimation() {
765+ if (state != "windowedRightEdge") {
762− hidingAnimation.start()
766+ hidingAnimation.start()
765 UbuntuNumberAnimation {
770 UbuntuNumberAnimation {
@@ -769,6 +774,8 @@ AbstractStage {
769 from: 0.98
774 from: 0.98
771 duration: UbuntuAnimation.SnapDuration
776 duration: UbuntuAnimation.SnapDuration
777+ onStarted: topLevelSurfaceList.raiseId(model.id);
778+ onStopped: appDelegate.focus = true
773 ParallelAnimation {
780 ParallelAnimation {
774 id: rightEdgeFocusAnimation
781 id: rightEdgeFocusAnimation
@@ -819,9 +826,24 @@ AbstractStage {
819 targetScale: spreadMaths.targetScale
826 targetScale: spreadMaths.targetScale
829+ WindowedRightEdgeMaths {
830+ id: windowedRightEdgeMaths
832+ startWidth: appDelegate.requestedWidth
833+ startHeight: appDelegate.requestedHeight
834+ targetHeight: spreadItem.stackHeight
835+ startX: appDelegate.windowedX
836+ startY: appDelegate.windowedY
837+ targetX: spreadMaths.targetX
838+ targetY: spreadMaths.targetY
839+ normalZ: appDelegate.normalZ
840+ targetAngle: spreadMaths.targetAngle
841+ targetScale: spreadMaths.targetScale
822// onXChanged: if (model.application.appId == "unity8-dash") print("dash moved to", x)
844// onXChanged: if (model.application.appId == "unity8-dash") print("dash moved to", x)
823// onRequestedWidthChanged: if (index == 0) print("requestedWidth", requestedWidth)
845// onRequestedWidthChanged: if (index == 0) print("requestedWidth", requestedWidth)
824− onStateChanged: if (model.application.appId == "unity8-dash") print("state changed", state)
846+ onStateChanged: print("+++ App", model.application.appId, "state changed to:", state)
825 states: [
847 states: [
827 name: "spread"; when: root.state == "spread"
849 name: "spread"; when: root.state == "spread"
@@ -852,8 +874,8 @@ AbstractStage {
852 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
874 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
855− name: "stagedrightedge"
877+ name: "stagedRightEdge"
856− when: root.state == "sidestagedrightedge" || root.state == "stagedrightedge" || rightEdgeFocusAnimation.running || hidingAnimation.running
878+ when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
857 PropertyChanges {
879 PropertyChanges {
858 target: stagedRightEdgeMaths
880 target: stagedRightEdgeMaths
859 progress: rightEdgeDragArea.progress
881 progress: rightEdgeDragArea.progress
@@ -877,11 +899,42 @@ AbstractStage {
877 shadowOpacity: .3
899 shadowOpacity: .3
903+ name: "windowedRightEdge"
904+ when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
906+ target: windowedRightEdgeMaths
907+ progress: rightEdgeDragArea.progress
911+ x: windowedRightEdgeMaths.animatedX
912+ y: windowedRightEdgeMaths.animatedY
913+ z: windowedRightEdgeMaths.animatedZ
914+ height: stagedRightEdgeMaths.animatedHeight
915+ requestedWidth: decoratedWindow.oldRequestedWidth
916+ requestedHeight: decoratedWindow.oldRequestedHeight
919+ target: decoratedWindow
920+ showDecoration: windowedRightEdgeMaths.decorationHeight
921+ angle: windowedRightEdgeMaths.animatedAngle
922+ itemScale: windowedRightEdgeMaths.animatedScale
923+ scaleToPreviewSize: spreadItem.stackHeight
924+ scaleToPreviewProgress: windowedRightEdgeMaths.scaleToPreviewProgress
928+ target: opacityEffect;
929+ opacityValue: windowedRightEdgeMaths.opacityMask
930+ sourceItem: windowedRightEdgeMaths.opacityMask < 1 ? decoratedWindow : null
881 name: "staged"; when: root.state == "staged"
934 name: "staged"; when: root.state == "staged"
882 PropertyChanges {
935 PropertyChanges {
883 target: appDelegate
936 target: appDelegate
884− x: appDelegate.focus ? 0 : root.width
937+ x: appDelegate.itemIndex == 0 ? 0 : root.width
885 y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
938 y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
886 requestedWidth: appContainer.width
939 requestedWidth: appContainer.width
887 requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
940 requestedHeight: appDelegate.fullscreen ? appContainer.height : appContainer.height - PanelState.panelHeight
@@ -1099,7 +1152,30 @@ AbstractStage {
1099 from: "normal,staged"; to: "stagedWithSideStage"
1152 from: "normal,staged"; to: "stagedWithSideStage"
1100 UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
1153 UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
1101 UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
1154 UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
1157+ to: "windowedRightEdge"
1161+ print("should calculate overlap from", model.application.appId, "with", appRepeater.itemAt(0).application.appId)
1162+ var thisRect = { x: appDelegate.windowedX, y: appDelegate.windowedY, width: appDelegate.requestedWidth, height: appDelegate.requestedHeight }
1163+ print("thisRect:", thisRect.x, thisRect.y, thisRect.width, thisRect.height)
1164+ var otherDelegate = appRepeater.itemAt(0);
1165+ var otherRect = { x: otherDelegate.windowedX, y: otherDelegate.windowedY, width: otherDelegate.requestedWidth, height: otherDelegate.requestedHeight }
1166+ print("otherRect:", otherRect.x, otherRect.y, otherRect.width, otherRect.height)
1167+ var intersectionRect = MathUtils.intersectionRect(thisRect, otherRect)
1168+ print("intersection is", intersectionRect.x, intersectionRect.y, intersectionRect.width, intersectionRect.height)
1169+ var mappedInterSectionRect = appDelegate.mapFromItem(root, intersectionRect.x, intersectionRect.y)
1170+ opacityEffect.maskX = mappedInterSectionRect.x
1171+ opacityEffect.maskY = mappedInterSectionRect.y
1172+ opacityEffect.maskWidth = intersectionRect.width
1173+ opacityEffect.maskHeight = intersectionRect.height
1105 Binding {
1181 Binding {
@@ -1151,7 +1227,7 @@ AbstractStage {
1151 surface: model.surface
1227 surface: model.surface
1152 active: appDelegate.focus
1228 active: appDelegate.focus
1153 focus: true
1229 focus: true
1154− showDecoration: true
1230+ showDecoration: 1
1155 maximizeButtonShown: (maximumWidth == 0 || maximumWidth >= appContainer.width) &&
1231 maximizeButtonShown: (maximumWidth == 0 || maximumWidth >= appContainer.width) &&
1156 (maximumHeight == 0 || maximumHeight >= appContainer.height)
1232 (maximumHeight == 0 || maximumHeight >= appContainer.height)
1157 overlayShown: touchControls.overlayShown
1233 overlayShown: touchControls.overlayShown
@@ -1179,6 +1255,7 @@ AbstractStage {
1180 property real angle: 0
1256 property real angle: 0
1181 property real itemScale: 1
1257 property real itemScale: 1
1258+ onAngleChanged: print("decoratedWindowd", model.application.appId, "angle", angle)
1182 transform: [
1259 transform: [
1184 origin.x: 0
1261 origin.x: 0
@@ -1194,6 +1271,10 @@ AbstractStage {
1276+ anchors.fill: decoratedWindow
1198 WindowControlsOverlay {
1279 WindowControlsOverlay {
1199 id: touchControls
1280 id: touchControls