[gnome-boxes] Add Util.fade_actor helper



commit 00cf37c6779decbff4eae043f3961fb9c233c78a
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Jun 1 15:30:04 2012 +0200

    Add Util.fade_actor helper
    
    This makes it easy to fade in/out actors, taking care to correctly
    hide the actor when completely invibile and making it non-reactive
    while fading.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677274

 src/util.vala |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/util.vala b/src/util.vala
index dacbd3d..c6b630d 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -234,6 +234,22 @@ namespace Boxes {
         return tryname;
     }
 
+    public void fade_actor (Clutter.Actor actor, uint opacity) {
+        if (opacity != 0)
+            actor.show ();
+        // Don't react to use input while fading out
+        actor.set_reactive (opacity == 255);
+        actor.save_easing_state ();
+        actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
+        actor.set_easing_duration (App.app.duration);
+        actor.opacity = opacity;
+        var t = actor.get_transition ("opacity");
+        t.completed.connect ( () => {
+            actor.visible = actor.opacity != 0;
+        });
+        actor.restore_easing_state ();
+    }
+
     public void actor_add (Clutter.Actor actor, Clutter.Container container) {
         if (actor.get_parent () == (Clutter.Actor) container)
             return;



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