on xenial help sign in
Compensate for PanelItemRow's origin changing
b7f044eRatchanan Srirattanamet
qml/Panel/Panel.qml+1−1
@@ -411,7 +411,7 @@ Item {
411 objectName: identifier+"-panelItem"
411 objectName: identifier+"-panelItem"
412
412
413 property int ownIndex: index
413 property int ownIndex: index
414− readonly property bool overflow: parent.width - x > __indicators.overFlowWidth
414+ readonly property bool overflow: parent.width - (x - __indicators.rowContentX) > __indicators.overFlowWidth
415 readonly property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
415 readonly property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
416 // HACK for indicator-session
416 // HACK for indicator-session
417 readonly property bool hideSessionIndicator: identifier == "indicator-session" && Math.min(Screen.width, Screen.height) <= units.gu(60)
417 readonly property bool hideSessionIndicator: identifier == "indicator-session" && Math.min(Screen.width, Screen.height) <= units.gu(60)
qml/Panel/PanelBar.qml+10−8
@@ -1,5 +1,6 @@
1/*
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
2 * Copyright (C) 2014 Canonical, Ltd.
3+ * Copyright (C) 2020 UBports Foundation
3 *
4 *
4 * This program is free software; you can redistribute it and/or modify
5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * it under the terms of the GNU General Public License as published by
@@ -29,6 +30,7 @@ Item {
29 readonly property alias currentItemIndex: row.currentItemIndex
30 readonly property alias currentItemIndex: row.currentItemIndex
30 property real lateralPosition: -1
31 property real lateralPosition: -1
31 property int alignment: Qt.AlignRight
32 property int alignment: Qt.AlignRight
33+ readonly property int rowContentX: row.contentX
32
34
33 property alias hideRow: row.hideRow
35 property alias hideRow: row.hideRow
34 property alias rowItemDelegate: row.delegate
36 property alias rowItemDelegate: row.delegate
@@ -133,12 +135,12 @@ Item {
133
135
134 if (root.alignment == Qt.AlignLeft) {
136 if (root.alignment == Qt.AlignLeft) {
135 // current item overlap on left
137 // current item overlap on left
136− if (row.currentItem && flickable.contentX > row.currentItem.x) {
138+ if (row.currentItem && flickable.contentX > (row.currentItem.x - row.contentX)) {
137− d.alignmentAdjustment -= (flickable.contentX - row.currentItem.x);
139+ d.alignmentAdjustment -= (flickable.contentX - (row.currentItem.x - row.contentX));
138
140
139 // current item overlap on right
141 // current item overlap on right
140− } else if (row.currentItem && flickable.contentX + flickable.width < row.currentItem.x + row.currentItem.width) {
142+ } else if (row.currentItem && flickable.contentX + flickable.width < (row.currentItem.x - row.contentX) + row.currentItem.width) {
141− d.alignmentAdjustment += (row.currentItem.x + row.currentItem.width) - (flickable.contentX + flickable.width);
143+ d.alignmentAdjustment += ((row.currentItem.x - row.contentX) + row.currentItem.width) - (flickable.contentX + flickable.width);
142 }
144 }
143 } else {
145 } else {
144 // gap between left and row?
146 // gap between left and row?
@@ -155,12 +157,12 @@ Item {
155 d.alignmentAdjustment -= flickable.contentX;
157 d.alignmentAdjustment -= flickable.contentX;
156
158
157 // current item overlap on left
159 // current item overlap on left
158− } else if (row.currentItem && (flickable.contentX + flickable.width) < (row.width - row.currentItem.x)) {
160+ } else if (row.currentItem && (flickable.contentX + flickable.width) < (row.width - (row.currentItem.x - row.contentX))) {
159− d.alignmentAdjustment += ((row.width - row.currentItem.x) - (flickable.contentX + flickable.width));
161+ d.alignmentAdjustment += ((row.width - (row.currentItem.x - row.contentX)) - (flickable.contentX + flickable.width));
160
162
161 // current item overlap on right
163 // current item overlap on right
162− } else if (row.currentItem && flickable.contentX > (row.width - row.currentItem.x - row.currentItem.width)) {
164+ } else if (row.currentItem && flickable.contentX > (row.width - (row.currentItem.x - row.contentX) - row.currentItem.width)) {
163− d.alignmentAdjustment -= flickable.contentX - (row.width - row.currentItem.x - row.currentItem.width);
165+ d.alignmentAdjustment -= flickable.contentX - (row.width - (row.currentItem.x - row.contentX) - row.currentItem.width);
164 }
166 }
165 }
167 }
166 }
168 }
qml/Panel/PanelItemRow.qml+5−3
@@ -1,5 +1,6 @@
1/*
1/*
2 * Copyright (C) 2013-2014 Canonical, Ltd.
2 * Copyright (C) 2013-2014 Canonical, Ltd.
3+ * Copyright (C) 2020 UBports Foundation
3 *
4 *
4 * This program is free software; you can redistribute it and/or modify
5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * it under the terms of the GNU General Public License as published by
@@ -36,6 +37,7 @@ Item {
36 property color hightlightColor: "#ffffff"
37 property color hightlightColor: "#ffffff"
37
38
38 property alias delegate: row.delegate
39 property alias delegate: row.delegate
40+ property alias contentX: row.contentX
39
41
40 property real lateralPosition: -1
42 property real lateralPosition: -1
41 onLateralPositionChanged: {
43 onLateralPositionChanged: {
@@ -85,7 +87,7 @@ Item {
85 }
87 }
86
88
87 function indicatorAt(x, y) {
89 function indicatorAt(x, y) {
88− var item = row.itemAt(x, y);
90+ var item = row.itemAt(x + row.contentX, y);
89 return item && item.hasOwnProperty("ownIndex") ? item : null;
91 return item && item.hasOwnProperty("ownIndex") ? item : null;
90 }
92 }
91
93
@@ -184,7 +186,7 @@ Item {
184 ScriptAction {
186 ScriptAction {
185 script: {
187 script: {
186 d.forceAlignmentAnimationDisabled = true;
188 d.forceAlignmentAnimationDisabled = true;
187− highlight.currentItemX = Qt.binding(function() { return currentItem ? currentItem.x : 0 });
189+ highlight.currentItemX = Qt.binding(function() { return currentItem ? currentItem.x - row.contentX : 0 });
188 d.forceAlignmentAnimationDisabled = false;
190 d.forceAlignmentAnimationDisabled = false;
189 }
191 }
190 }
192 }
@@ -235,7 +237,7 @@ Item {
235 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
237 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
236 }
238 }
237
239
238− property real currentItemX: currentItem ? currentItem.x : 0
240+ property real currentItemX: currentItem ? currentItem.x - row.contentX : 0
239 Behavior on currentItemX {
241 Behavior on currentItemX {
240 id: currentItemXBehavior
242 id: currentItemXBehavior
241 enabled: !d.firstItemSwitch && expanded && !d.forceAlignmentAnimationDisabled
243 enabled: !d.firstItemSwitch && expanded && !d.forceAlignmentAnimationDisabled
qml/Panel/PanelMenu.qml+5
@@ -49,6 +49,11 @@ Showable {
49 readonly property int barWidth: bar.width
49 readonly property int barWidth: bar.width
50 readonly property alias currentMenuIndex: bar.currentItemIndex
50 readonly property alias currentMenuIndex: bar.currentItemIndex
51
51
52+ // Exposes the current contentX of the PanelBar's internal ListView. This
53+ // must be used to offset absolute x values against the ListView, since
54+ // we commonly add or remove elements and cause the contentX to change.
55+ readonly property int rowContentX: bar.rowContentX
56+
52 // The user tapped the panel and did not move.
57 // The user tapped the panel and did not move.
53 // Note that this does not fire on mouse events, only touch events.
58 // Note that this does not fire on mouse events, only touch events.
54 signal showTapped()
59 signal showTapped()