on xenial help sign in
improve launcher bahavior

- fix initial snapping - improve foldingAreas behavior - increase clickFlick speed to flick 4 items

commitd99d6b8675bdf2cc96572af9b433ac67b756f2f0 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 2 Jul 2013, 21:19 (13 years ago) parente37e13c
3 files changed+41−16
Launcher/Launcher.qml+1−1 Launcher/LauncherDelegate.qml−1 Launcher/LauncherPanel.qml+40−14
Launcher/Launcher.qml+1−1
@@ -73,7 +73,7 @@ Item {
7373 interval: 5000
7474 onTriggered: {
7575 if (!panel.moving) {
76− root.state = ""
76+// root.state = ""
7777 } else {
7878 dismissTimer.restart()
7979 }
Launcher/LauncherDelegate.qml−1
@@ -65,7 +65,6 @@ Item {
6565 onClicked: root.clicked()
6666 onCanceled: root.released()
6767 preventStealing: false
68− enabled: root.angle < 5
6968
7069 onPressAndHold: {
7170 root.state = "moving"
Launcher/LauncherPanel.qml+40−14
@@ -108,7 +108,6 @@ Item {
108108 height: parent.height - dashItem.height - parent.spacing*2
109109 model: root.model
110110 cacheBuffer: itemSize * 3
111− snapMode: ListView.SnapToItem
112111 highlightRangeMode: ListView.ApplyRange
113112 preferredHighlightBegin: (height - itemSize) / 2
114113 preferredHighlightEnd: (height + itemSize) / 2
@@ -116,14 +115,22 @@ Item {
116115 // The height of the area where icons start getting folded
117116 property int foldingAreaHeight: itemSize * 0.75
118117 property int itemSize: width
119−
120− Component.onCompleted: {
121− // This is needed because snapping would partially fold
122− // the first item on initialisation. This can only be
123− // overridden by mouse interactions - which is what flick()
124− // simulates. Setting contentY to 0 would not work because
125− // of this.
126− flick(0, units.gu(20))
118+ property int clickFlickSpeed: units.gu(60)
119+
120+ // Setting snapMode delayed to make sure the ListView stays positioned
121+ // at the beginning. If the SnapMode is already set when the model
122+ // delivers the items, it's going to snap immediately. Depending on
123+ // the height of the list, this might cause the first item to be half
124+ // folded at the beginning. Once the list is populated we can set the
125+ // snapMode and actually snapping will only happens when the user
126+ // interacts with the list.
127+ Timer {
128+ interval: 1
129+ running: true
130+ repeat: false
131+ onTriggered: {
132+ launcherListView.snapMode = ListView.SnapToItem
133+ }
127134 }
128135
129136 delegate: LauncherDelegate {
@@ -139,7 +146,26 @@ Item {
139146 maxAngle: 60
140147
141148 onClicked: {
142− root.applicationSelected(launcherModel.get(index).desktopFile);
149+ // First/last item do the scrolling at more than 12 degrees
150+ if (index == 0 || index == launcherListView.count -1) {
151+ if (angle > 12) {
152+ launcherListView.flick(0, -launcherListView.clickFlickSpeed);
153+ } else if (angle < -12) {
154+ launcherListView.flick(0, launcherListView.clickFlickSpeed);
155+ } else {
156+ root.applicationSelected(launcherModel.get(index).desktopFile);
157+ }
158+ return;
159+ }
160+
161+ // the rest launches apps up to an angle of 30 degrees
162+ if (angle > 30) {
163+ launcherListView.flick(0, -launcherListView.clickFlickSpeed);
164+ } else if (angle < -30) {
165+ launcherListView.flick(0, launcherListView.clickFlickSpeed);
166+ } else {
167+ root.applicationSelected(launcherModel.get(index).desktopFile);
168+ }
143169 }
144170 }
145171
@@ -151,9 +177,9 @@ Item {
151177 top: parent.top
152178 topMargin: launcherListView.topMargin
153179 }
154− height: launcherListView.itemSize
180+ height: launcherListView.itemSize / 2
155181 enabled: launcherListView.contentY > -launcherListView.topMargin
156− onClicked: launcherListView.flick(0, units.gu(40))
182+ onClicked: launcherListView.flick(0, launcherListView.clickFlickSpeed)
157183 }
158184
159185 MouseArea {
@@ -164,9 +190,9 @@ Item {
164190 bottom: parent.bottom
165191 bottomMargin: launcherListView.bottomMargin
166192 }
167− height: launcherListView.itemSize
193+ height: launcherListView.itemSize / 2
168194 enabled: launcherListView.contentHeight - launcherListView.height - launcherListView.contentY > -launcherListView.bottomMargin
169− onClicked: launcherListView.flick(0, -units.gu(40))
195+ onClicked: launcherListView.flick(0, -launcherListView.clickFlickSpeed)
170196 }
171197 }
172198 }