on xenial help sign in
do the opacity and scale declaratively
6b5fb1aLukáš Tinkl
qml/Shell.qml+2−2
@@ -826,8 +826,8 @@ StyledItem {
826 }
826 }
827 onPushStopped: {
827 onPushStopped: {
828 if (previewRectangle) {
828 if (previewRectangle) {
829− if (previewRectangle.progress > 0 && previewRectangle.progress < 0.1) {
829+ if (previewRectangle.progress > 0 && previewRectangle.progress < previewRectangle.hintThreshold) {
830− print("!!! Stopping at", previewRectangle.progress)
830+ print("!!! Cancelling preview", previewRectangle.progress)
831 previewRectangle.stop();
831 previewRectangle.stop();
832 }
832 }
833 }
833 }
qml/Stages/FakeMaximizeDelegate.qml+10−23
@@ -21,12 +21,14 @@ import "../Components/PanelState"
21
21
22Rectangle {
22Rectangle {
23 id: fakeRectangle
23 id: fakeRectangle
24− visible: opacity > 0 && target && !target.anyMaximized // we go from 0.2 to 0.6
24+ visible: opacity > 0 && target && !target.anyMaximized // we go from 0.2 to 0.5
25 enabled: visible
25 enabled: visible
26 color: "#ffffff"
26 color: "#ffffff"
27− border.width: units.dp(1)
27+ border.width: units.dp(2)
28 border.color: "#99ffffff"
28 border.color: "#99ffffff"
29− opacity: 0
29+
30+ scale: progress > 0 && progress <= hintThreshold ? MathUtils.projectValue(progress, 0.0, 1.0, 1, 2) : 1
31+ opacity: progress > 0 ? MathUtils.projectValue(progress, 0.0, 1.0, 0.2, 0.5) : 0
30
32
31 property int edge: -1 // Item.TransformOrigin
33 property int edge: -1 // Item.TransformOrigin
32 property var target // appDelegate
34 property var target // appDelegate
@@ -34,11 +36,12 @@ Rectangle {
34 property real appContainerWidth
36 property real appContainerWidth
35 property real appContainerHeight
37 property real appContainerHeight
36
38
39+ readonly property real hintThreshold: 0.1
37 readonly property bool targetDragging: target && target.moveHandler.dragging
40 readonly property bool targetDragging: target && target.moveHandler.dragging
38
41
39 // Edge push progress
42 // Edge push progress
40 // Value range is [0.0, 1.0]
43 // Value range is [0.0, 1.0]
41− readonly property real progress: Math.min(Math.max(0.0, priv.accumulatedPush / EdgeBarrierSettings.pushThreshold), 1.0)
44+ readonly property real progress: MathUtils.clamp(priv.accumulatedPush / EdgeBarrierSettings.pushThreshold, 0.0, 1.0)
42 onProgressChanged: {
45 onProgressChanged: {
43 print("!!! Progress:", progress)
46 print("!!! Progress:", progress)
44 }
47 }
@@ -79,32 +82,17 @@ Rectangle {
79 fakeRectangle.transformOrigin = edge;
82 fakeRectangle.transformOrigin = edge;
80 }
83 }
81
84
82− function projectOpacity() {
83− // progress falls into [0,1], opacity moves in [0.2,0.6]
84− fakeRectangle.opacity = MathUtils.clampAndProject(progress, 0.0, 1.0, 0.2, 0.6);
85− }
86−
87− function projectScale() {
88− // progress falls into [0,1], scale moves in [1,2] as a hint, when under 10%
89− fakeRectangle.scale = MathUtils.clampAndProject(progress, 0, 1, 1, 2);
90− }
91−
92 function processAnimation(amount, animation) {
85 function processAnimation(amount, animation) {
93 priv.push(amount);
86 priv.push(amount);
94
87
95− if (progress > 0.1) { // above 10% we start the full preview animation
88+ if (progress > hintThreshold) { // above 10% we start the full preview animation
96− fakeRectangle.scale = 1;
97 animation.start();
89 animation.start();
98− } else {
99− priv.projectScale();
100 }
90 }
101−
102− priv.projectOpacity();
103 }
91 }
104 }
92 }
105
93
106 function commit() {
94 function commit() {
107− if (progress > 0.1 && edge != -1) {
95+ if (progress > hintThreshold && edge != -1) {
108 print("!!! Committing edge", edge, ", progress:", progress);
96 print("!!! Committing edge", edge, ", progress:", progress);
109 target.moveHandler.handlePressedChanged(false, Qt.LeftButton, 0, 0); // cancel the drag
97 target.moveHandler.handlePressedChanged(false, Qt.LeftButton, 0, 0); // cancel the drag
110 if (edge == Item.Top) {
98 if (edge == Item.Top) {
@@ -127,9 +115,8 @@ Rectangle {
127
115
128 function stop() {
116 function stop() {
129 print("!!! Stop")
117 print("!!! Stop")
130− opacity = 0;
131− edge = -1;
132 priv.accumulatedPush = 0;
118 priv.accumulatedPush = 0;
119+ edge = -1;
133 }
120 }
134
121
135 function maximize(amount) {
122 function maximize(amount) {
qml/Stages/MoveHandler.qml+1−1
@@ -29,7 +29,7 @@ Item {
29 property int stageHeight
29 property int stageHeight
30 property real buttonsWidth: 0
30 property real buttonsWidth: 0
31
31
32− property alias dragging: priv.dragging
32+ readonly property alias dragging: priv.dragging
33
33
34 signal fakeMaximizeAnimationRequested(real progress)
34 signal fakeMaximizeAnimationRequested(real progress)
35 signal fakeMaximizeLeftAnimationRequested(real progress)
35 signal fakeMaximizeLeftAnimationRequested(real progress)