2 import Ubuntu.Components 1.3
3 import Ubuntu.Components.Popups 1.3
4 import WindowManager 1.0
5 import Unity.Application 0.1
11 property string background
13 property var screensProxy: Screens.createProxy();
15 property QtObject activeWorkspace: null
21 anchors.bottom: parent.bottom
22 anchors.horizontalCenter: parent.horizontalCenter
23 Behavior on anchors.horizontalCenterOffset { NumberAnimation { duration: UbuntuAnimation.SlowDuration } }
26 property var selectedIndex: undefined
32 height: root.height - units.gu(6)
33 width: workspaces.width
37 anchors { left: parent.left; top: parent.top; right: parent.right }
41 property bool isCurrent: {
42 // another screen is selected.
43 if (row.selectedIndex != undefined && row.selectedIndex != index) return false;
45 // this screen is active.
46 if (WMScreen.active && WMScreen.isSameAs(model.screen) && WMScreen.currentWorkspace.isSameAs(activeWorkspace)) return true;
47 if (model.screen.workspaces.indexOf(activeWorkspace) >= 0) return true;
53 property bool isSelected: screenMA.containsMouse
54 onIsSelectedChanged: {
56 row.selectedIndex = Qt.binding(function() { return index; });
57 } else if (row.selectedIndex === index) {
58 row.selectedIndex = undefined;
64 backgroundColor: "white"
65 opacity: header.isCurrent || header.isSelected ? 1.0 : 0.5
73 workspaces.workspaceModel.insert(workspaces.workspaceModel.count, {text: drag.source.text})
74 drag.source.inDropArea = true;
78 workspaces.workspaceModel.remove(workspaces.workspaceModel.count - 1, 1)
79 drag.source.inDropArea = false;
83 drag.source.inDropArea = false;
89 anchors.margins: units.gu(1)
92 text: model.screen.name
93 color: header.isCurrent || header.isSelected ? "black" : "white"
97 text: model.screen.outputTypeName
98 color: header.isCurrent || header.isSelected ? "black" : "white"
103 text: screen.availableModes[screen.currentModeIndex].size.width + "x" + screen.availableModes[screen.currentModeIndex].size.height
104 color: header.isCurrent || header.isSelected ? "black" : "white"
117 source: "image://theme/select"
118 color: header.isCurrent || header.isSelected ? "black" : "white"
119 visible: model.screen.active
128 var obj = screensMenuComponent.createObject(header)
129 obj.open(mouseX, mouseY)
134 id: screensMenuComponent
138 height: contentColumn.childrenRect.height
139 backgroundColor: "white"
141 function open(mouseX, mouseY) {
142 x = Math.max(0, Math.min(mouseX - width / 2, parent.width - width))
143 y = mouseY + units.gu(1)
149 screensMenu.destroy()
157 height: layout.height
158 highlightColor: "transparent"
161 title.text: qsTr("Add workspace")
165 screen.workspaces.addWorkspace();
166 Screens.sync(root.screensProxy);
167 screensMenu.destroy();
177 height: parent.height - header.height - units.gu(2)
180 if (screensProxy.count == 1) {
181 width = Math.min(implicitWidth, root.width - units.gu(8));
183 width = Math.min(implicitWidth, model.screen.active ? root.width - units.gu(48) : units.gu(40))
185 return Math.max(workspaces.minimumWidth, width);
188 Behavior on width { UbuntuNumberAnimation {} }
189 anchors.bottom: parent.bottom
190 anchors.bottomMargin: units.gu(1)
191 anchors.horizontalCenter: parent.horizontalCenter
193 background: root.background
195 workspaceModel: model.screen.workspaces
196 activeWorkspace: root.activeWorkspace
199 onCommitScreenSetup: Screens.sync(root.screensProxy)
200 onCloseSpread: root.closeSpread();
203 root.activeWorkspace = workspace;
211 anchors { left: parent.left; top: parent.top; bottom: parent.bottom; topMargin: units.gu(6); bottomMargin: units.gu(1) }
214 visible: (row.width - root.width + units.gu(10)) / 2 - row.anchors.horizontalCenterOffset > units.gu(5)
219 onPressed: mouse.accepted = false;
224 keys: ["application", "workspace"]
228 anchors { right: parent.right; top: parent.top; bottom: parent.bottom; topMargin: units.gu(6); bottomMargin: units.gu(1) }
231 visible: (row.width - root.width + units.gu(10)) / 2 + row.anchors.horizontalCenterOffset > units.gu(5)
236 onPressed: mouse.accepted = false;
239 id: rightFakeDropArea
241 keys: ["application", "workspace"]
246 running: leftScrollArea.containsMouse || rightScrollArea.containsMouse || leftFakeDropArea.containsDrag || rightFakeDropArea.containsDrag
247 interval: UbuntuAnimation.SlowDuration
248 triggeredOnStart: true
250 var newOffset = row.anchors.horizontalCenterOffset;
251 var maxOffset = Math.max((row.width - root.width + units.gu(10)) / 2, 0);
252 if (leftScrollArea.containsMouse || leftFakeDropArea.containsDrag) {
253 newOffset += units.gu(20)
255 newOffset -= units.gu(20)
257 newOffset = Math.max(-maxOffset, Math.min(maxOffset, newOffset));
258 row.anchors.horizontalCenterOffset = newOffset;