On Wed, 2009-05-13 at 21:47 +0100, Glen Gray wrote:

> I've been spending what spare time I have looking at clutter and  
> attempting to port the astro-desktop toy to the newer API.

thanks!

> One of the issues is the replacement of ClutterEffectTemplate. Some of  
> the astro widgets have show/hide and move animations for user events.  
> In replacing these, I've changed the code to use ClutterAnimations.  
> I'd like some clarification if the follow approach is correct for the  
> new API.

as a rule of thumb, you should not be using the animation API like the
old effects API. also, astro-desktop slightly abused the 0.6 API at the
time... :-)

just to classify the bits of the animation framework exposed by Clutter:

  - ClutterBehaviour: the behaviours are useful if you want to
    repeat the same animation regardless of the initial state - that
    is if you already know the initial and final state, and you know
    that those states will be the same regardless of the current state
    of the actor(s) you want to animate.

  - Implicit animations: the clutter_actor_animate* family of functions
    are useful if you want to animate a single actor from its current
    state to a new state -- with the final state mostly depending on
    the initial state.

> static void
> astro_appview_show (ClutterActor *view)
> {
>    AstroAppviewPrivate *priv;
>    static ClutterTimeline *show_time = NULL;
> 
>    g_return_if_fail (ASTRO_IS_APPVIEW (view));
>    priv = ASTRO_APPVIEW (view)->priv;
>    if (CLUTTER_IS_ANIMATION (priv->show_temp))
>      show_time = clutter_animation_get_timeline (priv->show_temp);
> 
>    if (CLUTTER_IS_TIMELINE (show_time) &&clutter_timeline_is_playing  
> (show_time))
>      {
>        //clutter_timeline_stop (show_time);
>        //g_object_unref (show_time);
>        clutter_animation_completed (priv->show_temp);
>      }

I would maintain a flag instead of checking whether the Timeline is
playing; but this is fine. also, if an actor is being animated using any
of the clutter_actor_animate* functions you can get the Animation by
using:

  animation = clutter_actor_get_animation (actor);

if the actor is not being currently animated then this function will
return NULL.

>    clutter_actor_set_x (view, -1* clutter_actor_get_width (view));
>    CLUTTER_ACTOR_CLASS (astro_appview_parent_class)->show (view);
> 
>    gint xval = (int)(CSW()/2) - (priv->active*ASTRO_APPICON_SPACING());

please, replace those CSW macros with a propert
clutter_actor_get_width() on the stage -- use clutter_actor_get_stage()
to retrieve the stage to which an actor belongs.

>    priv->show_temp = clutter_actor_animate (CLUTTER_ACTOR (view),
>                        CLUTTER_LINEAR,
>                        600,
>                        "x", xval,
>                        "y", clutter_actor_get_y (CLUTTER_ACTOR (view)),
>                        "signal::new-frame",  
> on_move_timeline_new_frame, view,
>                        NULL);

signal::new-frame does not exist. the "signal::" special modifier only
works for signals of the Animation object, not of the Timeline that the
Animation uses.

>    if (CLUTTER_IS_ANIMATION (priv->show_temp)) {
>      show_time = clutter_animation_get_timeline (priv->show_temp);
>      g_signal_connect (show_time, "new-frame",
>                        G_CALLBACK (on_move_timeline_new_frame), view);
>    }
> }

there is not much point use the ::new-frame signal to animate something
else. if you need to do that then you're probably much better off using
a Behaviour in the first place -- because it means the animation you are
writing is not of the "fire and forget" type.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi, Senior Engineer        | [email protected]
Intel Open Source Technology Center     | http://oss.intel.com

-- 
To unsubscribe send a mail to [email protected]

Reply via email to