[gnome-shell/wip/gdm-shell] wip: more animation fix ups



commit 6f7f9e58269ed7f9318b5a44af3b8a61429bac5d
Author: Ray Strode <rstrode redhat com>
Date:   Fri Jul 1 18:54:54 2011 -0400

    wip: more animation fix ups

 js/ui/loginDialog.js |  145 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 97 insertions(+), 48 deletions(-)
---
diff --git a/js/ui/loginDialog.js b/js/ui/loginDialog.js
index 55b8a3b..42e33ad 100644
--- a/js/ui/loginDialog.js
+++ b/js/ui/loginDialog.js
@@ -91,6 +91,31 @@ function _fadeOutActor(actor) {
     return hold;
 }
 
+function _freezeActorSize(actor, width, height) {
+    actor.set_size(actor.width, actor.height);
+}
+
+function _thawActorSize(actor) {
+    let oldWidth = actor.width;
+    let oldHeight = actor.height;
+    actor.set_size(-1, -1);
+    let [minHeight, naturalHeight] = actor.get_preferred_height(-1);
+    actor.set_size(oldWidth, oldHeight);
+
+    let hold = new Batch.Hold();
+
+    Tweener.addTween(actor,
+                     { height: naturalHeight,
+                       time: _ANIMATION_TIME,
+                       transition: 'easeOutQuad',
+                       onComplete: Lang.bind(this, function() {
+                                       actor.set_size(-1, -1);
+                                       hold.release();
+                                   })
+                     });
+    return hold;
+}
+
 function ListItem(user, reason) {
     this._init(user, reason);
 }
@@ -177,8 +202,15 @@ ListItem.prototype = {
 
     _onClicked: function() {
         this.emit('activate');
-    }
+    },
+
+    fadeOutName: function() {
+        return _fadeOutActor(this._nameLabel);
+    },
 
+    fadeInName: function() {
+        return _fadeInActor(this._nameLabel);
+    }
 };
 Signals.addSignalMethods(ListItem.prototype);
 
