18 import
"../Components"
20 import Unity.Application 0.1
21 import Ubuntu.Gestures 0.1
22 import Ubuntu.Components 0.1
28 property bool applicationIsOnForeground
30 property variant theHud
31 property bool enabled:
false
32 property bool preventHiding: dragArea.dragging
33 readonly
property real bottomEdgeButtonCenterDistance: units.gu(34)
39 bottombar.state =
"hidden"
42 onApplicationIsOnForegroundChanged: {
43 if (!applicationIsOnForeground) {
49 if (state ==
"hidden") {
51 bottomBarVisibilityCommunicatorShell.forceHidden =
false
53 dismissTimer.restart()
57 onPreventHidingChanged: {
59 if (state ==
"hint" || state ==
"reveal")
63 if (dismissTimer.running) {
64 dismissTimer.restart();
72 if (!bottombar.preventHiding) {
73 bottombar.state =
"hidden"
75 dismissTimer.restart()
83 readonly
property bool centeredHud: parent.width < units.gu(68)
85 x: centeredHud ? parent.width / 2 - width / 2 : MathUtils.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
86 y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
91 if (dragArea.status === DirectionalDragArea.Recognized) {
92 var touchLocal = mapFromItem(dragArea, dragArea.touchX, dragArea.touchY)
93 return touchLocal.x > 0 && touchLocal.x < width
94 && touchLocal.y > 0 && touchLocal.y < height
100 onClicked: theHud.show()
102 Behavior on bottomMargin {
103 NumberAnimation{duration: hudButton.opacity < 0.01 ? 200 : 70; easing.type: Easing.OutQuart}
106 Behavior on opacity {
107 NumberAnimation{duration: 200; easing.type: Easing.OutCubic}
114 bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
116 bottombar.state =
"hidden"
123 objectName:
"hudDragArea"
125 height: shell.edgeSize
126 anchors.bottom: parent.bottom
128 distanceThreshold: units.gu(8)
129 enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
130 direction: Direction.Upwards
133 property int previousStatus: -1
134 property real touchStartX: -1
136 readonly
property real distanceFromThreshold: (-distance) - distanceThreshold
137 readonly property real revealDistance: units.gu(2)
138 readonly
property real commitDistance: units.gu(6)
139 readonly
property real commitProgress: MathUtils.clamp(distanceFromThreshold / commitDistance, 0, 1)
142 if (status === DirectionalDragArea.WaitingForTouch) {
143 if (previousStatus == DirectionalDragArea.Recognized) {
144 if (hudButton.mouseOver) {
148 }
else if (status === DirectionalDragArea.Undecided) {
149 if (!hudButton.centeredHud) {
152 }
else if (status === DirectionalDragArea.Recognized) {
153 bottombar.state =
"hint"
155 previousStatus = status
159 if (status === DirectionalDragArea.Recognized) {
160 if (distanceFromThreshold > commitDistance)
161 bottombar.state =
"shown"
162 else if (distanceFromThreshold > revealDistance)
163 bottombar.state =
"reveal"
175 height: parent.height - bottomBarVisibilityCommunicatorShell.position
179 enabled: bottombar.state ==
"shown"
181 bottomBarVisibilityCommunicatorShell.forceHidden =
true
182 bottombar.state =
"hidden"
188 blockInput: (hudButton.opacity == 1)
194 top: dismissArea.bottom
197 bottom: parent.bottom
199 enabled: bottombar.state ==
"shown" && bottomBarVisibilityCommunicatorShell.position > 0
201 bottombar.state =
"hidden"
208 PropertyChanges { target: hudButton; opacity: 0 }
209 PropertyChanges { target: hudButton; bottomMargin: units.gu(-2) }
214 PropertyChanges { target: hudButton; opacity: 0.5 }
219 PropertyChanges { target: hudButton; bottomMargin: units.gu(-2) + units.gu(2) * dragArea.commitProgress }
223 PropertyChanges { target: hudButton; opacity: 1 }
224 PropertyChanges { target: hudButton; bottomMargin: units.gu(0) }