on xenial help sign in
[indicators] rotate Flickable 180 so its contents right aligned, to fix positioning on panel resize
commit7e11feb346132e534b3b111cd9d54d6118394342 authorNick Dedekind <nick.dedekind@canonical.com> dateWed 3 Dec 2014, 10:57 (12 years ago) parent57f15d1
1 file changed+29−20
qml/Panel/IndicatorsBar.qml+29−20
qml/Panel/IndicatorsBar.qml+29−20
@@ -46,13 +46,14 @@ Item {
4646
4747 function addScrollOffset(scrollAmmout) {
4848 if (scrollAmmout < 0) { // left scroll
49− if (flickable.contentX < 0) return; // already off the left.
50− if (flickable.contentX + scrollAmmout < 0) scrollAmmout = -flickable.contentX; // going to be off the left
51− } else { // right scroll
52− if (flickable.contentX + flickable.width > row.width) return; // already off the right.
53− if (flickable.contentX + flickable.width + scrollAmmout > row.width) { // going to be off the right
54− scrollAmmout = row.width - (flickable.contentX + flickable.width);
49+ if (flickable.contentX + flickable.width > row.width) return; // already off the left.
50+
51+ if (flickable.contentX + flickable.width - scrollAmmout > row.width) { // going to be off the right
52+ scrollAmmout = (flickable.contentX + flickable.width) - row.width;
5553 }
54+ } else { // right scroll
55+ if (flickable.contentX < 0) return; // already off the right.
56+ if (flickable.contentX - scrollAmmout < 0) scrollAmmout = flickable.contentX; // going to be off the right
5657 }
5758 d.scrollOffset = d.scrollOffset + scrollAmmout;
5859 }
@@ -91,24 +92,26 @@ Item {
9192 flickable.resetContentXComponents();
9293
9394 if (expanded && !flickable.moving) {
94−
9595 // gap between left and row?
96− if (flickable.contentX < 0) {
97− d.alignmentAdjustment += flickable.contentX;
98− // gap between right and row?
99− } else if (flickable.contentX + flickable.width > row.width) {
96+ if (flickable.contentX + flickable.width > row.width) {
10097 // row width is less than flickable
10198 if (row.width < flickable.width) {
102− d.alignmentAdjustment += flickable.contentX;
99+ d.alignmentAdjustment -= flickable.contentX;
103100 } else {
104− d.alignmentAdjustment += ((flickable.contentX + flickable.width) - row.width);
101+ d.alignmentAdjustment -= ((flickable.contentX + flickable.width) - row.width);
105102 }
103+
104+ // gap between right and row?
105+ } else if (flickable.contentX < 0) {
106+ d.alignmentAdjustment -= flickable.contentX;
107+
106108 // current item overlap on left
107− } else if (row.currentItem && row.currentItem.x < flickable.contentX) {
108− d.alignmentAdjustment -= (row.currentItem.x - flickable.contentX);
109+ } else if (row.currentItem && (flickable.contentX + flickable.width) < (row.width - row.currentItem.x)) {
110+ d.alignmentAdjustment += ((row.width - row.currentItem.x) - (flickable.contentX + flickable.width));
111+
109112 // current item overlap on right
110− } else if (row.currentItem && row.currentItem.x + row.currentItem.width > flickable.contentX + flickable.width) {
111− d.alignmentAdjustment -= ((row.currentItem.x + row.currentItem.width) - (flickable.contentX + flickable.width));
113+ } else if (row.currentItem && flickable.contentX > (row.width - row.currentItem.x - row.currentItem.width)) {
114+ d.alignmentAdjustment -= flickable.contentX - (row.width - row.currentItem.x - row.currentItem.width);
112115 }
113116 }
114117 }
@@ -134,16 +137,19 @@ Item {
134137 id: flickable
135138 objectName: "flickable"
136139
140+ // we rotate it because we want the Flickable to align its content item
141+ // on the right instead of on the left
142+ rotation: 180
143+
137144 anchors.fill: parent
138145 contentWidth: row.width
146+ contentX: d.combinedOffset
139147 interactive: false
140− // align right + offset from row selection + scrolling
141− contentX: row.width - flickable.width - d.combinedOffset
142148
143149 // contentX can change by user interaction as well as user offset changes
144150 // This function re-aligns the offsets so that the offsets match the contentX
145151 function resetContentXComponents() {
146− d.scrollOffset += (flickable.contentX - (row.width - flickable.width - d.combinedOffset));
152+ d.scrollOffset += d.combinedOffset - flickable.contentX;
147153 }
148154
149155 rebound: Transition {
@@ -162,6 +168,9 @@ Item {
162168 bottom: parent.bottom
163169 }
164170
171+ // Compensate for the Flickable rotation (ie, counter-rotate)
172+ rotation: 180
173+
165174 lateralPosition: {
166175 if (root.lateralPosition == -1) return -1;
167176