@@ -205,7 +237,7 @@ UserList.prototype = {
 
     _showItem: function(item) {
         let tasks = [Lang.bind(this, function() {
-                         return _fadeInActor(item._nameLabel)
+                         return item.fadeInName();
                      }),
 
                      Lang.bind(this, function() {
@@ -220,11 +252,33 @@ UserList.prototype = {
         this.emit('activate', activatedItem);
     },
 
+    giveUpWhitespace: function() {
+        let container = this.actor.get_parent();
+
+        container.child_set(this.actor, { expand: false });
+    },
+
+    takeOverWhitespace: function() {
+        let container = this.actor.get_parent();
+
+        container.child_set(this.actor, { expand: true });
+    },
+
+    freezeSize: function() {
+        return _freezeActorSize(this._layout);
+    },
+
+    thawSize: function() {
+        return _thawActorSize(this._layout);
+    },
+
     shrinkToItem: function(activatedItem) {
-        this.actor.set_policy(Gtk.PolicyType.NEVER,
-                              Gtk.PolicyType.NEVER);
         let tasks = [];
 
+        tasks.push(Lang.bind(this, function() {
+            return _fadeOutActor(this.actor.vscroll);
+        }));
+
         for (userName in this._items) {
             let item = this._items[userName];
             if (item != activatedItem) {
@@ -234,21 +288,17 @@ UserList.prototype = {
             }
         }
 
-        let batch = new Batch.ConsecutiveBatch([new Batch.ConcurrentBatch(tasks),
-
-                                                Lang.bind(this, function() {
-                                                    _fadeOutActor(activatedItem._nameLabel);
-                                                })
-                                                ]);
+        let batch = new Batch.ConcurrentBatch(tasks);
         return batch.run();
     },
 
     hideAllItems: function() {
-        this.actor.set_policy(Gtk.PolicyType.NEVER,
-                              Gtk.PolicyType.NEVER);
-
         let tasks = [];
 
+        tasks.push(Lang.bind(this, function() {
+            return _fadeOutActor(this.actor.vscroll);
+        }));
+
         for (userName in this._items) {
             let item = this._items[userName];
             tasks.push(Lang.bind(this, function() {
@@ -270,11 +320,16 @@ UserList.prototype = {
             }));
         }
 
-        let batch = new Batch.ConsecutiveBatch([new Batch.ConcurrentBatch(tasks),
+        let batch = new Batch.ConsecutiveBatch([Lang.bind(this, function() {
+                                                    this.takeOverWhitespace();
+                                                }),
+
+                                                new Batch.ConcurrentBatch(tasks),
+
                                                 Lang.bind(this, function() {
-                                                    this.actor.set_policy(Gtk.PolicyType.NEVER,
-                                                                          Gtk.PolicyType.AUTOMATIC);
-                                                })]);
+                                                    return _fadeInActor(this.actor.vscroll);
+                                                })
+                                               ]);
         batch.run();
     },
 
@@ -377,12 +432,14 @@ LoginDialog.prototype = {
 
         let mainContentLayout = new St.BoxLayout({ vertical: false });
         this.contentLayout.add(mainContentLayout,
-                               { x_fill: true,
+                               { expand: true,
+                                 x_fill: true,
                                  y_fill: false });
 
         this._userList = new UserList();
         mainContentLayout.add(this._userList.actor,
-                              { x_fill: true,
+                              { expand: true,
+                                x_fill: true,
                                 y_fill: true });
 
         this._promptLayout = new St.BoxLayout({ style_class: 'login-dialog-prompt-layout',
@@ -583,7 +640,7 @@ LoginDialog.prototype = {
 
     _onNotListedClicked: function(user) {
         let tasks = [Lang.bind(this, function() {
-                         this._freezeSize();
+                         _freezeActorSize(this.contentLayout);
                      }),
 
                      new Batch.ConcurrentBatch([Lang.bind(this, this._fadeOutTitleLabel),
@@ -594,7 +651,7 @@ LoginDialog.prototype = {
                      }),
 
                      Lang.bind(this, function() {
-                         return this._thawSize();
+                         return this._thawSize(this.contentLayout);
                      }),
 
                      Lang.bind(this, function() {
@@ -621,34 +678,14 @@ LoginDialog.prototype = {
         return _fadeOutActor(this._notListedButton);
     },
 
-    _freezeSize: function() {
-        let [width, height] = this.contentLayout.get_transformed_size();
-        this.contentLayout.set_size(width, height);
-    },
-
-    _thawSize: function() {
-        let [oldWidth, oldHeight] = this.contentLayout.get_transformed_size();
-        this.contentLayout.set_size(-1, -1);
-        let [minHeight, naturalHeight] = this.contentLayout.get_preferred_height(-1);
-        this.contentLayout.set_size(oldWidth, oldHeight);
-
-        let hold = new Batch.Hold();
-
-        Tweener.addTween(this.contentLayout,
-                         { height: naturalHeight,
-                           time: _ANIMATION_TIME,
-                           transition: 'easeOutQuad',
-                           onComplete: Lang.bind(this, function() {
-                                           this.contentLayout.set_size(-1, -1);
-                                           hold.release();
-                                       })
-                         });
-        return hold;
-    },
-
     _onUserListActivated: function(item) {
+
         let tasks = [Lang.bind(this, function() {
-                         this._freezeSize();
+                         _freezeActorSize(this.contentLayout);
+                     }),
+
+                     Lang.bind(this, function() {
+                         return this._userList.freezeSize();
                      }),
 
                      new Batch.ConcurrentBatch([Lang.bind(this, this._fadeOutTitleLabel),
@@ -659,7 +696,19 @@ LoginDialog.prototype = {
                      }),
 
                      Lang.bind(this, function() {
-                         return this._thawSize();
+                         return _thawActorSize(this.contentLayout);
+                     }),
+
+                     Lang.bind(this, function() {
+                         return this._userList.giveUpWhitespace();
+                     }),
+
+                     Lang.bind(this, function() {
+                         return this._userList.thawSize();
+                     }),
+
+                     Lang.bind(this, function() {
+                         return item.fadeOutName();
                      }),
 
                      Lang.bind(this, function() {



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