[gnome-shell] modalDialog: fade in buttons when first showing them



commit e8914c6699d97079ac3448608e16fdfffc4a09c1
Author: Ray Strode <rstrode redhat com>
Date:   Sat Aug 27 22:51:54 2011 -0400

    modalDialog: fade in buttons when first showing them
    
    Right now, if buttons get set on a dialog after it is mapped,
    they just pop in instantly.
    
    We shouldn't have any harsh transitions like that, though.
    
    This commit changes the buttons to quickly fade in, instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=657082

 js/ui/modalDialog.js |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index 3674360..effc5be 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -18,6 +18,7 @@ const Main = imports.ui.main;
 const Tweener = imports.ui.tweener;
 
 const OPEN_AND_CLOSE_TIME = 0.1;
+const FADE_IN_BUTTONS_TIME = 0.33;
 const FADE_OUT_DIALOG_TIME = 1.0;
 
 const State = {
@@ -98,6 +99,8 @@ ModalDialog.prototype = {
     },
 
     setButtons: function(buttons) {
+        let hadChildren = this._buttonLayout.get_children() > 0;
+
         this._buttonLayout.destroy_children();
         this._actionKeys = {};
 
@@ -137,6 +140,22 @@ ModalDialog.prototype = {
                 this._actionKeys[key] = action;
             i++;
         }
+
+        // Fade in buttons if there weren't any before
+        if (!hadChildren && i > 0) {
+            this._buttonLayout.opacity = 0;
+            Tweener.addTween(this._buttonLayout,
+                             { opacity: 255,
+                               time: FADE_IN_BUTTONS_TIME,
+                               transition: 'easeOutQuad',
+                               onComplete: Lang.bind(this, function() {
+                                   this.emit('buttons-set');
+                               })
+                             });
+        } else {
+            this.emit('buttons-set');
+        }
+
     },
 
     _onKeyPressEvent: function(object, keyPressEvent) {



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