@@ -8,7 +8,7 @@ UbuntuShape {
88 id: previewSpace
99
1010 // Set the height. this preview will then automatically adjust the width, keeping aspect ratio of the screen
11− width: model.geometry.width * previewScale
11+ width: model.geometry.width * previewScale * 4
1212 color: "white"
1313 property string background
1414
@@ -20,6 +20,7 @@ UbuntuShape {
2020 id: header
2121 anchors { left: parent.left; top: parent.top; right: parent.right }
2222 height: units.gu(7)
23+
2324 Column {
2425 anchors.fill: parent
2526 anchors.margins: units.gu(1)
@@ -44,121 +45,168 @@ UbuntuShape {
4445 }
4546
4647
47− Wallpaper {
48+ Rectangle {
4849 anchors.fill: parent
4950 anchors.topMargin: header.height
50− source: previewSpace.background
51− clip: true
51+ color: "blue"
5252
5353 Repeater {
54− id: topLevelSurfaceRepeater
55− model: visible ? topLevelSurfaceList : null
56− delegate: Rectangle {
57− width: surfaceItem.width
58− height: surfaceItem.height + decorationHeight * previewScale
59− x: model.window.position.x * previewScale
60− y: (model.window.position.y - decorationHeight) * previewScale
61− color: "blue"
62− z: topLevelSurfaceRepeater.count - index
63−
64− property int decorationHeight: units.gu(3)
65−
66− WindowDecoration {
67− width: surfaceItem.implicitWidth
68− height: parent.decorationHeight
69− transform: Scale {
70− origin.x: 0
71− origin.y: 0
72− xScale: previewScale
73− yScale: previewScale
74− }
75− title: model.window && model.window.surface ? model.window.surface.name : ""
76− z: 3
77− }
78−
79− MirSurfaceItem {
80− id: surfaceItem
81− y: parent.decorationHeight * previewScale
82− width: implicitWidth * previewScale
83− height: implicitHeight * previewScale
84− surfaceWidth: -1
85− surfaceHeight: -1
86− onImplicitHeightChanged: print("item", surfaceItem, "height changed", implicitHeight)
87− surface: model.window.surface
54+ id: workspaceRepeater
55+ model: 15
56+
57+ delegate: Item {
58+ x: index * previewSpace.screenWidth * previewScale
59+ height: previewSpace.screenHeight * previewScale
60+ width: previewSpace.screenWidth * previewScale
61+ clip: true
62+
63+ Wallpaper {
64+ source: previewSpace.background
65+ anchors.fill: parent
66+
67+ // Repeater {
68+ // id: topLevelSurfaceRepeater
69+ // model: visible ? topLevelSurfaceList : null
70+ // delegate: Rectangle {
71+ // width: surfaceItem.width
72+ // height: surfaceItem.height + decorationHeight * previewScale
73+ // x: model.window.position.x * previewScale
74+ // y: (model.window.position.y - decorationHeight) * previewScale
75+ // color: "blue"
76+ // z: topLevelSurfaceRepeater.count - index
77+
78+ // property int decorationHeight: units.gu(3)
79+
80+ // WindowDecoration {
81+ // width: surfaceItem.implicitWidth
82+ // height: parent.decorationHeight
83+ // transform: Scale {
84+ // origin.x: 0
85+ // origin.y: 0
86+ // xScale: previewScale
87+ // yScale: previewScale
88+ // }
89+ // title: model.window && model.window.surface ? model.window.surface.name : ""
90+ // z: 3
91+ // }
92+
93+ // MirSurfaceItem {
94+ // id: surfaceItem
95+ // y: parent.decorationHeight * previewScale
96+ // width: implicitWidth * previewScale
97+ // height: implicitHeight * previewScale
98+ // surfaceWidth: -1
99+ // surfaceHeight: -1
100+ // onImplicitHeightChanged: print("item", surfaceItem, "height changed", implicitHeight)
101+ // surface: model.window.surface
102+ // }
103+ // }
104+ // }
88105 }
89106 }
90− }
91− }
92107
93− MouseArea {
94− id: mouseArea
95− anchors.centerIn: parent
96− anchors.verticalCenterOffset: header.height / 2
97− width: units.gu(8)
98− height: width
99− hoverEnabled: true
100− opacity: containsMouse ? 1 : 0
101108
102− Rectangle {
103− anchors.fill: parent
104− color: "#80000000"
105− radius: height / 2
109+// MouseArea {
110+// id: mouseArea
111+// anchors.centerIn: parent
112+// anchors.verticalCenterOffset: header.height / 2
113+// width: units.gu(8)
114+// height: width
115+// hoverEnabled: true
116+// opacity: containsMouse ? 1 : 0
117+
118+// Rectangle {
119+// anchors.fill: parent
120+// color: "#80000000"
121+// radius: height / 2
122+// }
123+
124+// NumberAnimation {
125+// target: canvas
126+// property: "progress"
127+// duration: 2000
128+// running: mouseArea.containsMouse
129+// from: 0
130+// to: 1
131+// }
132+
133+// Canvas {
134+// id: canvas
135+// height: parent.height
136+// width: height
137+// anchors.centerIn: parent
138+
139+// property real progress: 0.5
140+// property int lineWidth: units.dp(4)
141+// onProgressChanged: {
142+// requestPaint();
143+// if (progress == 1) {
144+// Screens.activateScreen(index);
145+// }
146+// }
147+
148+// rotation: -90
149+
150+// onPaint: {
151+// var ctx = canvas.getContext("2d");
152+// ctx.save();
153+// ctx.reset();
154+
155+// ctx.lineWidth = lineWidth;
156+
157+// ctx.strokeStyle = "#3bffffff"
158+// ctx.beginPath();
159+// ctx.arc(canvas.width/2,canvas.height/2, (canvas.height - ctx.lineWidth) / 2, 0, (Math.PI*2),false);
160+// ctx.stroke();
161+// ctx.closePath();
162+
163+// ctx.strokeStyle = "white"
164+// ctx.beginPath();
165+// ctx.arc(canvas.width/2,canvas.height/2, (canvas.height - ctx.lineWidth) / 2, 0, (Math.PI*2*(progress)),false);
166+// ctx.stroke();
167+// ctx.closePath();
168+
169+// ctx.restore();
170+// }
171+// }
172+
173+// Icon {
174+// source: "graphics/multi-monitor_leave.png"
175+// height: units.gu(4)
176+// width: height
177+// anchors.centerIn: parent
178+// }
179+// }
106180 }
107181
108− NumberAnimation {
109− target: canvas
110− property: "progress"
111− duration: 2000
112− running: mouseArea.containsMouse
113− from: 0
114− to: 1
182+ FloatingFlickable {
183+ id: flickable
184+ anchors.fill: parent
185+ contentWidth: workspaceRepeater.count * previewSpace.screenWidth * previewScale
186+ property real progress: contentX / contentWidth
187+ onContentXChanged: print("contentX:", contentX, "progress:", progress)
115188 }
116189
117− Canvas {
118− id: canvas
119− height: parent.height
120− width: height
121− anchors.centerIn: parent
122−
123− property real progress: 0.5
124− property int lineWidth: units.dp(4)
125− onProgressChanged: {
126− requestPaint();
127− if (progress == 1) {
128− Screens.activateScreen(index);
129− }
130− }
131−
132− rotation: -90
133−
134− onPaint: {
135− var ctx = canvas.getContext("2d");
136− ctx.save();
137− ctx.reset();
138−
139− ctx.lineWidth = lineWidth;
140−
141− ctx.strokeStyle = "#3bffffff"
142− ctx.beginPath();
143− ctx.arc(canvas.width/2,canvas.height/2, (canvas.height - ctx.lineWidth) / 2, 0, (Math.PI*2),false);
144− ctx.stroke();
145− ctx.closePath();
190+ MouseArea {
191+ anchors.fill: parent
192+ hoverEnabled: true
193+ property int scrollAreaWidth: width / 3
146194
147− ctx.strokeStyle = "white"
148− ctx.beginPath();
149− ctx.arc(canvas.width/2,canvas.height/2, (canvas.height - ctx.lineWidth) / 2, 0, (Math.PI*2*(progress)),false);
150− ctx.stroke();
151− ctx.closePath();
195+ onMouseXChanged: {
196+ var margins = flickable.width * 0.05;
152197
153− ctx.restore();
198+ // do we need to scroll?
199+ if (mouseX < scrollAreaWidth + margins) {
200+ var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
201+ var contentX = (1 - progress) * (flickable.contentWidth - flickable.width)
202+ flickable.contentX = Math.max(0, Math.min(flickable.contentX, contentX))
203+ }
204+ if (mouseX > flickable.width - scrollAreaWidth) {
205+ var progress = Math.min(1, (mouseX - (flickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
206+ var contentX = progress * (flickable.contentWidth - flickable.width)
207+ flickable.contentX = Math.min(flickable.contentWidth - flickable.width, Math.max(flickable.contentX, contentX))
208+ }
154209 }
155210 }
156−
157− Icon {
158− source: "graphics/multi-monitor_leave.png"
159− height: units.gu(4)
160− width: height
161− anchors.centerIn: parent
162− }
163211 }
164212}