on xenial help sign in
move right edge push area up some levels so it can be used on top of the indicators

Approved by: Lukáš Tinkl

commit32b9b6eb5cf62f7ebbc69c88592e2daba40a799d authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 16 Feb 2017, 13:43 (10 years ago) parent8146597a456cef
7 files changed+117−51
qml/Components/EdgeBarrierController.qml+1 qml/Shell.qml+29−1 qml/Stage/Stage.qml+14−36 tests/qmltests/Stage/tst_DesktopStage.qml+16−6 tests/qmltests/Stage/tst_PhoneStage.qml+4−5 tests/qmltests/Tutorial/tst_Tutorial.qml+2−2 tests/qmltests/tst_Shell.qml+51−1
qml/Components/EdgeBarrierController.qml+1
@@ -34,6 +34,7 @@ MouseArea {
3434
3535 function push(amount) {
3636 if (!root._containsMouse) {
37+ console.warn("pushing right edge without mouse actually being at right edge!")
3738 return;
3839 }
3940
qml/Shell.qml+29−1
@@ -288,6 +288,7 @@ StyledItem {
288288 applicationManager: ApplicationManager
289289 topLevelSurfaceList: topLevelSurfaceList
290290 inputMethodRect: inputMethod.visibleRect
291+ rightEdgePushProgress: rightEdgeBarrier.progress
291292
292293 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
293294 ? "phone"
@@ -694,6 +695,33 @@ StyledItem {
694695 }
695696 ]
696697 }
698+
699+ EdgeBarrier {
700+ id: rightEdgeBarrier
701+ enabled: !greeter.shown
702+
703+ // NB: it does its own positioning according to the specified edge
704+ edge: Qt.RightEdge
705+
706+ onPassed: {
707+ panel.indicators.hide()
708+ }
709+
710+ material: Component {
711+ Item {
712+ Rectangle {
713+ width: parent.height
714+ height: parent.width
715+ rotation: 90
716+ anchors.centerIn: parent
717+ gradient: Gradient {
718+ GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
719+ GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
720+ }
721+ }
722+ }
723+ }
724+ }
697725 }
698726
699727 Dialogs {
@@ -777,7 +805,7 @@ StyledItem {
777805
778806 onPushedRightBoundary: {
779807 if (buttons === Qt.NoButton) {
780− stage.pushRightEdge(amount);
808+ rightEdgeBarrier.push(amount);
781809 } else if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximizedLeftRight) {
782810 previewRectangle.maximizeRight(amount);
783811 }
qml/Stage/Stage.qml+14−36
@@ -46,6 +46,7 @@ FocusScope {
4646 property int leftMargin: 0
4747 property bool oskEnabled: false
4848 property rect inputMethodRect
49+ property real rightEdgePushProgress: 0
4950
5051 // Configuration
5152 property string mode: "staged"
@@ -127,11 +128,6 @@ FocusScope {
127128 // functions to be called from outside
128129 function updateFocusedAppOrientation() { /* TODO */ }
129130 function updateFocusedAppOrientationAnimated() { /* TODO */}
130− function pushRightEdge(amount) {
131− if (root.spreadEnabled) {
132− edgeBarrier.push(amount);
133− }
134− }
135131
136132 function closeSpread() {
137133 priv.goneToSpread = false;
@@ -143,6 +139,12 @@ FocusScope {
143139 }
144140 }
145141
142+ onRightEdgePushProgressChanged: {
143+ if (spreadEnabled && rightEdgePushProgress >= 1) {
144+ priv.goneToSpread = true
145+ }
146+ }
147+
146148 GSettings {
147149 id: lifecycleExceptions
148150 schema.id: "com.canonical.qtmir"
@@ -454,7 +456,7 @@ FocusScope {
454456 PropertyChanges { target: wallpaper; visible: false }
455457 },
456458 State {
457− name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
459+ name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
458460 PropertyChanges {
459461 target: blurLayer;
460462 visible: true;
@@ -464,7 +466,7 @@ FocusScope {
464466 }
465467 },
466468 State {
467− name: "sideStagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "stagedWithSideStage"
469+ name: "sideStagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "stagedWithSideStage"
468470 extend: "stagedRightEdge"
469471 PropertyChanges {
470472 target: sideStage
@@ -473,13 +475,13 @@ FocusScope {
473475 }
474476 },
475477 State {
476− name: "windowedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "windowed"
478+ name: "windowedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "windowed"
477479 PropertyChanges {
478480 target: blurLayer;
479481 visible: true
480482 blurRadius: 32
481483 brightness: .65
482− opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, edgeBarrier.progress))
484+ opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, rightEdgePushProgress))
483485 }
484486 },
485487 State {
@@ -1203,7 +1205,7 @@ FocusScope {
12031205 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
12041206 PropertyChanges {
12051207 target: stagedRightEdgeMaths
1206− progress: Math.max(edgeBarrier.progress, rightEdgeDragArea.draggedProgress)
1208+ progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
12071209 }
12081210 PropertyChanges {
12091211 target: appDelegate
@@ -1230,11 +1232,11 @@ FocusScope {
12301232 },
12311233 State {
12321234 name: "windowedRightEdge"
1233− when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || edgeBarrier.progress > 0)
1235+ when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
12341236 PropertyChanges {
12351237 target: windowedRightEdgeMaths
12361238 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1237− pushProgress: edgeBarrier.progress
1239+ pushProgress: rightEdgePushProgress
12381240 }
12391241 PropertyChanges {
12401242 target: appDelegate
@@ -1766,30 +1768,6 @@ FocusScope {
17661768 appContainerHeight: appContainer.height
17671769 }
17681770
1769− EdgeBarrier {
1770− id: edgeBarrier
1771−
1772− // NB: it does its own positioning according to the specified edge
1773− edge: Qt.RightEdge
1774−
1775− onPassed: priv.goneToSpread = true;
1776−
1777− material: Component {
1778− Item {
1779− Rectangle {
1780− width: parent.height
1781− height: parent.width
1782− rotation: 90
1783− anchors.centerIn: parent
1784− gradient: Gradient {
1785− GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
1786− GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
1787− }
1788− }
1789− }
1790− }
1791− }
1792−
17931771 MouseArea {
17941772 id: hoverMouseArea
17951773 objectName: "hoverMouseArea"
tests/qmltests/Stage/tst_DesktopStage.qml+16−6
@@ -92,7 +92,6 @@ Item {
9292 focus: true
9393
9494 Component.onCompleted: {
95− edgeBarrierControls.target = testCase.findChild(this, "edgeBarrierController");
9695 ApplicationManager.startApplication("unity8-dash");
9796 }
9897 Component.onDestruction: {
@@ -135,11 +134,22 @@ Item {
135134 }
136135 }
137136
138− EdgeBarrierControls {
139− id: edgeBarrierControls
140− text: "Drag here to pull out spread"
141− backgroundColor: "blue"
142− onDragged: { stageLoader.item.pushRightEdge(amount); }
137+ Label {
138+ text: "Right edge push progress"
139+ }
140+
141+ Slider {
142+ id: rightEdgePushSlider
143+ width: parent.width
144+ live: true
145+ minimumValue: 0.0
146+ maximumValue: 1.0
147+ onPressedChanged: {
148+ if (!pressed) {
149+ value = 0;
150+ }
151+ }
152+ Binding { target: stageLoader.item; property: "rightEdgePushProgress"; value: rightEdgePushSlider.value }
143153 }
144154
145155 Divider {}
tests/qmltests/Stage/tst_PhoneStage.qml+4−5
@@ -418,11 +418,10 @@ Item {
418418
419419 function test_mouseEdgePush() {
420420 addApps(1);
421− mouseMove(stage, stage.width - 1, units.gu(10));
422− for (var i = 0; i < units.gu(10); i++) {
423− stage.pushRightEdge(1);
424− }
425− mouseMove(stage, stage.width - units.gu(5), units.gu(10));
421+ // When progress goes to 1 it should switch to spread, but stay there even if progress goes back
422+ stage.rightEdgePushProgress = 1;
423+ compare(stage.state, "spread");
424+ stage.rightEdgePushProgress = 0;
426425 compare(stage.state, "spread");
427426 }
428427
tests/qmltests/Tutorial/tst_Tutorial.qml+2−2
@@ -719,9 +719,9 @@ Rectangle {
719719 ApplicationManager.startApplication("facebook-webapp");
720720 tryCompare(tutorialRightLoader, "shown", true);
721721
722− var stage = findChild(shell, "stage");
722+ var cursor = findChild(shell, "cursor");
723723 mouseMove(shell, shell.width, shell.height / 2);
724− stage.pushRightEdge(units.gu(8));
724+ cursor.pushedRightBoundary(units.gu(8), 0);
725725 tryCompare(tutorialRightLoader, "shown", false);
726726
727727 tryCompare(AccountsService, "demoEdges", false);
tests/qmltests/tst_Shell.qml+51−1
@@ -2587,6 +2587,55 @@ Rectangle {
25872587 tryCompareFunction(function() { return ApplicationManager.focusedApplicationId; }, "calendar-app");
25882588 }
25892589
2590+ function test_rightEdgePushWithOpenIndicators() {
2591+ loadShell("desktop");
2592+ shell.usageScenario = "desktop";
2593+ waitForRendering(shell);
2594+ swipeAwayGreeter();
2595+
2596+ var stage = findChild(shell, "stage");
2597+ var cursor = findChild(shell, "cursor");
2598+ var indicators = findChild(shell, "indicators");
2599+
2600+ // Open indicators
2601+ var touchX = shell.width - units.gu(5);
2602+ touchFlick(shell,
2603+ touchX /* fromX */, indicators.minimizedPanelHeight * 0.5 /* fromY */,
2604+ touchX /* toX */, shell.height * 0.9 /* toY */,
2605+ true /* beginTouch */, true /* endTouch */);
2606+ tryCompare(indicators, "fullyOpened", true);
2607+
2608+ // push the right edge
2609+ mouseMove(shell, shell.width - 1, units.gu(10));
2610+ for (var i = 0; i < units.gu(10); i++) {
2611+ cursor.pushedRightBoundary(1, 0);
2612+ }
2613+ tryCompare(stage, "rightEdgePushProgress", 1);
2614+ tryCompare(stage, "state", "spread");
2615+ tryCompare(indicators, "fullyOpened", false);
2616+
2617+ mouseMove(shell, shell.width - units.gu(5), units.gu(10));
2618+
2619+ tryCompare(stage, "rightEdgePushProgress", 0);
2620+ }
2621+
2622+ function test_rightEdgePushOnGreeter() {
2623+ loadShell("desktop");
2624+ shell.usageScenario = "desktop";
2625+ waitForRendering(shell);
2626+
2627+ var stage = findChild(shell, "stage");
2628+ var cursor = findChild(shell, "cursor");
2629+
2630+ // push the right edge, but verify it doesn't emit any progress
2631+ mouseMove(shell, shell.width - 1, units.gu(10));
2632+ for (var i = 0; i < units.gu(10); i++) {
2633+ cursor.pushedRightBoundary(1, 0);
2634+ compare(stage.rightEdgePushProgress, 0);
2635+ }
2636+ compare(stage.rightEdgePushProgress, 0);
2637+ }
2638+
25902639 function test_oskDisplacesWindow_data() {
25912640 return [
25922641 {tag: "no need to displace", windowHeight: units.gu(10), windowY: units.gu(5), targetDisplacement: units.gu(5), oskEnabled: true},
@@ -2709,9 +2758,10 @@ Rectangle {
27092758 tryCompare(stage, "state", "staged");
27102759
27112760 // Try by edge push
2761+ var cursor = findChild(shell, "cursor");
27122762 mouseMove(stage, stage.width - 1, units.gu(10));
27132763 for (var i = 0; i < units.gu(10); i++) {
2714− stage.pushRightEdge(1);
2764+ cursor.pushedRightBoundary(1, 0);
27152765 }
27162766 mouseMove(stage, stage.width - units.gu(5), units.gu(10));
27172767 tryCompare(stage, "state", data.spreadEnabled ? "spread" : "staged");