@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -323,7 +323,7 @@ FocusScope {
323323 scopeView.enableHeightBehaviorOnNextCreation = false;
324324 }
325325 item.model = Qt.binding(function() { return results })
326− item.objectName = Qt.binding(function() { return categoryId })
326+ item.objectName = Qt.binding(function() { return scopeView.scope.name + " " + categoryId })
327327 item.scopeStyle = scopeView.scopeStyle;
328328 if (baseItem.expandable) {
329329 var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
@@ -401,59 +401,102 @@ FocusScope {
401401 }
402402
403403 if (item && item.hasOwnProperty("displayMarginBeginning")) {
404− // A item view creates its delegates synchronously from
405− // -displayMarginBeginning
406− // to
407− // height + displayMarginEnd
408− // Around that area it adds the cacheBuffer area where delegates are created async
409− //
410− // We adjust displayMarginBeginning and displayMarginEnd so
411− // * In non visible scopes nothing is considered visible and we set cacheBuffer
412− // so that creates the items that would be in the viewport asynchronously
413− // * For the current scope set the visible range to the viewport and then
414− // use cacheBuffer to create extra items for categoryView.height * 1.5
415− // to make scrolling nicer by mantaining a higher number of
416− // cached items
417− // * For non current but visible scopes (i.e. when the user changes from one scope
418− // to the next, we set the visible range to the viewport so
419− // items are not culled (invisible) but still use no cacheBuffer
420− // (it will be set once the scope is the current one)
421− var displayMarginBeginning = baseItem.y;
422− displayMarginBeginning = -Math.max(-displayMarginBeginning, 0);
423− displayMarginBeginning = -Math.min(-displayMarginBeginning, baseItem.height);
424− displayMarginBeginning = Math.round(displayMarginBeginning);
425− var displayMarginEnd = -baseItem.height + seeAll.height + categoryView.height - baseItem.y;
426− displayMarginEnd = -Math.max(-displayMarginEnd, 0);
427− displayMarginEnd = -Math.min(-displayMarginEnd, baseItem.height);
428− displayMarginEnd = Math.round(displayMarginEnd);
429− if (scopeView.isCurrent || scopeView.visibleToParent) {
430− item.displayMarginBeginning = displayMarginBeginning;
431− item.displayMarginEnd = displayMarginEnd;
432− if (holdingList && holdingList.moving) {
433− // If we are moving we need to reset the cache buffer of the
434− // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
435− // otherwise the cache buffer we had set to preload the items of the
436− // visible range will trigger some item creations and we want move to
437− // be as smooth as possible meaning no need creations
438− if (!wasCurrentOnMoveStart) {
439− item.cacheBuffer = 0;
404+ if (item.growsVertically) {
405+ // A item view creates its delegates synchronously from
406+ // -displayMarginBeginning
407+ // to
408+ // height + displayMarginEnd
409+ // Around that area it adds the cacheBuffer area where delegates are created async
410+ //
411+ // We adjust displayMarginBeginning and displayMarginEnd so
412+ // * In non visible scopes nothing is considered visible and we set cacheBuffer
413+ // so that creates the items that would be in the viewport asynchronously
414+ // * For the current scope set the visible range to the viewport and then
415+ // use cacheBuffer to create extra items for categoryView.height * 1.5
416+ // to make scrolling nicer by mantaining a higher number of
417+ // cached items
418+ // * For non current but visible scopes (i.e. when the user changes from one scope
419+ // to the next, we set the visible range to the viewport so
420+ // items are not culled (invisible) but still use no cacheBuffer
421+ // (it will be set once the scope is the current one)
422+ var displayMarginBeginning = baseItem.y;
423+ displayMarginBeginning = -Math.max(-displayMarginBeginning, 0);
424+ displayMarginBeginning = -Math.min(-displayMarginBeginning, baseItem.height);
425+ displayMarginBeginning = Math.round(displayMarginBeginning);
426+ var displayMarginEnd = -baseItem.height + seeAll.height + categoryView.height - baseItem.y;
427+ displayMarginEnd = -Math.max(-displayMarginEnd, 0);
428+ displayMarginEnd = -Math.min(-displayMarginEnd, baseItem.height);
429+ displayMarginEnd = Math.round(displayMarginEnd);
430+
431+ if (scopeView.isCurrent || scopeView.visibleToParent) {
432+ item.displayMarginBeginning = displayMarginBeginning;
433+ item.displayMarginEnd = displayMarginEnd;
434+ if (holdingList && holdingList.moving) {
435+ // If we are moving we need to reset the cache buffer of the
436+ // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
437+ // otherwise the cache buffer we had set to preload the items of the
438+ // visible range will trigger some item creations and we want move to
439+ // be as smooth as possible meaning no need creations
440+ if (!wasCurrentOnMoveStart) {
441+ item.cacheBuffer = 0;
442+ }
443+ } else {
444+ item.cacheBuffer = categoryView.height * 1.5;
440445 }
441446 } else {
442− item.cacheBuffer = categoryView.height * 1.5;
447+ var visibleRange = baseItem.height + displayMarginEnd + displayMarginBeginning;
448+ if (visibleRange < 0) {
449+ item.displayMarginBeginning = displayMarginBeginning;
450+ item.displayMarginEnd = displayMarginEnd;
451+ item.cacheBuffer = 0;
452+ } else {
453+ // This should be visibleRange/2 in each of the properties
454+ // but some item views still (like GridView) like creating sync delegates even if
455+ // the visible range is 0 so let's make sure the visible range is negative
456+ item.displayMarginBeginning = displayMarginBeginning - visibleRange;
457+ item.displayMarginEnd = displayMarginEnd - visibleRange;
458+ item.cacheBuffer = visibleRange;
459+ }
443460 }
444461 } else {
445− var visibleRange = baseItem.height + displayMarginEnd + displayMarginBeginning;
446− if (visibleRange < 0) {
447− item.displayMarginBeginning = displayMarginBeginning;
448− item.displayMarginEnd = displayMarginEnd;
462+ var buffer = wasCurrentOnMoveStart ? categoryView.height * 1.5 : 0;
463+ var onViewport = baseItem.y + baseItem.height > 0 &&
464+ baseItem.y < categoryView.height;
465+ var onBufferViewport = baseItem.y + baseItem.height > -buffer &&
466+ baseItem.y < categoryView.height + buffer;
467+ if (!onBufferViewport) {
468+ // If not on the buffered viewport, don't load anything
469+ item.displayMarginBeginning = 0;
470+ item.displayMarginEnd = -item.innerWidth;
449471 item.cacheBuffer = 0;
450472 } else {
451− // This should be visibleRange/2 in each of the properties
452− // but some item views still (like GridView) like creating sync delegates even if
453− // the visible range is 0 so let's make sure the visible range is negative
454− item.displayMarginBeginning = displayMarginBeginning - visibleRange;
455− item.displayMarginEnd = displayMarginEnd - visibleRange;
456− item.cacheBuffer = visibleRange;
473+ if (onViewport && (scopeView.isCurrent || scopeView.visibleToParent)) {
474+ // If on the buffered viewport and the viewport and the on a visible scope
475+ // Set displayMargin so that cards are rendered
476+ // And if not moving the parent list also give it some extra asynchronously
477+ // buffering
478+ item.displayMarginBeginning = 0;
479+ item.displayMarginEnd = 0;
480+ if (holdingList && holdingList.moving) {
481+ // If we are moving we need to reset the cache buffer of the
482+ // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
483+ // otherwise the cache buffer we had set to preload the items of the
484+ // visible range will trigger some item creations and we want move to
485+ // be as smooth as possible meaning no need creations
486+ if (!wasCurrentOnMoveStart) {
487+ item.cacheBuffer = 0;
488+ }
489+ } else {
490+ item.cacheBuffer = baseItem.width * 1.5;
491+ }
492+ } else {
493+ // If on the buffered viewport but either not in the real viewport
494+ // or in the viewport of the non current scope, use displayMargin + cacheBuffer
495+ // to render asynchronously the width of cards
496+ item.displayMarginBeginning = 0;
497+ item.displayMarginEnd = -item.innerWidth;
498+ item.cacheBuffer = item.innerWidth;
499+ }
457500 }
458501 }
459502 }