on xenial help sign in
Streamline some new HUD interactions to be more consistent with the Unity Launcher.
c3755eeAndrea Cimitan
Bottombar/Bottombar.qml+60−6
@@ -18,6 +18,7 @@ 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.Application 0.1
21import Ubuntu.Gestures 0.1
22import Ubuntu.Gestures 0.1
22
23
23Item {
24Item {
@@ -28,15 +29,46 @@ Item {
28
29
29 property variant theHud
30 property variant theHud
30 property bool enabled: false
31 property bool enabled: false
32+ property bool preventHiding: dragArea.dragging
31 readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
33 readonly property real bottomEdgeButtonCenterDistance: units.gu(34)
32
34
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+ }
34
62
35 HudButton {
63 HudButton {
36 id: hudButton
64 id: hudButton
37
65
66+ readonly property bool centeredHud: parent.width < units.gu(68) // Nexus 7 has 67 gu width
67+
38− x: MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
68+ 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
69 y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
70+ z: 1
71+ visible: opacity != 0
40
72
41 mouseOver: {
73 mouseOver: {
42 if (dragArea.status === DirectionalDragArea.Recognized) {
74 if (dragArea.status === DirectionalDragArea.Recognized) {
@@ -55,13 +87,18 @@ Item {
55 }
87 }
56
88
57 Behavior on opacity {
89 Behavior on opacity {
58− NumberAnimation{ duration: 200; easing.type: Easing.OutCubic}
90+ NumberAnimation{duration: 200; easing.type: Easing.OutCubic}
59 }
91 }
60 }
92 }
61
93
62 Connections {
94 Connections {
63 target: theHud
95 target: theHud
96+ onShownChanged: {
64− onShownChanged: bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
97+ bottomBarVisibilityCommunicatorShell.forceHidden = theHud.shown
98+ if (theHud.shown) {
99+ bottombar.state = "hidden"
100+ }
101+ }
65 }
102 }
66
103
67 EdgeDragArea {
104 EdgeDragArea {
@@ -70,6 +107,7 @@ Item {
70 height: distanceThreshold
107 height: distanceThreshold
71 anchors.bottom: parent.bottom
108 anchors.bottom: parent.bottom
72
109
110+ distanceThreshold: units.gu(8)
73 enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
111 enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
74 direction: Direction.Upwards
112 direction: Direction.Upwards
75
113
@@ -84,12 +122,29 @@ Item {
84 }
122 }
85 }
123 }
86 } else if (status === DirectionalDragArea.Undecided) {
124 } else if (status === DirectionalDragArea.Undecided) {
125+ if (!hudButton.centeredHud) {
87− touchStartX = touchX
126+ touchStartX = touchX
127+ }
128+ } else if (status === DirectionalDragArea.Recognized) {
129+ bottombar.state = "shown"
88 }
130 }
89 previousStatus = status
131 previousStatus = status
90 }
132 }
91 }
133 }
92
134
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+
93 states: [
148 states: [
94 State {
149 State {
95 name: "hidden"
150 name: "hidden"
@@ -102,5 +157,4 @@ Item {
102 PropertyChanges { target: hudButton; bottomMargin: units.gu(0)}
157 PropertyChanges { target: hudButton; bottomMargin: units.gu(0)}
103 }
158 }
104 ]
159 ]
105−
106}
160}
Bottombar/HudButton.qml+8−8
@@ -33,24 +33,24 @@ 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)
40 width: height
39 width: height
41− opacity: item.mouseOver ? 1 : 0.7
40+ opacity: item.mouseOver || abstractButton.pressed ? 1 : 0.7
42− scale: item.mouseOver ? scaleOnMouseOver : 1
41+ scale: item.mouseOver || abstractButton.pressed ? scaleOnMouseOver : 1
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
46+ id: abstractButton
48 anchors.fill: parent
47 anchors.fill: parent
49−
50− borderSource: ""
51− image: Image {
48+ style: Image {
49+ anchors.fill: parent
52 source: "graphics/hud_invoke_button_active.png"
50 source: "graphics/hud_invoke_button_active.png"
53 }
51 }
52+
53+ onClicked: item.clicked()
54 }
54 }
55
55
56 Image {
56 Image {