@@ -38,6 +38,7 @@ FocusScope {
38 property int paginationCount: 0
38 property int paginationCount: 0
39 property int paginationIndex: 0
39 property int paginationIndex: 0
40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
41+ property var holdingList: null
42 property var scopeStyle: ScopeStyle {
43 property var scopeStyle: ScopeStyle {
43 style: scope ? scope.customizations : {}
44 style: scope ? scope.customizations : {}
@@ -47,6 +48,10 @@ FocusScope {
48 signal backClicked()
49 signal backClicked()
52+ floatingSeeLess.companionBase = null;
50 function positionAtBeginning() {
55 function positionAtBeginning() {
51 categoryView.positionAtBeginning()
56 categoryView.positionAtBeginning()
@@ -153,11 +158,55 @@ FocusScope {
153 pixelAligned: true
158 pixelAligned: true
154 interactive: !navigationShown
159 interactive: !navigationShown
156− property Item expandedCategoryItem: null
161+ property string expandedCategoryId: ""
162+ property int runMaximizeAfterSizeChanges: 0
158 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
164 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
159 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
165 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
167+ onExpandedCategoryIdChanged: {
168+ var firstCreated = firstCreatedIndex();
169+ var shrinkingAny = false;
170+ var shrinkHeightDifference = 0;
171+ for (var i = 0; i < createdItemCount(); ++i) {
172+ var baseItem = item(firstCreated + i);
173+ if (baseItem.expandable) {
174+ var shouldExpand = baseItem.category === expandedCategoryId;
175+ if (shouldExpand != baseItem.expanded) {
177+ var animate = false;
178+ if (!subPageLoader.open) {
179+ var animateShrinking = !shouldExpand && baseItem.y + baseItem.item.collapsedHeight + baseItem.seeAll.height < categoryView.height;
180+ var animateGrowing = shouldExpand && baseItem.y + baseItem.height < categoryView.height;
181+ animate = shrinkingAny || animateShrinking || animateGrowing;
184+ if (!shouldExpand) {
185+ shrinkingAny = true;
186+ shrinkHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
189+ if (shouldExpand && !subPageLoader.open) {
190+ if (!shrinkingAny) {
191+ categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAll.height);
193+ // If the space that shrkinking is smaller than the one we need to grow we'll call maximizeVisibleArea
194+ // after the shrink/grow animation ends
195+ var growHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
196+ if (growHeightDifference > shrinkHeightDifference) {
197+ runMaximizeAfterSizeChanges = 2;
199+ runMaximizeAfterSizeChanges = 0;
204+ baseItem.expand(shouldExpand, animate);
161 delegate: ListItems.Base {
210 delegate: ListItems.Base {
162 id: baseItem
211 id: baseItem
163 objectName: "dashCategory" + category
212 objectName: "dashCategory" + category
@@ -176,6 +225,7 @@ FocusScope {
176 readonly property string category: categoryId
225 readonly property string category: categoryId
177 readonly property string headerLink: model.headerLink
226 readonly property string headerLink: model.headerLink
178 readonly property var item: rendererLoader.item
227 readonly property var item: rendererLoader.item
228+ readonly property var seeAll: seeAll
180 function expand(expand, animate) {
230 function expand(expand, animate) {
181 heightBehaviour.enabled = animate;
231 heightBehaviour.enabled = animate;
@@ -195,13 +245,13 @@ FocusScope {
195 // This can happen with the VJ that doesn't know how height it will be on creation
245 // This can happen with the VJ that doesn't know how height it will be on creation
196 // so doesn't set expandable until a bit too late for onLoaded
246 // so doesn't set expandable until a bit too late for onLoaded
197 if (expandable) {
247 if (expandable) {
198− var shouldExpand = baseItem === categoryView.expandedCategoryItem;
248+ var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
199 baseItem.expand(shouldExpand, false /*animate*/);
249 baseItem.expand(shouldExpand, false /*animate*/);
203− onHeightChanged: rendererLoader.updateDelegateCreationRange();
253+ onHeightChanged: rendererLoader.updateRanges();
204− onYChanged: rendererLoader.updateDelegateCreationRange();
254+ onYChanged: rendererLoader.updateRanges();
207 id: rendererLoader
257 id: rendererLoader
@@ -216,9 +266,23 @@ FocusScope {
216 id: heightBehaviour
266 id: heightBehaviour
217 enabled: false
267 enabled: false
218 animation: UbuntuNumberAnimation {
268 animation: UbuntuNumberAnimation {
269+ duration: UbuntuAnimation.FastDuration
219 onRunningChanged: {
270 onRunningChanged: {
220 if (!running) {
271 if (!running) {
221 heightBehaviour.enabled = false
272 heightBehaviour.enabled = false
273+ if (categoryView.runMaximizeAfterSizeChanges > 0) {
274+ categoryView.runMaximizeAfterSizeChanges--;
275+ if (categoryView.runMaximizeAfterSizeChanges == 0) {
276+ var firstCreated = categoryView.firstCreatedIndex();
277+ for (var i = 0; i < categoryView.createdItemCount(); ++i) {
278+ var baseItem = categoryView.item(firstCreated + i);
279+ if (baseItem.category === categoryView.expandedCategoryId) {
280+ categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAll.height);
@@ -246,10 +310,10 @@ FocusScope {
246 item.objectName = Qt.binding(function() { return categoryId })
310 item.objectName = Qt.binding(function() { return categoryId })
247 item.scopeStyle = scopeView.scopeStyle;
311 item.scopeStyle = scopeView.scopeStyle;
248 if (baseItem.expandable) {
312 if (baseItem.expandable) {
249− var shouldExpand = baseItem === categoryView.expandedCategoryItem;
313+ var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
250 baseItem.expand(shouldExpand, false /*animate*/);
314 baseItem.expand(shouldExpand, false /*animate*/);
252− updateDelegateCreationRange();
316+ updateRanges();
253 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {
317 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {
254 // Yeah, hackish :/
318 // Yeah, hackish :/
255 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
319 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
@@ -304,13 +368,25 @@ FocusScope {
307− onOriginYChanged: rendererLoader.updateDelegateCreationRange();
371+ onOriginYChanged: rendererLoader.updateRanges();
308− onContentYChanged: rendererLoader.updateDelegateCreationRange();
372+ onContentYChanged: rendererLoader.updateRanges();
309− onHeightChanged: rendererLoader.updateDelegateCreationRange();
373+ onHeightChanged: rendererLoader.updateRanges();
310− onContentHeightChanged: rendererLoader.updateDelegateCreationRange();
374+ onContentHeightChanged: rendererLoader.updateRanges();
378+ onIsCurrentChanged: rendererLoader.updateRanges();
382+ onMovingChanged: if (!moving) rendererLoader.updateRanges();
313− function updateDelegateCreationRange() {
385+ function updateRanges() {
386+ if (holdingList && holdingList.moving) {
314 if (categoryView.moving) {
390 if (categoryView.moving) {
315 // Do not update the range if we are overshooting up or down, since we'll come back
391 // Do not update the range if we are overshooting up or down, since we'll come back
316 // to the stable position and delete/create items without any reason
392 // to the stable position and delete/create items without any reason
@@ -322,10 +398,18 @@ FocusScope {
401+ if (item && item.hasOwnProperty("visibleRangeBegin")) {
402+ item.visibleRangeBegin = Math.max(-baseItem.y, 0)
403+ item.visibleRangeEnd = item.visibleRangeBegin + Math.min(categoryView.height, rendererLoader.height)
325 if (item && item.hasOwnProperty("displayMarginBeginning")) {
406 if (item && item.hasOwnProperty("displayMarginBeginning")) {
326 // TODO do we need item.originY here, test 1300302 once we have a silo
407 // TODO do we need item.originY here, test 1300302 once we have a silo
327 // and we can run it on the phone
408 // and we can run it on the phone
409+ if (scopeView.isCurrent) {
410+ item.displayMarginBeginning = 1073741823;
411+ item.displayMarginEnd = 1073741823;
328− if (baseItem.y + baseItem.height <= 0) {
412+ } else if (baseItem.y + baseItem.height <= 0) {
329 // Not visible (item at top of the list viewport)
413 // Not visible (item at top of the list viewport)
330 item.displayMarginBeginning = -baseItem.height;
414 item.displayMarginBeginning = -baseItem.height;
331 item.displayMarginEnd = 0;
415 item.displayMarginEnd = 0;
@@ -334,9 +418,9 @@ FocusScope {
334 item.displayMarginBeginning = 0;
418 item.displayMarginBeginning = 0;
335 item.displayMarginEnd = -baseItem.height;
419 item.displayMarginEnd = -baseItem.height;
337− item.displayMarginBeginning = -Math.max(-baseItem.y, 0);
421+ item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
338− item.displayMarginEnd = -Math.max(baseItem.height - seeAll.height
422+ item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height
339− - categoryView.height + baseItem.y, 0)
423+ - categoryView.height + baseItem.y, 0));
@@ -353,10 +437,11 @@ FocusScope {
353 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
437 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
355 onClicked: {
439 onClicked: {
356− if (categoryView.expandedCategoryItem !== baseItem) {
440+ if (categoryView.expandedCategoryId !== baseItem.category) {
357− categoryView.expandedCategoryItem = baseItem;
441+ categoryView.expandedCategoryId = baseItem.category;
442+ floatingSeeLess.companionBase = baseItem;
359− categoryView.expandedCategoryItem = null;
444+ categoryView.expandedCategoryId = "";
@@ -456,7 +541,7 @@ FocusScope {
456 objectName: "floatingSeeLess"
541 objectName: "floatingSeeLess"
458 property Item companionTo: companionBase ? companionBase.seeAllButton : null
543 property Item companionTo: companionBase ? companionBase.seeAllButton : null
459− property Item companionBase: categoryView.expandedCategoryItem
544+ property Item companionBase: null
460 property bool showBecausePosition: false
545 property bool showBecausePosition: false
461 property real yOffset: 0
546 property real yOffset: 0
@@ -468,7 +553,7 @@ FocusScope {
468 height: seeLessLabel.font.pixelSize + units.gu(4)
553 height: seeLessLabel.font.pixelSize + units.gu(4)
469 visible: companionTo && showBecausePosition
554 visible: companionTo && showBecausePosition
471− onClicked: categoryView.expandedCategoryItem = null;
556+ onClicked: categoryView.expandedCategoryId = "";
473 function updateVisibility() {
558 function updateVisibility() {
474 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
559 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
@@ -477,6 +562,10 @@ FocusScope {
477 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
562 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
478 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
563 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
479 yOffset = Math.min(yOffset, height);
564 yOffset = Math.min(yOffset, height);
566+ if (!showBecausePosition && categoryView.expandedCategoryId === "") {
567+ companionBase = null;