on xenial help sign in
better indicator switch detection
5387d8dNick Dedekind
qml/Panel/IndicatorsMenu.qml+42−15
@@ -57,17 +57,7 @@ Showable {
57
57
58 height: minimizedPanelHeight
58 height: minimizedPanelHeight
59
59
60− onUnitProgressChanged: {
60+ onUnitProgressChanged: d.updateState()
61− if (!showAnimation.running && !hideAnimation.running) {
62− if (unitProgress <= 0) {
63− root.state = "initial";
64− } else if (unitProgress >= 0.9 && d.hasCommitted) {
65− root.state = "locked";
66− } else {
67− root.state = "reveal";
68− }
69− }
70− }
71 clip: root.partiallyOpened
61 clip: root.partiallyOpened
72
62
73 // eater
63 // eater
@@ -196,12 +186,21 @@ Showable {
196 stretch: true
186 stretch: true
197 maxTotalDragDistance: openedHeight - expandedPanelHeight - handle.height
187 maxTotalDragDistance: openedHeight - expandedPanelHeight - handle.height
198 distanceThreshold: 0
188 distanceThreshold: 0
189+
190+ onTouchSceneXChanged: {
191+ if (root.state === "locked") {
192+ d.xDisplacementSinceLock += (touchSceneX - d.lastHideTouchSceneX)
193+ d.lastHideTouchSceneX = touchSceneX;
194+ }
195+ }
199 }
196 }
200
197
201 PanelVelocityCalculator {
198 PanelVelocityCalculator {
202 id: yVelocityCalculator
199 id: yVelocityCalculator
203− velocityThreshold: 0.5
200+ velocityThreshold: d.hasCommitted ? 0.1 : 0.3
204 trackedValue: d.activeDragHandle ? d.activeDragHandle.touchSceneY : 0
201 trackedValue: d.activeDragHandle ? d.activeDragHandle.touchSceneY : 0
202+
203+ onVelocityAboveThresholdChanged: d.updateState()
205 }
204 }
206
205
207 Connections {
206 Connections {
@@ -226,11 +225,27 @@ Showable {
226 id: d
225 id: d
227 property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
226 property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
228 property bool hasCommitted: false
227 property bool hasCommitted: false
228+ property real lastHideTouchSceneX: 0
229+ property real xDisplacementSinceLock: 0
230+ onXDisplacementSinceLockChanged: d.updateState()
229
231
230 property real rowMappedLateralPosition: {
232 property real rowMappedLateralPosition: {
231 if (!d.activeDragHandle) return -1;
233 if (!d.activeDragHandle) return -1;
232 return d.activeDragHandle.mapToItem(bar, d.activeDragHandle.touchX, 0).x;
234 return d.activeDragHandle.mapToItem(bar, d.activeDragHandle.touchX, 0).x;
233 }
235 }
236+
237+ function updateState() {
238+ if (!showAnimation.running && !hideAnimation.running) {
239+ if (unitProgress <= 0) {
240+ root.state = "initial";
241+ // lock indicator if we've been committed and aren't moving too much laterally or too fast up.
242+ } else if (d.hasCommitted && (Math.abs(d.xDisplacementSinceLock) < units.gu(1) || yVelocityCalculator.velocityAboveThreshold)) {
243+ root.state = "locked";
244+ } else {
245+ root.state = "reveal";
246+ }
247+ }
248+ }
234 }
249 }
235
250
236 states: [
251 states: [
@@ -244,7 +259,8 @@ Showable {
244 script: {
259 script: {
245 yVelocityCalculator.reset();
260 yVelocityCalculator.reset();
246 // initial item selection
261 // initial item selection
247− bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchX : -1);
262+ if (!d.hasCommitted) bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchX : -1);
263+ d.hasCommitted = false;
248 }
264 }
249 }
265 }
250 PropertyChanges {
266 PropertyChanges {
@@ -274,17 +290,28 @@ Showable {
274 return mapped.x;
290 return mapped.x;
275 }
291 }
276 }
292 }
277− PropertyChanges { target: d; hasCommitted: false; restoreEntryValues: false }
278 },
293 },
279 State {
294 State {
280 name: "locked"
295 name: "locked"
296+ StateChangeScript {
297+ script: {
298+ d.xDisplacementSinceLock = 0;
299+ d.lastHideTouchSceneX = hideDragHandle.touchSceneX;
300+ }
301+ }
281 PropertyChanges { target: bar; expanded: true }
302 PropertyChanges { target: bar; expanded: true }
282 },
303 },
283 State {
304 State {
284 name: "commit"
305 name: "commit"
285 extend: "locked"
306 extend: "locked"
286 PropertyChanges { target: bar; interactive: true }
307 PropertyChanges { target: bar; interactive: true }
308+ PropertyChanges {
309+ target: d;
310+ hasCommitted: true
311+ lastHideTouchSceneX: 0
312+ xDisplacementSinceLock: 0
287− PropertyChanges { target: d; hasCommitted: true; restoreEntryValues: false }
313+ restoreEntryValues: false
314+ }
288 }
315 }
289 ]
316 ]
290 state: "initial"
317 state: "initial"