[gnome-boxes] util: Use explicit transition for fading actors



commit c142c3a6f20b4932003d713c4cbe6c917106a2e7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue May 14 18:02:46 2013 +0300

    util: Use explicit transition for fading actors
    
    As strongly suggested by ebassi on IRC:
    
    <ebassi> [19:34:50] zeenix: and I would *strongly* suggest you use a
    proper ClutterTransition in this case, instead of relying on implicit
    animations, since you're controlling the start and end states, and you
    want to get notifications
    
    Besides being the right thing to do here, this also works around the issue of
    Boxes unable to change the actor visibility at the end of transition and
    avoid the warning on console about transition being null against clutter
    1.16 in certain cases.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700306

 src/util-app.vala |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/util-app.vala b/src/util-app.vala
index 94a5c86..0370b0c 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -109,20 +109,27 @@ namespace Boxes {
         actor.set_easing_duration (old_duration);
     }
 
+    private uint transition_index = 0;
+
     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 ( () => {
+
+        var transition = new Clutter.PropertyTransition ("opacity");
+        var value = GLib.Value (typeof (uint));
+        value.set_uint (opacity);
+        transition.set_to_value (value);
+        transition.set_duration (App.app.duration);
+        transition.set_progress_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
+        var name = "opacity%u".printf (transition_index++);
+        transition.completed.connect (() => {
+            actor.remove_transition (name);
             actor.visible = actor.opacity != 0;
         });
-        actor.restore_easing_state ();
+        actor.add_transition (name, transition);
     }
 
     public delegate void ActorFunc (Clutter.Actor actor);


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