@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import "../Components"
1919import "../Components/Math.js" as MathLocal
2020import Unity 0.1
21+import Ubuntu.Application 0.1
2122import Ubuntu.Gestures 0.1
2223
2324Item {
@@ -28,15 +29,46 @@ Item {
2829
2930 property variant theHud
3031 property bool enabled: false
32+ property bool preventHiding: dragArea.dragging
3133 readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
3234
33− state: dragArea.status === DirectionalDragArea.Recognized ? "shown" : "hidden"
35+ state: "hidden"
36+
37+ onStateChanged: {
38+ if (state == "hidden") {
39+ dismissTimer.stop()
40+ } else {
41+ dismissTimer.restart()
42+ }
43+ }
44+
45+ onPreventHidingChanged: {
46+ if (dismissTimer.running) {
47+ dismissTimer.restart();
48+ }
49+ }
50+
51+ Timer {
52+ id: dismissTimer
53+ interval: 5000
54+ onTriggered: {
55+ if (!bottombar.preventHiding) {
56+ bottombar.state = "hidden"
57+ } else {
58+ dismissTimer.restart()
59+ }
60+ }
61+ }
3462
3563 HudButton {
3664 id: hudButton
3765
38− x: MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
66+ readonly property bool centeredHud: parent.width < units.gu(68) // Nexus 7 has 67 gu width
67+
68+ x: centeredHud ? parent.width / 2 - width / 2 : MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
3969 y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
70+ z: 1
71+ visible: opacity != 0
4072
4173 mouseOver: {
4274 if (dragArea.status === DirectionalDragArea.Recognized) {
@@ -55,13 +87,18 @@ Item {
5587 }
5688
5789 Behavior on opacity {
58− NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
90+ NumberAnimation{duration: 200; easing.type: Easing.OutCubic}
5991 }
6092 }
6193
6294 Connections {
6395 target: theHud
64− onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
96+ onShownChanged: {
97+ bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
98+ if (theHud.shown) {
99+ bottombar.state = "hidden"
100+ }
101+ }
65102 }
66103
67104 EdgeDragArea {
@@ -70,6 +107,7 @@ Item {
70107 height: distanceThreshold
71108 anchors.bottom: parent.bottom
72109
110+ distanceThreshold: units.gu(8)
73111 enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
74112 direction: Direction.Upwards
75113
@@ -84,12 +122,29 @@ Item {
84122 }
85123 }
86124 } else if (status === DirectionalDragArea.Undecided) {
87− touchStartX = touchX
125+ if (!hudButton.centeredHud) {
126+ touchStartX = touchX
127+ }
128+ } else if (status === DirectionalDragArea.Recognized) {
129+ bottombar.state = "shown"
88130 }
89131 previousStatus = status
90132 }
91133 }
92134
135+ MouseArea {
136+ anchors.fill: parent
137+ enabled: bottombar.state == "shown"
138+ onPressed: {
139+ bottombar.state = "hidden"
140+ }
141+ }
142+
143+ InputFilterArea {
144+ anchors.fill: parent
145+ blockInput: hudButton.visible
146+ }
147+
93148 states: [
94149 State {
95150 name: "hidden"
@@ -102,5 +157,4 @@ Item {
102157 PropertyChanges { target: hudButton; bottomMargin: units.gu(0)}
103158 }
104159 ]
105−
106160}