on xenial help sign in
Streamline some new HUD interactions to be more consistent with the Unity Launcher.

Approved by PS Jenkins bot, Albert Astals Cid.

commitc3755ee63084f2de162c1d6ac6ecd4ebb771d26e authorAndrea Cimitan <andrea.cimitan@canonical.com> dateWed 28 Aug 2013, 13:12 (13 years ago) parentafd417e1713a8b
2 files changed+68−14
Bottombar/Bottombar.qml+60−6 Bottombar/HudButton.qml+8−8
Bottombar/Bottombar.qml+60−6
@@ -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}
Bottombar/HudButton.qml+8−8
@@ -33,24 +33,24 @@ Item {
3333
3434 Item {
3535 id: hudButton
36− property alias actionButton: actionButton
3736
3837 anchors.centerIn: parent
3938 height: units.gu(12)
4039 width: height
41− opacity: item.mouseOver ? 1 : 0.7
42− scale: item.mouseOver ? scaleOnMouseOver : 1
40+ opacity: item.mouseOver || abstractButton.pressed ? 1 : 0.7
41+ scale: item.mouseOver || abstractButton.pressed ? scaleOnMouseOver : 1
4342 Behavior on opacity {NumberAnimation{duration: 200; easing.type: Easing.OutQuart}}
4443 Behavior on scale {NumberAnimation{duration: 200; easing.type: Easing.OutQuart}}
4544
46− UbuntuShape {
47− id: actionButton
45+ AbstractButton {
46+ id: abstractButton
4847 anchors.fill: parent
49−
50− borderSource: ""
51− image: Image {
48+ style: Image {
49+ anchors.fill: parent
5250 source: "graphics/hud_invoke_button_active.png"
5351 }
52+
53+ onClicked: item.clicked()
5454 }
5555
5656 Image {