on xenial help sign in
Added indicator highlight drag offset
2700f8bNick Dedekind
Panel/IndicatorItem.qml−12
@@ -46,16 +46,4 @@ Item {
46 }
46 }
47 }
47 }
48 }
48 }
49−
50− Rectangle {
51− color: Theme.palette.selected.foreground
52− objectName: "highlight"
53− height: units.dp(2)
54− width: parent.width
55− anchors.top: parent.bottom
56− visible: highlighted
57−
58− opacity: highlighted ? 1 : 0
59− Behavior on opacity { StandardAnimation {} }
60− }
61}
49}
Panel/IndicatorRow.qml+24
@@ -29,6 +29,7 @@ Item {
29 property var visibleIndicators: defined
29 property var visibleIndicators: defined
30 property int overFlowWidth: width
30 property int overFlowWidth: width
31 property bool showAll: false
31 property bool showAll: false
32+ property real currentItemOffset: 0.0
32
33
33 width: units.gu(40)
34 width: units.gu(40)
34 height: units.gu(3)
35 height: units.gu(3)
@@ -145,4 +146,27 @@ Item {
145 }
146 }
146 }
147 }
147 }
148 }
149+
150+ Rectangle {
151+ id: highlight
152+ color: Theme.palette.selected.foreground
153+ objectName: "highlight"
154+ height: units.dp(2)
155+ anchors.top: row.bottom
156+ visible: indicatorRow.currentItem != null
157+ x: row.x + (indicatorRow.currentItem != null ? indicatorRow.currentItem.x + centerOffset : 0)
158+ width: indicatorRow.currentItem != null ? indicatorRow.currentItem.width : 0
159+
160+ property real centerOffset: {
161+ if (indicatorRow.currentItemOffset > 0.2) {
162+ return (indicatorRow.currentItemOffset - 0.2) * units.gu(0.4);
163+ } else if (indicatorRow.currentItemOffset < -0.2) {
164+ return (indicatorRow.currentItemOffset + 0.2) * units.gu(0.4);
165+ }
166+ return 0.0;
167+ }
168+
169+ Behavior on width { UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration } }
170+ Behavior on x { UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration } }
171+ }
148}
172}
Panel/Indicators.qml+19−11
@@ -128,23 +128,31 @@ Showable {
128 rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
128 rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
129 // get the current delegate
129 // get the current delegate
130 currentItem = indicatorRow.row.childAt(rowCoordinates.x, 0);
130 currentItem = indicatorRow.row.childAt(rowCoordinates.x, 0);
131− if (currentItem && currentItem != indicatorRow.currentItem ) {
131+ if (currentItem) {
132 itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
132 itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
133 distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
133 distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
134+ if (currentItem != indicatorRow.currentItem) {
134− if (Math.abs(currentItem.ownIndex - indicatorRow.currentItemIndex) > 1) {
135+ if (Math.abs(currentItem.ownIndex - indicatorRow.currentItemIndex) > 1) {
135− bufferExceeded = true;
136− } else {
137− if (indicatorRow.currentItemIndex < currentItem.ownIndex && distanceFromRightEdge < (1 - effectiveBufferThreshold)) {
138− bufferExceeded = true;
139− } else if (indicatorRow.currentItemIndex > currentItem.ownIndex && distanceFromRightEdge > effectiveBufferThreshold) {
140 bufferExceeded = true;
136 bufferExceeded = true;
137+ } else {
138+ if (indicatorRow.currentItemIndex < currentItem.ownIndex && distanceFromRightEdge < (1 - effectiveBufferThreshold)) {
139+ bufferExceeded = true;
140+ } else if (indicatorRow.currentItemIndex > currentItem.ownIndex && distanceFromRightEdge > effectiveBufferThreshold) {
141+ bufferExceeded = true;
142+ }
141 }
143 }
144+ if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null) {
145+ indicatorRow.currentItem = currentItem;
146+ }
147+
148+ // need to re-init the distanceFromRightEdge for offset calculation
149+ itemCoordinates = indicatorRow.row.mapToItem(indicatorRow.currentItem, rowCoordinates.x, 0);
150+ distanceFromRightEdge = (indicatorRow.currentItem.width - itemCoordinates.x) / (indicatorRow.currentItem.width);
142 }
151 }
143− if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItem < 0 || indicatorRow.currentItem == null) {
152+ indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
144− indicatorRow.currentItem = currentItem;
153+ } else {
145− }
146− } else if (!currentItem) {
147 indicatorRow.setDefaultItem();
154 indicatorRow.setDefaultItem();
155+ indicatorRow.currentItemOffset = 0;
148 }
156 }
149 initalizeItem = indicatorRow.currentItem == null;
157 initalizeItem = indicatorRow.currentItem == null;
150 }
158 }