on xenial help sign in
1. HUD button now persistent on screen for 5 seconds
e45b297Andrea Cimitan
Bottombar/Bottombar.qml+52−6
@@ -28,15 +28,46 @@ Item {
28
28
29 property variant theHud
29 property variant theHud
30 property bool enabled: false
30 property bool enabled: false
31+ property bool preventHiding: dragArea.dragging
31 readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
32 readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
32
33
33− state: dragArea.status === DirectionalDragArea.Recognized ? "shown" : "hidden"
34+ state: "hidden"
35+
36+ onStateChanged: {
37+ if (state == "hidden") {
38+ dismissTimer.stop()
39+ } else {
40+ dismissTimer.restart()
41+ }
42+ }
43+
44+ onPreventHidingChanged: {
45+ if (dismissTimer.running) {
46+ dismissTimer.restart();
47+ }
48+ }
49+
50+ Timer {
51+ id: dismissTimer
52+ interval: 5000
53+ onTriggered: {
54+ if (!bottombar.preventHiding) {
55+ bottombar.state = "hidden"
56+ } else {
57+ dismissTimer.restart()
58+ }
59+ }
60+ }
34
61
35 HudButton {
62 HudButton {
36 id: hudButton
63 id: hudButton
37
64
65+ readonly property bool centeredHud: parent.width < units.gu(68) // Nexus 7 has 67 gu width
66+
38− x: MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
67+ x: centeredHud ? parent.width / 2 - width / 2 : MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
39 y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
68 y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
69+ z: 1
70+ visible: opacity != 0
40
71
41 mouseOver: {
72 mouseOver: {
42 if (dragArea.status === DirectionalDragArea.Recognized) {
73 if (dragArea.status === DirectionalDragArea.Recognized) {
@@ -55,13 +86,18 @@ Item {
55 }
86 }
56
87
57 Behavior on opacity {
88 Behavior on opacity {
58− NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
89+ NumberAnimation{duration: 200; easing.type: Easing.OutCubic}
59 }
90 }
60 }
91 }
61
92
62 Connections {
93 Connections {
63 target: theHud
94 target: theHud
95+ onShownChanged: {
64− onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
96+ bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
97+ if (theHud.shown) {
98+ bottombar.state = "hidden"
99+ }
100+ }
65 }
101 }
66
102
67 EdgeDragArea {
103 EdgeDragArea {
@@ -70,6 +106,7 @@ Item {
70 height: distanceThreshold
106 height: distanceThreshold
71 anchors.bottom: parent.bottom
107 anchors.bottom: parent.bottom
72
108
109+ distanceThreshold: units.gu(8)
73 enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
110 enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
74 direction: Direction.Upwards
111 direction: Direction.Upwards
75
112
@@ -83,13 +120,23 @@ Item {
83 hudButton.clicked()
120 hudButton.clicked()
84 }
121 }
85 }
122 }
86− } else if (status === DirectionalDragArea.Undecided) {
123+ } else if (status === DirectionalDragArea.Undecided && !hudButton.centeredHud) {
87 touchStartX = touchX
124 touchStartX = touchX
125+ } else if (status === DirectionalDragArea.Recognized) {
126+ bottombar.state = "shown"
88 }
127 }
89 previousStatus = status
128 previousStatus = status
90 }
129 }
91 }
130 }
92
131
132+ MouseArea {
133+ anchors.fill: parent
134+ enabled: bottombar.state == "shown"
135+ onPressed: {
136+ bottombar.state = "hidden"
137+ }
138+ }
139+
93 states: [
140 states: [
94 State {
141 State {
95 name: "hidden"
142 name: "hidden"
@@ -102,5 +149,4 @@ Item {
102 PropertyChanges { target: hudButton; bottomMargin: units.gu(0)}
149 PropertyChanges { target: hudButton; bottomMargin: units.gu(0)}
103 }
150 }
104 ]
151 ]
105−
106}
152}
Bottombar/HudButton.qml+5−6
@@ -33,7 +33,6 @@ Item {
33
33
34 Item {
34 Item {
35 id: hudButton
35 id: hudButton
36− property alias actionButton: actionButton
37
36
38 anchors.centerIn: parent
37 anchors.centerIn: parent
39 height: units.gu(12)
38 height: units.gu(12)
@@ -43,14 +42,14 @@ Item {
43 Behavior on opacity {NumberAnimation{duration: 200; easing.type: Easing.OutQuart}}
42 Behavior on opacity {NumberAnimation{duration: 200; easing.type: Easing.OutQuart}}
44 Behavior on scale {NumberAnimation{duration: 200; easing.type: Easing.OutQuart}}
43 Behavior on scale {NumberAnimation{duration: 200; easing.type: Easing.OutQuart}}
45
44
46− UbuntuShape {
45+ AbstractButton {
47− id: actionButton
48 anchors.fill: parent
46 anchors.fill: parent
49−
50− borderSource: ""
51− image: Image {
47+ style: Image {
48+ anchors.fill: parent
52 source: "graphics/hud_invoke_button_active.png"
49 source: "graphics/hud_invoke_button_active.png"
53 }
50 }
51+
52+ onClicked: item.clicked()
54 }
53 }
55
54
56 Image {
55 Image {