actor: Add delay to the easing state
authorEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 15 Mar 2012 12:24:02 +0000 (12:24 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 15 Mar 2012 17:01:13 +0000 (17:01 +0000)
It should be possible to set up the delay of a transition, but since
we start the Transition instance before returning control to the caller,
we cannot use clutter_actor_get_transition() to do it without something
extra-awkward, like:

  transition = clutter_actor_get_transition (actor, "width");
  clutter_timeline_stop (transition);
  clutter_timeline_set_delay (transition, 1000);
  clutter_timeline_start (transition);

for each property involved. It's much easier to add a delay to the
easing state of an actor.

clutter/clutter-actor-private.h
clutter/clutter-actor.c
clutter/clutter-actor.h
clutter/clutter.symbols
doc/reference/clutter/clutter-sections.txt

index 32da6e0..2ef6aaa 100644 (file)
@@ -213,6 +213,7 @@ ClutterTransformInfo *          _clutter_actor_get_transform_info
 
 typedef struct _AState {
   guint easing_duration;
+  guint easing_delay;
   ClutterAnimationMode easing_mode;
 } AState;
 
index 19761cc..753def0 100644 (file)
@@ -16764,6 +16764,8 @@ _clutter_actor_create_transition (ClutterActor *actor,
       clutter_transition_set_interval (res, interval);
       clutter_transition_set_remove_on_complete (res, TRUE);
 
+      clutter_timeline_set_delay (CLUTTER_TIMELINE (res),
+                                  info->cur_state->easing_delay);
       clutter_timeline_set_duration (CLUTTER_TIMELINE (res),
                                      info->cur_state->easing_duration);
       clutter_timeline_set_progress_mode (CLUTTER_TIMELINE (res),
@@ -16907,6 +16909,63 @@ clutter_actor_get_easing_mode (ClutterActor *self)
 }
 
 /**
+ * clutter_actor_set_easing_delay:
+ * @self: a #ClutterActor
+ * @msecs: the delay before the start of the tweening, in milliseconds
+ *
+ * Sets the delay that should be applied before tweening animatable
+ * properties.
+ *
+ * Calling this function will implicitly call
+ * clutter_actor_save_easing_state() if no previous calls to
+ * that function were made.
+ *
+ * Since: 1.10
+ */
+void
+clutter_actor_set_easing_delay (ClutterActor *self,
+                                guint         msecs)
+{
+  ClutterAnimationInfo *info;
+
+  g_return_if_fail (CLUTTER_IS_ACTOR (self));
+
+  info = _clutter_actor_get_animation_info (self);
+
+  if (info->states == NULL)
+    clutter_actor_save_easing_state (self);
+
+  if (info->cur_state->easing_delay != msecs)
+    info->cur_state->easing_delay = msecs;
+}
+
+/**
+ * clutter_actor_get_easing_delay:
+ * @self: a #ClutterActor
+ *
+ * Retrieves the delay that should be applied when tweening animatable
+ * properties.
+ *
+ * Return value: a delay, in milliseconds
+ *
+ * Since: 1.10
+ */
+guint
+clutter_actor_get_easing_delay (ClutterActor *self)
+{
+  const ClutterAnimationInfo *info;
+
+  g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
+
+  info = _clutter_actor_get_animation_info_or_defaults (self);
+
+  if (info->cur_state != NULL)
+    return info->cur_state->easing_delay;
+
+  return 0;
+}
+
+/**
  * clutter_actor_get_transition:
  * @self: a #ClutterActor
  * @name: the name of the transition
@@ -16977,6 +17036,7 @@ clutter_actor_save_easing_state (ClutterActor *self)
 
   new_state.easing_mode = CLUTTER_EASE_OUT_CUBIC;
   new_state.easing_duration = 250;
+  new_state.easing_delay = 0;
 
   g_array_append_val (info->states, new_state);
 
index 3993a22..2e4bd18 100644 (file)
@@ -651,6 +651,9 @@ ClutterAnimationMode            clutter_actor_get_easing_mode
 void                            clutter_actor_set_easing_duration               (ClutterActor               *self,
                                                                                  guint                       msecs);
 guint                           clutter_actor_get_easing_duration               (ClutterActor               *self);
+void                            clutter_actor_set_easing_delay                  (ClutterActor               *self,
+                                                                                 guint                       msecs);
+guint                           clutter_actor_get_easing_delay                  (ClutterActor               *self);
 ClutterTransition *             clutter_actor_get_transition                    (ClutterActor               *self,
                                                                                  const char                 *name);
 
index 662ac14..d5748f2 100644 (file)
@@ -92,6 +92,7 @@ clutter_actor_get_constraint
 clutter_actor_get_constraints
 clutter_actor_get_default_paint_volume
 clutter_actor_get_depth
+clutter_actor_get_easing_delay
 clutter_actor_get_easing_duration
 clutter_actor_get_easing_mode
 clutter_actor_get_effect
@@ -213,6 +214,7 @@ clutter_actor_set_child_at_index
 clutter_actor_set_clip
 clutter_actor_set_clip_to_allocation
 clutter_actor_set_depth
+clutter_actor_set_easing_delay
 clutter_actor_set_easing_duration
 clutter_actor_set_easing_mode
 clutter_actor_set_fixed_position_set
index 8de47fd..6c2803e 100644 (file)
@@ -455,6 +455,17 @@ clutter_actor_move_anchor_point
 clutter_actor_move_anchor_point_from_gravity
 
 <SUBSECTION>
+clutter_actor_save_easing_state
+clutter_actor_restore_easing_state
+clutter_actor_set_easing_duration
+clutter_actor_get_easing_duration
+clutter_actor_set_easing_mode
+clutter_actor_get_easing_mode
+clutter_actor_set_easing_delay
+clutter_actor_get_easing_delay
+clutter_actor_get_transition
+
+<SUBSECTION>
 clutter_actor_set_reactive
 clutter_actor_get_reactive
 clutter_actor_set_shader