[gnome-shell/wip/paging] we don't need anymore the pagination calculation at allocation time, since we calcualte the responsi
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/paging] we don't need anymore the pagination calculation at allocation time, since we calcualte the responsi
- Date: Sat, 3 Aug 2013 08:31:16 +0000 (UTC)
commit 9efa3dd6d318e7b38711906d72b245b8b4f93ba7
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Fri Aug 2 13:52:13 2013 +0200
we don't need anymore the pagination calculation at allocation time,
since we calcualte the responsive grid in parents allocation before
js/ui/appDisplay.js | 12 ------------
js/ui/iconGrid.js | 38 +++++++++++++++++++++++++++++++++-----
js/ui/searchDisplay.js | 2 +-
3 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 84ae7a4..54be9b2 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1127,15 +1127,6 @@ const FolderView = new Lang.Class({
_init: function() {
this.parent({ useSurroundingSpacing: true });
-
- /*this._grid = new IconGrid.IconGrid({ xAlign: St.Align.MIDDLE,
- columnLimit: MAX_COLUMNS,
- minRows: MIN_ROWS,
- minColumns: MIN_COLUMNS,
- useSurroundingSpacing: true});*/
- // If it not expand, the parent doesn't take into account its preferred_width when allocating
- // the second time it allocates, so we apply the "Standard hack for ClutterBinLayout"
- this._grid.actor.x_expand = true;
this.actor = new St.ScrollView({overlay_scrollbars: true});
this.actor.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
@@ -1144,9 +1135,6 @@ const FolderView = new Lang.Class({
this._widget.add_child(this._grid.actor);
this._box.add_actor(this._widget);
this.actor.add_actor(this._box);
- this._items = {};
- this._allItems = [];
-
this._boxPointerOffsets = {};
},
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 2a44028..dc8e388 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -302,7 +302,7 @@ const IconGrid = new Lang.Class({
let availHeight = box.y2 - box.y1;
let spacing = this.getSpacing();
let [nColumns, usedWidth] = this._computeLayout(availWidth);
- if(this._usePagination) {
+ /*if(this._usePagination) {
// Calculate icongrid box inside the scrollView
let parentBox = this._viewForPageSize.allocation;
let gridBox = this.actor.get_theme_node().get_content_box(parentBox);
@@ -328,7 +328,7 @@ const IconGrid = new Lang.Class({
return false;
}));
}
- }
+ }*/
let leftPadding;
switch(this._xAlign) {
case St.Align.START:
@@ -387,10 +387,22 @@ const IconGrid = new Lang.Class({
} else {
x += this.getHItemSize() + spacing;
}
- }
+ }
},
- _calculatePaginationValues: function (availHeightPerPage, nColumns, nRows) {
+ _calculatePaginationValues: function (availWidthPerPage, availHeightPerPage) {
+ let [nColumns, usedWidth] = this._computeLayout(availWidthPerPage);
+ let nRows;
+ let children = this._getVisibleChildren();
+ if (nColumns > 0)
+ nRows = Math.ceil(children.length / nColumns);
+ else
+ nRows = 0;
+ if (this._rowLimit)
+ nRows = Math.min(nRows, this._rowLimit);
+ let oldHeightUsedPerPage = this.usedHeightPerPage();
+ let oldNPages = this._nPages;
+
let spacing = this.getSpacing();
this._spacePerRow = this.getVItemSize() + spacing;
// We want to contain the grid inside the parent box with padding
@@ -403,6 +415,19 @@ const IconGrid = new Lang.Class({
this._spaceBetweenPages = availHeightPerPage - (this._rowsPerPage * (this.getVItemSize() + spacing)
- spacing);
this._spaceBetweenPagesTotal = this._spaceBetweenPages * (this._nPages);
this._childrenPerPage = nColumns * this._rowsPerPage;
+
+ global.log("nPages " + this._nPages);
+ global.log("availHeightPerPage, availWidthPerPage")
+ // Take into account when the number of pages changed (then the height of the entire grid changed
for sure)
+ // and also when the spacing is changed, sure the hegiht per page changed and the entire grid height
changes, althougt
+ // maybe the number of pages doesn't change
+ if(oldNPages != this._nPages || oldHeightUsedPerPage != this.usedHeightPerPage()) {
+ this.emit('n-pages-changed', this._nPages);
+ /*Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
+ this._grid.queue_relayout();
+ return false;
+ }));*/
+ }
},
_calculateChildrenBox: function(child, x, y, box) {
@@ -450,7 +475,7 @@ const IconGrid = new Lang.Class({
this._vItemSize = themeNode.get_length('-shell-grid-vertical-item-size') || ICON_SIZE;
this._grid.queue_relayout();
},
-
+
columnsForWidth: function(rowWidth) {
return this._computeLayout(rowWidth)[0];
},
@@ -599,6 +624,7 @@ const IconGrid = new Lang.Class({
calculateResponsiveGrid: function(availWidth, availHeight) {
this._fixedHItemSize = this._hItemSize;
this._fixedVItemSize = this._vItemSize;
+
let spacing = this.maxSpacingForWidthHeight(availWidth, availHeight);
this.setSpacing(spacing);
if(this._useSurroundingSpacing)
@@ -640,6 +666,8 @@ const IconGrid = new Lang.Class({
let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize,
this._vItemSize);
this.updateChildrenScale(scale);
+ if(this._usePagination)
+ this._calculatePaginationValues(availWidth, availHeight);
},
/**
* FLORIAN REVIEW
diff --git a/js/ui/searchDisplay.js b/js/ui/searchDisplay.js
index 2177874..9d47e44 100644
--- a/js/ui/searchDisplay.js
+++ b/js/ui/searchDisplay.js
@@ -320,7 +320,7 @@ const GridSearchResults = new Lang.Class({
},
_getMaxDisplayedResults: function() {
- return this._grid.childrenInRow(this._bin.width) * this._grid.getRowLimit();
+ return this._grid.columnsForWidth(this._bin.width) * this._grid.getRowLimit();
},
_renderResults: function(metas) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]