mirror of
https://github.com/brl/mutter.git
synced 2025-02-18 06:04:10 +00:00
actor: Add ::transition-stopped
The ::transition-stopped signal can be used to get notification of the end of a transition.
This commit is contained in:
parent
e0e5ab9dd4
commit
28c2eeef95
@ -964,6 +964,7 @@ enum
|
|||||||
ALLOCATION_CHANGED,
|
ALLOCATION_CHANGED,
|
||||||
TRANSITIONS_COMPLETED,
|
TRANSITIONS_COMPLETED,
|
||||||
TOUCH_EVENT,
|
TOUCH_EVENT,
|
||||||
|
TRANSITION_STOPPED,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
@ -4449,8 +4450,6 @@ clutter_actor_set_rotation_angle (ClutterActor *self,
|
|||||||
_clutter_actor_create_transition (self, pspec, *cur_angle_p, angle);
|
_clutter_actor_create_transition (self, pspec, *cur_angle_p, angle);
|
||||||
else
|
else
|
||||||
_clutter_actor_update_transition (self, pspec, angle);
|
_clutter_actor_update_transition (self, pspec, angle);
|
||||||
|
|
||||||
clutter_actor_queue_redraw (self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8014,6 +8013,32 @@ clutter_actor_class_init (ClutterActorClass *klass)
|
|||||||
_clutter_marshal_VOID__VOID,
|
_clutter_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterActor::transition-stopped:
|
||||||
|
* @actor: a #ClutterActor
|
||||||
|
* @name: the name of the transition
|
||||||
|
* @is_finished: whether the transition was finished, or stopped
|
||||||
|
*
|
||||||
|
* The ::transition-stopped signal is emitted once a transition
|
||||||
|
* is stopped; a transition is stopped once it reached its total
|
||||||
|
* duration (including eventual repeats), it has been stopped
|
||||||
|
* using clutter_timeline_stop(), or it has been removed from the
|
||||||
|
* transitions applied on @actor, using clutter_actor_remove_transition().
|
||||||
|
*
|
||||||
|
* Since: 1.12
|
||||||
|
*/
|
||||||
|
actor_signals[TRANSITION_STOPPED] =
|
||||||
|
g_signal_new (I_("transition-stopped"),
|
||||||
|
G_TYPE_FROM_CLASS (object_class),
|
||||||
|
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
|
||||||
|
G_SIGNAL_NO_HOOKS | G_SIGNAL_DETAILED,
|
||||||
|
0,
|
||||||
|
NULL, NULL,
|
||||||
|
_clutter_marshal_VOID__STRING_BOOLEAN,
|
||||||
|
G_TYPE_NONE, 2,
|
||||||
|
G_TYPE_STRING,
|
||||||
|
G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterActor::touch-event:
|
* ClutterActor::touch-event:
|
||||||
* @actor: a #ClutterActor
|
* @actor: a #ClutterActor
|
||||||
@ -18350,6 +18375,11 @@ on_transition_stopped (ClutterTransition *transition,
|
|||||||
{
|
{
|
||||||
ClutterActor *actor = clos->actor;
|
ClutterActor *actor = clos->actor;
|
||||||
ClutterAnimationInfo *info;
|
ClutterAnimationInfo *info;
|
||||||
|
GQuark t_quark;
|
||||||
|
gchar *t_name;
|
||||||
|
|
||||||
|
if (clos->name == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* reset the caches used by animations */
|
/* reset the caches used by animations */
|
||||||
clutter_actor_store_content_box (actor, NULL);
|
clutter_actor_store_content_box (actor, NULL);
|
||||||
@ -18359,6 +18389,9 @@ on_transition_stopped (ClutterTransition *transition,
|
|||||||
|
|
||||||
info = _clutter_actor_get_animation_info (actor);
|
info = _clutter_actor_get_animation_info (actor);
|
||||||
|
|
||||||
|
t_quark = g_quark_from_string (clos->name);
|
||||||
|
t_name = g_strdup (clos->name);
|
||||||
|
|
||||||
/* we take a reference here because removing the closure
|
/* we take a reference here because removing the closure
|
||||||
* will release the reference on the transition, and we
|
* will release the reference on the transition, and we
|
||||||
* want the transition to survive the signal emission;
|
* want the transition to survive the signal emission;
|
||||||
@ -18368,6 +18401,16 @@ on_transition_stopped (ClutterTransition *transition,
|
|||||||
g_object_ref (transition);
|
g_object_ref (transition);
|
||||||
g_hash_table_remove (info->transitions, clos->name);
|
g_hash_table_remove (info->transitions, clos->name);
|
||||||
|
|
||||||
|
/* we emit the ::transition-stopped after removing the
|
||||||
|
* transition, so that we can chain up new transitions
|
||||||
|
* without interfering with the one that just finished
|
||||||
|
*/
|
||||||
|
g_signal_emit (actor, actor_signals[TRANSITION_STOPPED], t_quark,
|
||||||
|
t_name,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
|
g_free (t_name);
|
||||||
|
|
||||||
/* if it's the last transition then we clean up */
|
/* if it's the last transition then we clean up */
|
||||||
if (g_hash_table_size (info->transitions) == 0)
|
if (g_hash_table_size (info->transitions) == 0)
|
||||||
{
|
{
|
||||||
@ -18481,6 +18524,9 @@ _clutter_actor_create_transition (ClutterActor *actor,
|
|||||||
TransitionClosure *clos;
|
TransitionClosure *clos;
|
||||||
va_list var_args;
|
va_list var_args;
|
||||||
|
|
||||||
|
g_assert (pspec != NULL);
|
||||||
|
g_assert ((pspec->flags & CLUTTER_PARAM_ANIMATABLE) != 0);
|
||||||
|
|
||||||
info = _clutter_actor_get_animation_info (actor);
|
info = _clutter_actor_get_animation_info (actor);
|
||||||
|
|
||||||
/* XXX - this will go away in 2.0
|
/* XXX - this will go away in 2.0
|
||||||
@ -18559,9 +18605,6 @@ _clutter_actor_create_transition (ClutterActor *actor,
|
|||||||
|
|
||||||
interval = clutter_interval_new_with_values (ptype, &initial, &final);
|
interval = clutter_interval_new_with_values (ptype, &initial, &final);
|
||||||
|
|
||||||
g_value_unset (&initial);
|
|
||||||
g_value_unset (&final);
|
|
||||||
|
|
||||||
res = clutter_property_transition_new (pspec->name);
|
res = clutter_property_transition_new (pspec->name);
|
||||||
|
|
||||||
clutter_transition_set_interval (res, interval);
|
clutter_transition_set_interval (res, interval);
|
||||||
@ -18572,22 +18615,45 @@ _clutter_actor_create_transition (ClutterActor *actor,
|
|||||||
clutter_timeline_set_duration (timeline, info->cur_state->easing_duration);
|
clutter_timeline_set_duration (timeline, info->cur_state->easing_duration);
|
||||||
clutter_timeline_set_progress_mode (timeline, info->cur_state->easing_mode);
|
clutter_timeline_set_progress_mode (timeline, info->cur_state->easing_mode);
|
||||||
|
|
||||||
CLUTTER_NOTE (ANIMATION,
|
#ifdef CLUTTER_ENABLE_DEBUG
|
||||||
"Created transition for %s:%s (len:%u, mode:%s, delay:%u)",
|
{
|
||||||
_clutter_actor_get_debug_name (actor),
|
gchar *initial_v, *final_v;
|
||||||
pspec->name,
|
|
||||||
info->cur_state->easing_duration,
|
initial_v = g_strdup_value_contents (&initial);
|
||||||
clutter_get_easing_name_for_mode (info->cur_state->easing_mode),
|
final_v = g_strdup_value_contents (&final);
|
||||||
info->cur_state->easing_delay);
|
|
||||||
|
CLUTTER_NOTE (ANIMATION,
|
||||||
|
"Created transition for %s:%s "
|
||||||
|
"(len:%u, mode:%s, delay:%u) "
|
||||||
|
"initial:%s, final:%s",
|
||||||
|
_clutter_actor_get_debug_name (actor),
|
||||||
|
pspec->name,
|
||||||
|
info->cur_state->easing_duration,
|
||||||
|
clutter_get_easing_name_for_mode (info->cur_state->easing_mode),
|
||||||
|
info->cur_state->easing_delay,
|
||||||
|
initial_v, final_v);
|
||||||
|
|
||||||
|
g_free (initial_v);
|
||||||
|
g_free (final_v);
|
||||||
|
}
|
||||||
|
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||||
|
|
||||||
/* this will start the transition as well */
|
/* this will start the transition as well */
|
||||||
clutter_actor_add_transition (actor, pspec->name, res);
|
clutter_actor_add_transition (actor, pspec->name, res);
|
||||||
|
|
||||||
/* the actor now owns the transition */
|
/* the actor now owns the transition */
|
||||||
g_object_unref (res);
|
g_object_unref (res);
|
||||||
|
|
||||||
|
g_value_unset (&initial);
|
||||||
|
g_value_unset (&final);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = clos->transition;
|
{
|
||||||
|
CLUTTER_NOTE (ANIMATION, "Existing transition for %s:%s",
|
||||||
|
_clutter_actor_get_debug_name (actor),
|
||||||
|
pspec->name);
|
||||||
|
res = clos->transition;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (call_restore)
|
if (call_restore)
|
||||||
@ -18698,6 +18764,11 @@ clutter_actor_remove_transition (ClutterActor *self,
|
|||||||
if (info->transitions == NULL)
|
if (info->transitions == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
g_signal_emit (self, actor_signals[TRANSITION_STOPPED],
|
||||||
|
g_quark_from_string (name),
|
||||||
|
name,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
g_hash_table_remove (info->transitions, name);
|
g_hash_table_remove (info->transitions, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ VOID:OBJECT,PARAM
|
|||||||
VOID:OBJECT,POINTER
|
VOID:OBJECT,POINTER
|
||||||
VOID:OBJECT,UINT
|
VOID:OBJECT,UINT
|
||||||
VOID:POINTER
|
VOID:POINTER
|
||||||
|
VOID:STRING,BOOLEAN
|
||||||
VOID:STRING,BOOLEAN,BOOLEAN
|
VOID:STRING,BOOLEAN,BOOLEAN
|
||||||
VOID:STRING,INT
|
VOID:STRING,INT
|
||||||
VOID:UINT
|
VOID:UINT
|
||||||
|
@ -49,36 +49,37 @@ on_crossing (ClutterActor *actor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_transition_stopped (ClutterTransition *transition,
|
on_transition_stopped (ClutterActor *actor,
|
||||||
gboolean is_finished,
|
const gchar *transition_name,
|
||||||
ClutterActor *actor)
|
gboolean is_finished)
|
||||||
{
|
{
|
||||||
clutter_actor_save_easing_state (actor);
|
clutter_actor_save_easing_state (actor);
|
||||||
clutter_actor_set_easing_duration (actor, 250);
|
|
||||||
|
|
||||||
clutter_actor_set_rotation_angle (actor, CLUTTER_Y_AXIS, 0.0f);
|
clutter_actor_set_rotation_angle (actor, CLUTTER_Y_AXIS, 0.0f);
|
||||||
|
|
||||||
clutter_actor_restore_easing_state (actor);
|
clutter_actor_restore_easing_state (actor);
|
||||||
|
|
||||||
|
/* disconnect so we don't get multiple notifications */
|
||||||
|
g_signal_handlers_disconnect_by_func (actor,
|
||||||
|
on_transition_stopped,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
animate_rotation (ClutterActor *actor,
|
animate_rotation (ClutterActor *actor,
|
||||||
ClutterEvent *event)
|
ClutterEvent *event)
|
||||||
{
|
{
|
||||||
ClutterTransition *transition;
|
|
||||||
|
|
||||||
clutter_actor_save_easing_state (actor);
|
clutter_actor_save_easing_state (actor);
|
||||||
clutter_actor_set_easing_duration (actor, 1000);
|
clutter_actor_set_easing_duration (actor, 1000);
|
||||||
|
|
||||||
clutter_actor_set_rotation_angle (actor, CLUTTER_Y_AXIS, 360.0);
|
clutter_actor_set_rotation_angle (actor, CLUTTER_Y_AXIS, 360.0);
|
||||||
|
|
||||||
transition = clutter_actor_get_transition (actor, "rotation-angle-y");
|
|
||||||
g_signal_connect (transition, "stopped",
|
|
||||||
G_CALLBACK (on_transition_stopped),
|
|
||||||
actor);
|
|
||||||
|
|
||||||
clutter_actor_restore_easing_state (actor);
|
clutter_actor_restore_easing_state (actor);
|
||||||
|
|
||||||
|
/* get a notification when the rotation-angle-y transition ends */
|
||||||
|
g_signal_connect (actor,
|
||||||
|
"transition-stopped::rotation-angle-y",
|
||||||
|
G_CALLBACK (on_transition_stopped),
|
||||||
|
NULL);
|
||||||
|
|
||||||
return CLUTTER_EVENT_STOP;
|
return CLUTTER_EVENT_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user