@@ -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
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
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)
32− property bool __applicationInFocus: false
34− state: "hidden"
33+ state: dragArea.status === DirectionalDragArea.Recognized ? "shown" : "hidden"
36 HudButton {
35 HudButton {
37 id: hudButton
36 id: hudButton
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)
49− return mouse
47+ return false
51+ onClicked: theHud.show()
53+ Behavior on bottomMargin {
54+ NumberAnimation{duration: hudButton.opacity < 0.01 ? 200 : 70; easing.type: Easing.OutQuart}
53 Behavior on opacity {
57 Behavior on opacity {
54 NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
58 NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
@@ -60,74 +64,36 @@ Item {
60 onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
64 onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
63− function updateApplicationInFocus() {
67+ DirectionalDragArea {
64− if (shell.applicationManager.mainStageFocusedApplication || shell.applicationManager.sideStageFocusedApplication) {
68+ id: dragArea
65− __applicationInFocus = true
67− __applicationInFocus = false
72− target: shell.applicationManager
73− ignoreUnknownSignals: true
74− onMainStageFocusedApplicationChanged: updateApplicationInFocus()
75− onSideStageFocusedApplicationChanged: updateApplicationInFocus()
79− id: hudButtonShowable
82 width: parent.width
69 width: parent.width
83− height: bottomEdgeShowButtonDistance
70+ height: distanceThreshold
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 }
88− if (y == hudButtonRevealer.openedValue)
89− bottombar.state = "shown"
94− anchors.fill: parent
71+ anchors.bottom: parent.bottom
99− id: hudButtonRevealer
101− property double pressedX
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+
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()
120− hudButtonShowable.hide()
93+ } else if (status === DirectionalDragArea.Undecided) {
121− }
94+ touchStartX = touchX
126− target: hudButtonShowable.hideAnimation
128− if (hudButtonShowable.hideAnimation.running) {
129− bottombar.state = "hidden"
96+ previousStatus = status