on xenial help sign in
adjust progress on left and right to restrict overshooting. Improves the highlight too.
commitd012b1babbf6a5a755a0665962ac17b5bc72f513 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 1 Apr 2015, 12:52 (12 years ago) parenta550870
2 files changed+12−3
qml/Stages/DesktopStage.qml+2−2 qml/Stages/SpreadMaths.qml+10−1
qml/Stages/DesktopStage.qml+2−2
@@ -45,7 +45,7 @@ FocusScope {
4545 function altTabNext() {
4646 if (root.altTabPressed) {
4747 print("should tab next")
48− appRepeater.highlightedIndex = (appRepeater.highlightedIndex + 1) % ApplicationManager.count
48+ appRepeater.highlightedIndex = (appRepeater.highlightedIndex + 1) % ApplicationManager.count;
4949 spreadFlickable.snapTo(spreadFlickable.width / 5 * Math.max(0, Math.min(ApplicationManager.count - 5, appRepeater.highlightedIndex - 3)))
5050 }
5151 }
@@ -315,7 +315,7 @@ FocusScope {
315315 Transition {
316316 from: "*"
317317 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 }
319319 }
320320 ]
321321}
qml/Stages/SpreadMaths.qml+10−1
@@ -25,6 +25,15 @@ Item {
2525 readonly property int flickableWidth: flickable ? flickable.width : 0
2626 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
2727 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+
2837
2938 readonly property int contentWidth: flickableWidth - root.margins * 2
3039
@@ -95,7 +104,7 @@ Item {
95104 type: EasingCurve.InOutSine
96105
97106 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
99108 progress: normalizedProgress
100109 }
101110