[gnome-shell/wip/overviewAnimationsBakcup: 3/3] save me



commit e9ccb84c113fb4f8268ef6927c7713dde5488e90
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Sun Jul 13 15:40:49 2014 +0200

    save me

 js/ui/overviewControls.js |    4 +-
 js/ui/viewSelector.js     |   27 +++++--
 js/ui/workspace.js        |  180 ++++++++++++++++++++++++++++++++++-----------
 js/ui/workspacesView.js   |   13 ++--
 4 files changed, 167 insertions(+), 57 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index b396ff0..d78a119 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -588,6 +588,7 @@ const ControlsManager = new Lang.Class({
     },
 
     _setVisibility: function() {
+        log("_setVisibility");
         // Ignore the case when we're leaving the overview, since
         // actors will be made visible again when entering the overview
         // next time, and animating them while doing so is just
@@ -597,9 +598,10 @@ const ControlsManager = new Lang.Class({
             return;
 
         let activePage = this.viewSelector.getActivePage();
+        log("_setVisibility real " + activePage);
         let dashVisible = (activePage == ViewSelector.ViewPage.WINDOWS ||
                            activePage == ViewSelector.ViewPage.APPS);
-        let thumbnailsVisible = (activePage == ViewSelector.ViewPage.WINDOWS);
+        let thumbnailsVisible = (activePage == ViewSelector.ViewPage.WINDOWS && 
!this.viewSelector.showingApps);
 
         if (dashVisible)
             this._dashSlider.slideIn();
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 8b350da..186a5df 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -299,6 +299,7 @@ const ViewSelector = new Lang.Class({
     },
 
     _toggleAppsPage: function() {
+        this.showingApps = true;
         Main.overview.show();
         this._showAppsButton.checked = !this._showAppsButton.checked;
     },
@@ -311,13 +312,14 @@ const ViewSelector = new Lang.Class({
 
     show: function() {
         this.reset();
-
-        this._workspacesDisplay.show();
+        log("viewSelector show " + this.showingApps);
+        this._workspacesDisplay.show(this.showingApps ? Workspace.AnimationType.FADE : 
Workspace.AnimationType.ZOOM);
         this._activePage = null;
-        if (this.showingApps)
+        if (this.showingApps) {
             this._showPage(this._appsPage);
-        else
+        } else {
             this._showPage(this._workspacesPage);
+        }
 
         if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows())
             Main.overview.fadeOutDesktop();
@@ -325,8 +327,8 @@ const ViewSelector = new Lang.Class({
 
     animateFromOverview: function() {
         let animationType = this._activePage == this._workspacesPage ? Workspace.AnimationType.ZOOM :
-                                                                       Workspace.AnimationType.FADE_IN;
-        if (animationType == Workspace.AnimationType.FADE_IN) {
+                                                                       Workspace.AnimationType.FADE;
+        if (animationType == Workspace.AnimationType.FADE) {
             this._workspacesPage.show();
             this._workspacesPage.opacity = 255;
             this._showPage(this._workspacesPage);
@@ -378,14 +380,23 @@ const ViewSelector = new Lang.Class({
         Tweener.addTween(this._activePage,
             { opacity: 255,
               time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
-              transition: 'easeOutQuad'
+              transition: 'easeOutQuad',
+              onComplete: Lang.bind(this, 
+                function() {
+                    if (this.showingApps) {
+                        log("hiding workspace");
+                        this.showingApps = false;
+                        // this._workspacesPage.opacity = 0;
+                        this._workspacesPage.hide();
+                    }
+                })
             });
     },
 
     _showPage: function(page, noFade) {
         if (page == this._activePage)
             return;
-
+        log("show page " + [this._activePage, page]);
         let oldPage = this._activePage;
         this._activePage = page;
         this.emit('page-changed');
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 29fc940..57229fb 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -34,9 +34,12 @@ const DRAGGING_WINDOW_OPACITY = 100;
 const LAYOUT_SCALE_WEIGHT = 1;
 const LAYOUT_SPACE_WEIGHT = 0.1;
 
+const WINDOW_ANIMATION_BLENDING = 0.5 // %
+const WINDOW_ANIMATION_MAX_NUMBER_BLENDING = 3;
+
 const AnimationType = {
     ZOOM: 0,
-    FADE_IN: 1
+    FADE: 1
 };
 
 function _interpolate(start, end, step) {
@@ -1227,8 +1230,9 @@ const Workspace = new Lang.Class({
 
         if (this._positionWindowsId > 0)
             return;
-
+        log("_recalculateWindowPositions");
         this._positionWindowsId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
+            log("_recalculateWindowPositions real");
             this._realRecalculateWindowPositions(this._positionWindowsFlags);
             this._positionWindowsFlags = 0;
             this._positionWindowsId = 0;
@@ -1258,6 +1262,7 @@ const Workspace = new Lang.Class({
     },
 
     _updateWindowPositions: function(flags) {
+        log("_updateWindowPositions");
         if (this._currentLayout == null) {
             this._recalculateWindowPositions(flags);
             return;
@@ -1266,9 +1271,9 @@ const Workspace = new Lang.Class({
         // We will reposition windows when enter again overview anyway.
         // In this way we avoid unwanted animations of windows repositioning while
         // animating overview
-        if (this.leavingOverview)
+        if (this.leavingOverview || this.showingApps)
             return;
-
+        log("_updateWindowPositions real");
         let initialPositioning = flags & WindowPositionFlags.INITIAL;
         let animate = flags & WindowPositionFlags.ANIMATE;
 
@@ -1568,9 +1573,49 @@ const Workspace = new Lang.Class({
     },
 
     // Animate the full-screen to Overview transition.
-    animateToOverview : function() {
-        // Position and scale the windows.
-        this._recalculateWindowPositions(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL);
+    animateToOverview : function(animationType) {
+        log("animateToOverview " + animationType);
+        if (animationType == AnimationType.ZOOM) {
+            // Position and scale the windows.
+            this._recalculateWindowPositions(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL);
+        } else if(animationType == AnimationType.FADE) {
+            this.showingApps = true;
+            for (let i = 0; i < this._windows.length; i++) {
+                let clone = this._windows[i];
+                Tweener.removeTweens(clone.actor);
+            }
+
+            if (this._repositionWindowsId > 0) {
+                Mainloop.source_remove(this._repositionWindowsId);
+                this._repositionWindowsId = 0;
+            }
+
+            for (let i = 0; i < this._windows.length; i++) {
+                let clone = this._windows[i];
+                let overlay = this._windowOverlays[i];
+
+                if (overlay)
+                    overlay.hide();
+
+                let [origX, origY] = clone.getOriginalPosition();
+                clone.actor.scale_x = 0.5;
+                clone.actor.scale_y = 0.5;
+                clone.actor.x = origX;
+                clone.actor.y = origY;
+                //clone.actor.opacity = 255;
+                Tweener.addTween(clone.actor,
+                             { opacity: 0,
+                               time: 0.5,
+                               transition: 'easeOutQuad',
+                               onComplete: function() { clone.actor.opacity = 255; }});
+            }
+            log("workspace animateToOverview");
+            //this.actor.opacity = 255;
+            /*Tweener.addTween(this.actor,
+                             { opacity: 0,
+                               time: 0.5,
+                               transition: 'easeOutQuad'});*/
+        }
     },
 
     // Animates the return from Overview mode
@@ -1594,43 +1639,94 @@ const Workspace = new Lang.Class({
         if (this.metaWorkspace != null && this.metaWorkspace != currentWorkspace)
             return;
 
-        // Position and scale the windows.
-        for (let i = 0; i < this._windows.length; i++) {
-            let clone = this._windows[i];
-            let overlay = this._windowOverlays[i];
-
-            if (overlay)
-                overlay.hide();
-
-            if (clone.metaWindow.showing_on_its_workspace()) {
-                let [origX, origY] = clone.getOriginalPosition();
-
-                if (animationType == AnimationType.FADE_IN) {
-                    clone.actor.scale_x = 1;
-                    clone.actor.scale_y = 1;
-                    clone.actor.x = origX;
-                    clone.actor.y = origY;
-                    clone.actor.opacity = 0;
-                }
-                Tweener.addTween(clone.actor,
-                                 { x: origX,
-                                   y: origY,
-                                   scale_x: 1.0,
-                                   scale_y: 1.0,
-                                   time: Overview.ANIMATION_TIME,
-                                   opacity: 255,
-                                   transition: 'easeOutQuad'
-                                 });
+        if (animationType == AnimationType.ZOOM) {
+            // Position and scale the windows.
+            for (let i = 0; i < this._windows.length; i++)
+               this._animateWindowFromOverviewZoom(i);
+        } else if (animationType == AnimationType.FADE) {
+            let timeForEachWindow;
+            if (this._windows.length > WINDOW_ANIMATION_MAX_NUMBER_BLENDING) {
+                // Reserve one "slot" for the animation of the windows from
+                // WINDOW_ANIMATION_MAX_NUMBER_BLENDING to this._windows.length
+                timeForEachWindow = Overview.ANIMATION_TIME / ((WINDOW_ANIMATION_MAX_NUMBER_BLENDING + 1) * 
WINDOW_ANIMATION_BLENDING);
             } else {
-                // The window is hidden, make it shrink and fade it out
-                Tweener.addTween(clone.actor,
-                                 { scale_x: 0,
-                                   scale_y: 0,
-                                   opacity: 0,
-                                   time: Overview.ANIMATION_TIME,
-                                   transition: 'easeOutQuad'
-                                 });
+                timeForEachWindow = Overview.ANIMATION_TIME / 
(Math.min(WINDOW_ANIMATION_MAX_NUMBER_BLENDING, this._windows.length) * WINDOW_ANIMATION_BLENDING);
+            }
+            // Animate the most WINDOW_ANIMATION_MAX_NUMBER_BLENDING accesed windows hoping that those covers
+            // most of the screen so we can achieve a smooth transition.
+            for (let i = 0; i < Math.min(this._windows.length, WINDOW_ANIMATION_MAX_NUMBER_BLENDING); i++) {
+                // Reverse order of windows, so the most upper in the stack is animated first
+                let delay = i * (timeForEachWindow - timeForEachWindow * WINDOW_ANIMATION_BLENDING);
+                this._animateWindowFromOverviewFade(i, timeForEachWindow, delay);                
             }
+            // Animate the rest of the windows from WINDOW_ANIMATION_MAX_NUMBER_BLENDING to 
this._windows.length
+            // at the same time.
+            for (let i = WINDOW_ANIMATION_MAX_NUMBER_BLENDING; i < this._windows.length; i++) {
+                this._animateWindowFromOverviewFade(i, timeForEachWindow, (timeForEachWindow - 
timeForEachWindow * WINDOW_ANIMATION_BLENDING) * WINDOW_ANIMATION_MAX_NUMBER_BLENDING);
+            }
+        }
+    },
+
+    _animateWindowFromOverviewFade: function(index, time, delay) {
+        // Up in the stack first
+        let reverseStackWindow = this._windows.slice();
+        reverseStackWindow.reverse();
+        let reverseStackOverlays = this._windowOverlays.slice();
+        reverseStackOverlays.reverse();
+
+        let clone = reverseStackWindow[index];
+        let overlay = reverseStackOverlays[index];
+
+        if (overlay)
+            overlay.hide();
+
+        if (clone.metaWindow.showing_on_its_workspace()) {
+            let [origX, origY] = clone.getOriginalPosition();
+            clone.actor.scale_x = 1;
+            clone.actor.scale_y = 1;
+            clone.actor.x = origX;
+            clone.actor.y = origY;
+            clone.actor.opacity = 0;
+            Tweener.addTween(clone.actor,
+                             { time: time,
+                               opacity: 255,
+                               delay : delay,
+                               transition: 'easeOutQuad' });
+        } else {
+            // The window is hidden
+            clone.actor.scale_x = 0;
+            clone.actor.scale_y = 0;
+            clone.actor.opacity = 0;
+        }
+    },
+
+    _animateWindowFromOverviewZoom: function(index) {
+        let clone = this._windows[index];
+        let overlay = this._windowOverlays[index];
+
+        if (overlay)
+            overlay.hide();
+
+        if (clone.metaWindow.showing_on_its_workspace()) {
+            let [origX, origY] = clone.getOriginalPosition();
+            Tweener.addTween(clone.actor,
+                             { x: origX,
+                               y: origY,
+                               scale_x: 1.0,
+                               scale_y: 1.0,
+                               time: Overview.ANIMATION_TIME,
+                               opacity: 255,
+                               transition: 'easeOutQuad'
+                             });
+        } else {
+            // The window is hidden, make it shrink and fade it out
+            Tweener.addTween(clone.actor,
+                             { scale_x: 0,
+                               scale_y: 0,
+                               opacity: 0,
+                               time: Overview.ANIMATION_TIME,
+                               transition: 'easeOutQuad'
+                             });
         }
     },
 
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 98dc2e6..32aea43 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -142,9 +142,9 @@ const WorkspacesView = new Lang.Class({
         return this._workspaces[active];
     },
 
-    animateToOverview: function() {
+    animateToOverview: function(animationType) {
         for (let w = 0; w < this._workspaces.length; w++)
-            this._workspaces[w].animateToOverview();
+            this._workspaces[w].animateToOverview(animationType);
         this._updateWorkspaceActors(false);
     },
 
@@ -365,8 +365,8 @@ const ExtraWorkspaceView = new Lang.Class({
         this._workspace.setActualGeometry(this._actualGeometry);
     },
 
-    animateToOverview: function() {
-        this._workspace.animateToOverview();
+    animateToOverview: function(animationType) {
+        this._workspace.animateToOverview(animationType);
     },
 
     animateFromOverview: function(animationType) {
@@ -462,10 +462,11 @@ const WorkspacesDisplay = new Lang.Class({
         return this._getPrimaryView().actor.navigate_focus(from, direction, false);
     },
 
-    show: function() {
+    show: function(animationType) {
+        log("workspace view show " + animationType);
         this._updateWorkspacesViews();
         for (let i = 0; i < this._workspacesViews.length; i++)
-            this._workspacesViews[i].animateToOverview();
+            this._workspacesViews[i].animateToOverview(animationType);
 
         this._restackedNotifyId =
             Main.overview.connect('windows-restacked',


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