on xenial help sign in
fix positioning of context
commitfe249d3840506f838127ced230ee677f990a3479 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 15 Oct 2013, 14:37 (13 years ago) parent6b3d47b
2 files changed+20−29
Components/Carousel.qml+4−2 Dash/GenericScopeView.qml+16−27
Components/Carousel.qml+4−2
@@ -49,6 +49,8 @@ Item {
4949 property alias highlightIndex: listView.highlightIndex
5050 /// exposes the delegate of the currentItem
5151 readonly property alias currentItem: listView.currentItem
52+ /// exposes the distance to the next row (only one row in carousel, so it's the topMargins
53+ readonly property alias verticalSpacing: listView.verticalMargin
5254
5355 /// Emitted when the user clicked on an item
5456 /// @param index is the index of the clicked item
@@ -160,7 +162,7 @@ Item {
160162 /* We're clicking the selected item and
161163 we're in the neighbourhood of radius 1 pixel from it.
162164 Let's emit the clicked signal. */
163− carousel.clicked(index, listView.model, delegateItem.y)
165+ carousel.clicked(index, listView.model, 0)
164166 return
165167 }
166168
@@ -184,7 +186,7 @@ Item {
184186 /* We're pressAndHold the selected item and
185187 we're in the neighbourhood of radius 1 pixel from it.
186188 Let's emit the pressAndHold signal. */
187− carousel.pressAndHold(index, listView.model, delegateItem.y);
189+ carousel.pressAndHold(index, listView.model, 0);
188190 return;
189191 }
190192
Dash/GenericScopeView.qml+16−27
@@ -381,42 +381,30 @@ ScopeView {
381381 // when the first preview is ready to be displayed.
382382 property bool init: true
383383
384− // Used internally
385− property int oldRow: -1
386− property bool categoryWasFiltered: false
387− property int initialContenY: 0
388−
389384 onCurrentIndexChanged: {
390385 var row = Math.floor(currentIndex / categoryDelegate.columns);
391386 if (categoryDelegate.collapsedRowCount <= row) {
392387 categoryView.expandedCategoryId = categoryId
393388 }
394− if (!init && model !== undefined) {
395− var item = model.get(currentIndex)
396− scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title, item.comment, item.dndUri, item.metadata)
397− if (oldRow != -1) {
398− if (row < oldRow) {
399− var effectMove = 0;
400− if (categoryView.contentY - categoryDelegate.cellHeight < 0) {
401− effectMove = categoryDelegate.cellHeight - categoryView.contentY;
402− effect.positionPx -= effectMove;
403− }
404− categoryView.contentY -= categoryDelegate.cellHeight - effectMove;
405− } else if (row > oldRow){
406− var effectMove = 0;
407− if (categoryView.contentY + categoryDelegate.cellHeight > categoryView.contentHeight - categoryView.height) {
408− effectMove = (categoryView.contentY + categoryDelegate.cellHeight) - (categoryView.contentHeight - categoryView.height);
409− effect.positionPx += effectMove;
410− }
411− categoryView.contentY += categoryDelegate.cellHeight - effectMove
412− }
413− }
414− }
415− oldRow = row;
416389
417390 if (open) {
418391 categoryDelegate.highlightIndex = currentIndex
419392 }
393+ var itemY = categoryView.contentItem.mapFromItem(categoryDelegate.currentItem).y;
394+ var newContentY = itemY - effect.positionPx - categoryDelegate.verticalSpacing;
395+ print("newContentY", newContentY, categoryView.originY);
396+ var effectAdjust = effect.positionPx;
397+ if (newContentY < 0) {
398+ effectAdjust += newContentY;
399+ newContentY = 0;
400+ }
401+ if (newContentY > categoryView.contentHeight - categoryView.height) {
402+ effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
403+ newContentY = categoryView.contentHeight - categoryView.height;
404+ }
405+
406+ effect.positionPx = effectAdjust;
407+ categoryView.contentY = newContentY;
420408 }
421409
422410 property bool open: false
@@ -426,6 +414,7 @@ ScopeView {
426414 if (open) {
427415 onScreen = true;
428416 categoryDelegate.highlightIndex = currentIndex;
417+ newContentY = categoryView.contentY;
429418 } else {
430419 // Cancel any pending preview requests or actions
431420 if (previewListView.currentItem.previewData !== undefined) {