[gnome-shell/wip/swarm: 24/30] IconGrid: Give preference for icons size updates over before_redraw
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/swarm: 24/30] IconGrid: Give preference for icons size updates over before_redraw
- Date: Wed, 25 Jun 2014 15:04:38 +0000 (UTC)
commit b01a19704f9cffead5cd987a243dbb54c56db6e7
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Thu Jun 19 20:30:40 2014 +0200
IconGrid: Give preference for icons size updates over before_redraw
js/ui/appDisplay.js | 9 +++++----
js/ui/iconGrid.js | 26 +++++++++++++++++++++-----
2 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 41044d0..be5999a 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -461,7 +461,8 @@ const AllView = new Lang.Class({
// a call before redraw, but also we need to hide items
// to not show them for a moment before the animation is
// started
- //this._grid.actor.opacity = 0;
+ this._grid.actor.opacity = 0;
+ log("------- animate before redraw");
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
function() {
this._grid.actor.opacity = 255;
@@ -656,7 +657,7 @@ const AllView = new Lang.Class({
let availHeight = box.y2 - box.y1;
let oldNPages = this._grid.nPages();
- this._grid.adaptToSize(availWidth, availHeight);
+ this._grid.adaptToSize(availWidth, availHeight, 'allView');
let fadeOffset = Math.min(this._grid.topPadding,
this._grid.bottomPadding);
@@ -781,7 +782,7 @@ const FrequentView = new Lang.Class({
box = this._grid.actor.get_theme_node().get_content_box(box);
let availWidth = box.x2 - box.x1;
let availHeight = box.y2 - box.y1;
- this._grid.adaptToSize(availWidth, availHeight);
+ this._grid.adaptToSize(availWidth, availHeight, 'frequent view');
}
});
@@ -1081,7 +1082,7 @@ const FolderView = new Lang.Class({
this._parentAvailableWidth = width;
this._parentAvailableHeight = height;
- this._grid.adaptToSize(width, height);
+ this._grid.adaptToSize(width, height, 'folder view');
// To avoid the fade effect being applied to the unscrolled grid,
// the offset would need to be applied after adjusting the padding;
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 92bb403..c593e16 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -298,6 +298,7 @@ const IconGrid = new Lang.Class({
},
_allocate: function (grid, box, flags) {
+ log("allocate start");
if (this._fillParent) {
// Reset the passed in box to fill the parent
let parentBox = this.actor.get_parent().allocation;
@@ -351,6 +352,7 @@ const IconGrid = new Lang.Class({
x += this._getHItemSize() + spacing;
}
}
+ log("allocate ends");
},
/**
@@ -433,6 +435,7 @@ const IconGrid = new Lang.Class({
},
_animateSwarmSpring: function(actors, animationDirection, sourcePosition, sourceSize) {
+ log("###### animate swarm start " + this._items[0].icon.iconSize);
let distances = actors.map(Lang.bind(this, function(actor) {
return this._distance(actor.get_transformed_position(), sourcePosition);
}));
@@ -477,6 +480,7 @@ const IconGrid = new Lang.Class({
onComplete: Lang.bind(this, function() {
if (isLastItem){
this._animating = false;
+ log("animate swarm ends " + this._items[0].icon.iconSize);
this.emit('animation-done');
}
actor.opacity = 255;
@@ -704,13 +708,19 @@ const IconGrid = new Lang.Class({
* This function must to be called before iconGrid allocation,
* to know how much spacing can the grid has
*/
- adaptToSize: function(availWidth, availHeight) {
+ adaptToSize: function(availWidth, availHeight, view) {
this._fixedHItemSize = this._hItemSize;
this._fixedVItemSize = this._vItemSize;
this._updateSpacingForSize(availWidth, availHeight);
let spacing = this._getSpacing();
+ log("adapt to size view " + view);
+ log("Adapt to size " + [availWidth, availHeight]);
+ log("adapt to size spacing " + spacing);
+ log("columns/rows per width " + [this.columnsForWidth(availWidth), this.rowsForHeight(availHeight)]);
+
if (this.columnsForWidth(availWidth) < this._minColumns || this.rowsForHeight(availHeight) <
this._minRows) {
+ log("adapt to size inside");
let neededWidth = this.usedWidthForNColumns(this._minColumns) - availWidth ;
let neededHeight = this.usedHeightForNRows(this._minRows) - availHeight ;
@@ -722,15 +732,21 @@ const IconGrid = new Lang.Class({
this._updateSpacingForSize(availWidth, availHeight);
}
let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize,
this._vItemSize);
- Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
this._updateChildrenScale(scale); }));
+
+ log("****** Before redraw new icon size " + Math.floor(ICON_SIZE * scale) + " id " +
this._updateIconSizeId);
+ if (this._updateIconSizeId)
+ Meta.later_remove(this._updateIconSizeId);
+ this._updateIconSizeId = Meta.later_add(Meta.LaterType.RESIZE, Lang.bind(this, function() {
this._updateChildrenScale(scale, view); }));
},
// Note that this is ICON_SIZE as used by BaseIcon, not elsewhere in IconGrid; it's a bit messed up
- _updateChildrenScale: function(scale) {
+ _updateChildrenScale: function(scale, view) {
let newIconSize = Math.floor(ICON_SIZE * scale);
for (let i in this._items) {
this._items[i].icon.setIconSize(newIconSize);
}
+ log("new icon size view " + view);
+ log("++++++++ new icon size " + newIconSize + " id " + this._updateIconSizeId);
}
});
Signals.addSignalMethods(IconGrid.prototype);
@@ -832,8 +848,8 @@ const PaginatedIconGrid = new Lang.Class({
this._childrenPerPage = nColumns * this._rowsPerPage;
},
- adaptToSize: function(availWidth, availHeight) {
- this.parent(availWidth, availHeight);
+ adaptToSize: function(availWidth, availHeight, view) {
+ this.parent(availWidth, availHeight, view);
this._computePages(availWidth, availHeight);
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]