on xenial help sign in
Active Scree visuals in Spread
commitfb0297b2580777418addc6dc722d615fadde0058 authorNick Dedekind <nick.dedekind@canonical.com> dateWed 5 Apr 2017, 13:22 (10 years ago) parentb6ab28f
2 files changed+50−9
qml/Stage/Spread/ScreensAndWorkspaces.qml+49−8 qml/Stage/Spread/Workspaces.qml+1−1
qml/Stage/Spread/ScreensAndWorkspaces.qml+49−8
@@ -12,8 +12,8 @@ Item {
1212
1313 property var screensProxy: Screens.createProxy();
1414
15− property var lastClickedWorkspace: null
16− property var activeWorkspace: null
15+ property QtObject lastClickedWorkspace: null
16+ property QtObject activeWorkspace: null
1717 onActiveWorkspaceChanged: print("********************* active workspace changed:", activeWorkspace)
1818
1919 signal closeSpread();
@@ -23,9 +23,9 @@ Item {
2323 anchors.bottom: parent.bottom
2424 anchors.horizontalCenter: parent.horizontalCenter
2525 Behavior on anchors.horizontalCenterOffset { NumberAnimation { duration: UbuntuAnimation.SlowDuration } }
26−// anchors.left: parent.left
2726 spacing: units.gu(1)
2827
28+ property var selectedIndex: undefined
2929
3030 Repeater {
3131 model: screensProxy
@@ -34,13 +34,39 @@ Item {
3434 height: root.height - units.gu(6)
3535 width: workspaces.width
3636
37− UbuntuShape {
37+ Item {
3838 id: header
3939 anchors { left: parent.left; top: parent.top; right: parent.right }
4040 height: units.gu(7)
41− backgroundColor: "white"
4241 z: 1
4342
43+ property bool isCurrent: {
44+ // another screen is selected.
45+ if (row.selectedIndex != undefined && row.selectedIndex != index) return false;
46+
47+ // this screen is active.
48+ if (WMScreen.active && WMScreen.isSameAs(model.screen) && WMScreen.currentWorkspace.isSameAs(activeWorkspace)) return true;
49+ if (model.screen.workspaces.indexOf(activeWorkspace) >= 0) return true;
50+
51+ // not active.
52+ return false;
53+ }
54+
55+ property bool isSelected: screenMA.containsMouse
56+ onIsSelectedChanged: {
57+ if (isSelected) {
58+ row.selectedIndex = Qt.binding(function() { return index; });
59+ } else if (row.selectedIndex === index) {
60+ row.selectedIndex = undefined;
61+ }
62+ }
63+
64+ UbuntuShape {
65+ anchors.fill: parent
66+ backgroundColor: "white"
67+ opacity: header.isCurrent || header.isSelected ? 1.0 : 0.5
68+ }
69+
4470 DropArea {
4571 anchors.fill: parent
4672 keys: ["workspace"]
@@ -66,23 +92,38 @@ Item {
6692
6793 Label {
6894 text: model.screen.name
69− color: "black"
95+ color: header.isCurrent || header.isSelected ? "black" : "white"
7096 }
7197
7298 Label {
7399 text: model.screen.outputTypeName
74− color: "black"
100+ color: header.isCurrent || header.isSelected ? "black" : "white"
75101 fontSize: "x-small"
76102 }
77103
78104 Label {
79105 text: screen.availableModes[screen.currentModeIndex].size.width + "x" + screen.availableModes[screen.currentModeIndex].size.height
80− color: "black"
106+ color: header.isCurrent || header.isSelected ? "black" : "white"
81107 fontSize: "x-small"
82108 }
83109 }
84110
111+ Icon {
112+ anchors {
113+ top: parent.top
114+ right: parent.right
115+ margins: units.gu(1)
116+ }
117+ width: units.gu(3)
118+ height: width
119+ source: "image://theme/select"
120+ color: header.isCurrent || header.isSelected ? "black" : "white"
121+ visible: model.screen.active
122+ }
123+
85124 MouseArea {
125+ id: screenMA
126+ hoverEnabled: true
86127 anchors.fill: parent
87128
88129 onClicked: {
qml/Stage/Spread/Workspaces.qml+1−1
@@ -257,7 +257,7 @@ Item {
257257 screenHeight: listView.screenHeight
258258 containsDragLeft: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "left"
259259 containsDragRight: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "right"
260− isActive: workspace == root.activeWorkspace
260+ isActive: workspace.isSameAs(root.activeWorkspace)
261261 isSelected: index === root.selectedIndex
262262 workspace: model.workspace
263263 }