Fix flickable speed to be resolution independent, by subclassing components Fixes: 1348557
Approved by: Albert Astals Cid
commit9f68029c899cc3b795717ab546f3301c89d429b3
authorAndrea Cimitan <andrea.cimitan@gmail.com>
dateMon 13 Oct 2014, 15:42 (12 years ago)
parent16cc3a97f38f3f
qml/Components/Carousel.qml+2−3
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import "carousel.js" as CarouselJS
20+import "Flickables" as Flickables
2021
2122/*! The Carousel component presents the items of a model in a carousel view. It's similar to a
2223 cover flow. But it stops at it's boundaries (therefore no PathView is used).
@@ -63,7 +64,7 @@ Item {
6364 and footer item to compensate that.
6465
6566 The scaling of the items is controlled by the variable continuousIndex, described below. */
66− ListView {
67+ Flickables.ListView {
6768 id: listView
6869 objectName: "listView"
6970
@@ -135,8 +136,6 @@ Item {
135136
136137 boundsBehavior: Flickable.DragOverBounds
137138 cacheBuffer: carousel.cacheBuffer
138− flickDeceleration: Math.max(1500 * Math.pow(realWidth / referenceWidth, 1.5), 1500) // 1500 is platform default
139− maximumFlickVelocity: Math.max(2500 * Math.pow(realWidth / referenceWidth, 1.5), 2500) // 2500 is platform default
140139 orientation: ListView.Horizontal
141140
142141 function getXFromContinuousIndex(index) {
qml/Components/Flickables/Flickable.qmlnew file+23
@@ -0,0 +1,23 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.3 as QtQuick
18+import Ubuntu.Components 1.1
19+
20+QtQuick.Flickable {
21+ flickDeceleration: 1500 * units.gridUnit / 8
22+ maximumFlickVelocity: 2500 * units.gridUnit / 8
23+}
qml/Components/Flickables/GridView.qmlnew file+25
@@ -0,0 +1,25 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.3 as QtQuick
18+import Ubuntu.Components 1.1
19+
20+QtQuick.GridView {
21+ // Attached components and usages like GridView.onRemove are known not to work
22+ // please use GridView directly from QtQuick if needed
23+ flickDeceleration: 1500 * units.gridUnit / 8
24+ maximumFlickVelocity: 2500 * units.gridUnit / 8
25+}
qml/Components/Flickables/ListView.qmlnew file+25
@@ -0,0 +1,25 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.3 as QtQuick
18+import Ubuntu.Components 1.1
19+
20+QtQuick.ListView {
21+ // Attached components and usages like ListView.onRemove are known not to work
22+ // please use ListView directly from QtQuick if needed
23+ flickDeceleration: 1500 * units.gridUnit / 8
24+ maximumFlickVelocity: 2500 * units.gridUnit / 8
25+}
qml/Components/Flickables/ListViewWithPageHeader.qmlnew file+23
@@ -0,0 +1,23 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import Dash 0.1
18+import Ubuntu.Components 1.1
19+
20+ListViewWithPageHeader {
21+ flickDeceleration: 1500 * units.gridUnit / 8
22+ maximumFlickVelocity: 2500 * units.gridUnit / 8
23+}
qml/Components/ResponsiveGridView.qml+2−1
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.3
1818import Ubuntu.Components 0.1
19+import "Flickables" as Flickables
1920
2021/*
2122 Essentially a GridView where you can specify the maximum number of columns it can have.
@@ -55,7 +56,7 @@ Item {
5556 return rows * height
5657 }
5758
58− GridView {
59+ Flickables.GridView {
5960 id: gridView
6061 objectName: "responsiveGridViewGrid"
6162 anchors {
qml/Components/ZoomableImage.qml+2−2
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import "../Components"
19+import "Flickables" as Flickables
2020
2121/*! \brief Zoomable for image.
2222
@@ -32,7 +32,7 @@ Item {
3232 property alias scaleTo: lazyImage.scaleTo
3333 property alias asynchronous: lazyImage.asynchronous
3434
35− Flickable {
35+ Flickables.Flickable {
3636 id: flickable
3737 objectName: "flickable"
3838 clip: true
qml/Dash/CardHorizontalList.qml+2−1
@@ -17,6 +17,7 @@
1717import QtQuick 2.2
1818import Ubuntu.Components 1.1
1919import "../Components"
20+import "../Components/Flickables" as Flickables
2021
2122DashRenderer {
2223 id: root
@@ -25,7 +26,7 @@ DashRenderer {
2526 collapsedHeight: expandedHeight
2627 clip: true
2728
28− ListView {
29+ Flickables.ListView {
2930 id: listView
3031 anchors {
3132 fill: parent
qml/Dash/DashContent.qml+2−3
@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
1919import Unity 0.2
2020import Utils 0.1
2121import "../Components"
22+import "../Components/Flickables" as Flickables
2223
2324Item {
2425 id: dashContent
@@ -97,7 +98,7 @@ Item {
9798 anchors.fill: parent
9899 }
99100
100− ListView {
101+ Flickables.ListView {
101102 id: dashContentList
102103 objectName: "dashContentList"
103104
@@ -105,8 +106,6 @@ Item {
105106 anchors.fill: parent
106107 orientation: ListView.Horizontal
107108 boundsBehavior: Flickable.DragAndOvershootBounds
108− flickDeceleration: units.gu(625)
109− maximumFlickVelocity: width * 5
110109 snapMode: ListView.SnapOneItem
111110 highlightMoveDuration: 250
112111 highlightRangeMode: ListView.StrictlyEnforceRange
qml/Dash/DashNavigationButton.qml+2−1
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.2
1818import Ubuntu.Components 1.1
19+import "../Components/Flickables" as Flickables
1920
2021AbstractButton {
2122 id: root
@@ -75,7 +76,7 @@ AbstractButton {
7576 }
7677
7778 // navigationListView is outside root
78− ListView {
79+ Flickables.ListView {
7980 id: navigationListView
8081 objectName: "navigationListView"
8182 visible: height > 0
qml/Dash/DashNavigationList.qml+2−1
@@ -17,6 +17,7 @@
1717import QtQuick 2.2
1818import Ubuntu.Components 1.1
1919import "../Components"
20+import "../Components/Flickables" as Flickables
2021
2122Item {
2223 id: root
@@ -45,7 +46,7 @@ Item {
4546 }
4647 }
4748
48− Flickable {
49+ Flickables.Flickable {
4950 id: flickable
5051
5152 anchors.fill: parent
qml/Dash/PageHeader.qml+2−1
@@ -21,6 +21,7 @@ import Ubuntu.Components.Popups 1.0
2121import Ubuntu.Components.ListItems 1.0
2222import "../Components"
2323import "../Components/SearchHistoryModel"
24+import "../Components/Flickables" as Flickables
2425
2526Item {
2627 id: root
@@ -127,7 +128,7 @@ Item {
127128 }
128129 }
129130
130− Flickable {
131+ Flickables.Flickable {
131132 id: headerContainer
132133 objectName: "headerContainer"
133134 clip: contentY < height
qml/Dash/PreviewListView.qml+2−3
@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Unity 0.2
2020import "../Components"
21+import "../Components/Flickables" as Flickables
2122import "Previews" as Previews
2223
2324Item {
@@ -52,7 +53,7 @@ Item {
5253 onBackClicked: root.backClicked()
5354 }
5455
55− ListView {
56+ Flickables.ListView {
5657 id: previewListView
5758 objectName: "listView"
5859 anchors {
@@ -66,8 +67,6 @@ Item {
6667 snapMode: ListView.SnapOneItem
6768 boundsBehavior: Flickable.DragAndOvershootBounds
6869 highlightMoveDuration: 250
69− flickDeceleration: units.gu(625)
70− maximumFlickVelocity: width * 5
7170 cacheBuffer: 0
7271
7372 property bool open: false
qml/Dash/Previews/Preview.qml+2−1
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import "../../Components/Flickables" as Flickables
1920
2021/*! \brief This component constructs the Preview UI.
2122 *
@@ -63,7 +64,7 @@ Item {
6364 Repeater {
6465 model: previewModel
6566
66− delegate: ListView {
67+ delegate: Flickables.ListView {
6768 id: column
6869 anchors { top: parent.top; bottom: parent.bottom }
6970 width: row.columnWidth
qml/Dash/Previews/PreviewImageGallery.qml+3−2
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 1.1
1919import "../../Components"
20+import "../../Components/Flickables" as Flickables
2021
2122/*! This preview widget shows a horizontal list of images.
2223 * The URIs for the images should be an array in widgetData["sources"].
@@ -28,7 +29,7 @@ PreviewWidget {
2829
2930 property Item rootItem: QuickUtils.rootItem(root)
3031
31− ListView {
32+ Flickables.ListView {
3233 id: previewImageListView
3334 objectName: "previewImageListView"
3435 spacing: units.gu(1)
@@ -102,7 +103,7 @@ PreviewWidget {
102103 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
103104 }
104105
105− ListView {
106+ Flickables.ListView {
106107 id: slideShowListView
107108 objectName: "slideShowListView"
108109 anchors.fill: parent
qml/Dash/ScopeListView.qml+3−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2014 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -14,11 +14,8 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import QtQuick 2.0
18−import Dash 0.1
17+import "../Components/Flickables" as Flickables
1918
20−ListViewWithPageHeader {
21− maximumFlickVelocity: height * 10
22− flickDeceleration: height * 2
19+Flickables.ListViewWithPageHeader {
2320 cacheBuffer: Number.MAX_VALUE
2421}
qml/Dash/ScopeSettingsPage.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.2
1818import Ubuntu.Components 1.1
1919import Unity 0.2
2020import "../Components"
21+import "../Components/Flickables" as Flickables
2122import "ScopeSettings"
2223
2324Item {
@@ -39,7 +40,7 @@ Item {
3940 onBackClicked: root.backClicked()
4041 }
4142
42− ListView {
43+ Flickables.ListView {
4344 id: scopeSettings
4445 objectName: "scopeSettings"
4546 anchors {
qml/Dash/ScopesOverviewAll.qml+2−1
@@ -16,8 +16,9 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import "../Components/Flickables" as Flickables
1920
20−Flickable {
21+Flickables.Flickable {
2122 id: root
2223
2324 property alias model: cardGrid.model
qml/Dash/ScopesOverviewFavorites.qml+4−2
@@ -14,9 +14,11 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import QtQuick 2.0
17+import QtQuick 2.3
18+import Ubuntu.Components 1.1
19+import "../Components/Flickables" as Flickables
1820
19−Flickable {
21+Flickables.Flickable {
2022 id: root
2123
2224 signal clicked(int index, var result, var itemModel)
qml/Greeter/LoginList.qml+2−2
@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import LightDM 0.1 as LightDM
2020import "../Components"
21+import "../Components/Flickables" as Flickables
2122
2223Item {
2324 id: root
@@ -68,7 +69,7 @@ Item {
6869 antialiasing: true
6970 }
7071
71− ListView {
72+ Flickables.ListView {
7273 id: userList
7374 objectName: "userList"
7475
@@ -78,7 +79,6 @@ Item {
7879 preferredHighlightEnd: userList.height / 2 - root.highlightedHeight / 2
7980 highlightRangeMode: ListView.StrictlyEnforceRange
8081 highlightMoveDuration: root.moveDuration
81− flickDeceleration: 10000
8282
8383 readonly property bool movingInternally: moveTimer.running || userList.moving
8484
qml/Hud/Hud.qml+2−1
@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
1919import HudClient 0.1
2020
2121import "../Components"
22+import "../Components/Flickables" as Flickables
2223
2324Item {
2425 id: hud
@@ -400,7 +401,7 @@ Item {
400401 }
401402 progress: MathUtils.clamp((y - hudShowable.y + height - units.gu(8))/elementsYSliding, 0, 1)
402403
403− Flickable {
404+ Flickables.Flickable {
404405 anchors.left: parent.left
405406 anchors.right: parent.right
406407 contentHeight: resultList.height
qml/Hud/HudParametrizedActionsPage.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import Ubuntu.Components 1.1
1919import Ubuntu.Components.Themes.Ambiance 1.1
2020import "../Components"
21+import "../Components/Flickables" as Flickables
2122
2223Item {
2324 property alias header: header.title
@@ -74,7 +75,7 @@ Item {
7475 return values
7576 }
7677
77− Flickable {
78+ Flickables.Flickable {
7879 anchors.top: parent.top
7980 anchors.bottom: buttons.top
8081 anchors.left: parent.left
qml/Launcher/LauncherPanel.qml+2−1
@@ -21,6 +21,7 @@ import Unity.Launcher 0.1
2121import Ubuntu.Components.Popups 0.1
2222import "../Components/ListItems"
2323import "../Components/"
24+import "../Components/Flickables" as Flickables
2425
2526Rectangle {
2627 id: root
@@ -74,7 +75,7 @@ Rectangle {
7475 anchors.fill: parent
7576 clip: true
7677
77− ListView {
78+ Flickables.ListView {
7879 id: launcherListView
7980 objectName: "launcherListView"
8081 anchors {
qml/Notifications/Notification.qml+2−1
@@ -20,6 +20,7 @@ import Ubuntu.Components 1.1
2020import Unity.Notifications 1.0
2121import QMenuModel 0.1
2222import Utils 0.1
23+import "../Components/Flickables" as Flickables
2324
2425import Ubuntu.Components.ListItems 0.1 as ListItem
2526
@@ -455,7 +456,7 @@ Item {
455456 onClicked: notification.notification.invokeAction(comboRepeater.itemAt(2).actionId)
456457 expanded: false
457458 expandedHeight: (comboRepeater.count - 2) * units.gu(4) + units.gu(.5)
458− comboList: Flickable {
459+ comboList: Flickables.Flickable {
459460 // this has to be wrapped inside a flickable
460461 // to work around a feature/bug? of the
461462 // ComboButton SDK-element, making a regular
qml/Notifications/Notifications.qml+2−1
@@ -19,8 +19,9 @@ import Ubuntu.Components 0.1
1919import Unity.Notifications 1.0 as UnityNotifications
2020import Utils 0.1
2121import "../Components"
22+import "../Components/Flickables" as Flickables
2223
23−ListView {
24+Flickables.ListView {
2425 id: notificationList
2526
2627 objectName: "notificationList"
qml/Panel/IndicatorRow.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Unity.Indicators 0.1 as Indicators
2020import "../Components"
21+import "../Components/Flickables" as Flickables
2122
2223Item {
2324 id: indicatorRow
@@ -60,7 +61,7 @@ Item {
6061 }
6162 }
6263
63− ListView {
64+ Flickables.ListView {
6465 id: itemView
6566 objectName: "indicatorRowItems"
6667 interactive: false
qml/Panel/Indicators/DefaultIndicatorPage.qml+2−1
@@ -21,6 +21,7 @@
2121import QtQuick 2.0
2222import Ubuntu.Components 0.1 as Components
2323import Unity.Indicators 0.1 as Indicators
24+import "../../Components/Flickables" as Flickables
2425
2526IndicatorBase {
2627 id: main
@@ -65,7 +66,7 @@ IndicatorBase {
6566 }
6667 }
6768
68− ListView {
69+ Flickables.ListView {
6970 id: mainMenu
7071 objectName: "mainMenu"
7172 model: menuStack.rootMenu
qml/Panel/Indicators/client/IndicatorsList.qml+2−1
@@ -22,6 +22,7 @@ import Ubuntu.Components 0.1
2222import Ubuntu.Components.ListItems 0.1 as ListItem
2323import Unity.Indicators 0.1 as Indicators
2424import "../.."
25+import "../../../Components/Flickables" as Flickables
2526
2627Page {
2728 id: page
@@ -35,7 +36,7 @@ Page {
3536 Component.onCompleted: load(profile)
3637 }
3738
38− ListView {
39+ Flickables.ListView {
3940 id: mainMenu
4041 objectName: "mainMenu"
4142 anchors.fill: parent
qml/Panel/Indicators/client/IndicatorsTree.qml+2−1
@@ -22,6 +22,7 @@ import Ubuntu.Components 0.1
2222import Unity.Indicators 0.1 as Indicators
2323import QMenuModel 0.1
2424import Ubuntu.Components.ListItems 0.1 as ListItem
25+import "../../../Components/Flickables" as Flickables
2526
2627Page {
2728 id: page
@@ -52,7 +53,7 @@ Page {
5253 model: unityModel
5354 }
5455
55− Flickable {
56+ Flickables.Flickable {
5657 anchors.fill: parent
5758 contentHeight: all_data.height
5859 clip:true
qml/Panel/MenuContent.qml+3−2
@@ -20,6 +20,7 @@ import Ubuntu.Components 1.1
2020import Unity.Indicators 0.1 as Indicators
2121import Utils 0.1
2222import "../Components"
23+import "../Components/Flickables" as Flickables
2324import "Indicators"
2425
2526Rectangle {
@@ -39,7 +40,7 @@ Rectangle {
3940 listViewHeader.currentIndex = index;
4041 }
4142
42− ListView {
43+ Flickables.ListView {
4344 id: listViewHeader
4445 objectName: "indicatorsHeaderListView"
4546 model: content.indicatorsModel
@@ -80,7 +81,7 @@ Rectangle {
8081 }
8182 }
8283
83− ListView {
84+ Flickables.ListView {
8485 id: listViewContent
8586 objectName: "indicatorsContentListView"
8687 anchors {
qml/Stages/PhoneStage.qml+2−1
@@ -21,6 +21,7 @@ import Unity.Application 0.1
2121import Unity.Session 0.1
2222import Utils 0.1
2323import "../Components"
24+import "../Components/Flickables" as Flickables
2425
2526Rectangle {
2627 id: root
@@ -120,7 +121,7 @@ Rectangle {
120121
121122 }
122123
123− Flickable {
124+ Flickables.Flickable {
124125 id: spreadView
125126 objectName: "spreadView"
126127 anchors.fill: parent
qml/Stages/TabletStage.qml+2−1
@@ -20,6 +20,7 @@ import Ubuntu.Gestures 0.1
2020import Unity.Application 0.1
2121import Utils 0.1
2222import "../Components"
23+import "../Components/Flickables" as Flickables
2324
2425Rectangle {
2526 id: root
@@ -153,7 +154,7 @@ Rectangle {
153154 }
154155 }
155156
156− Flickable {
157+ Flickables.Flickable {
157158 id: spreadView
158159 anchors.fill: parent
159160 interactive: (spreadDragArea.status == DirectionalDragArea.Recognized || phase > 1)