on xenial help sign in
fix touch dragging \o/
commit4ae834f6062578976d51a93994fc8c091c316428 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 31 Aug 2016, 13:26 (10 years ago) parent6eab3ed
4 files changed+56−49
qml/Stages/DesktopStage.qml+7−7 qml/Stages/FakeMaximizeDelegate.qml+25−17 qml/Stages/MoveHandler.qml+17−18 qml/Stages/WindowControlsOverlay.qml+7−7
qml/Stages/DesktopStage.qml+7−7
@@ -756,13 +756,13 @@ AbstractStage {
756756 stageWidth: appContainer.width
757757 stageHeight: appContainer.height
758758
759− onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount)
760− onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount)
761− onFakeMaximizeRightAnimationRequested: if (!appDelegate.maximizedRight) fakeRectangle.maximizeRight(amount)
762− onFakeMaximizeTopLeftAnimationRequested: if (!appDelegate.maximizedTopLeft) fakeRectangle.maximizeTopLeft(amount);
763− onFakeMaximizeTopRightAnimationRequested: if (!appDelegate.maximizedTopRight) fakeRectangle.maximizeTopRight(amount);
764− onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount);
765− onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount);
759+ onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
760+ onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
761+ onFakeMaximizeRightAnimationRequested: if (!appDelegate.maximizedRight) fakeRectangle.maximizeRight(amount, true)
762+ onFakeMaximizeTopLeftAnimationRequested: if (!appDelegate.maximizedTopLeft) fakeRectangle.maximizeTopLeft(amount, true);
763+ onFakeMaximizeTopRightAnimationRequested: if (!appDelegate.maximizedTopRight) fakeRectangle.maximizeTopRight(amount, true);
764+ onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
765+ onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
766766 onStopFakeAnimation: fakeRectangle.stop();
767767 onShouldCommitSnapWindow: fakeRectangle.commit();
768768 }
qml/Stages/FakeMaximizeDelegate.qml+25−17
@@ -41,7 +41,7 @@ Rectangle {
4141
4242 // Edge push progress
4343 // Value range is [0.0, 1.0]
44− readonly property real progress: MathUtils.clamp(priv.accumulatedPush / EdgeBarrierSettings.pushThreshold, 0.0, 1.0)
44+ readonly property real progress: priv.directProgress != -1 ? priv.directProgress : priv.accumulatedProgress
4545 onProgressChanged: {
4646 print("!!! Progress:", progress)
4747 }
@@ -51,6 +51,8 @@ Rectangle {
5151 QtObject {
5252 id: priv
5353
54+ readonly property real accumulatedProgress: MathUtils.clamp(accumulatedPush / EdgeBarrierSettings.pushThreshold, 0.0, 1.0)
55+ property real directProgress: -1
5456 property real accumulatedPush: 0
5557
5658 function push(amount) {
@@ -85,8 +87,13 @@ Rectangle {
8587 fakeRectangle.transformOrigin = edge;
8688 }
8789
88− function processAnimation(amount, animation) {
89− priv.push(amount);
90+ function processAnimation(amount, animation, isProgress) {
91+ if (isProgress) {
92+ priv.directProgress = amount;
93+ } else {
94+ priv.directProgress = -1;
95+ priv.push(amount);
96+ }
9097
9198 if (progress > hintThreshold) { // above 10% we start the full preview animation
9299 animation.start();
@@ -121,56 +128,57 @@ Rectangle {
121128 function stop() {
122129 print("!!! Stop")
123130 priv.accumulatedPush = 0;
131+ priv.directProgress = -1;
124132 edge = -1;
125133 }
126134
127− function maximize(amount) {
135+ function maximize(amount, isProgress) {
128136 if (fakeRectangle.edge != Item.Top) {
129137 priv.setup(Item.Top);
130138 }
131− priv.processAnimation(amount, fakeMaximizeAnimation);
139+ priv.processAnimation(amount, fakeMaximizeAnimation, isProgress);
132140 }
133141
134− function maximizeLeft(amount) {
142+ function maximizeLeft(amount, isProgress) {
135143 if (fakeRectangle.edge != Item.Left) {
136144 priv.setup(Item.Left);
137145 }
138− priv.processAnimation(amount, fakeMaximizeLeftAnimation);
146+ priv.processAnimation(amount, fakeMaximizeLeftAnimation, isProgress);
139147 }
140148
141− function maximizeRight(amount) {
149+ function maximizeRight(amount, isProgress) {
142150 if (fakeRectangle.edge != Item.Right) {
143151 priv.setup(Item.Right);
144152 }
145− priv.processAnimation(amount, fakeMaximizeRightAnimation);
153+ priv.processAnimation(amount, fakeMaximizeRightAnimation, isProgress);
146154 }
147155
148− function maximizeTopLeft(amount) {
156+ function maximizeTopLeft(amount, isProgress) {
149157 if (fakeRectangle.edge != Item.TopLeft) {
150158 priv.setup(Item.TopLeft);
151159 }
152− priv.processAnimation(amount, fakeMaximizeTopLeftAnimation);
160+ priv.processAnimation(amount, fakeMaximizeTopLeftAnimation, isProgress);
153161 }
154162
155− function maximizeTopRight(amount) {
163+ function maximizeTopRight(amount, isProgress) {
156164 if (fakeRectangle.edge != Item.TopRight) {
157165 priv.setup(Item.TopRight);
158166 }
159− priv.processAnimation(amount, fakeMaximizeTopRightAnimation);
167+ priv.processAnimation(amount, fakeMaximizeTopRightAnimation, isProgress);
160168 }
161169
162− function maximizeBottomLeft(amount) {
170+ function maximizeBottomLeft(amount, isProgress) {
163171 if (fakeRectangle.edge != Item.BottomLeft) {
164172 priv.setup(Item.BottomLeft);
165173 }
166− priv.processAnimation(amount, fakeMaximizeBottomLeftAnimation);
174+ priv.processAnimation(amount, fakeMaximizeBottomLeftAnimation, isProgress);
167175 }
168176
169− function maximizeBottomRight(amount) {
177+ function maximizeBottomRight(amount, isProgress) {
170178 if (fakeRectangle.edge != Item.BottomRight) {
171179 priv.setup(Item.BottomRight);
172180 }
173− priv.processAnimation(amount, fakeMaximizeBottomRightAnimation);
181+ priv.processAnimation(amount, fakeMaximizeBottomRightAnimation, isProgress);
174182 }
175183
176184 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
qml/Stages/MoveHandler.qml+17−18
@@ -119,46 +119,45 @@ Item {
119119 target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
120120
121121 if (sensingPoints) { // edge/corner detection when dragging via the touch overlay
122− if (sensingPoints.topLeft.x < priv.triggerArea && sensingPoints.topLeft.y < PanelState.panelHeight
122+ if (sensingPoints.topLeft.x < priv.triggerArea && sensingPoints.topLeft.y < PanelState.panelHeight + priv.triggerArea
123123 && target.canBeCornerMaximized) { // top left
124− priv.progress = priv.progressInCorner(0, PanelState.panelHeight, sensingPoints.topLeft.x, sensingPoints.topLeft.y) - priv.progress;
124+ priv.progress = priv.progressInCorner(0, PanelState.panelHeight, sensingPoints.topLeft.x, sensingPoints.topLeft.y);
125125 priv.resetEdges();
126126 priv.nearTopLeftCorner = true;
127− root.fakeMaximizeTopLeftAnimationRequested(priv.progress * priv.triggerArea);
128− } else if (sensingPoints.topRight.x > stageWidth - priv.triggerArea && sensingPoints.topRight.y < PanelState.panelHeight
127+ root.fakeMaximizeTopLeftAnimationRequested(priv.progress);
128+ } else if (sensingPoints.topRight.x > stageWidth - priv.triggerArea && sensingPoints.topRight.y < PanelState.panelHeight + priv.triggerArea
129129 && target.canBeCornerMaximized) { // top right
130− priv.progress = priv.progressInCorner(stageWidth, PanelState.panelHeight, sensingPoints.topRight.x, sensingPoints.topRight.y) - priv.progress;
130+ priv.progress = priv.progressInCorner(stageWidth, PanelState.panelHeight, sensingPoints.topRight.x, sensingPoints.topRight.y);
131131 priv.resetEdges();
132132 priv.nearTopRightCorner = true;
133− root.fakeMaximizeTopRightAnimationRequested(priv.progress * priv.triggerArea);
133+ root.fakeMaximizeTopRightAnimationRequested(priv.progress);
134134 } else if (sensingPoints.bottomLeft.x < priv.triggerArea && sensingPoints.bottomLeft.y > stageHeight - priv.triggerArea
135135 && target.canBeCornerMaximized) { // bottom left
136− priv.progress = priv.progressInCorner(0, stageHeight, sensingPoints.bottomLeft.x, sensingPoints.bottomLeft.y) - priv.progress;
136+ priv.progress = priv.progressInCorner(0, stageHeight, sensingPoints.bottomLeft.x, sensingPoints.bottomLeft.y);
137137 priv.resetEdges();
138138 priv.nearBottomLeftCorner = true;
139− root.fakeMaximizeBottomLeftAnimationRequested(priv.progress * priv.triggerArea);
139+ root.fakeMaximizeBottomLeftAnimationRequested(priv.progress);
140140 } else if (sensingPoints.bottomRight.x > stageWidth - priv.triggerArea && sensingPoints.bottomRight.y > stageHeight - priv.triggerArea
141141 && target.canBeCornerMaximized) { // bottom right
142− priv.progress = priv.progressInCorner(stageWidth, stageHeight, sensingPoints.bottomRight.x, sensingPoints.bottomRight.y) - priv.progress;
142+ priv.progress = priv.progressInCorner(stageWidth, stageHeight, sensingPoints.bottomRight.x, sensingPoints.bottomRight.y);
143143 priv.resetEdges();
144144 priv.nearBottomRightCorner = true;
145− root.fakeMaximizeBottomRightAnimationRequested(priv.progress * priv.triggerArea);
145+ root.fakeMaximizeBottomRightAnimationRequested(priv.progress);
146146 } else if (sensingPoints.left.x < priv.triggerArea && target.canBeMaximizedLeftRight) { // left
147− priv.progress = MathUtils.clampAndProject(sensingPoints.left.x, priv.triggerArea, 0, 0, 1) - priv.progress;
147+ priv.progress = MathUtils.clampAndProject(sensingPoints.left.x, priv.triggerArea, 0, 0, 1);
148148 priv.resetEdges();
149149 priv.nearLeftEdge = true;
150− root.fakeMaximizeLeftAnimationRequested(priv.progress * priv.triggerArea);
150+ root.fakeMaximizeLeftAnimationRequested(priv.progress);
151151 } else if (sensingPoints.right.x > stageWidth - priv.triggerArea && target.canBeMaximizedLeftRight) { // right
152− priv.progress = MathUtils.clampAndProject(sensingPoints.right.x, stageWidth - priv.triggerArea, stageWidth, 0, 1) - priv.progress;
152+ priv.progress = MathUtils.clampAndProject(sensingPoints.right.x, stageWidth - priv.triggerArea, stageWidth, 0, 1);
153153 priv.resetEdges();
154154 priv.nearRightEdge = true;
155− root.fakeMaximizeRightAnimationRequested(priv.progress * priv.triggerArea);
156− } else if (sensingPoints.top.y < PanelState.panelHeight && target.canBeMaximized) { // top
157− priv.progress = MathUtils.clampAndProject(sensingPoints.top.y, Math.max(PanelState.panelHeight, priv.triggerArea), 0, 0, 1) - priv.progress;
155+ root.fakeMaximizeRightAnimationRequested(priv.progress);
156+ } else if (sensingPoints.top.y < PanelState.panelHeight + priv.triggerArea && target.canBeMaximized) { // top
157+ priv.progress = MathUtils.clampAndProject(sensingPoints.top.y, PanelState.panelHeight + priv.triggerArea, 0, 0, 1);
158158 priv.resetEdges();
159159 priv.nearTopEdge = true;
160− root.fakeMaximizeAnimationRequested(priv.progress * priv.triggerArea);
161− priv.progress = tmpProgress;
160+ root.fakeMaximizeAnimationRequested(priv.progress);
162161 } else if (priv.nearLeftEdge || priv.nearRightEdge || priv.nearTopEdge || priv.nearTopLeftCorner || priv.nearTopRightCorner ||
163162 priv.nearBottomLeftCorner || priv.nearBottomRightCorner) {
164163 print("!!! Exited")
qml/Stages/WindowControlsOverlay.qml+7−7
@@ -161,13 +161,13 @@ Item {
161161 objectName: "moveHandler"
162162 target: root.target
163163
164− onFakeMaximizeAnimationRequested: root.fakeMaximizeAnimationRequested(progress)
165− onFakeMaximizeLeftAnimationRequested: root.fakeMaximizeLeftAnimationRequested(progress)
166− onFakeMaximizeRightAnimationRequested: root.fakeMaximizeRightAnimationRequested(progress)
167− onFakeMaximizeTopLeftAnimationRequested: root.fakeMaximizeTopLeftAnimationRequested(progress)
168− onFakeMaximizeTopRightAnimationRequested: root.fakeMaximizeTopRightAnimationRequested(progress)
169− onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(progress)
170− onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(progress)
164+ onFakeMaximizeAnimationRequested: root.fakeMaximizeAnimationRequested(amount)
165+ onFakeMaximizeLeftAnimationRequested: root.fakeMaximizeLeftAnimationRequested(amount)
166+ onFakeMaximizeRightAnimationRequested: root.fakeMaximizeRightAnimationRequested(amount)
167+ onFakeMaximizeTopLeftAnimationRequested: root.fakeMaximizeTopLeftAnimationRequested(amount)
168+ onFakeMaximizeTopRightAnimationRequested: root.fakeMaximizeTopRightAnimationRequested(amount)
169+ onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(amount)
170+ onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(amount)
171171 onStopFakeAnimation: root.stopFakeAnimation()
172172 onShouldCommitSnapWindow: root.shouldCommitSnapWindow();
173173 }