[gnome-shell/wip/gdm-shell] wip: more animation tweaks (needs squash)



commit f4730de2c9a844682ed7834cf6cdab8ee525a34e
Author: Ray Strode <rstrode redhat com>
Date:   Thu Jun 30 17:55:54 2011 -0400

    wip: more animation tweaks (needs squash)

 js/ui/loginDialog.js |  178 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 128 insertions(+), 50 deletions(-)
---
diff --git a/js/ui/loginDialog.js b/js/ui/loginDialog.js
index 4b40c04..6f69759 100644
--- a/js/ui/loginDialog.js
+++ b/js/ui/loginDialog.js
@@ -45,7 +45,7 @@ const ModalDialog = imports.ui.modalDialog;
 const Tweener = imports.ui.tweener;
 
 const _DIALOG_ICON_SIZE = 64;
-const _ANIMATION_TIME = 0.16;
+const _ANIMATION_TIME = 0.25;
 
 let _loginDialog = null;
 
@@ -53,7 +53,7 @@ function _fadeInActor(actor) {
     let hold = new Batch.Hold();
 
     if (actor.opacity == 255 && actor.visible)
-      return;
+      return null;
 
     actor.opacity = 0;
     actor.show();
@@ -73,14 +73,17 @@ function _fadeOutActor(actor) {
     let hold = new Batch.Hold();
 
     if (actor.opacity == 0 || !actor.visible)
-      return;
+      return null;
+
 
     Tweener.addTween(actor,
                      { opacity: 0,
+                       height: 0,
                        time: _ANIMATION_TIME,
                        transition: 'easeOutQuad',
                        onComplete: function() {
                            actor.hide();
+                           actor.set_height(-1);
                            hold.release();
                        },
                        onCompleteScope: this
@@ -202,25 +205,17 @@ UserList.prototype = {
 
     _showItem: function(item) {
         let tasks = [Lang.bind(this, function() {
-                         _fadeInActor(item._nameLabel)
+                         return _fadeInActor(item._nameLabel)
                      }),
 
                      Lang.bind(this, function() {
-                         _fadeInActor(item.actor);
+                         return _fadeInActor(item.actor);
                      })];
 
         let batch = new Batch.ConcurrentBatch(tasks);
         return batch.run();
     },
 
-    _shrinkItem: function(item) {
-        return _fadeOutActor(item._nameLabel);
-    },
-
-    _growItem: function(item) {
-        item._nameLabel.show();
-    },
-
     _onItemActivated: function(activatedItem) {
         this.emit('activate', activatedItem);
     },
@@ -234,16 +229,17 @@ UserList.prototype = {
             let item = this._items[userName];
             if (item != activatedItem) {
                 tasks.push(Lang.bind(this, function() {
-                    _fadeOutActor(item.actor);
-                }));
-            } else {
-                tasks.push(Lang.bind(this, function() {
-                    this._shrinkItem(item);
+                    return _fadeOutActor(item.actor);
                 }));
             }
         }
 
-        let batch = new Batch.ConcurrentBatch(tasks);
+        let batch = new Batch.ConsecutiveBatch([new Batch.ConcurrentBatch(tasks),
+
+                                                Lang.bind(this, function() {
+                                                    _fadeOutActor(activatedItem._nameLabel);
+                                                })
+                                                ]);
         return batch.run();
     },
 
@@ -251,10 +247,17 @@ UserList.prototype = {
         this.actor.set_policy(Gtk.PolicyType.NEVER,
                               Gtk.PolicyType.NEVER);
 
+        let tasks = [];
+
         for (userName in this._items) {
             let item = this._items[userName];
-            this._hideItem(item);
+            tasks.push(Lang.bind(this, function() {
+                return _fadeOutActor(item.actor);
+            }));
         }
+
+        let batch = new Batch.ConcurrentBatch(tasks);
+        return batch.run();
     },
 
     showAllItems: function() {
@@ -263,7 +266,7 @@ UserList.prototype = {
         for (userName in this._items) {
             let item = this._items[userName];
             tasks.push(Lang.bind(this, function() {
-                this._showItem(item);
+                return this._showItem(item);
             }));
         }
 
@@ -332,7 +335,6 @@ LoginDialog.prototype = {
     _init: function() {
         Dialog.Dialog.prototype._init.call(this, { lowerBelowChrome: true,
                                                    styleClass: 'login-dialog' });
-
         this.connect('destroy',
                      Lang.bind(this, this._onDestroy));
         this.connect('opened',
@@ -484,48 +486,74 @@ LoginDialog.prototype = {
         this._greeterClient.call_answer_query(serviceName, _text);
     },
 
-    _showPrompt: function(callback) {
+    _fadeInPrompt: function() {
+        this._promptLayout.show();
+
+        let tasks = [Lang.bind(this, function() {
+                         return _fadeInActor(this._promptLabel);
+                     }),
+
+                     Lang.bind(this, function() {
+                         return _fadeInActor(this._promptEntry);
+                     }),
+
+                     Lang.bind(this, function() {
+                         this._promptEntry.grab_key_focus();
+                     })];
+
+        let batch = new Batch.ConcurrentBatch(tasks);
+        return batch.run();
+    },
+
+    _showPrompt: function() {
+        let hold = new Batch.Hold();
+
         let buttons = [{ action: Lang.bind(this, this._onCancel),
                          label:  _("Cancel"),
                          key:    Clutter.Escape },
-                       { action: callback,
+                       { action: Lang.bind(this, function() {
+                                     hold.release();
+                                 }),
                          label:  _("Sign In") }];
 
-        if (!this._promptLayout.visible) {
-            this._promptLayout.show();
-            this._promptLabel.show();
-            this._promptEntry.show();
-            this._promptEntry.grab_key_focus();
-        }
-
         this._promptEntryActivateCallbackId = this._promptEntry.clutter_text.connect('activate',
                                                               Lang.bind(this, function() {
-                                                                  callback();
-                                                                  this._promptEntry.clutter_text.disconnect(this._promptEntryActivateCallbackId);
-                                                                  this._promptEntryActivateCallbackId = null;
+                                                                  hold.release();
                                                               }));
+        hold.connect('release', Lang.bind(this, function() {
+                         this._promptEntry.clutter_text.disconnect(this._promptEntryActivateCallbackId);
+                         this._promptEntryActivateCallbackId = null;
+                     }));
 
         this.setButtons(buttons);
+
+        return this._fadeInPrompt();
     },
 
+    _askQuestion: function(serviceName, question) {
+        this._promptLabel.set_text(question);
+
+        let tasks = [Lang.bind(this, function() {
+                         return this._showPrompt();
+                     }),
+
+                     Lang.bind(this, function() {
+                         this._onSignIn(serviceName);
+                     })];
+
+        let batch = new Batch.ConsecutiveBatch(tasks);
+        return batch.run();
+    },
     _onInfoQuery: function(client, serviceName, question) {
         this._promptEntry.set_text('');
         this._promptEntry.clutter_text.set_password_char('');
-        this._promptLabel.set_text(question);
-        this._showPrompt(Lang.bind(this, function() {
-                             this._onSignIn(serviceName);
-                         }));
-
+        this._askQuestion(serviceName, question);
     },
 
     _onSecretInfoQuery: function(client, serviceName, secretQuestion) {
         this._promptEntry.set_text('');
         this._promptEntry.clutter_text.set_password_char('\u25cf');
-        this._promptLabel.set_text(secretQuestion);
-
-        this._showPrompt(Lang.bind(this, function() {
-                             this._onSignIn(serviceName);
-                         }));
+        this._askQuestion(serviceName, secretQuestion);
     },
 
     _onSessionOpened: function(client, serviceName) {
@@ -544,10 +572,27 @@ LoginDialog.prototype = {
     },
 
     _onNotListedClicked: function(user) {
-        this._titleLabel.hide();
-        this._notListedButton.hide();
-        this._userList.hideAllItems();
-        this._greeterClient.call_begin_verification('gdm-password');
+        let tasks = [Lang.bind(this, function() {
+                         this._freezeSize();
+                     }),
+
+                     new Batch.ConcurrentBatch([Lang.bind(this, this._fadeOutTitleLabel),
+                                                Lang.bind(this, this._fadeOutNotListedButton)]),
+
+                     Lang.bind(this, function() {
+                         return this._userList.hideAllItems();
+                     }),
+
+                     Lang.bind(this, function() {
+                         return this._thawSize();
+                     }),
+
+                     Lang.bind(this, function() {
+                         this._greeterClient.call_begin_verification('gdm-password');
+                     })];
+
+        let batch = new Batch.ConsecutiveBatch(tasks);
+        batch.run();
     },
 
     _fadeInTitleLabel: function() {
@@ -566,12 +611,45 @@ 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 = [new Batch.ConcurrentBatch([Lang.bind(this, this._fadeOutTitleLabel),
+        let tasks = [Lang.bind(this, function() {
+                         this._freezeSize();
+                     }),
+
+                     new Batch.ConcurrentBatch([Lang.bind(this, this._fadeOutTitleLabel),
                                                 Lang.bind(this, this._fadeOutNotListedButton)]),
 
                      Lang.bind(this, function() {
-                         this._userList.shrinkToItem(item);
+                         return this._userList.shrinkToItem(item);
+                     }),
+
+                     Lang.bind(this, function() {
+                         return this._thawSize();
                      }),
 
                      Lang.bind(this, function() {



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