on xenial help sign in
do the opacity and scale declaratively
commit6b5fb1a661149c082041b841fb1a65e4e65f347c authorLukáš Tinkl <lukas.tinkl@canonical.com> dateThu 25 Aug 2016, 20:14 (10 years ago) parent5015805
3 files changed+13−26
qml/Shell.qml+2−2 qml/Stages/FakeMaximizeDelegate.qml+10−23 qml/Stages/MoveHandler.qml+1−1
qml/Shell.qml+2−2
@@ -826,8 +826,8 @@ StyledItem {
826826 }
827827 onPushStopped: {
828828 if (previewRectangle) {
829− if (previewRectangle.progress > 0 && previewRectangle.progress < 0.1) {
830− print("!!! Stopping at", previewRectangle.progress)
829+ if (previewRectangle.progress > 0 && previewRectangle.progress < previewRectangle.hintThreshold) {
830+ print("!!! Cancelling preview", previewRectangle.progress)
831831 previewRectangle.stop();
832832 }
833833 }
qml/Stages/FakeMaximizeDelegate.qml+10−23
@@ -21,12 +21,14 @@ import "../Components/PanelState"
2121
2222Rectangle {
2323 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
2525 enabled: visible
2626 color: "#ffffff"
27− border.width: units.dp(1)
27+ border.width: units.dp(2)
2828 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
3032
3133 property int edge: -1 // Item.TransformOrigin
3234 property var target // appDelegate
@@ -34,11 +36,12 @@ Rectangle {
3436 property real appContainerWidth
3537 property real appContainerHeight
3638
39+ readonly property real hintThreshold: 0.1
3740 readonly property bool targetDragging: target && target.moveHandler.dragging
3841
3942 // Edge push progress
4043 // 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)
4245 onProgressChanged: {
4346 print("!!! Progress:", progress)
4447 }
@@ -79,32 +82,17 @@ Rectangle {
7982 fakeRectangle.transformOrigin = edge;
8083 }
8184
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−
9285 function processAnimation(amount, animation) {
9386 priv.push(amount);
9487
95− if (progress > 0.1) { // above 10% we start the full preview animation
96− fakeRectangle.scale = 1;
88+ if (progress > hintThreshold) { // above 10% we start the full preview animation
9789 animation.start();
98− } else {
99− priv.projectScale();
10090 }
101−
102− priv.projectOpacity();
10391 }
10492 }
10593
10694 function commit() {
107− if (progress > 0.1 && edge != -1) {
95+ if (progress > hintThreshold && edge != -1) {
10896 print("!!! Committing edge", edge, ", progress:", progress);
10997 target.moveHandler.handlePressedChanged(false, Qt.LeftButton, 0, 0); // cancel the drag
11098 if (edge == Item.Top) {
@@ -127,9 +115,8 @@ Rectangle {
127115
128116 function stop() {
129117 print("!!! Stop")
130− opacity = 0;
131− edge = -1;
132118 priv.accumulatedPush = 0;
119+ edge = -1;
133120 }
134121
135122 function maximize(amount) {
qml/Stages/MoveHandler.qml+1−1
@@ -29,7 +29,7 @@ Item {
2929 property int stageHeight
3030 property real buttonsWidth: 0
3131
32− property alias dragging: priv.dragging
32+ readonly property alias dragging: priv.dragging
3333
3434 signal fakeMaximizeAnimationRequested(real progress)
3535 signal fakeMaximizeLeftAnimationRequested(real progress)