on xenial help sign in
better handling of indicator current item.
commita869d33c6c9baf253f660241dd3b8a214103e83a authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 17 Jul 2013, 17:14 (13 years ago) parent22d7190
3 files changed+52−26
Panel/IndicatorRow.qml+7−8 Panel/Indicators.qml+44−17 Panel/MenuContent.qml+1−1
Panel/IndicatorRow.qml+7−8
@@ -31,16 +31,15 @@ Item {
3131 width: units.gu(40)
3232 height: units.gu(3)
3333
34− Component.onCompleted: setDefaultItem()
35−
3634 function setDefaultItem() {
3735 // The leftmost indicator
38− var defaultItemIndex = 0
39− setItem(defaultItemIndex)
36+ setCurrentItem(0);
4037 }
4138
42− function setItem(index) {
43− currentItem = rowRepeater.itemAt(index)
39+ function setCurrentItem(index) {
40+ if (currentItemIndex !== index) {
41+ currentItem = rowRepeater.itemAt(index);
42+ }
4443 }
4544
4645 Row {
@@ -68,9 +67,9 @@ Item {
6867 height: indicatorRow.height
6968 y: {
7069 if (!highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
71− return -indicatorRow.height
70+ return -indicatorRow.height;
7271 } else {
73− return 0
72+ return 0;
7473 }
7574 }
7675 Behavior on y {
Panel/Indicators.qml+44−17
@@ -41,6 +41,13 @@ Showable {
4141 duration: 350
4242 to: openedHeight
4343 easing.type: Easing.OutCubic
44+
45+ // Re-size if we've changed the openHeight while shown.
46+ onToChanged: {
47+ if (indicators.shown) {
48+ indicators.show();
49+ }
50+ }
4451 }
4552
4653 hideAnimation: StandardAnimation {
@@ -73,11 +80,11 @@ Showable {
7380 }
7481
7582 function calculateCurrentItem(xValue, useBuffer) {
76− var rowCoordinates
77− var itemCoordinates
78− var currentItem
79− var distanceFromRightEdge
80− var bufferExceeded = false
83+ var rowCoordinates;
84+ var itemCoordinates;
85+ var currentItem;
86+ var distanceFromRightEdge;
87+ var bufferExceeded = false;
8188
8289 if (indicators.state == "commit" || indicators.state == "locked" || showAnimation.running || hideAnimation.running) return;
8390
@@ -162,8 +169,15 @@ Showable {
162169 indicatorsModel: indicatorsModel
163170 clip: !indicators.fullyOpened
164171
165− onMenuSelected: {
166− indicatorRow.setItem(index)
172+ Connections {
173+ target: indicatorRow
174+ onCurrentItemIndexChanged: menuContent.updateCurrentMenu();
175+ }
176+
177+ function updateCurrentMenu() {
178+ if (currentMenuIndex != indicatorRow.currentItemIndex) {
179+ currentMenuIndex = indicatorRow.currentItemIndex;
180+ }
167181 }
168182
169183 //small shadow gradient at bottom of menu
@@ -233,28 +247,35 @@ Showable {
233247 indicatorsModel: indicatorsModel
234248 state: indicators.state
235249
236− onCurrentItemIndexChanged: menuContent.currentIndex = currentItemIndex
250+ Connections {
251+ target: menuContent
252+ onCurrentMenuIndexChanged: {
253+ indicatorRow.setCurrentItem(menuContent.currentMenuIndex);
254+ }
255+ }
237256 }
238257
239258 Connections {
240− target: hideAnimation
259+ target: showAnimation
241260 onRunningChanged: {
242− if (hideAnimation.running) {
243− indicators.state = "initial"
244− indicatorRow.currentItem = null;
261+ if (showAnimation.running) {
262+ indicators.state = "commit";
245263 }
246264 }
247265 }
266+
248267 Connections {
249− target: showAnimation
268+ target: hideAnimation
250269 onRunningChanged: {
251− if (showAnimation.running) {
252− indicators.calculateCurrentItem(dragHandle.touchX, false);
253− indicators.state = "commit";
270+ if (hideAnimation.running) {
271+ indicators.state = "initial";
272+ indicatorRow.currentItem = null;
254273 }
255274 }
256275 }
257276
277+ property var dragHandle: null
278+ // connections to the active drag handle
258279 Connections {
259280 target: dragHandle
260281 onTouchXChanged: {
@@ -263,7 +284,6 @@ Showable {
263284 }
264285 }
265286
266− property var dragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle
267287 DragHandle {
268288 id: showDragHandle
269289 anchors.bottom: parent.bottom
@@ -285,6 +305,9 @@ Showable {
285305 menuContent.activateContent();
286306 }
287307 }
308+ onDraggingChanged: {
309+ dragHandle = dragging ? showDragHandle : null;
310+ }
288311 }
289312 DragHandle {
290313 id: hideDragHandle
@@ -296,6 +319,10 @@ Showable {
296319 stretch: true
297320 maxTotalDragDistance: openedHeight - panelHeight
298321 distanceThreshold: 0
322+
323+ onDraggingChanged: {
324+ dragHandle = dragging ? hideDragHandle : null;
325+ }
299326 }
300327
301328 states: [
Panel/MenuContent.qml+1−1
@@ -24,7 +24,7 @@ Rectangle {
2424
2525 property QtObject indicatorsModel: null
2626 property bool __contentActive: false
27− property alias currentIndex : menus.currentIndex
27+ property alias currentMenuIndex : menus.currentIndex
2828 property color backgroundColor: "#221e1c"
2929 property int contentReleaseInterval: 20000
3030