on xenial help sign in
add right edge push area to all stages
commit2655afe47f9ed9f8cec341ed874e8cb3e7711ca8 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 25 Feb 2016, 14:22 (11 years ago) parentad60084
4 files changed+104−7
qml/Stages/PhoneStage.qml+33 qml/Stages/TabletStage.qml+33 tests/qmltests/Stages/tst_PhoneStage.qml+19−6 tests/qmltests/Stages/tst_TabletStage.qml+19−1
qml/Stages/PhoneStage.qml+33
@@ -74,6 +74,12 @@ AbstractStage {
7474 }
7575 }
7676
77+ function pushRightEdge(amount) {
78+ if (spreadView.contentX == -spreadView.shift) {
79+ edgeBarrier.push(amount);
80+ }
81+ }
82+
7783 mainApp: applicationManager.focusedApplicationId
7884 ? applicationManager.findApplication(applicationManager.focusedApplicationId)
7985 : null
@@ -651,4 +657,31 @@ AbstractStage {
651657 }
652658 }
653659 }
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+ }
654687}
qml/Stages/TabletStage.qml+33
@@ -70,6 +70,12 @@ AbstractStage {
7070 }
7171 }
7272
73+ function pushRightEdge(amount) {
74+ if (spreadView.contentX == -spreadView.shift) {
75+ edgeBarrier.push(amount);
76+ }
77+ }
78+
7379 orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
7480
7581 supportedOrientations: mainApp ? mainApp.supportedOrientations
@@ -805,4 +811,31 @@ AbstractStage {
805811 }
806812 }
807813 }
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+ }
808841}
tests/qmltests/Stages/tst_PhoneStage.qml+19−6
@@ -40,12 +40,6 @@ Item {
4040 orientations: Orientations {}
4141 }
4242
43− Binding {
44− target: ApplicationManager
45− property: "rightMargin"
46− value: phoneStage.anchors.rightMargin
47− }
48−
4943 Rectangle {
5044 anchors { fill: parent; leftMargin: phoneStage.width }
5145
@@ -77,6 +71,15 @@ Item {
7771 ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfoInterface.Stopped);
7872 }
7973 }
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+ }
8083 }
8184 ListView {
8285 id: appList
@@ -463,5 +466,15 @@ Item {
463466
464467 tryCompare(delegate.application, "requestedState", ApplicationInfoInterface.RequestedRunning);
465468 }
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+ }
466479 }
467480}
tests/qmltests/Stages/tst_TabletStage.qml+19−1
@@ -21,6 +21,7 @@ import Ubuntu.Components.ListItems 1.3 as ListItem
2121import Unity.Application 0.1
2222import Unity.Test 0.1
2323
24+import ".."
2425import "../../../qml/Stages"
2526import "../../../qml/Components"
2627
@@ -77,6 +78,15 @@ Rectangle {
7778 Column {
7879 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
7980 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+ }
8090 ApplicationCheckBox {
8191 id: webbrowserCheckBox
8292 appId: "webbrowser-app"
@@ -365,6 +375,14 @@ Rectangle {
365375 tryCompare(webbrowserApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
366376 tryCompare(dialerApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
367377 }
368− }
369378
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+ }
370388}