[gnome-shell/wip/re-search: 34/48] dash: Add show/hide methods



commit 018f906daa5f9bf34b2eac35ff75f8adb996ebd1
Author: Tanner Doshier <doshitan gmail com>
Date:   Thu Aug 16 19:59:07 2012 -0500

    dash: Add show/hide methods
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682050

 js/ui/dash.js |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/dash.js b/js/ui/dash.js
index 65705c6..e681cc5 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -372,6 +372,9 @@ const Dash = new Lang.Class({
         this._maxHeight = -1;
         this.iconSize = 64;
         this._shownInitially = false;
+        this.visible = false;
+        this._hiddenX;
+        this._targetX;
 
         this._dragPlaceholder = null;
         this._dragPlaceholderPos = -1;
@@ -545,6 +548,17 @@ const Dash = new Lang.Class({
         }
     },
 
+    _computeDashX: function() {
+        this._targetX = this.actor.get_x();
+
+        let rtl = (this.actor.get_text_direction() == Clutter.TextDirection.RTL);
+
+        if (rtl)
+            this._hiddenX = this._targetX + this.actor.width;
+        else
+            this._hiddenX = -this.actor.width;
+    },
+
     _adjustIconSize: function() {
         // For the icon size, we only consider children which are "proper"
         // icons (i.e. ignoring drag placeholders) and which are not
@@ -640,6 +654,8 @@ const Dash = new Lang.Class({
                                }
                              });
         }
+
+        this._computeDashX();
     },
 
     _redisplay: function () {
@@ -756,6 +772,7 @@ const Dash = new Lang.Class({
         // of items, to avoid all items zooming in at once
         if (!this._shownInitially) {
             this._shownInitially = true;
+            this.visible = true;
             return;
         }
 
@@ -900,6 +917,34 @@ const Dash = new Lang.Class({
             }));
 
         return true;
+    },
+
+    show: function() {
+        if (this.visible)
+            return;
+
+        this.visible = true;
+
+        this.actor.show();
+        Tweener.addTween(this.actor, { translation_x: this._targetX,
+                                       transition: 'easeOutQuad',
+                                       time: DASH_ANIMATION_TIME
+                                     });
+    },
+
+    hide: function() {
+        if (!this.visible)
+            return;
+
+        this.visible = false;
+
+        Tweener.addTween(this.actor, { translation_x: this._hiddenX,
+                                       transition: 'easeOutQuad',
+                                       time: DASH_ANIMATION_TIME,
+                                       onComplete: Lang.bind(this, function () {
+                                                       this.actor.hide();
+                                                   })
+                                     });
     }
 });
 



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