[gnome-shell/wip/swarm: 50/51] f



commit ce6d08198208c27e79d4b46d054ec6bb68d1ad6b
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Tue Jun 3 20:23:29 2014 +0200

    f

 js/ui/appDisplay.js   |   63 +++++++++++++++++++++++++++++++++++++++---------
 js/ui/iconGrid.js     |   62 ++++++++++++++++++++++++++++++++++--------------
 js/ui/viewSelector.js |    2 +-
 3 files changed, 96 insertions(+), 31 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index ea44724..9861835 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -143,6 +143,14 @@ const BaseAppView = new Lang.Class({
     _compareItems: function(a, b) {
         return a.name.localeCompare(b.name);
     },
+    
+    animateIn: function(origin, animationType) {
+        throw new Error('Not implemented');
+    },
+    
+    animateOut: function(origin, animationType) {
+        throw new Error('Not implemented');
+    },
 
     loadGrid: function() {
         this._allItems.sort(this._compareItems);
@@ -436,6 +444,18 @@ const AllView = new Lang.Class({
         this.loadGrid();
         this._refilterApps();
     },
+    
+    animateIn: function(origin, animationType) {
+        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
+            function() {
+                this._grid.animateIn(origin, animationType);
+            }));
+    },
+    
+    animateOut: function(origin, animationType) {
+        throw new Error('Not implemented');
+    },
+
 
     getCurrentPageY: function() {
         return this._grid.getPageY(this._currentPage);
@@ -624,10 +644,6 @@ const AllView = new Lang.Class({
         // Update folder views
         for (let i = 0; i < this.folderIcons.length; i++)
             this.folderIcons[i].adaptToSize(availWidth, availHeight);
-    },
-
-    swarmAnimation: function() {
-        //this._grid.swarmAnimation(0);
     }
 });
 Signals.addSignalMethods(AllView.prototype);
@@ -681,6 +697,17 @@ const FrequentView = new Lang.Class({
             this._grid.addItem(appIcon, -1);
         }
     },
+    
+    animateIn: function(origin, animationType) {
+        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
+            function() {
+                this._grid.animateIn(origin, animationType);
+            }));
+    },
+    
+    animateOut: function(origin, animationType) {
+        throw new Error('Not implemented');
+    },
 
     // Called before allocation to calculate dynamic spacing
     adaptToSize: function(width, height) {
@@ -818,12 +845,13 @@ const AppDisplay = new Lang.Class({
             */
     },
     
-    swarmAnimation: function() {
+    animateIn: function() {
         log("appDisplay");
         log(this._views);
         let view = this._views[global.settings.get_uint('app-picker-view')].view;
         log(view);
-        view.swarmAnimation();
+        view.animateIn(Main.overview._dash._showAppsIcon.get_transformed_position(),
+                       IconGrid.ANIMATION_SWARM_FAR_FIRST);
     },
 
     _showView: function(activeIndex) {
@@ -975,8 +1003,17 @@ const FolderView = new Lang.Class({
         Util.ensureActorVisibleInScrollView(this.actor, actor);
     },
     
-    animateItems: function() {
-        this._grid.animate(this._grid._getVisibleItems());
+    animateIn: function(origin, animationType) {
+        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
+            function() {
+                this._grid.animateIn(origin, animationType);
+            }));
+        
+        log("FolderView in");
+    },
+    
+     animateOut: function(origin, animationType) {
+        log("FolderView out");
     },
 
     createFolderIcon: function(size) {
@@ -1219,8 +1256,6 @@ const FolderIcon = new Lang.Class({
                 function(popup, isOpen) {
                     if (!isOpen)
                         this.actor.checked = false;
-                    else
-                        this.view.animateItems();
                 }));
         } else {
             this._popup.updateArrowSide(this._boxPointerArrowside);
@@ -1319,7 +1354,11 @@ const AppFolderPopup = new Lang.Class({
         this.actor.show();
 
         this._boxPointer.setArrowActor(this._source.actor);
-        this._boxPointer.show(BoxPointer.PopupAnimation.FADE);
+        this._boxPointer.show(BoxPointer.PopupAnimation.SLIDE, Lang.bind(this, 
+            function() {
+                this._view.animateIn(this._source.actor.get_transformed_position(),
+                                     IconGrid.ANIMATION_SWARM_FAR_FIRST);
+            }));
 
         this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
 
@@ -1331,7 +1370,7 @@ const AppFolderPopup = new Lang.Class({
         if (!this._isOpen)
             return;
 
-        this._boxPointer.hide(BoxPointer.PopupAnimation.FADE);
+        this._boxPointer.hide(BoxPointer.PopupAnimation.FADE, this._view.animateOut );
         this._isOpen = false;
         this.emit('open-state-changed', false);
     },
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index d717e0f..a39f5a5 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -233,11 +233,11 @@ const IconGrid = new Lang.Class({
         
         this._paintedItems = [];
         this._animating = false;
-        this._mappedId = this.actor.connect("notify::allocation", Lang.bind(this, 
+        /*this._mappedId = this.actor.connect("notify::allocated", Lang.bind(this, 
                 function() {
                     if (this.actor.mapped)
-                        this.animate(this._paintedItems);
-                }));
+                        this._animateInReal(this._paintedItems);
+                }));*/
     },
 
     _keyFocusIn: function(actor) {
@@ -373,14 +373,28 @@ const IconGrid = new Lang.Class({
             }
         }
     },
+    
+        
+    animateIn: function(origin, animationType) {
+        this._animateInNextAllocation = true;
+        this._animationOrigin = origin;
+        this._animationType = animationType;
+        this._animateInReal(this._paintedItems);
+        log("Animating in");
+    },
 
-    animate: function(items) {
-        if (this._animating)
+    _animateInReal: function(items) {
+        log("animate real " + this._animateInNextAllocation + " " + this._animating);
+        if (!this._animateInNextAllocation)
             return;
 
+        this._animateInNextAllocation = false;
+        log("items " + items.length);
+        if (this._animating || items.length == 0)
+            return;
+        log("animating real to be done");
         this._animating = true;
-        
-        let [startX, startY] = Main.overview._dash._showAppsIcon.get_transformed_position();
+        let [startX, startY] = this._animationOrigin;
         let distances = items.map(Lang.bind(this, function(item) {
             return this._distance(item.actor.get_transformed_position(), [startX, startY]);
         }));
@@ -389,14 +403,19 @@ const IconGrid = new Lang.Class({
         let normalization = Math.max.apply(Math, distances);
         
         for (let index = 0; index < items.length; index++) {
+            // FIXME? Seems that putting the items at opacity 0
+            // for animating seems like it doesn't belongs here.
+            // But works well.
             items[index].actor.opacity = 0;
             let [finalX, finalY] = items[index].actor.get_transformed_position();
             switch (this._animationType) {
                 case ANIMATION_SWARM_FAR_FIRST:
                     let distance = this._distance([startX, startY], [finalX, finalY]);
+                    [startX, startY] = this._animationOrigin;
                     delay = (1 - this._distance([startX, startY], [finalX, finalY]) / normalization) * 
SWARM_ANIMATION_MAX_DELAY_FOR_ITEM;
                     break;
                 case ANIMATION_SWARM_RANDOM:
+                    [startX, startY] = this._animationOrigin;
                     delay = Math.random() * SWARM_ANIMATION_MAX_DELAY_FOR_ITEM;
                     break;
                 case ANIMATION_APPEAR:
@@ -670,12 +689,17 @@ const PaginatedIconGrid = new Lang.Class({
         this._spaceBetweenPages = 0;
         this._childrenPerPage = 0;
         
-        this._mappedId = 0;
-        this._mappedId = this.actor.connect("notify::allocation", Lang.bind(this, 
+        log("#####################");
+        log("Already mappedId? " + this._mappedId);
+        /*this.actor.disconnect(this._mappedId);
+        this._mappedId = this.actor.connect("notify::allocated", Lang.bind(this, 
                 function() {
-                    if (this.actor.mapped)
-                        this.animate();
-                }));
+                    if (this.actor.mapped) {
+                        let items = this._getItemsInPage(0);
+                        log("jsut before " + items.length);
+                        this._animateInReal(items);
+                    }
+                })); */
     },
 
     _getPreferredHeight: function (grid, forWidth, alloc) {
@@ -736,13 +760,13 @@ const PaginatedIconGrid = new Lang.Class({
                 x += this._getHItemSize() + spacing;
         }
     },
-
-    animate: function() {
-        let items = this._getItemsInPage(0);
-        // TODO: Fix this
+    
+   _animateInReal: function(items) {
+        log("secundario " + this._getItemsInPage(0).length);
+        log("Animating paginated. Items " + items.length);
+        // FIXME
         if (items.length == 0)
             return;
-
         this.parent(items);
     },
 
@@ -803,6 +827,8 @@ const PaginatedIconGrid = new Lang.Class({
 
     _getItemsInPage: function(pageNumber) {
         let items = this._getVisibleItems();
+        log("getItemsPAge " + items.length);
+
         let firstIndex = this._childrenPerPage * pageNumber;
         let indexOffset = 0;
         let itemsInPage = []
@@ -811,7 +837,7 @@ const PaginatedIconGrid = new Lang.Class({
                itemsInPage.push(items[firstIndex + indexOffset]);
                indexOffset++;
         }
-
+        log("intems in page " + itemsInPage.length + " chidren per page " + this._childrenPerPage);
         return itemsInPage;
     },
 
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 9e7dd87..941eaf4 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -242,7 +242,7 @@ const ViewSelector = new Lang.Class({
             this._fadePageIn(oldPage);
 
         if (this._activePage == this._appsPage)
-            this.appDisplay.swarmAnimation();
+            this.appDisplay.animateIn();
     },
 
     _a11yFocusPage: function(page) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]