actor: Add delay to the easing state

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.
This commit is contained in:
Emmanuele Bassi 2012-03-15 12:24:02 +00:00
parent 303ebaea88
commit 1511e588df
5 changed files with 77 additions and 0 deletions

View File

@ -213,6 +213,7 @@ ClutterTransformInfo * _clutter_actor_get_transform_info
typedef struct _AState {
guint easing_duration;
guint easing_delay;
ClutterAnimationMode easing_mode;
} AState;

View 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),
@ -16906,6 +16908,63 @@ clutter_actor_get_easing_mode (ClutterActor *self)
return CLUTTER_EASE_OUT_CUBIC;
}
/**
* 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
@ -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);

View 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);

View 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

View File

@ -454,6 +454,17 @@ clutter_actor_get_anchor_point_gravity
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