on xenial help sign in
merge with spread-blur
commita4e2fff4d6de5625ca7fb8bfe7fa9fcf6c09b969 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 8 Nov 2016, 12:02 (10 years ago) parentc54debe8db011a
2 files changed+34−7
qml/Components/BlurLayer.qml+9−5 qml/Stage/Stage.qml+25−2
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/Stage/Stage.qml+25−2
@@ -53,7 +53,7 @@ FocusScope {
5353 property real leftEdgeDragProgress: 0
5454
5555 // Used by the tutorial code
56− 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
5757
5858 // used by the snap windows (edge maximize) feature
5959 readonly property alias previewRectangle: fakeRectangle
@@ -413,12 +413,20 @@ FocusScope {
413413 PropertyChanges { target: hoverMouseArea; enabled: true }
414414 PropertyChanges { target: rightEdgeDragArea; enabled: false }
415415 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
416+ PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65 }
416417 },
417418 State {
418419 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+ }
419426 },
420427 State {
421428 name: "sideStagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "stagedWithSideStage"
429+ extend: "stagedRightEdge"
422430 PropertyChanges {
423431 target: sideStage
424432 opacity: priv.sideStageDelegate.x === sideStage.x ? 1 : 0
@@ -427,9 +435,16 @@ FocusScope {
427435 },
428436 State {
429437 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+ }
430444 },
431445 State {
432446 name: "staged"; when: root.mode === "staged"
447+ PropertyChanges { target: wallpaper; visible: false }
433448 },
434449 State {
435450 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
@@ -444,6 +459,7 @@ FocusScope {
444459 Transition {
445460 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
446461 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
462+ PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
447463 },
448464 Transition {
449465 to: "spread"
@@ -498,6 +514,13 @@ FocusScope {
498514 z: -2
499515 }
500516
517+ BlurLayer {
518+ id: blurLayer
519+ anchors.fill: parent
520+ source: wallpaper
521+ visible: false
522+ }
523+
501524 Spread {
502525 id: spreadItem
503526 objectName: "spreadItem"
@@ -1739,7 +1762,7 @@ FocusScope {
17391762 property var gesturePoints: []
17401763 property bool cancelled: false
17411764
1742− property real progress: dragging ? -touchPosition.x / root.width : 0
1765+ property real progress: -touchPosition.x / root.width
17431766 onProgressChanged: {
17441767 if (dragging) {
17451768 draggedProgress = progress;