on xenial help sign in
adjust progress on left and right to restrict overshooting. Improves the highlight too.
d012b1bMichael Zanetti
qml/Stages/DesktopStage.qml+2−2
@@ -45,7 +45,7 @@ FocusScope {
45 function altTabNext() {
45 function altTabNext() {
46 if (root.altTabPressed) {
46 if (root.altTabPressed) {
47 print("should tab next")
47 print("should tab next")
48− appRepeater.highlightedIndex = (appRepeater.highlightedIndex + 1) % ApplicationManager.count
48+ appRepeater.highlightedIndex = (appRepeater.highlightedIndex + 1) % ApplicationManager.count;
49 spreadFlickable.snapTo(spreadFlickable.width / 5 * Math.max(0, Math.min(ApplicationManager.count - 5, appRepeater.highlightedIndex - 3)))
49 spreadFlickable.snapTo(spreadFlickable.width / 5 * Math.max(0, Math.min(ApplicationManager.count - 5, appRepeater.highlightedIndex - 3)))
50 }
50 }
51 }
51 }
@@ -315,7 +315,7 @@ FocusScope {
315 Transition {
315 Transition {
316 from: "*"
316 from: "*"
317 to: "altTab"
317 to: "altTab"
318− PropertyAction { target: spreadFlickable; property: "contentX"; value: (2.6 / ApplicationManager.count) * (spreadFlickable.contentWidth - spreadFlickable.width) }
318+ PropertyAction { target: spreadFlickable; property: "contentX"; value: 0 }
319 }
319 }
320 ]
320 ]
321}
321}
qml/Stages/SpreadMaths.qml+10−1
@@ -25,6 +25,15 @@ Item {
25 readonly property int flickableWidth: flickable ? flickable.width : 0
25 readonly property int flickableWidth: flickable ? flickable.width : 0
26 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
26 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
27 readonly property real flickableProgress: flickable ? flickable.contentX / (flickable.contentWidth - flickableWidth) : 0
27 readonly property real flickableProgress: flickable ? flickable.contentX / (flickable.contentWidth - flickableWidth) : 0
28+ // We require the full flickable progress going from 0 to 1 so the user can drag/overshoot tiles in both directions
29+ // 0 => all the tiles are stacked up on the right edge
30+ // 1 => all the tiles are stacked up on the left edge
31+ // However, we also want to restrict tiles to start/end distributed across the screen, so let's adjust the
32+ // progress to work on a smaller area => trim progress on left and right by progressAdjust
33+ // TODO: 2.6 is a value figured by try&error. Is there a way we can calculate it?
34+ readonly property real progressAdjust: (2.6 / ApplicationManager.count)
35+ readonly property real adjustedProgress: (flickableProgress * (1-2*progressAdjust)) + progressAdjust
36+
28
37
29 readonly property int contentWidth: flickableWidth - root.margins * 2
38 readonly property int contentWidth: flickableWidth - root.margins * 2
30
39
@@ -95,7 +104,7 @@ Item {
95 type: EasingCurve.InOutSine
104 type: EasingCurve.InOutSine
96
105
97 readonly property real normalizedEndProgress: endProgress - startProgress
106 readonly property real normalizedEndProgress: endProgress - startProgress
98− readonly property real normalizedProgress: (root.flickableProgress - root.startProgress) / normalizedEndProgress
107+ readonly property real normalizedProgress: (root.adjustedProgress - root.startProgress) / normalizedEndProgress
99 progress: normalizedProgress
108 progress: normalizedProgress
100 }
109 }
101
110