@@ -2,38 +2,62 @@ import QtQuick 2.4
2import Ubuntu.Components 1.3
2import Ubuntu.Components 1.3
3import Unity.Screens 0.1
3import Unity.Screens 0.1
4import Unity.Application 0.1
4import Unity.Application 0.1
5import "../../Components"
6import "../../Components"
8 id: previewSpace
9 id: previewSpace
10− // Set the height. this preview will then automatically adjust the width, keeping aspect ratio of the screen
11− width: model.geometry.width * previewScale * 4
13 property string background
11 property string background
12+ property int screenHeight
15− property int screenWidth: model.geometry.width
16− property int screenHeight: model.geometry.height
17 property real previewScale: previewSpace.height / previewSpace.screenHeight
14 property real previewScale: previewSpace.height / previewSpace.screenHeight
20− Rectangle {
17+ source: previewSpace.background
21 anchors.fill: parent
18 anchors.fill: parent
24 Repeater {
20 Repeater {
25− id: workspaceRepeater
21+ id: topLevelSurfaceRepeater
26− model: 15
22+ model: visible ? topLevelSurfaceList : null
23+ delegate: Rectangle {
24+ width: surfaceItem.width
25+ height: surfaceItem.height + decorationHeight * previewScale
26+ x: model.window.position.x * previewScale
27+ y: (model.window.position.y - decorationHeight) * previewScale
29+ z: topLevelSurfaceRepeater.count - index
31+ property int decorationHeight: units.gu(3)
34+ width: surfaceItem.implicitWidth
35+ height: parent.decorationHeight
42+ title: model.window && model.window.surface ? model.window.surface.name : ""
28− delegate: Item {
46+ MirSurfaceItem {
29− x: index * previewSpace.screenWidth * previewScale
47+ id: surfaceItem
30− height: previewSpace.screenHeight * previewScale
48+ y: parent.decorationHeight * previewScale
31− width: previewSpace.screenWidth * previewScale
49+ width: implicitWidth * previewScale
32− clip: true
50+ height: implicitHeight * previewScale
53+ onImplicitHeightChanged: print("item", surfaceItem, "height changed", implicitHeight)
54+ surface: model.window.surface
35− source: previewSpace.background
60+}
38 // Repeater {
62 // Repeater {
39 // id: topLevelSurfaceRepeater
63 // id: topLevelSurfaceRepeater
@@ -73,8 +97,8 @@ UbuntuShape {
80// MouseArea {
104// MouseArea {
@@ -148,36 +172,36 @@ UbuntuShape {
148// anchors.centerIn: parent
172// anchors.centerIn: parent
153− FloatingFlickable {
177+// FloatingFlickable {
154− id: flickable
178+// id: flickable
155− anchors.fill: parent
179+// anchors.fill: parent
156− contentWidth: workspaceRepeater.count * previewSpace.screenWidth * previewScale
180+// contentWidth: workspaceRepeater.count * previewSpace.screenWidth * previewScale
157− property real progress: contentX / contentWidth
181+// property real progress: contentX / contentWidth
158− onContentXChanged: print("contentX:", contentX, "progress:", progress)
182+// onContentXChanged: print("contentX:", contentX, "progress:", progress)
161− MouseArea {
185+// MouseArea {
162− anchors.fill: parent
186+// anchors.fill: parent
163− hoverEnabled: true
187+// hoverEnabled: true
164− property int scrollAreaWidth: width / 3
188+// property int scrollAreaWidth: width / 3
166− onMouseXChanged: {
190+// onMouseXChanged: {
167− var margins = flickable.width * 0.05;
191+// var margins = flickable.width * 0.05;
169− // do we need to scroll?
193+// // do we need to scroll?
170− if (mouseX < scrollAreaWidth + margins) {
194+// if (mouseX < scrollAreaWidth + margins) {
171− var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
195+// var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
172− var contentX = (1 - progress) * (flickable.contentWidth - flickable.width)
196+// var contentX = (1 - progress) * (flickable.contentWidth - flickable.width)
173− flickable.contentX = Math.max(0, Math.min(flickable.contentX, contentX))
197+// flickable.contentX = Math.max(0, Math.min(flickable.contentX, contentX))
175− if (mouseX > flickable.width - scrollAreaWidth) {
199+// if (mouseX > flickable.width - scrollAreaWidth) {
176− var progress = Math.min(1, (mouseX - (flickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
200+// var progress = Math.min(1, (mouseX - (flickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
177− var contentX = progress * (flickable.contentWidth - flickable.width)
201+// var contentX = progress * (flickable.contentWidth - flickable.width)
178− flickable.contentX = Math.min(flickable.contentWidth - flickable.width, Math.max(flickable.contentX, contentX))
202+// flickable.contentX = Math.min(flickable.contentWidth - flickable.width, Math.max(flickable.contentX, contentX))