18
18
import "../Components"
19
19
import "../Components/Math.js" as MathLocal
21
import Ubuntu.Gestures 0.1
26
// Whether there's an application on foreground (as opposed to have shell's Dash on foreground)
27
property bool applicationIsOnForeground
27
29
property variant theHud
28
30
property bool enabled: false
29
31
readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
30
readonly property real bottomEdgeShowButtonDistance: units.gu(2)
32
property bool __applicationInFocus: false
33
state: dragArea.status === DirectionalDragArea.Recognized ? "shown" : "hidden"
39
x: MathLocal.clamp(hudButtonRevealer.pressedX - width / 2, 0, bottombar.width - width)
40
y: bottombar.height - bottomEdgeButtonCenterDistance - height / 2 - bottomMargin
38
x: MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
39
y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
42
if (dragArea.status === DirectionalDragArea.Recognized) {
43
var touchLocal = mapFromItem(dragArea, dragArea.touchX, dragArea.touchY)
44
return touchLocal.x > 0 && touchLocal.x < width
45
&& touchLocal.y > 0 && touchLocal.y < height
51
onClicked: theHud.show()
41
53
Behavior on bottomMargin {
42
54
NumberAnimation{duration: hudButton.opacity < 0.01 ? 200 : 70; easing.type: Easing.OutQuart}
45
if (hudButtonRevealer.draggingArea.pressed) {
46
var mapped = mapFromItem(hudButtonRevealer.draggingArea, hudButtonRevealer.draggingArea.mouseX, hudButtonRevealer.draggingArea.mouseY)
47
return Qt.point(mapped.x, mapped.y)
53
57
Behavior on opacity {
54
58
NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
60
64
onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
63
function updateApplicationInFocus() {
64
if (shell.applicationManager.mainStageFocusedApplication || shell.applicationManager.sideStageFocusedApplication) {
65
__applicationInFocus = true
67
__applicationInFocus = false
72
target: shell.applicationManager
73
ignoreUnknownSignals: true
74
onMainStageFocusedApplicationChanged: updateApplicationInFocus()
75
onSideStageFocusedApplicationChanged: updateApplicationInFocus()
82
69
width: parent.width
83
height: bottomEdgeShowButtonDistance
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"
101
property double pressedX
103
enabled: !theHud.shown && bottombar.enabled && __applicationInFocus
104
direction: Qt.RightToLeft
105
openedValue: bottombar.height - height
106
closedValue: bottombar.height
107
target: hudButtonShowable
108
width: hudButtonShowable.width
109
height: hudButtonShowable.height
110
anchors.bottom: bottombar.bottom
116
if (hudButton.opacity != 0 && hudButton.mouseOver) {
117
hudButtonShowable.hide()
120
hudButtonShowable.hide()
126
target: hudButtonShowable.hideAnimation
128
if (hudButtonShowable.hideAnimation.running) {
129
bottombar.state = "hidden"
70
height: distanceThreshold
71
anchors.bottom: parent.bottom
73
enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
74
direction: Direction.Upwards
76
// values to be tweaked and later removed from here and set in stone as defaults
77
// once we are confident it's all good.
78
maxDeviation: units.gu(1)
80
distanceThreshold: units.gu(3)
83
property int previousStatus: -1
84
property real touchStartX: -1
87
if (status === DirectionalDragArea.WaitingForTouch) {
88
if (previousStatus == DirectionalDragArea.Recognized) {
89
if (hudButton.mouseOver) {
93
} else if (status === DirectionalDragArea.Undecided) {
96
previousStatus = status