on xenial help sign in
add scrolling areas
commitec5e81690a24053020eab9e209289d1aa3e3ae61 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 13 Feb 2017, 11:39 (10 years ago) parentf57eab2
2 files changed+49−8
qml/Stage/Spread/ScreensAndWorkspaces.qml+47−6 qml/Stage/Spread/Workspaces.qml+2−2
qml/Stage/Spread/ScreensAndWorkspaces.qml+47−6
@@ -11,8 +11,10 @@ Item {
1111 property string background
1212
1313 Row {
14+ id: row
1415 anchors.bottom: parent.bottom
1516 anchors.horizontalCenter: parent.horizontalCenter
17+ Behavior on anchors.horizontalCenterOffset { UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration } }
1618// anchors.left: parent.left
1719 spacing: units.gu(1)
1820
@@ -70,7 +72,7 @@ Item {
7072 actions: ActionList {
7173 Action {
7274 text: "Add workspace"
73− onTriggered: workspaces.workspaceModel.append({text: "" + workspaces.workspaceModel.count})
75+ onTriggered: workspaces.workspaceModel.append({text: "" + (workspaces.workspaceModel.count + 1)})
7476 }
7577 }
7678 }
@@ -92,11 +94,11 @@ Item {
9294 workspaceModel: ListModel {
9395 onCountChanged: print("model count changed to", count)
9496 ListElement {text: "1"}
95−// ListElement {text: "2"}
96−// ListElement {text: "3"}
97−// ListElement {text: "4"}
98−// ListElement {text: "5"}
99−// ListElement {text: "6"}
97+ ListElement {text: "2"}
98+ ListElement {text: "3"}
99+ ListElement {text: "4"}
100+ ListElement {text: "5"}
101+ ListElement {text: "6"}
100102// ListElement {text: "7"}
101103// ListElement {text: "8"}
102104// ListElement {text: "9"}
@@ -105,4 +107,43 @@ Item {
105107 }
106108 }
107109 }
110+
111+ Rectangle {
112+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; topMargin: units.gu(6); bottomMargin: units.gu(1) }
113+ width: units.gu(5)
114+ color: "#33000000"
115+ MouseArea {
116+ id: leftScrollArea
117+ anchors.fill: parent
118+ hoverEnabled: true
119+ onPressed: mouse.accepted = false;
120+ }
121+ }
122+ Rectangle {
123+ anchors { right: parent.right; top: parent.top; bottom: parent.bottom; topMargin: units.gu(6); bottomMargin: units.gu(1) }
124+ width: units.gu(5)
125+ color: "#33000000"
126+ MouseArea {
127+ id: rightScrollArea
128+ anchors.fill: parent
129+ hoverEnabled: true
130+ onPressed: mouse.accepted = false;
131+ }
132+ }
133+ Timer {
134+ repeat: true
135+ running: leftScrollArea.containsMouse || rightScrollArea.containsMouse
136+ interval: UbuntuAnimation.SlowDuration
137+ onTriggered: {
138+ var newOffset = row.anchors.horizontalCenterOffset;
139+ var maxOffset = Math.max((row.width - root.width) / 2, 0);
140+ if (leftScrollArea.containsMouse) {
141+ newOffset += units.gu(20)
142+ } else {
143+ newOffset -= units.gu(20)
144+ }
145+ newOffset = Math.max(-maxOffset, Math.min(maxOffset, newOffset));
146+ row.anchors.horizontalCenterOffset = newOffset;
147+ }
148+ }
108149}
qml/Stage/Spread/Workspaces.qml+2−2
@@ -184,9 +184,9 @@ Item {
184184 property int draggedIndex: -1
185185
186186 onMouseXChanged: {
187− var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth*2) / (width - listView.foldingAreaWidth * 4)))
187+ var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.foldingAreaWidth * 2)))
188188// var progress = mouseX / width
189−// print("p:", progress)
189+ print("p:", progress)
190190 listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
191191 }
192192