/**
- * clutter_state_change_noanim:
- * @state_name: a #ClutterState
- *
- * Change to @state_name and spend duration msecs when doing so.
- *
- * Return value: the #ClutterTimeline that drives the #ClutterState instance.
- */
-ClutterTimeline *
-clutter_state_change_noanim (ClutterState *this,
- const gchar *target_state_name)
-{
- ClutterStatePrivate *priv = this->priv;
- State *state;
-
- g_return_val_if_fail (CLUTTER_IS_STATE (this), NULL);
- g_return_val_if_fail (target_state_name, NULL);
-
- if (target_state_name == NULL)
- target_state_name = "default";
- target_state_name = g_intern_string (target_state_name);
- if (priv->target_state_name == NULL)
- priv->target_state_name = g_intern_static_string ("default");
-
- if (priv->current_animator)
- {
- clutter_animator_set_timeline (priv->current_animator, NULL);
- priv->current_animator = NULL;
- }
-
- priv->source_state_name = priv->target_state_name;
- priv->target_state_name = target_state_name;
-
- clutter_timeline_set_duration (priv->timeline, 1);
-
- state = g_hash_table_lookup (priv->states, target_state_name);
-
- g_return_val_if_fail (state, NULL);
-
- {
- ClutterAnimator *animator;
- animator = clutter_state_get_animator (this, priv->source_state_name,
- priv->target_state_name);
- if (animator)
- {
- priv->current_animator = animator;
- clutter_animator_set_timeline (animator, priv->timeline);
- clutter_timeline_stop (priv->timeline);
- clutter_timeline_rewind (priv->timeline);
- clutter_timeline_start (priv->timeline);
- return priv->timeline;
- }
- }
-
- if (state)
- {
- GList *k;
-
- for (k = state->keys; k; k = k->next)
- {
- ClutterStateKey *key = k->data;
- GValue initial = {0,};
-
- g_value_init (&initial,
- clutter_interval_get_value_type (key->interval));
-
- g_object_get_property (key->object,
- key->property_name, &initial);
- if (clutter_alpha_get_mode (key->alpha) != key->mode)
- clutter_alpha_set_mode (key->alpha, key->mode);
- clutter_interval_set_initial_value (key->interval, &initial);
- clutter_interval_set_final_value (key->interval, &key->value);
-
- g_value_unset (&initial);
- }
-
- priv->target_state = state;
- clutter_timeline_rewind (priv->timeline);
- clutter_timeline_start (priv->timeline);
- }
- else
- {
- g_warning ("Anim state '%s' not found\n", target_state_name);
- }
-
- return priv->timeline;
-}
-
-
-/**
* clutter_state_change:
* @state_name: a #ClutterState
+ * @animate: whether we should animate the transition or not.
*
* Change to @state_name and spend duration msecs when doing so.
*
*/
ClutterTimeline *
clutter_state_change (ClutterState *this,
- const gchar *target_state_name)
+ const gchar *target_state_name,
+ gboolean animate)
{
ClutterStatePrivate *priv = this->priv;
State *state;
priv->source_state_name = priv->target_state_name;
priv->target_state_name = target_state_name;
- clutter_timeline_set_duration (priv->timeline,
- clutter_state_get_duration (this, priv->source_state_name,
- priv->target_state_name));
+ if (animate)
+ clutter_timeline_set_duration (priv->timeline,
+ clutter_state_get_duration (this, priv->source_state_name,
+ priv->target_state_name));
+ else
+ clutter_timeline_set_duration (priv->timeline, 1);
state = g_hash_table_lookup (priv->states, target_state_name);
gpointer user_data)
{
clutter_grab_pointer (actor);
- clutter_state_change (state, "end");
+ clutter_state_change (state, "end", TRUE);
return TRUE;
}
ClutterEvent *event,
gpointer user_data)
{
- clutter_state_change (state, "start");
+ clutter_state_change (state, "start", TRUE);
clutter_ungrab_pointer ();
return TRUE;
}
-static void completed (ClutterState *state,
+static void completed (ClutterState *sstate,
gpointer data)
{
g_print ("Completed transitioning to state: %s\n",
- clutter_state_get_target_state (state), data);
+ clutter_state_get_target_state (sstate));
}
static ClutterActor *new_rect (gint r,
g_signal_connect (state, "completed", G_CALLBACK (completed), NULL);
clutter_actor_show (stage);
- clutter_state_change (state, "start");
+ clutter_state_change (state, "start", TRUE);
clutter_main ();
g_object_unref (state);