[ease] [transitions] Add "assemble" transition.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [transitions] Add "assemble" transition.
- Date: Mon, 26 Jul 2010 06:54:15 +0000 (UTC)
commit 219bd6035b0116725c0aa64601d78ba3cdba6ea8
Author: Nate Stedman <natesm gmail com>
Date: Mon Jul 26 02:53:39 2010 -0400
[transitions] Add "assemble" transition.
src/ease-slide-actor.vala | 100 +++++++++++++++++++++++++++++++++++++++++----
src/ease-transitions.vala | 7 +++
2 files changed, 99 insertions(+), 8 deletions(-)
---
diff --git a/src/ease-slide-actor.vala b/src/ease-slide-actor.vala
index 35d8685..27692b2 100644
--- a/src/ease-slide-actor.vala
+++ b/src/ease-slide-actor.vala
@@ -125,6 +125,11 @@ public class Ease.SlideActor : Clutter.Group
private const int EXPLODE_PARTICLES = 10;
/**
+ *
+ */
+ private const int ASSEMBLE_TILES = 12;
+
+ /**
* Emitted when a subactor of this SlideActor is removed.
*/
public signal void ease_actor_removed(Actor actor);
@@ -510,6 +515,10 @@ public class Ease.SlideActor : Clutter.Group
explode_transition(new_slide, container, length);
break;
+ case Transition.ASSEMBLE:
+ assemble_transition(new_slide, container, length);
+ break;
+
default: // FADE, or something undefined
fade_transition(new_slide, container, length);
break;
@@ -1434,20 +1443,95 @@ public class Ease.SlideActor : Clutter.Group
particles[i].show();
}
}
+
+ // cleanup
+ animation_time.completed.connect(() => {
+ for (int j = 0; j < count; j++)
+ {
+ container.remove_actor(particles[j]);
+ }
+ });
+ }
+
+ /**
+ * Starts an "Assemble" transition
+ *
+ * @param new_slide The new SlideActor.
+ * @param container The container that holds the displayed SlideActors.
+ * @param length The length of the transition, in milliseconds.
+ */
+ private void assemble_transition(SlideActor new_slide,
+ Clutter.Group container,
+ uint length)
+ {
+ // hide the real new SlideActor
+ new_slide.reparent(container);
+ new_slide.x = slide.parent.width;
- // make an alpha for easing
- animation_alpha = new Clutter.Alpha.full(animation_time,
- Clutter.AnimationMode.EASE_IN_OUT_BACK);
+ // make an array for the particles
+ var v_count = (int)Math.ceil(1 / slide.parent.aspect * ASSEMBLE_TILES);
+ var count = ASSEMBLE_TILES * v_count;
+ var particles = new Clutter.Clone[count];
+
+ // calculate the size of each particle
+ var size = (float)slide.parent.width / ASSEMBLE_TILES;
- // animate
- animation_time.new_frame.connect((m) => {
- });
+ // create the particles
+ int i;
+ for (int vpos = 0; vpos < v_count; vpos++)
+ {
+ for (int hpos = 0; hpos < ASSEMBLE_TILES; hpos++)
+ {
+ // make a new particle
+ i = vpos * ASSEMBLE_TILES + hpos;
+ particles[i] = new Clutter.Clone(new_slide);
+
+ // clip the particle
+ particles[i].set_clip(hpos * size, vpos * size,
+ size + 1, size + 1);
+
+ // randomly move the particle off of the screen
+ var anim_x = false;
+ switch (Random.int_range(0, 4))
+ {
+ case 0:
+ particles[i].x = -(hpos + 1) * size;
+ anim_x = true;
+ break;
+ case 1:
+ particles[i].y = -(vpos + 1) * size;
+ break;
+ case 2:
+ particles[i].x = (ASSEMBLE_TILES - hpos + 1) * size;
+ anim_x = true;
+ break;
+ case 3:
+ particles[i].y = (v_count - vpos + 1) * size;
+ break;
+ }
+
+ /*var time = (uint)(50 + Random.next_double() * (length - 50));
+ var timer = new Clutter.Timeline(time);
+ timer.completed.connect(() => {*/
+ particles[i].animate(Clutter.AnimationMode.EASE_OUT_SINE,
+ length, anim_x ? "x" : "y", 0);
+ //});
+ //timer.start();
+ container.add_actor(particles[i]);
+ particles[i].show();
+ }
+ }
+ // cleanup
animation_time.completed.connect(() => {
+ new_slide.x = 0;
for (int j = 0; j < count; j++)
{
- container.remove_actor(particles[j]);
- }
+ if (particles[j].get_parent() == container)
+ {
+ container.remove_actor(particles[j]);
+ }
+ }
});
}
diff --git a/src/ease-transitions.vala b/src/ease-transitions.vala
index bbb9a2a..30d4369 100644
--- a/src/ease-transitions.vala
+++ b/src/ease-transitions.vala
@@ -32,6 +32,7 @@ public enum Ease.Transition
SLATS,
OPEN_DOOR,
EXPLODE,
+ ASSEMBLE,
ZOOM,
PANEL,
SPIN_CONTENTS,
@@ -53,6 +54,7 @@ public enum Ease.Transition
SLATS,
OPEN_DOOR,
EXPLODE,
+ ASSEMBLE,
ZOOM,
PANEL,
SPIN_CONTENTS,
@@ -116,6 +118,8 @@ public enum Ease.Transition
return OPEN_DOOR;
case "EASE_TRANSITION_EXPLODE":
return EXPLODE;
+ case "EASE_TRANSITION_ASSEMBLE":
+ return ASSEMBLE;
case "EASE_TRANSITION_ZOOM":
return ZOOM;
case "EASE_TRANSITION_PANEL":
@@ -147,6 +151,7 @@ public enum Ease.Transition
case SLATS:
case OPEN_DOOR:
case EXPLODE:
+ case ASSEMBLE:
case SWING_CONTENTS:
return {};
@@ -226,6 +231,8 @@ public enum Ease.Transition
return _("Open Door");
case EXPLODE:
return _("Explode");
+ case ASSEMBLE:
+ return _("Assemble");
case ZOOM:
return _("Zoom");
case PANEL:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]