hi everyone;

in this short email I'm going to expose the changes in the timelines
that will be in the next stable branch of Clutter.

first of all, the ClutterTimeline class gained the new "duration"
property; it will hold the duration of the timeline in milliseconds at
the given frame rate of the timeline itself. the frame rate can be
controlled for each instance using the "fps" property; it is also
possible to set the default frame rate to be used by every newly created
instance using the clutter_set_default_frame_rate() function. the
default frame rate will affect the newly created timelines, not every
instance already created by the time the default frame rate is set:

  /* default: 60fps */
  t1 = clutter_timeline_new_for_duration (2000);

  /* slow hardware, set to 30 fps */
  clutter_set_default_frame_rate (30);
  t2 = clutter_timeline_new_for_duration (2000);
  /* t1 is not affected by this change, unless the fps
   * property is changed as well
   */

the default frame rate is usually set by the backend, but can be
controlled by any application or library depending on the speed of the
hardware[1] used.

it is also possible to retrieve the progress of the timeline in the [0,
1] interval using clutter_timeline_get_progress(). for instance, a
simple linear alpha function can be construed as:

  def linear_alpha (alpha, dummy):
      return int(alpha.get_timeline().get_progress() * clutter.MAX_ALPHA)

another feature is the ability to set the direction of a timeline:
forward (from the first frame to the last) or backward (from the last
frame to the first); for instance, this code snippet will make a
timeline loop and switch direction back and forward at each ::completed
signal:

  t1 = clutter_timeline_new_for_duration (500);
  clutter_timeline_set_loop (t1, TRUE);
  g_signal_connect (timeline, "completed", G_CALLBACK (timeline_completed), 
NULL);

  static void
  timeline_completed (ClutterTimeline *timeline)
  {
    ClutterTimelineDirection direction;

    direction = clutter_timeline_get_direction (timeline);
    switch (direction)
      {
      case CLUTTER_TIMELINE_FORWARD:
        clutter_timeline_set_direction (timeline, CLUTTER_TIMELINE_BACKWARD);
        break;

      case CLUTTER_TIMELINE_BACKWARD:
        clutter_timeline_set_direction (timeline, CLUTTER_TIMELINE_FORWARD);
        break;
      }
  }

another API addition is the ability to know how many frames and
milliseconds elapsed since the last ::new-frame signal, using the
clutter_timeline_get_delta() function.

a new class has been added: it is called ClutterScore and it can be used
to manage multiple timelines. a score can start multiple timelines at
the same time:

  /* start t1, t2, t3 and t4 when clutter_score_start() is called */
  clutter_score_add (score, NULL, t1);
  clutter_score_add (score, NULL, t2);
  clutter_score_add (score, NULL, t3);
  clutter_score_add (score, NULL, t4);

or when another timeline terminates:

  /* start t1 and t2, and then start t3 and t4 when t2 terminates */
  clutter_score_add (score, NULL, t1);
  clutter_score_add (score, NULL, t2);
  clutter_score_add (score, t2, t3);
  clutter_score_add (score, t2, t4);

each ClutterScore will hold a reference on the timelines it controls, so
you can unref them after they have been added. you can retrieve and
remove the timelines from a ClutterScore using the unique id returned by
clutter_score_add().

ciao,
 Emmanuele.

+++

[1] the default frame rate also controls the default frequency of
delivery of motion events to the actor, acting as the upper bound of
this setting.

-- 
Emmanuele Bassi, OpenedHand Ltd.
Unit R, Homesdale Business Centre
216-218 Homesdale Rd., Bromley - BR12QZ
http://www.o-hand.com

-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to