void mx_toggle_set_active (MxToggle *toggle, gboolean active) { MxTogglePrivate *priv; g_return_if_fail (MX_IS_TOGGLE (toggle)); priv = toggle->priv; if (priv->active != active || (priv->position > 0 && priv->position < 1)) { ClutterTimeline *timeline; priv->active = active; if (active) mx_stylable_set_style_pseudo_class (MX_STYLABLE (toggle), "checked"); else mx_stylable_set_style_pseudo_class (MX_STYLABLE (toggle), NULL); g_object_notify (G_OBJECT (toggle), "active"); /* don't run an animation if the actor is not mapped */ if (!CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (toggle))) { priv->position = (active) ? 1 : 0; return; } timeline = clutter_alpha_get_timeline (priv->alpha); if (active) clutter_timeline_set_direction (timeline, CLUTTER_TIMELINE_FORWARD); else clutter_timeline_set_direction (timeline, CLUTTER_TIMELINE_BACKWARD); if (clutter_timeline_is_playing (timeline)) return; clutter_timeline_rewind (timeline); if (priv->drag_offset > -1) { clutter_alpha_set_mode (priv->alpha, CLUTTER_LINEAR); clutter_timeline_advance (timeline, priv->position * 300); } else { clutter_alpha_set_mode (priv->alpha, CLUTTER_EASE_IN_OUT_CUBIC); } clutter_timeline_start (timeline); } }
static ClutterAlpha * layout_manager_real_begin_animation (ClutterLayoutManager *manager, guint duration, gulong mode) { ClutterTimeline *timeline; ClutterAlpha *alpha; alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha); if (alpha != NULL) { clutter_alpha_set_mode (alpha, mode); timeline = clutter_alpha_get_timeline (alpha); clutter_timeline_set_duration (timeline, duration); clutter_timeline_rewind (timeline); return alpha; }; timeline = clutter_timeline_new (duration); alpha = clutter_alpha_new_full (timeline, mode); /* let the alpha take ownership of the timeline */ g_object_unref (timeline); g_signal_connect_swapped (timeline, "completed", G_CALLBACK (clutter_layout_manager_end_animation), manager); g_signal_connect_swapped (timeline, "new-frame", G_CALLBACK (clutter_layout_manager_layout_changed), manager); g_object_set_qdata_full (G_OBJECT (manager), quark_layout_alpha, alpha, (GDestroyNotify) g_object_unref); clutter_timeline_start (timeline); return alpha; }
static void clutter_alpha_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { ClutterAlpha *alpha = CLUTTER_ALPHA (object); switch (prop_id) { case PROP_TIMELINE: clutter_alpha_set_timeline (alpha, g_value_get_object (value)); break; case PROP_MODE: clutter_alpha_set_mode (alpha, g_value_get_ulong (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
StThemeNodeTransition * st_theme_node_transition_new (StThemeNode *from_node, StThemeNode *to_node, guint duration) { StThemeNodeTransition *transition; g_return_val_if_fail (ST_IS_THEME_NODE (from_node), NULL); g_return_val_if_fail (ST_IS_THEME_NODE (to_node), NULL); duration = st_theme_node_get_transition_duration (to_node); transition = g_object_new (ST_TYPE_THEME_NODE_TRANSITION, NULL); transition->priv->old_theme_node = g_object_ref (from_node); transition->priv->new_theme_node = g_object_ref (to_node); transition->priv->alpha = clutter_alpha_new (); transition->priv->timeline = clutter_timeline_new (duration); transition->priv->timeline_completed_id = g_signal_connect (transition->priv->timeline, "completed", G_CALLBACK (on_timeline_completed), transition); transition->priv->timeline_new_frame_id = g_signal_connect (transition->priv->timeline, "new-frame", G_CALLBACK (on_timeline_new_frame), transition); clutter_alpha_set_mode (transition->priv->alpha, CLUTTER_EASE_IN_OUT_QUAD); clutter_alpha_set_timeline (transition->priv->alpha, transition->priv->timeline); clutter_timeline_start (transition->priv->timeline); return transition; }