on xenial help sign in
add scrolling areas
ec5e816Michael Zanetti
qml/Stage/Spread/ScreensAndWorkspaces.qml+47−6
@@ -11,8 +11,10 @@ Item {
11 property string background
11 property string background
12
12
13 Row {
13 Row {
14+ id: row
14 anchors.bottom: parent.bottom
15 anchors.bottom: parent.bottom
15 anchors.horizontalCenter: parent.horizontalCenter
16 anchors.horizontalCenter: parent.horizontalCenter
17+ Behavior on anchors.horizontalCenterOffset { UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration } }
16// anchors.left: parent.left
18// anchors.left: parent.left
17 spacing: units.gu(1)
19 spacing: units.gu(1)
18
20
@@ -70,7 +72,7 @@ Item {
70 actions: ActionList {
72 actions: ActionList {
71 Action {
73 Action {
72 text: "Add workspace"
74 text: "Add workspace"
73− onTriggered: workspaces.workspaceModel.append({text: "" + workspaces.workspaceModel.count})
75+ onTriggered: workspaces.workspaceModel.append({text: "" + (workspaces.workspaceModel.count + 1)})
74 }
76 }
75 }
77 }
76 }
78 }
@@ -92,11 +94,11 @@ Item {
92 workspaceModel: ListModel {
94 workspaceModel: ListModel {
93 onCountChanged: print("model count changed to", count)
95 onCountChanged: print("model count changed to", count)
94 ListElement {text: "1"}
96 ListElement {text: "1"}
95−// ListElement {text: "2"}
97+ ListElement {text: "2"}
96−// ListElement {text: "3"}
98+ ListElement {text: "3"}
97−// ListElement {text: "4"}
99+ ListElement {text: "4"}
98−// ListElement {text: "5"}
100+ ListElement {text: "5"}
99−// ListElement {text: "6"}
101+ ListElement {text: "6"}
100// ListElement {text: "7"}
102// ListElement {text: "7"}
101// ListElement {text: "8"}
103// ListElement {text: "8"}
102// ListElement {text: "9"}
104// ListElement {text: "9"}
@@ -105,4 +107,43 @@ Item {
105 }
107 }
106 }
108 }
107 }
109 }
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+ }
108}
149}
qml/Stage/Spread/Workspaces.qml+2−2
@@ -184,9 +184,9 @@ Item {
184 property int draggedIndex: -1
184 property int draggedIndex: -1
185
185
186 onMouseXChanged: {
186 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)))
188// var progress = mouseX / width
188// var progress = mouseX / width
189−// print("p:", progress)
189+ print("p:", progress)
190 listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
190 listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
191 }
191 }
192
192