on xenial help sign in
Bottombar: s/Revealer/DirectionalDragArea + refactoring.
1e359e2Daniel d'Andrada
Bottombar/Bottombar.qml+48−82
@@ -18,38 +18,42 @@ import QtQuick 2.0
18import "../Components"
18import "../Components"
19import "../Components/Math.js" as MathLocal
19import "../Components/Math.js" as MathLocal
20import Unity 0.1
20import Unity 0.1
21+import Ubuntu.Gestures 0.1
21
22
22Item {
23Item {
23 id: bottombar
24 id: bottombar
24− width: shell.width
25+
25− height: shell.height
26+ // Whether there's an application on foreground (as opposed to have shell's Dash on foreground)
27+ property bool applicationIsOnForeground
26
28
27 property variant theHud
29 property variant theHud
28 property bool enabled: false
30 property bool enabled: false
29 readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
31 readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
30− readonly property real bottomEdgeShowButtonDistance: units.gu(2)
31−
32− property bool __applicationInFocus: false
33
32
34− state: "hidden"
33+ state: dragArea.status === DirectionalDragArea.Recognized ? "shown" : "hidden"
35
34
36 HudButton {
35 HudButton {
37 id: hudButton
36 id: hudButton
38
37
39− x: MathLocal.clamp(hudButtonRevealer.pressedX - width / 2, 0, bottombar.width - width)
38+ x: MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
40− y: bottombar.height - bottomEdgeButtonCenterDistance - height / 2 - bottomMargin
39+ y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
41− Behavior on bottomMargin {
40+
42− NumberAnimation{duration: hudButton.opacity < 0.01 ? 200 : 70; easing.type: Easing.OutQuart}
41+ mouseOver: {
43− }
42+ if (dragArea.status === DirectionalDragArea.Recognized) {
44− mouse: {
43+ var touchLocal = mapFromItem(dragArea, dragArea.touchX, dragArea.touchY)
45− if (hudButtonRevealer.draggingArea.pressed) {
44+ return touchLocal.x > 0 && touchLocal.x < width
46− var mapped = mapFromItem(hudButtonRevealer.draggingArea, hudButtonRevealer.draggingArea.mouseX, hudButtonRevealer.draggingArea.mouseY)
45+ && touchLocal.y > 0 && touchLocal.y < height
47− return Qt.point(mapped.x, mapped.y)
48 } else {
46 } else {
49− return mouse
47+ return false
50 }
48 }
51 }
49 }
52
50
51+ onClicked: theHud.show()
52+
53+ Behavior on bottomMargin {
54+ NumberAnimation{duration: hudButton.opacity < 0.01 ? 200 : 70; easing.type: Easing.OutQuart}
55+ }
56+
53 Behavior on opacity {
57 Behavior on opacity {
54 NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
58 NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
55 }
59 }
@@ -60,74 +64,36 @@ Item {
60 onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
64 onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
61 }
65 }
62
66
63− function updateApplicationInFocus() {
67+ DirectionalDragArea {
64− if (shell.applicationManager.mainStageFocusedApplication || shell.applicationManager.sideStageFocusedApplication) {
68+ id: dragArea
65− __applicationInFocus = true
66− } else {
67− __applicationInFocus = false
68− }
69− }
70−
71− Connections {
72− target: shell.applicationManager
73− ignoreUnknownSignals: true
74− onMainStageFocusedApplicationChanged: updateApplicationInFocus()
75− onSideStageFocusedApplicationChanged: updateApplicationInFocus()
76− }
77−
78− Showable {
79− id: hudButtonShowable
80−
81− opacity: 1.0
82 width: parent.width
69 width: parent.width
83− height: bottomEdgeShowButtonDistance
70+ height: distanceThreshold
84− shown: false
85− showAnimation: StandardAnimation { property: "y"; duration: 350; to: hudButtonRevealer.openedValue; easing.type: Easing.OutCubic }
86− hideAnimation: StandardAnimation { property: "y"; duration: 350; to: hudButtonRevealer.closedValue; easing.type: Easing.OutCubic }
87− onYChanged: {
88− if (y == hudButtonRevealer.openedValue)
89− bottombar.state = "shown"
90− }
91−
92− // eater
93− MouseArea {
94− anchors.fill: parent
71+ anchors.bottom: parent.bottom
95− }
72+
96− }
97−
98− Revealer {
99− id: hudButtonRevealer
100−
101− property double pressedX
102−
103− enabled: !theHud.shown && bottombar.enabled && __applicationInFocus
73+ enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
104− direction: Qt.RightToLeft
74+ direction: Direction.Upwards
105− openedValue: bottombar.height - height
75+
106− closedValue: bottombar.height
76+ // values to be tweaked and later removed from here and set in stone as defaults
107− target: hudButtonShowable
77+ // once we are confident it's all good.
108− width: hudButtonShowable.width
78+ maxDeviation: units.gu(1)
109− height: hudButtonShowable.height
79+ wideningAngle: 30
110− anchors.bottom: bottombar.bottom
80+ distanceThreshold: units.gu(3)
111− onOpenPressed: {
81+ minSpeed: units.gu(5)
112− pressedX = mouseX
82+
113− }
83+ property int previousStatus: -1
114−
84+ property real touchStartX: -1
115− onOpenReleased: {
85+
86+ onStatusChanged: {
87+ if (status === DirectionalDragArea.WaitingForTouch) {
88+ if (previousStatus == DirectionalDragArea.Recognized) {
116− if (hudButton.opacity != 0 && hudButton.mouseOver) {
89+ if (hudButton.mouseOver) {
117− hudButtonShowable.hide()
90+ hudButton.clicked()
118− theHud.show()
91+ }
119− } else {
92+ }
120− hudButtonShowable.hide()
93+ } else if (status === DirectionalDragArea.Undecided) {
121− }
94+ touchStartX = touchX
122− }
123− }
124−
125− Connections {
126− target: hudButtonShowable.hideAnimation
127− onRunningChanged: {
128− if (hudButtonShowable.hideAnimation.running) {
129− bottombar.state = "hidden"
130 }
95 }
96+ previousStatus = status
131 }
97 }
132 }
98 }
133
99
Bottombar/HudButton.qml+3−2
@@ -20,10 +20,11 @@ import Ubuntu.Components 0.1
20Item {
20Item {
21 id: item
21 id: item
22
22
23+ property bool mouseOver
24+
23 property int bottomMargin: units.gu(2)
25 property int bottomMargin: units.gu(2)
24− property bool mouseOver: contains(mouse)
25
26
26− property point mouse: Qt.point(-1,-1)
27+ signal clicked()
27
28
28 readonly property real scaleOnMouseOver: 1.2
29 readonly property real scaleOnMouseOver: 1.2
29
30
Shell.qml+3
@@ -188,6 +188,7 @@ FocusScope {
188
188
189 property bool fullyShown: shown && stages[stagesRevealer.boundProperty] == stagesRevealer.openedValue
189 property bool fullyShown: shown && stages[stagesRevealer.boundProperty] == stagesRevealer.openedValue
190 && parent.x == 0
190 && parent.x == 0
191+
191 property bool fullyHidden: !shown && stages[stagesRevealer.boundProperty] == stagesRevealer.closedValue
192 property bool fullyHidden: !shown && stages[stagesRevealer.boundProperty] == stagesRevealer.closedValue
192 available: !greeter.shown
193 available: !greeter.shown
193 hides: [launcher, panel.indicators]
194 hides: [launcher, panel.indicators]
@@ -515,6 +516,8 @@ FocusScope {
515 theHud: hud
516 theHud: hud
516 anchors.fill: parent
517 anchors.fill: parent
517 enabled: !panel.indicators.shown
518 enabled: !panel.indicators.shown
519+ applicationIsOnForeground: applicationManager.mainStageFocusedApplication
520+ || applicationManager.sideStageFocusedApplication
518 }
521 }
519
522
520 InputFilterArea {
523 InputFilterArea {
tests/autopilot/unity8/tests/helpers.py+2−1
@@ -98,7 +98,8 @@ class TestShellHelpers(object):
98 # go to the void for the first time because there's no real way to know what the display has
98 # go to the void for the first time because there's no real way to know what the display has
99 # painted already. Give it another (max retries) chance.
99 # painted already. Give it another (max retries) chance.
100 try:
100 try:
101− self.assertThat(lambda: getattr(bottombar, "__applicationInFocus"), Eventually(Equals(True)))
101+ self.assertThat(lambda: getattr(bottombar, "applicationIsOnForeground"),
102+ Eventually(Equals(True)))
102 except:
103 except:
103 if retries > 0:
104 if retries > 0:
104 logger.warning("Failed to launch app. Retrying...")
105 logger.warning("Failed to launch app. Retrying...")