on xenial help sign in
add right edge push area to all stages
2655afeMichael Zanetti
qml/Stages/PhoneStage.qml+33
@@ -74,6 +74,12 @@ AbstractStage {
74 }
74 }
75 }
75 }
76
76
77+ function pushRightEdge(amount) {
78+ if (spreadView.contentX == -spreadView.shift) {
79+ edgeBarrier.push(amount);
80+ }
81+ }
82+
77 mainApp: applicationManager.focusedApplicationId
83 mainApp: applicationManager.focusedApplicationId
78 ? applicationManager.findApplication(applicationManager.focusedApplicationId)
84 ? applicationManager.findApplication(applicationManager.focusedApplicationId)
79 : null
85 : null
@@ -651,4 +657,31 @@ AbstractStage {
651 }
657 }
652 }
658 }
653 }
659 }
660+
661+ EdgeBarrier {
662+ id: edgeBarrier
663+
664+ // NB: it does its own positioning according to the specified edge
665+ edge: Qt.RightEdge
666+
667+ onPassed: {
668+ // Add 1 pixel to make sure we definitely hit positionMarker4 even with rounding errors of the animation.
669+ snapAnimation.targetContentX = root.width * spreadView.positionMarker4 + 1 - spreadView.shift;
670+ snapAnimation.start();
671+ }
672+ material: Component {
673+ Item {
674+ Rectangle {
675+ width: parent.height
676+ height: parent.width
677+ rotation: 90
678+ anchors.centerIn: parent
679+ gradient: Gradient {
680+ GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.7)}
681+ GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
682+ }
683+ }
684+ }
685+ }
686+ }
654}
687}
qml/Stages/TabletStage.qml+33
@@ -70,6 +70,12 @@ AbstractStage {
70 }
70 }
71 }
71 }
72
72
73+ function pushRightEdge(amount) {
74+ if (spreadView.contentX == -spreadView.shift) {
75+ edgeBarrier.push(amount);
76+ }
77+ }
78+
73 orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
79 orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
74
80
75 supportedOrientations: mainApp ? mainApp.supportedOrientations
81 supportedOrientations: mainApp ? mainApp.supportedOrientations
@@ -805,4 +811,31 @@ AbstractStage {
805 }
811 }
806 }
812 }
807 }
813 }
814+
815+ EdgeBarrier {
816+ id: edgeBarrier
817+
818+ // NB: it does its own positioning according to the specified edge
819+ edge: Qt.RightEdge
820+
821+ onPassed: {
822+ // Add 1 pixel to make sure we definitely hit positionMarker4 even with rounding errors of the animation.
823+ snapAnimation.targetContentX = root.width * spreadView.positionMarker4 + 1 - spreadView.shift;
824+ snapAnimation.start();
825+ }
826+ material: Component {
827+ Item {
828+ Rectangle {
829+ width: parent.height
830+ height: parent.width
831+ rotation: 90
832+ anchors.centerIn: parent
833+ gradient: Gradient {
834+ GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.7)}
835+ GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
836+ }
837+ }
838+ }
839+ }
840+ }
808}
841}
tests/qmltests/Stages/tst_PhoneStage.qml+19−6
@@ -40,12 +40,6 @@ Item {
40 orientations: Orientations {}
40 orientations: Orientations {}
41 }
41 }
42
42
43− Binding {
44− target: ApplicationManager
45− property: "rightMargin"
46− value: phoneStage.anchors.rightMargin
47− }
48−
49 Rectangle {
43 Rectangle {
50 anchors { fill: parent; leftMargin: phoneStage.width }
44 anchors { fill: parent; leftMargin: phoneStage.width }
51
45
@@ -77,6 +71,15 @@ Item {
77 ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfoInterface.Stopped);
71 ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfoInterface.Stopped);
78 }
72 }
79 }
73 }
74+ EdgeBarrierControls {
75+ id: edgeBarrierControls
76+ text: "Drag here to pull out spread"
77+ backgroundColor: "blue"
78+ onDragged: { phoneStage.pushRightEdge(amount); }
79+ Component.onCompleted: {
80+ edgeBarrierControls.target = testCase.findChild(phoneStage, "edgeBarrierController");
81+ }
82+ }
80 }
83 }
81 ListView {
84 ListView {
82 id: appList
85 id: appList
@@ -463,5 +466,15 @@ Item {
463
466
464 tryCompare(delegate.application, "requestedState", ApplicationInfoInterface.RequestedRunning);
467 tryCompare(delegate.application, "requestedState", ApplicationInfoInterface.RequestedRunning);
465 }
468 }
469+
470+ function test_mouseEdgePush() {
471+ var spreadView = findChild(phoneStage, "spreadView")
472+ addApps(1);
473+ mouseMove(phoneStage, phoneStage.width - 1, units.gu(10));
474+ for (var i = 0; i < units.gu(10); i++) {
475+ phoneStage.pushRightEdge(1);
476+ }
477+ tryCompare(spreadView, "phase", 2);
478+ }
466 }
479 }
467}
480}
tests/qmltests/Stages/tst_TabletStage.qml+19−1
@@ -21,6 +21,7 @@ import Ubuntu.Components.ListItems 1.3 as ListItem
21import Unity.Application 0.1
21import Unity.Application 0.1
22import Unity.Test 0.1
22import Unity.Test 0.1
23
23
24+import ".."
24import "../../../qml/Stages"
25import "../../../qml/Stages"
25import "../../../qml/Components"
26import "../../../qml/Components"
26
27
@@ -77,6 +78,15 @@ Rectangle {
77 Column {
78 Column {
78 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
79 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
79 spacing: units.gu(1)
80 spacing: units.gu(1)
81+ EdgeBarrierControls {
82+ id: edgeBarrierControls
83+ text: "Drag here to pull out spread"
84+ backgroundColor: "blue"
85+ onDragged: { tabletStageLoader.item.pushRightEdge(amount); }
86+ Component.onCompleted: {
87+ edgeBarrierControls.target = testCase.findChild(tabletStageLoader, "edgeBarrierController");
88+ }
89+ }
80 ApplicationCheckBox {
90 ApplicationCheckBox {
81 id: webbrowserCheckBox
91 id: webbrowserCheckBox
82 appId: "webbrowser-app"
92 appId: "webbrowser-app"
@@ -365,6 +375,14 @@ Rectangle {
365 tryCompare(webbrowserApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
375 tryCompare(webbrowserApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
366 tryCompare(dialerApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
376 tryCompare(dialerApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
367 }
377 }
368− }
369
378
379+ function test_mouseEdgePush() {
380+ var spreadView = findChild(tabletStageLoader, "spreadView")
381+ mouseMove(tabletStageLoader, tabletStageLoader.width - 1, units.gu(10));
382+ for (var i = 0; i < units.gu(10); i++) {
383+ tabletStageLoader.item.pushRightEdge(1);
384+ }
385+ tryCompare(spreadView, "phase", 2);
386+ }
387+ }
370}
388}