@@ -20,11 +20,9 @@ import "Spread"
2020import WindowManager 1.0
2121import Unity.Application 0.1
2222
23−UbuntuShape {
23+Item {
2424 id: root
2525
26− backgroundColor: "#F2111111"
27− width: screensRow.childrenRect.width + units.gu(4)
2826 opacity: d.shown ? 1 : 0
2927 visible: opacity > 0
3028 Behavior on opacity { UbuntuNumberAnimation {} }
@@ -36,11 +34,19 @@ UbuntuShape {
3634
3735 function showLeft() {
3836 show();
39− d.decreaseHighlight();
37+ d.previousWorkspace();
4038 }
4139 function showRight() {
4240 show();
43− d.increaseHighlight();
41+ d.nextWorkspace();
42+ }
43+ function showUp() {
44+ show();
45+ d.previousScreen();
46+ }
47+ function showDown() {
48+ show();
49+ d.nextScreen();
4450 }
4551
4652 function show() {
@@ -64,27 +70,27 @@ UbuntuShape {
6470 property bool altPressed: false
6571 property bool ctrlPressed: false
6672
73+ property int rowHeight: root.height - units.gu(4)
74+
6775 property int highlightedScreenIndex: -1
6876 property int highlightedWorkspaceIndex: -1
6977
70− function increaseHighlight() {
78+ function previousWorkspace() {
79+ highlightedWorkspaceIndex = Math.max(highlightedWorkspaceIndex - 1, 0);
80+ }
81+ function nextWorkspace() {
7182 var screen = screensProxy.get(highlightedScreenIndex);
72− highlightedWorkspaceIndex++
73− if (highlightedWorkspaceIndex >= screen.workspaces.count) {
74− highlightedScreenIndex = (highlightedScreenIndex + 1) % screensProxy.count;
75− highlightedWorkspaceIndex = 0;
76− }
83+ highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex + 1, screen.workspaces.count - 1);
7784 }
78− function decreaseHighlight() {
79− highlightedWorkspaceIndex--;
80− if (highlightedWorkspaceIndex < 0) {
81− highlightedScreenIndex--;
82− if (highlightedScreenIndex < 0) {
83− highlightedScreenIndex = screensProxy.count - 1
84− }
85− var screen = screensProxy.get(highlightedScreenIndex);
86− highlightedWorkspaceIndex = screen.workspaces.count -1;
87− }
85+ function previousScreen() {
86+ highlightedScreenIndex = Math.max(highlightedScreenIndex - 1, 0);
87+ var screen = screensProxy.get(highlightedScreenIndex);
88+ highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
89+ }
90+ function nextScreen() {
91+ highlightedScreenIndex = Math.min(highlightedScreenIndex + 1, screensProxy.count - 1);
92+ var screen = screensProxy.get(highlightedScreenIndex);
93+ highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
8894 }
8995 }
9096
@@ -95,14 +101,18 @@ UbuntuShape {
95101 }
96102
97103 Keys.onPressed: {
98− hideTimer.restart();
99104 switch (event.key) {
100105 case Qt.Key_Left:
101− d.decreaseHighlight();
106+ d.previousWorkspace();
102107 break;
103108 case Qt.Key_Right:
104− d.increaseHighlight();
109+ d.nextWorkspace()
110+ break;
111+ case Qt.Key_Up:
112+ d.previousScreen();
105113 break;
114+ case Qt.Key_Down:
115+ d.nextScreen();
106116 }
107117 }
108118 Keys.onReleased: {
@@ -116,7 +126,6 @@ UbuntuShape {
116126 }
117127
118128 if (!d.altPressed && !d.ctrlPressed) {
119− print("starting hidetimer")
120129 d.active = false;
121130 hideTimer.start();
122131 focus = false;
@@ -124,56 +133,62 @@ UbuntuShape {
124133 }
125134 }
126135
127− Row {
128− id: screensRow
129− anchors {
130− top: parent.top; topMargin: units.gu(2)
131− left: parent.left; leftMargin: units.gu(2)
132− }
133− spacing: units.gu(2)
134−
135− Repeater {
136− model: screensProxy
137−
138− delegate: Item {
139− height: root.height - units.gu(4)
140− width: workspaces.width
141−
142− UbuntuShape {
143− id: header
144− anchors { left: parent.left; top: parent.top; right: parent.right }
145− height: units.gu(4)
146− backgroundColor: "white"
147−
148− Label {
149− anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
150− text: model.screen.name
151− color: UbuntuColors.ash
152− }
153− }
154−
155− Workspaces {
156− id: workspaces
157− height: parent.height - header.height - units.gu(2)
158− width: {
159− var width = 0;
160− if (screensProxy.count == 1) {
161− width = Math.min(implicitWidth, root.width - units.gu(8));
162− } else {
163− width = Math.min(implicitWidth, model.screen.active ? root.width - units.gu(48) : units.gu(40))
136+ UbuntuShape {
137+ backgroundColor: "#F2111111"
138+ clip: true
139+ width: Math.min(parent.width, screensColumn.width + units.gu(4))
140+ anchors.horizontalCenter: parent.horizontalCenter
141+ height: parent.height
142+
143+ Column {
144+ id: screensColumn
145+ anchors {
146+ top: parent.top; topMargin: units.gu(2) - d.highlightedScreenIndex * (d.rowHeight + screensColumn.spacing)
147+ left: parent.left; leftMargin: units.gu(2)
148+ }
149+ width: screensRepeater.itemAt(d.highlightedScreenIndex).width
150+ spacing: units.gu(2)
151+ Behavior on anchors.topMargin { UbuntuNumberAnimation {} }
152+ Behavior on width { UbuntuNumberAnimation {} }
153+
154+ Repeater {
155+ id: screensRepeater
156+ model: screensProxy
157+
158+ delegate: Item {
159+ height: d.rowHeight
160+ width: workspaces.width
161+ anchors.horizontalCenter: parent.horizontalCenter
162+ opacity: d.highlightedScreenIndex == index ? 1 : 0
163+ Behavior on opacity { UbuntuNumberAnimation {} }
164+
165+ UbuntuShape {
166+ id: header
167+ anchors { left: parent.left; top: parent.top; right: parent.right }
168+ height: units.gu(4)
169+ backgroundColor: "white"
170+
171+ Label {
172+ anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
173+ text: model.screen.name
174+ color: UbuntuColors.ash
164175 }
165− return Math.max(workspaces.minimumWidth, width);
166176 }
167177
168− Behavior on width { UbuntuNumberAnimation {} }
169− anchors.bottom: parent.bottom
170− anchors.bottomMargin: units.gu(1)
171− anchors.horizontalCenter: parent.horizontalCenter
172− screen: model.screen
173− background: root.background
174− selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
178+ Workspaces {
179+ id: workspaces
180+ height: parent.height - header.height - units.gu(2)
181+ width: Math.min(implicitWidth, root.width - units.gu(4))
182+
183+ anchors.bottom: parent.bottom
184+ anchors.bottomMargin: units.gu(1)
185+ anchors.horizontalCenter: parent.horizontalCenter
186+ screen: model.screen
187+ background: root.background
188+ selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
175189
176− workspaceModel: model.screen.workspaces
190+ workspaceModel: model.screen.workspaces
191+ }
177192 }
178193 }
179194 }