on xenial help sign in
add hover item to screens
2f4159aMichael Zanetti
qml/Stage/Stage.qml+82−77
@@ -451,6 +451,7 @@ FocusScope {
451 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
451 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
452 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
452 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
453 PropertyChanges { target: wallpaper; visible: false }
453 PropertyChanges { target: wallpaper; visible: false }
454+ PropertyChanges { target: screensAndWorkspaces; opacity: 1 }
454 },
455 },
455 State {
456 State {
456 name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
457 name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
@@ -499,11 +500,13 @@ FocusScope {
499 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
500 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
500 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
501 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
501 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
502 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
503+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
502 },
504 },
503 Transition {
505 Transition {
504 to: "spread"
506 to: "spread"
505 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
507 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
506 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
508 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
509+ UbuntuNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
507 },
510 },
508 Transition {
511 Transition {
509 from: "spread"
512 from: "spread"
@@ -565,6 +568,8 @@ FocusScope {
565 anchors { left: parent.left; top: parent.top; right: parent.right }
568 anchors { left: parent.left; top: parent.top; right: parent.right }
566 height: parent.height / 3
569 height: parent.height / 3
567 background: root.background
570 background: root.background
571+ opacity: 0
572+ visible: opacity > 0
568 }
573 }
569
574
570 Spread {
575 Spread {
@@ -579,6 +584,83 @@ FocusScope {
579 onLeaveSpread: {
584 onLeaveSpread: {
580 priv.goneToSpread = false;
585 priv.goneToSpread = false;
581 }
586 }
587+
588+ FloatingFlickable {
589+ id: floatingFlickable
590+ objectName: "spreadFlickable"
591+ anchors.fill: parent
592+ enabled: false
593+ contentWidth: spreadItem.spreadTotalWidth
594+
595+ function snap(toIndex) {
596+ var delegate = appRepeater.itemAt(toIndex)
597+ var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
598+ if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
599+ var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
600+ snapAnimation.to = floatingFlickable.contentX - offset;
601+ snapAnimation.start();
602+ } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
603+ var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
604+ snapAnimation.to = floatingFlickable.contentX - offset;
605+ snapAnimation.start();
606+ }
607+ }
608+ UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
609+ }
610+
611+ MouseArea {
612+ id: hoverMouseArea
613+ objectName: "hoverMouseArea"
614+ anchors.fill: parent
615+ propagateComposedEvents: true
616+ hoverEnabled: true
617+ enabled: false
618+ visible: enabled
619+
620+ property int scrollAreaWidth: width / 3
621+ property bool progressiveScrollingEnabled: false
622+
623+ onMouseXChanged: {
624+ mouse.accepted = false
625+
626+ if (hoverMouseArea.pressed) {
627+ return;
628+ }
629+
630+ // Find the hovered item and mark it active
631+ for (var i = appRepeater.count - 1; i >= 0; i--) {
632+ var appDelegate = appRepeater.itemAt(i);
633+ var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
634+ var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
635+ if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
636+ spreadItem.highlightedIndex = i;
637+ break;
638+ }
639+ }
640+
641+ if (floatingFlickable.contentWidth > floatingFlickable.width) {
642+ var margins = floatingFlickable.width * 0.05;
643+
644+ if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
645+ progressiveScrollingEnabled = true
646+ }
647+
648+ // do we need to scroll?
649+ if (mouseX < scrollAreaWidth + margins) {
650+ var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
651+ var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
652+ floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
653+ }
654+ if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
655+ var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
656+ var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
657+ floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
658+ }
659+ }
660+ }
661+
662+ onPressed: mouse.accepted = false
663+ }
582 }
664 }
583
665
584 Connections {
666 Connections {
@@ -1750,83 +1832,6 @@ FocusScope {
1750 }
1832 }
1751 }
1833 }
1752
1834
1753− MouseArea {
1754− id: hoverMouseArea
1755− objectName: "hoverMouseArea"
1756− anchors.fill: appContainer
1757− propagateComposedEvents: true
1758− hoverEnabled: true
1759− enabled: false
1760− visible: enabled
1761−
1762− property int scrollAreaWidth: width / 3
1763− property bool progressiveScrollingEnabled: false
1764−
1765− onMouseXChanged: {
1766− mouse.accepted = false
1767−
1768− if (hoverMouseArea.pressed) {
1769− return;
1770− }
1771−
1772− // Find the hovered item and mark it active
1773− for (var i = appRepeater.count - 1; i >= 0; i--) {
1774− var appDelegate = appRepeater.itemAt(i);
1775− var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1776− var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
1777− if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
1778− spreadItem.highlightedIndex = i;
1779− break;
1780− }
1781− }
1782−
1783− if (floatingFlickable.contentWidth > floatingFlickable.width) {
1784− var margins = floatingFlickable.width * 0.05;
1785−
1786− if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
1787− progressiveScrollingEnabled = true
1788− }
1789−
1790− // do we need to scroll?
1791− if (mouseX < scrollAreaWidth + margins) {
1792− var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
1793− var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
1794− floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
1795− }
1796− if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
1797− var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
1798− var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
1799− floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
1800− }
1801− }
1802− }
1803−
1804− onPressed: mouse.accepted = false
1805− }
1806−
1807− FloatingFlickable {
1808− id: floatingFlickable
1809− objectName: "spreadFlickable"
1810− anchors.fill: appContainer
1811− enabled: false
1812− contentWidth: spreadItem.spreadTotalWidth
1813−
1814− function snap(toIndex) {
1815− var delegate = appRepeater.itemAt(toIndex)
1816− var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
1817− if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
1818− var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
1819− snapAnimation.to = floatingFlickable.contentX - offset;
1820− snapAnimation.start();
1821− } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
1822− var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
1823− snapAnimation.to = floatingFlickable.contentX - offset;
1824− snapAnimation.start();
1825− }
1826− }
1827− UbuntuNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
1828− }
1829−
1830 PropertyAnimation {
1835 PropertyAnimation {
1831 id: shortRightEdgeSwipeAnimation
1836 id: shortRightEdgeSwipeAnimation
1832 property: "x"
1837 property: "x"
qml/Stage/WorkspacePreview.qml+64−1
@@ -52,7 +52,7 @@ UbuntuShape {
52
52
53 Repeater {
53 Repeater {
54 id: topLevelSurfaceRepeater
54 id: topLevelSurfaceRepeater
55− model: topLevelSurfaceList
55+ model: visible ? topLevelSurfaceList : null
56 delegate: Rectangle {
56 delegate: Rectangle {
57 width: surfaceItem.width
57 width: surfaceItem.width
58 height: surfaceItem.height + decorationHeight * previewScale
58 height: surfaceItem.height + decorationHeight * previewScale
@@ -89,4 +89,67 @@ UbuntuShape {
89 }
89 }
90 }
90 }
91 }
91 }
92+
93+ MouseArea {
94+ id: mouseArea
95+ anchors.centerIn: parent
96+ anchors.verticalCenterOffset: header.height / 2
97+ width: units.gu(10)
98+ height: width
99+ hoverEnabled: true
100+ opacity: containsMouse ? 1 : 0
101+
102+ Rectangle {
103+ anchors.fill: parent
104+ color: "#55000000"
105+ radius: height / 2
106+ }
107+
108+ NumberAnimation {
109+ target: canvas
110+ property: "progress"
111+ duration: 2000
112+ running: mouseArea.containsMouse
113+ from: 0
114+ to: 1
115+ }
116+
117+ Canvas {
118+ id: canvas
119+ height: parent.height
120+ width: height
121+ anchors.centerIn: parent
122+
123+ property real progress: 0.5
124+ property int lineWidth: units.dp(4)
125+ onProgressChanged: {
126+ requestPaint()
127+ }
128+
129+ rotation: -90
130+
131+ onPaint: {
132+ var ctx = canvas.getContext("2d");
133+ ctx.save();
134+ ctx.reset();
135+
136+ ctx.lineWidth = lineWidth;
137+
138+ ctx.strokeStyle = "#55ffffff"
139+ ctx.beginPath();
140+ ctx.arc(canvas.width/2,canvas.height/2, (canvas.height - ctx.lineWidth) / 2, 0, (Math.PI*2),false);
141+ ctx.stroke();
142+ ctx.closePath();
143+
144+ ctx.strokeStyle = "white"
145+ ctx.beginPath();
146+ ctx.arc(canvas.width/2,canvas.height/2, (canvas.height - ctx.lineWidth) / 2, 0, (Math.PI*2*(progress)),false);
147+ ctx.stroke();
148+ ctx.closePath();
149+
150+
151+ ctx.restore();
152+ }
153+ }
154+ }
92}
155}
src/DebuggingController.cpp+1−1
@@ -50,7 +50,7 @@ public:
50
50
51DebuggingController::DebuggingController(QObject *parent):
51DebuggingController::DebuggingController(QObject *parent):
52 UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent),
52 UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent),
53− m_logOverlay(true)
53+ m_logOverlay(false)
54{
54{
55}
55}
56
56
tests/mocks/Unity/Application/MirSurfaceItem.cpp+5−1
@@ -185,7 +185,7 @@ void MirSurfaceItem::createQmlContentItem()
185 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
185 m_qmlItem = qobject_cast<QQuickItem*>(m_qmlContentComponent->create());
186 m_qmlItem->setParentItem(this);
186 m_qmlItem->setParentItem(this);
187
187
188− if (m_fillMode == FillMode::Stretch) {
188+ if (m_fillMode == FillMode::Stretch && width() != 0 && height() != 0) {
189 m_qmlItem->setWidth(width());
189 m_qmlItem->setWidth(width());
190 m_qmlItem->setHeight(height());
190 m_qmlItem->setHeight(height());
191 } else {
191 } else {
@@ -193,6 +193,7 @@ void MirSurfaceItem::createQmlContentItem()
193 m_qmlItem->setHeight(m_surfaceHeight);
193 m_qmlItem->setHeight(m_surfaceHeight);
194 }
194 }
195
195
196+ qDebug() << "set size to" << m_surfaceWidth;
196 setImplicitWidth(m_qmlItem->implicitWidth());
197 setImplicitWidth(m_qmlItem->implicitWidth());
197 setImplicitHeight(m_qmlItem->implicitHeight());
198 setImplicitHeight(m_qmlItem->implicitHeight());
198
199
@@ -306,6 +307,8 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
306 }
307 }
307 setImplicitSize(m_qmlSurface->width(), m_qmlSurface->height());
308 setImplicitSize(m_qmlSurface->width(), m_qmlSurface->height());
308 });
309 });
310+ m_surfaceWidth = surface->size().width();
311+ m_surfaceHeight = surface->size().height();
309
312
310 QUrl qmlComponentFilePath;
313 QUrl qmlComponentFilePath;
311 if (!m_qmlSurface->qmlFilePath().isEmpty()) {
314 if (!m_qmlSurface->qmlFilePath().isEmpty()) {
@@ -319,6 +322,7 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
319 switch (m_qmlContentComponent->status()) {
322 switch (m_qmlContentComponent->status()) {
320 case QQmlComponent::Ready:
323 case QQmlComponent::Ready:
321 createQmlContentItem();
324 createQmlContentItem();
325+ qDebug() << "content created" << m_surfaceWidth << implicitWidth() << width();
322 break;
326 break;
323 case QQmlComponent::Loading:
327 case QQmlComponent::Loading:
324 connect(m_qmlContentComponent, &QQmlComponent::statusChanged,
328 connect(m_qmlContentComponent, &QQmlComponent::statusChanged,