@@ -20,11 +20,9 @@ import "Spread"
20import WindowManager 1.0
20import WindowManager 1.0
21import Unity.Application 0.1
21import Unity.Application 0.1
23−UbuntuShape {
23+Item {
26− backgroundColor: "#F2111111"
27− width: screensRow.childrenRect.width + units.gu(4)
28 opacity: d.shown ? 1 : 0
26 opacity: d.shown ? 1 : 0
29 visible: opacity > 0
27 visible: opacity > 0
30 Behavior on opacity { UbuntuNumberAnimation {} }
28 Behavior on opacity { UbuntuNumberAnimation {} }
@@ -36,11 +34,19 @@ UbuntuShape {
37 function showLeft() {
35 function showLeft() {
39− d.decreaseHighlight();
37+ d.previousWorkspace();
41 function showRight() {
39 function showRight() {
43− d.increaseHighlight();
41+ d.nextWorkspace();
47+ function showDown() {
46 function show() {
52 function show() {
@@ -64,27 +70,27 @@ UbuntuShape {
64 property bool altPressed: false
70 property bool altPressed: false
65 property bool ctrlPressed: false
71 property bool ctrlPressed: false
73+ property int rowHeight: root.height - units.gu(4)
67 property int highlightedScreenIndex: -1
75 property int highlightedScreenIndex: -1
68 property int highlightedWorkspaceIndex: -1
76 property int highlightedWorkspaceIndex: -1
70− function increaseHighlight() {
78+ function previousWorkspace() {
79+ highlightedWorkspaceIndex = Math.max(highlightedWorkspaceIndex - 1, 0);
81+ function nextWorkspace() {
71 var screen = screensProxy.get(highlightedScreenIndex);
82 var screen = screensProxy.get(highlightedScreenIndex);
72− highlightedWorkspaceIndex++
73− if (highlightedWorkspaceIndex >= screen.workspaces.count) {
83+ highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex + 1, screen.workspaces.count - 1);
74− highlightedScreenIndex = (highlightedScreenIndex + 1) % screensProxy.count;
75− highlightedWorkspaceIndex = 0;
78− function decreaseHighlight() {
85+ function previousScreen() {
79− highlightedWorkspaceIndex--;
86+ highlightedScreenIndex = Math.max(highlightedScreenIndex - 1, 0);
80− if (highlightedWorkspaceIndex < 0) {
81− highlightedScreenIndex--;
87+ var screen = screensProxy.get(highlightedScreenIndex);
82− if (highlightedScreenIndex < 0) {
88+ highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
90+ function nextScreen() {
83− highlightedScreenIndex = screensProxy.count - 1
91+ highlightedScreenIndex = Math.min(highlightedScreenIndex + 1, screensProxy.count - 1);
85− var screen = screensProxy.get(highlightedScreenIndex);
92+ var screen = screensProxy.get(highlightedScreenIndex);
86− highlightedWorkspaceIndex = screen.workspaces.count -1;
93+ highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
@@ -95,14 +101,18 @@ UbuntuShape {
97 Keys.onPressed: {
103 Keys.onPressed: {
99 switch (event.key) {
104 switch (event.key) {
100 case Qt.Key_Left:
105 case Qt.Key_Left:
101− d.decreaseHighlight();
106+ d.previousWorkspace();
103 case Qt.Key_Right:
108 case Qt.Key_Right:
104− d.increaseHighlight();
109+ d.nextWorkspace()
108 Keys.onReleased: {
118 Keys.onReleased: {
@@ -116,7 +126,6 @@ UbuntuShape {
118 if (!d.altPressed && !d.ctrlPressed) {
128 if (!d.altPressed && !d.ctrlPressed) {
119− print("starting hidetimer")
120 d.active = false;
129 d.active = false;
121 hideTimer.start();
130 hideTimer.start();
122 focus = false;
131 focus = false;
@@ -124,56 +133,62 @@ UbuntuShape {
127− Row {
136+ UbuntuShape {
128− id: screensRow
137+ backgroundColor: "#F2111111"
129− anchors {
138+ clip: true
139+ width: Math.min(parent.width, screensColumn.width + units.gu(4))
140+ anchors.horizontalCenter: parent.horizontalCenter
141+ height: parent.height
130− top: parent.top; topMargin: units.gu(2)
146+ top: parent.top; topMargin: units.gu(2) - d.highlightedScreenIndex * (d.rowHeight + screensColumn.spacing)
131− left: parent.left; leftMargin: units.gu(2)
147+ left: parent.left; leftMargin: units.gu(2)
149+ width: screensRepeater.itemAt(d.highlightedScreenIndex).width
133− spacing: units.gu(2)
150+ spacing: units.gu(2)
134−
151+ Behavior on anchors.topMargin { UbuntuNumberAnimation {} }
152+ Behavior on width { UbuntuNumberAnimation {} }
135− Repeater {
154+ Repeater {
136− model: screensProxy
156+ model: screensProxy
138− delegate: Item {
158+ delegate: Item {
139− height: root.height - units.gu(4)
159+ height: d.rowHeight
140− width: workspaces.width
160+ width: workspaces.width
141−
161+ anchors.horizontalCenter: parent.horizontalCenter
142− UbuntuShape {
162+ opacity: d.highlightedScreenIndex == index ? 1 : 0
163+ Behavior on opacity { UbuntuNumberAnimation {} }
143− id: header
166+ id: header
144− anchors { left: parent.left; top: parent.top; right: parent.right }
167+ anchors { left: parent.left; top: parent.top; right: parent.right }
145− height: units.gu(4)
168+ height: units.gu(4)
146− backgroundColor: "white"
169+ backgroundColor: "white"
149− anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
172+ anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
150− text: model.screen.name
173+ text: model.screen.name
151− color: UbuntuColors.ash
174+ color: UbuntuColors.ash
157− height: parent.height - header.height - units.gu(2)
160− if (screensProxy.count == 1) {
161− width = Math.min(implicitWidth, root.width - units.gu(8));
163− width = Math.min(implicitWidth, model.screen.active ? root.width - units.gu(48) : units.gu(40))
165− return Math.max(workspaces.minimumWidth, width);
168− Behavior on width { UbuntuNumberAnimation {} }
178+ Workspaces {
180+ height: parent.height - header.height - units.gu(2)
181+ width: Math.min(implicitWidth, root.width - units.gu(4))
169− anchors.bottom: parent.bottom
183+ anchors.bottom: parent.bottom
170− anchors.bottomMargin: units.gu(1)
184+ anchors.bottomMargin: units.gu(1)
171− anchors.horizontalCenter: parent.horizontalCenter
185+ anchors.horizontalCenter: parent.horizontalCenter
172− screen: model.screen
186+ screen: model.screen
173− background: root.background
187+ background: root.background
174− selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
188+ selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
176− workspaceModel: model.screen.workspaces
190+ workspaceModel: model.screen.workspaces