on xenial help sign in
merge lp:~mzanetti/unity8/spread-fixes
commit196356b6fe02dabbf6914156ea485827313cfb1d authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 8 Nov 2016, 16:35 (10 years ago) parent8e86b3ca4e2fff
5 files changed+59−16
qml/Components/BlurLayer.qml+9−5 qml/Shell.qml+2−1 qml/Stage/Spread/Spread.qml+1−1 qml/Stage/Spread/SpreadDelegateInputArea.qml+7−1 qml/Stage/Stage.qml+40−8
qml/Components/BlurLayer.qml+9−5
@@ -21,8 +21,9 @@ Item {
2121 id: root
2222
2323 property alias source: shaderEffectSource.sourceItem
24− property alias saturation: desaturateEffect.saturationValue
25− property alias blurRadius: fastBlur.radius
24+ property real saturation: 1
25+ property real brightness: 1
26+ property real blurRadius: 0
2627
2728 readonly property alias ready: shaderEffectSource.ready
2829
@@ -30,7 +31,8 @@ Item {
3031 id: desaturateEffect
3132 anchors.fill: root
3233
33− property real saturationValue: 1
34+ property real saturationValue: Math.min(Math.max(root.saturation, 0), 1)
35+ property real brightnessValue: Math.min(Math.max(root.brightness, 0), 1)
3436
3537 property variant source: ShaderEffectSource {
3638 id: shaderEffectSource
@@ -50,12 +52,14 @@ Item {
5052 varying highp vec2 qt_TexCoord0;
5153 uniform sampler2D source;
5254 uniform lowp float saturationValue;
55+ uniform lowp float brightnessValue;
5356 void main(void)
5457 {
5558 highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
5659 highp vec4 scaledColor = sourceColor * vec4(0.3, 0.59, 0.11, 1.0);
5760 lowp float luminance = scaledColor.r + scaledColor.g + scaledColor.b ;
58− gl_FragColor = mix(vec4(luminance, luminance, luminance, sourceColor.a), sourceColor, saturationValue);
61+ highp vec4 tmp = mix(vec4(luminance, luminance, luminance, sourceColor.a), sourceColor, saturationValue);
62+ gl_FragColor = mix(vec4(0, 0, 0, 1), tmp, brightnessValue);
5963 }"
6064 }
6165
@@ -64,6 +68,6 @@ Item {
6468 anchors.fill: parent
6569 source: desaturateEffect
6670 visible: radius > 0
67− radius: 0
71+ radius: Math.max(root.blurRadius, 0)
6872 }
6973}
qml/Shell.qml+2−1
@@ -442,9 +442,10 @@ StyledItem {
442442 }
443443
444444 if (!greeter.locked && tutorial.launcherLongSwipeEnabled
445− && ApplicationManager.focusedApplicationId != "unity8-dash") {
445+ && (ApplicationManager.focusedApplicationId != "unity8-dash" || stage.spreadShown)) {
446446 ApplicationManager.requestFocusApplication("unity8-dash")
447447 launcher.fadeOut();
448+ stage.closeSpread();
448449 }
449450 }
450451
qml/Stage/Spread/Spread.qml+1−1
@@ -91,7 +91,7 @@ Item {
9191
9292 readonly property real visibleItemCount: (spreadWidth / spreadItemWidth) / (1 - itemOverlap)
9393
94− readonly property real spreadTotalWidth: totalItemCount * spreadWidth / visibleItemCount
94+ readonly property real spreadTotalWidth: Math.max(2,totalItemCount) * spreadWidth / visibleItemCount
9595
9696 readonly property real centeringOffset: Math.max(spreadWidth - spreadTotalWidth ,0) / (2 * spreadWidth)
9797
qml/Stage/Spread/SpreadDelegateInputArea.qml+7−1
@@ -119,7 +119,13 @@ Item {
119119 }
120120 }
121121
122− d.distance = tp.y - tp.startY - offset
122+ if (root.closeable) {
123+ d.distance = tp.y - tp.startY - offset
124+ } else {
125+ var value = tp.y - tp.startY - offset;
126+ d.distance = Math.sqrt(Math.abs(value)) * (value < 0 ? -1 : 1) * 3
127+ }
128+
123129 d.pushDragEvent(tp);
124130 }
125131
qml/Stage/Stage.qml+40−8
@@ -53,18 +53,18 @@ FocusScope {
5353 property real leftEdgeDragProgress: 0
5454
5555 // Used by the tutorial code
56− readonly property bool spreadShown: state == "spread"
57− readonly property real rightEdgeDragProgress: rightEdgeDragArea.progress // How far left the stage has been dragged
56+ readonly property real rightEdgeDragProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0 // How far left the stage has been dragged
5857
5958 // used by the snap windows (edge maximize) feature
6059 readonly property alias previewRectangle: fakeRectangle
6160
61+ readonly property bool spreadShown: state == "spread"
6262 readonly property var mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
6363
6464 // application windows never rotate independently
6565 property int mainAppWindowOrientationAngle: shellOrientationAngle
6666
67− property bool orientationChangesEnabled: priv.focusedAppDelegate && priv.focusedAppDelegate.orientationChangesEnabled
67+ property bool orientationChangesEnabled: !priv.focusedAppDelegate || priv.focusedAppDelegate.orientationChangesEnabled
6868
6969 property int supportedOrientations: {
7070 if (mainApp) {
@@ -105,9 +105,13 @@ FocusScope {
105105 edgeBarrier.push(amount);
106106 }
107107
108+ function closeSpread() {
109+ priv.goneToSpread = false;
110+ }
111+
108112 onSpreadEnabledChanged: {
109− if (!spreadEnabled && root.state == "spread") {
110− priv.goneToSpread = false;
113+ if (!spreadEnabled && spreadShown) {
114+ closeSpread();
111115 }
112116 }
113117
@@ -409,12 +413,20 @@ FocusScope {
409413 PropertyChanges { target: hoverMouseArea; enabled: true }
410414 PropertyChanges { target: rightEdgeDragArea; enabled: false }
411415 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
416+ PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65 }
412417 },
413418 State {
414419 name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
420+ PropertyChanges {
421+ target: blurLayer;
422+ visible: true;
423+ blurRadius: 32
424+ brightness: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, .65, Math.max(rightEdgeDragArea.progress, edgeBarrier.progress))
425+ }
415426 },
416427 State {
417428 name: "sideStagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "stagedWithSideStage"
429+ extend: "stagedRightEdge"
418430 PropertyChanges {
419431 target: sideStage
420432 opacity: priv.sideStageDelegate.x === sideStage.x ? 1 : 0
@@ -423,9 +435,16 @@ FocusScope {
423435 },
424436 State {
425437 name: "windowedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "windowed"
438+ PropertyChanges {
439+ target: blurLayer;
440+ visible: true
441+ blurRadius: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 32, Math.max(rightEdgeDragArea.progress, edgeBarrier.progress))
442+ brightness: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 1, .65, Math.max(rightEdgeDragArea.progress, edgeBarrier.progress))
443+ }
426444 },
427445 State {
428446 name: "staged"; when: root.mode === "staged"
447+ PropertyChanges { target: wallpaper; visible: false }
429448 },
430449 State {
431450 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
@@ -440,6 +459,7 @@ FocusScope {
440459 Transition {
441460 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
442461 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
462+ PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
443463 },
444464 Transition {
445465 to: "spread"
@@ -462,7 +482,7 @@ FocusScope {
462482 }
463483 },
464484 Transition {
465− to: "stagedRightEdge"
485+ to: "stagedRightEdge,sideStagedRightEdge"
466486 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
467487 },
468488 Transition {
@@ -494,6 +514,13 @@ FocusScope {
494514 z: -2
495515 }
496516
517+ BlurLayer {
518+ id: blurLayer
519+ anchors.fill: parent
520+ source: wallpaper
521+ visible: false
522+ }
523+
497524 Spread {
498525 id: spreadItem
499526 objectName: "spreadItem"
@@ -1052,6 +1079,7 @@ FocusScope {
10521079 showHighlight: spreadItem.highlightedIndex === index
10531080 darkening: spreadItem.highlightedIndex >= 0
10541081 anchors.topMargin: dragArea.distance
1082+ interactive: false
10551083 }
10561084 PropertyChanges {
10571085 target: appDelegate
@@ -1091,7 +1119,10 @@ FocusScope {
10911119 scaleToPreviewSize: spreadItem.stackHeight
10921120 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
10931121 shadowOpacity: .3
1122+ interactive: false
10941123 }
1124+ // make sure it's visible but transparent so it fades in when we transition to spread
1125+ PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
10951126 },
10961127 State {
10971128 name: "windowedRightEdge"
@@ -1350,6 +1381,7 @@ FocusScope {
13501381 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
13511382 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
13521383 UbuntuNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1384+ UbuntuNumberAnimation { target: windowInfoItem; properties: "opacity"; duration: priv.animationDuration }
13531385 },
13541386 Transition {
13551387 from: "normal,staged"; to: "stagedWithSideStage"
@@ -1562,7 +1594,7 @@ FocusScope {
15621594 maxWidth: {
15631595 var nextApp = appRepeater.itemAt(index + 1);
15641596 if (nextApp) {
1565− return nextApp.x - appDelegate.x - units.gu(1)
1597+ return Math.max(iconHeight, nextApp.x - appDelegate.x - units.gu(1))
15661598 }
15671599 return appDelegate.width;
15681600 }
@@ -1730,7 +1762,7 @@ FocusScope {
17301762 property var gesturePoints: []
17311763 property bool cancelled: false
17321764
1733− property real progress: dragging ? -touchPosition.x / root.width : 0
1765+ property real progress: -touchPosition.x / root.width
17341766 onProgressChanged: {
17351767 if (dragging) {
17361768 draggedProgress = progress;