[gnome-shell/gbsneto/icon-grid-dnd: 27/37] paginatedIconGrid: Store extra space data



commit 1bac0e3df57dc55884175f534c836df2cf11be46
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Jul 2 15:12:40 2019 -0300

    paginatedIconGrid: Store extra space data
    
    This will be used by future commits to calculate the correct
    drag row when hovering the icon grid.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603

 js/ui/iconGrid.js | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 07cbc3be5..c524f3dad 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -784,6 +784,7 @@ var PaginatedIconGrid = GObject.registerClass({
         this._rowsPerPage = 0;
         this._spaceBetweenPages = 0;
         this._childrenPerPage = 0;
+        this._extraSpaceData = null;
     }
 
     vfunc_get_preferred_height(forWidth) {
@@ -820,6 +821,10 @@ var PaginatedIconGrid = GObject.registerClass({
             leftEmptySpace = availWidth - usedWidth;
         }
 
+        // Store some information about the allocated layout
+        this._leftPadding = leftEmptySpace;
+        this._allocatedColumns = nColumns;
+
         let x = box.x1 + leftEmptySpace + this.leftPadding;
         let y = box.y1 + this.topPadding;
         let columnIndex = 0;
@@ -944,6 +949,11 @@ var PaginatedIconGrid = GObject.registerClass({
         let childrenUp = children.splice(pageOffset,
                                          nRowsAbove * childrenPerRow);
 
+        // Store the resulting calculations so that we can properly take
+        // the open space when dragging icons over the icon grid from a
+        // folder popup.
+        this._extraSpaceData = [sourceRow, nRowsUp, nRowsDown];
+
         // Special case: On the last row with no rows below the icon,
         // there's no need to move any rows either up or down
         if (childrenDown.length == 0 && nRowsUp == 0) {
@@ -978,18 +988,27 @@ var PaginatedIconGrid = GObject.registerClass({
 
     closeExtraSpace() {
         if (!this._translatedChildren || !this._translatedChildren.length) {
+            this._extraSpaceData = null;
             this.emit('space-closed');
             return;
         }
 
+        let nTweenedItems = 0;
         for (let i = 0; i < this._translatedChildren.length; i++) {
             if (!this._translatedChildren[i].translation_y)
                 continue;
+
+            nTweenedItems++;
             Tweener.addTween(this._translatedChildren[i],
                              { translation_y: 0,
                                time: EXTRA_SPACE_ANIMATION_TIME,
                                transition: 'easeInOutQuad',
-                               onComplete: () => this.emit('space-closed')
+                               onComplete: () => {
+                                   if (--nTweenedItems == 0) {
+                                       this._extraSpaceData = null;
+                                       this.emit('space-closed');
+                                    }
+                               }
                              });
         }
     }


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