on xenial help sign in
Add back support for bottom edge
commit0c1ddcc9ea75ccd07a4f834cd090c69fa4737a4f authorMichael Terry <michael.terry@canonical.com> dateFri 13 Nov 2015, 15:04 (11 years ago) parentd1cc34e
5 files changed+53−32
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+6−3 qml/Shell.qml+1−2 qml/Tutorial/TutorialBottom.qml+38−3 qml/Tutorial/TutorialContent.qml+7−23 qml/Tutorial/TutorialPage.qml+1−1
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+6−3
@@ -436,11 +436,14 @@ void DirectionalDragAreaPrivate::touchEvent_absent(QTouchEvent *event)
436436 if (recognitionIsDisabled()) {
437437 // Behave like a dumb TouchArea
438438 ddaDebug("Gesture recognition is disabled. Requesting touch ownership immediately.");
439− if (!monitorOnly) {
439+ setStatus(Recognized);
440+ if (monitorOnly) {
441+ watchPressedTouchPoints(touchPoints);
442+ event->ignore();
443+ } else {
440444 TouchRegistry::instance()->requestTouchOwnership(touchId, q);
445+ event->accept();
441446 }
442− setStatus(Recognized);
443− event->accept();
444447 } else {
445448 // just monitor the touch points for now.
446449 if (monitorOnly) {
qml/Shell.qml+1−2
@@ -247,8 +247,7 @@ Item {
247247 }
248248 }
249249
250− property bool interactive: tutorial.spreadEnabled
251− && (!greeter || !greeter.shown)
250+ property bool interactive: (!greeter || !greeter.shown)
252251 && panel.indicators.fullyClosed
253252 && launcher.progress == 0
254253 && !notifications.useModal
qml/Tutorial/TutorialBottom.qml+38−3
@@ -21,6 +21,32 @@ import Ubuntu.Gestures 0.1
2121TutorialPage {
2222 id: root
2323
24+ // This page is a bit fragile. It relies on knowing how the app beneath
25+ // the shell will react to a drag. What we do is put a monitor-only DDA
26+ // at the bottom of the page (so that we know when the drag is finished)
27+ // and pass the events on through to the app. Thus, it sees the drag and
28+ // brings its bottom edge up.
29+ //
30+ // Unfortunately, each app is on its own when implementing the bottom edge
31+ // drag. Most share copied-and-pasted code right now, but they will
32+ // eventually consolidate on a version of DirectionalDragArea that will
33+ // land in the SDK (making our guessing job easier). Though, also in the
34+ // future, this whole bottom tutorial component will also land in the SDK,
35+ // rending our version here obsolete.
36+ //
37+ // Anyway, for the moment, we base our guesses on the copied-and-pasted
38+ // code used in several of the core apps and only bring this component
39+ // up if we are in those core apps.
40+
41+ readonly property real dragAreaHeight: units.gu(3) // based on PageWithBottomEdge.qml
42+ readonly property real targetDistance: height * 0.2 + dragAreaHeight // based on PageWithBottomEdge.qml
43+
44+ opacityOverride: dragArea.dragging ? 1 - (-dragArea.distance / targetDistance) : 1
45+
46+ mouseArea {
47+ anchors.bottomMargin: root.dragAreaHeight
48+ }
49+
2450 background {
2551 sourceSize.height: 1080
2652 sourceSize.width: 1916
@@ -44,11 +70,20 @@ TutorialPage {
4470 width: root.width - units.gu(8)
4571 }
4672
47− /*DirectionalDragArea {
73+ // Watches drag events but does not intercept them, so that the app beneath
74+ // will still drag the bottom edge up.
75+ DirectionalDragArea {
76+ id: dragArea
77+ monitorOnly: true
4878 direction: Direction.Upwards
4979 anchors.left: parent.left
5080 anchors.right: parent.right
5181 anchors.bottom: parent.bottom
52− height: units.gu(1)
53− }*/
82+ height: root.dragAreaHeight
83+
84+ // Because apps currently don't use DDA, and DDA will stop a gesture if
85+ // horizontal motion is detected. But our apps wont'. So turn off
86+ // that gesture cleverness on our part, it will only get us out of sync.
87+ immediateRecognition: true
88+ }
5489}
qml/Tutorial/TutorialContent.qml+7−23
@@ -74,7 +74,7 @@ Item {
7474 readonly property bool skipped: (root.usageScenario !== "phone"
7575 && root.usageScenario !== "tablet")
7676 || AccountsService.demoEdgesCompleted.indexOf("top") != -1
77− isReady: tutorialLeft.skipped && !skipped && !paused && !keyboardVisible
77+ isReady: tutorialLeft.skipped && !skipped && !paused && !keyboardVisible && !tutorialBottom.shown
7878
7979 Timer {
8080 id: tutorialTopTimer
@@ -103,7 +103,8 @@ Item {
103103 paused: root.paused
104104
105105 readonly property bool skipped: AccountsService.demoEdgesCompleted.indexOf("right") != -1
106− isReady: tutorialTop.skipped && !skipped && !paused && !keyboardVisible && ApplicationManager.count >= 3
106+ isReady: tutorialTop.skipped && !skipped && !paused && !keyboardVisible && !tutorialBottom.shown &&
107+ ApplicationManager.count >= 3
107108
108109 Timer {
109110 id: tutorialRightTimer
@@ -119,10 +120,7 @@ Item {
119120
120121 onSkippedChanged: if (skipped && shown) hide()
121122 onIsReadyChanged: if (isReady && !shown) tutorialRightTimer.start()
122− onFinished: {
123− AccountsService.markDemoEdgeCompleted("right");
124− root.finish();
125− }
123+ onFinished: AccountsService.markDemoEdgeCompleted("right")
126124 }
127125
128126 TutorialBottom {
@@ -135,30 +133,16 @@ Item {
135133 readonly property bool skipped: (root.usageScenario !== "phone"
136134 && root.usageScenario !== "tablet")
137135 || AccountsService.demoEdgesCompleted.indexOf("bottom") != -1
138− isReady: false /* tutorialRight.skipped && !skipped && !paused && !keyboardVisible &&
136+ isReady: !skipped && !paused && !keyboardVisible && !tutorialTop.shown && !tutorialRight.shown &&
139137 // focused app is an app known to have a bottom edge
140138 (ApplicationManager.focusedApplicationId == "dialer-app" ||
141− ApplicationManager.focusedApplicationId == "webbrowser-app" ||
142139 ApplicationManager.focusedApplicationId == "messaging-app" ||
143140 ApplicationManager.focusedApplicationId == "address-book-app" ||
144− ApplicationManager.focusedApplicationId == "camera-app" ||
145141 ApplicationManager.focusedApplicationId == "ubuntu-calculator-app" ||
146− ApplicationManager.focusedApplicationId == "ubuntu-clock-app") */
147−
148− /*Timer {
149− id: tutorialBottomTimer
150− objectName: "tutorialBottomTimer"
151− interval: 3000
152− onTriggered: if (tutorialBottom.isReady && !tutorialBottom.shown) tutorialBottom.show()
153− }*/
154−
155− Connections {
156− target: ApplicationManager
157− onApplicationAdded: if (tutorialBottom.isReady && !tutorialBottom.shown) tutorialBottom.show()
158− }
142+ ApplicationManager.focusedApplicationId == "ubuntu-clock-app")
159143
160144 onSkippedChanged: if (skipped && shown) hide()
161− //onIsReadyChanged: if (isReady && !shown) tutorialBottomTimer.start()
145+ onIsReadyChanged: if (isReady && !shown) show()
162146 onFinished: {
163147 AccountsService.markDemoEdgeCompleted("bottom");
164148 root.finish();
qml/Tutorial/TutorialPage.qml+1−1
@@ -41,7 +41,7 @@ Showable {
4141 visible: false
4242 shown: false
4343
44− opacity: Math.min(_showOpacity, opacityOverride)
44+ opacity: Math.max(Math.min(_showOpacity, opacityOverride), 0)
4545 onOpacityOverrideChanged: if (opacityOverride <= 0) hide()
4646 property real _showOpacity: 0
4747