/** * clutter_score_append: * @score: a #ClutterScore * @parent: a #ClutterTimeline in the score, or %NULL * @timeline: a #ClutterTimeline * * Appends a timeline to another one existing in the score; the newly * appended timeline will be started when @parent is complete. * * If @parent is %NULL, the new #ClutterTimeline will be started when * clutter_score_start() is called. * * #ClutterScore will take a reference on @timeline. * * Return value: the id of the #ClutterTimeline inside the score, or * 0 on failure. The returned id can be used with clutter_score_remove() * or clutter_score_get_timeline(). * * Since: 0.6 */ gulong clutter_score_append (ClutterScore *score, ClutterTimeline *parent, ClutterTimeline *timeline) { ClutterScorePrivate *priv; ClutterScoreEntry *entry; g_return_val_if_fail (CLUTTER_IS_SCORE (score), 0); g_return_val_if_fail (parent == NULL || CLUTTER_IS_TIMELINE (parent), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); priv = score->priv; if (!parent) { entry = g_slice_new (ClutterScoreEntry); entry->timeline = g_object_ref (timeline); entry->parent = NULL; entry->id = priv->last_id; entry->marker = NULL; entry->marker_id = 0; entry->complete_id = 0; entry->score = score; entry->node = g_node_append_data (priv->root, entry); } else { GNode *node; node = find_entry_by_timeline (score, parent); if (G_UNLIKELY (!node)) { g_warning ("Unable to find the parent timeline inside the score."); return 0; } entry = g_slice_new (ClutterScoreEntry); entry->timeline = g_object_ref (timeline); entry->parent = parent; entry->id = priv->last_id; entry->marker = NULL; entry->marker_id = 0; entry->complete_id = 0; entry->score = score; entry->node = g_node_append_data (node, entry); } priv->last_id += 1; return entry->id; }
/** * clutter_score_append_at_marker: * @score: a #ClutterScore * @parent: the parent #ClutterTimeline * @marker_name: the name of the marker to use * @timeline: the #ClutterTimeline to append * * Appends @timeline at the given @marker_name on the @parent * #ClutterTimeline. * * If you want to append @timeline at the end of @parent, use * clutter_score_append(). * * The #ClutterScore will take a reference on @timeline. * * Return value: the id of the #ClutterTimeline inside the score, or * 0 on failure. The returned id can be used with clutter_score_remove() * or clutter_score_get_timeline(). * * Since: 0.8 * Deprecated: 1.8 */ gulong clutter_score_append_at_marker (ClutterScore *score, ClutterTimeline *parent, const gchar *marker_name, ClutterTimeline *timeline) { ClutterScorePrivate *priv; GNode *node; ClutterScoreEntry *entry; gchar *marker_reached_signal; g_return_val_if_fail (CLUTTER_IS_SCORE (score), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (parent), 0); g_return_val_if_fail (marker_name != NULL, 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); if (!clutter_timeline_has_marker (parent, marker_name)) { g_warning ("The parent timeline has no marker '%s'", marker_name); return 0; } priv = score->priv; node = find_entry_by_timeline (score, parent); if (G_UNLIKELY (!node)) { g_warning ("Unable to find the parent timeline inside the score."); return 0; } entry = g_slice_new (ClutterScoreEntry); entry->timeline = g_object_ref (timeline); entry->parent = parent; entry->marker = g_strdup (marker_name); entry->id = priv->last_id; entry->score = score; entry->complete_id = 0; marker_reached_signal = g_strdup_printf ("marker-reached::%s", marker_name); entry->marker_id = g_signal_connect (entry->parent, marker_reached_signal, G_CALLBACK (on_timeline_marker), entry); entry->node = g_node_append_data (node, entry); g_free (marker_reached_signal); priv->last_id += 1; return entry->id; }
/** * clutter_timeline_get_delay: * @timeline: a #ClutterTimeline * * Retrieves the delay set using clutter_timeline_set_delay(). * * Return value: the delay in milliseconds. * * Since: 0.4 */ guint clutter_timeline_get_delay (ClutterTimeline *timeline) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); return timeline->priv->delay; }
void astro_appview_advance (AstroAppview *view, gint n) { AstroAppviewPrivate *priv; static ClutterTimeline *move_time = NULL; gint new_active; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = view->priv; new_active = priv->active + n; if (new_active < 0 || new_active >= g_list_length (priv->apps)) return; priv->active = new_active; if (CLUTTER_IS_TIMELINE (move_time) &&clutter_timeline_is_playing (move_time)) { clutter_timeline_stop (move_time); g_object_unref (move_time); } move_time = clutter_effect_move (priv->move_temp, CLUTTER_ACTOR (view), (CSW()/2)- (priv->active * ASTRO_APPICON_SPACING ()), clutter_actor_get_y (CLUTTER_ACTOR (view)), NULL, NULL); g_signal_connect (move_time, "new-frame", G_CALLBACK (on_move_timeline_new_frame), view); }
static void astro_appview_show (ClutterActor *view) { AstroAppviewPrivate *priv; static ClutterTimeline *show_time = NULL; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = ASTRO_APPVIEW (view)->priv; if (CLUTTER_IS_TIMELINE (show_time) &&clutter_timeline_is_playing (show_time)) { clutter_timeline_stop (show_time); g_object_unref (show_time); } clutter_actor_set_x (view, -1* clutter_actor_get_width (view)); CLUTTER_ACTOR_CLASS (astro_appview_parent_class)->show (view); show_time = clutter_effect_move (priv->show_temp, CLUTTER_ACTOR (view), (CSW()/2)- (priv->active * ASTRO_APPICON_SPACING()), clutter_actor_get_y (CLUTTER_ACTOR (view)), NULL, NULL); g_signal_connect (show_time, "new-frame", G_CALLBACK (on_move_timeline_new_frame), view); }
static void astro_appview_hide (ClutterActor *view) { AstroAppviewPrivate *priv; static ClutterTimeline *hide_time = NULL; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = ASTRO_APPVIEW (view)->priv; if (CLUTTER_IS_TIMELINE (hide_time) &&clutter_timeline_is_playing (hide_time)) { clutter_timeline_stop (hide_time); g_object_unref (hide_time); } hide_time = clutter_effect_move (priv->hide_temp, CLUTTER_ACTOR (view), -1 * clutter_actor_get_width (view), clutter_actor_get_y (CLUTTER_ACTOR (view)), NULL, NULL); g_signal_connect (hide_time, "new-frame", G_CALLBACK (on_move_timeline_new_frame), view); g_signal_connect (hide_time, "completed", G_CALLBACK (on_hide_timeline_completed), view); }
/** * clutter_timeline_skip: * @timeline: A #ClutterTimeline * @msecs: Amount of time to skip * * Advance timeline by the requested time in milliseconds */ void clutter_timeline_skip (ClutterTimeline *timeline, guint msecs) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; if (priv->direction == CLUTTER_TIMELINE_FORWARD) { priv->elapsed_time += msecs; if (priv->elapsed_time > priv->duration) priv->elapsed_time = 1; } else if (priv->direction == CLUTTER_TIMELINE_BACKWARD) { priv->elapsed_time -= msecs; if (priv->elapsed_time < 1) priv->elapsed_time = priv->duration - 1; } priv->msecs_delta = 0; }
/** * clutter_timeline_get_loop: * @timeline: a #ClutterTimeline * * Gets whether @timeline is looping * * Return value: %TRUE if the timeline is looping */ gboolean clutter_timeline_get_loop (ClutterTimeline *timeline) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); return timeline->priv->loop; }
/** * clutter_timeline_start: * @timeline: A #ClutterTimeline * * Starts the #ClutterTimeline playing. **/ void clutter_timeline_start (ClutterTimeline *timeline) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; if (priv->delay_id || priv->is_playing) return; if (priv->duration == 0) return; if (priv->delay) priv->delay_id = clutter_threads_add_timeout (priv->delay, delay_timeout_func, timeline); else { priv->msecs_delta = 0; set_is_playing (timeline, TRUE); g_signal_emit (timeline, timeline_signals[STARTED], 0); } }
/** * clutter_timeline_is_playing: * @timeline: A #ClutterTimeline * * Queries state of a #ClutterTimeline. * * Return value: %TRUE if timeline is currently playing */ gboolean clutter_timeline_is_playing (ClutterTimeline *timeline) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); return timeline->priv->is_playing; }
/** * clutter_alpha_set_timeline: * @alpha: A #ClutterAlpha * @timeline: A #ClutterTimeline * * Binds @alpha to @timeline. * * Since: 0.2 * * Deprecated: 1.12 */ void clutter_alpha_set_timeline (ClutterAlpha *alpha, ClutterTimeline *timeline) { ClutterAlphaPrivate *priv; g_return_if_fail (CLUTTER_IS_ALPHA (alpha)); g_return_if_fail (timeline == NULL || CLUTTER_IS_TIMELINE (timeline)); priv = alpha->priv; if (priv->timeline == timeline) return; if (priv->timeline) { g_signal_handlers_disconnect_by_func (priv->timeline, timeline_new_frame_cb, alpha); g_object_unref (priv->timeline); priv->timeline = NULL; } if (timeline) { priv->timeline = g_object_ref (timeline); g_signal_connect (priv->timeline, "new-frame", G_CALLBACK (timeline_new_frame_cb), alpha); } g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_TIMELINE]); }
/** * clutter_timeline_get_elapsed_time: * @timeline: A #ClutterTimeline * * Request the current time position of the timeline. * * Return value: current elapsed time in milliseconds. */ guint clutter_timeline_get_elapsed_time (ClutterTimeline *timeline) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); return timeline->priv->elapsed_time; }
/** * clutter_timeline_get_direction: * @timeline: a #ClutterTimeline * * Retrieves the direction of the timeline set with * clutter_timeline_set_direction(). * * Return value: the direction of the timeline * * Since: 0.6 */ ClutterTimelineDirection clutter_timeline_get_direction (ClutterTimeline *timeline) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), CLUTTER_TIMELINE_FORWARD); return timeline->priv->direction; }
/** * clutter_timeline_get_delta: * @timeline: a #ClutterTimeline * * Retrieves the amount of time elapsed since the last * ClutterTimeline::new-frame signal. * * This function is only useful inside handlers for the ::new-frame * signal, and its behaviour is undefined if the timeline is not * playing. * * Return value: the amount of time in milliseconds elapsed since the * last frame * * Since: 0.6 */ guint clutter_timeline_get_delta (ClutterTimeline *timeline) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); if (!clutter_timeline_is_playing (timeline)) return 0; return timeline->priv->msecs_delta; }
/** * clutter_timeline_get_progress: * @timeline: a #ClutterTimeline * * The position of the timeline in a [0, 1] interval. * * Return value: the position of the timeline. * * Since: 0.6 */ gdouble clutter_timeline_get_progress (ClutterTimeline *timeline) { ClutterTimelinePrivate *priv; g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0.0); priv = timeline->priv; return (gdouble) priv->elapsed_time / (gdouble) priv->duration; }
/** * clutter_timeline_add_marker_at_time: * @timeline: a #ClutterTimeline * @marker_name: the unique name for this marker * @msecs: position of the marker in milliseconds * * Adds a named marker that will be hit when the timeline has been * running for @msecs milliseconds. Markers are unique string * identifiers for a given time. Once @timeline reaches * @msecs, it will emit a ::marker-reached signal for each marker * attached to that time. * * A marker can be removed with clutter_timeline_remove_marker(). The * timeline can be advanced to a marker using * clutter_timeline_advance_to_marker(). * * Since: 0.8 */ void clutter_timeline_add_marker_at_time (ClutterTimeline *timeline, const gchar *marker_name, guint msecs) { g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (marker_name != NULL); g_return_if_fail (msecs <= clutter_timeline_get_duration (timeline)); clutter_timeline_add_marker_internal (timeline, marker_name, msecs); }
/** * clutter_timeline_get_duration: * @timeline: a #ClutterTimeline * * Retrieves the duration of a #ClutterTimeline in milliseconds. * See clutter_timeline_set_duration(). * * Return value: the duration of the timeline, in milliseconds. * * Since: 0.6 */ guint clutter_timeline_get_duration (ClutterTimeline *timeline) { ClutterTimelinePrivate *priv; g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); priv = timeline->priv; return priv->duration; }
/** * clutter_timeline_advance: * @timeline: A #ClutterTimeline * @msecs: Time to advance to * * Advance timeline to the requested point. The point is given as a * time in milliseconds since the timeline started. * * <note><para>The @timeline will not emit the #ClutterTimeline::new-frame * signal for the given time. The first ::new-frame signal after the call to * clutter_timeline_advance() will be emit the skipped markers. * </para></note> */ void clutter_timeline_advance (ClutterTimeline *timeline, guint msecs) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; priv->elapsed_time = CLAMP (msecs, 0, priv->duration); }
/** * clutter_alpha_new_full: * @timeline: #ClutterTimeline timeline * @mode: animation mode * * Creates a new #ClutterAlpha instance and sets the timeline * and animation mode. * * See also clutter_alpha_set_timeline() and clutter_alpha_set_mode(). * * Return Value: the newly created #ClutterAlpha * * Since: 1.0 * * Deprecated: 1.12 */ ClutterAlpha * clutter_alpha_new_full (ClutterTimeline *timeline, gulong mode) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL); g_return_val_if_fail (mode != CLUTTER_ANIMATION_LAST, NULL); return g_object_new (CLUTTER_TYPE_ALPHA, "timeline", timeline, "mode", mode, NULL); }
/** * clutter_timeline_set_loop: * @timeline: a #ClutterTimeline * @loop: %TRUE for enable looping * * Sets whether @timeline should loop. */ void clutter_timeline_set_loop (ClutterTimeline *timeline, gboolean loop) { g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); if (timeline->priv->loop != loop) { timeline->priv->loop = loop; g_object_notify (G_OBJECT (timeline), "loop"); } }
/** * clutter_timeline_rewind: * @timeline: A #ClutterTimeline * * Rewinds #ClutterTimeline to the first frame if its direction is * %CLUTTER_TIMELINE_FORWARD and the last frame if it is * %CLUTTER_TIMELINE_BACKWARD. */ void clutter_timeline_rewind (ClutterTimeline *timeline) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; if (priv->direction == CLUTTER_TIMELINE_FORWARD) clutter_timeline_advance (timeline, 0); else if (priv->direction == CLUTTER_TIMELINE_BACKWARD) clutter_timeline_advance (timeline, priv->duration); }
/** * clutter_timeline_set_delay: * @timeline: a #ClutterTimeline * @msecs: delay in milliseconds * * Sets the delay, in milliseconds, before @timeline should start. * * Since: 0.4 */ void clutter_timeline_set_delay (ClutterTimeline *timeline, guint msecs) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; if (priv->delay != msecs) { priv->delay = msecs; g_object_notify (G_OBJECT (timeline), "delay"); } }
/** * clutter_timeline_clone: * @timeline: #ClutterTimeline to duplicate. * * Create a new #ClutterTimeline instance which has property values * matching that of supplied timeline. The cloned timeline will not * be started and will not be positioned to the current position of * @timeline: you will have to start it with clutter_timeline_start(). * * Return Value: a new #ClutterTimeline, cloned from @timeline * * Since: 0.4 */ ClutterTimeline * clutter_timeline_clone (ClutterTimeline *timeline) { ClutterTimeline *copy; g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL); copy = g_object_new (CLUTTER_TYPE_TIMELINE, "duration", clutter_timeline_get_duration (timeline), "loop", clutter_timeline_get_loop (timeline), "delay", clutter_timeline_get_delay (timeline), "direction", clutter_timeline_get_direction (timeline), NULL); return copy; }
/** * clutter_alpha_new_with_func: * @timeline: a #ClutterTimeline * @func: a #ClutterAlphaFunc * @data: data to pass to the function, or %NULL * @destroy: function to call when removing the alpha function, or %NULL * * Creates a new #ClutterAlpha instances and sets the timeline * and the alpha function. * * This function will not register @func as a global alpha function. * * See also clutter_alpha_set_timeline() and clutter_alpha_set_func(). * * Return value: the newly created #ClutterAlpha * * Since: 1.0 * * Deprecated: 1.12 */ ClutterAlpha * clutter_alpha_new_with_func (ClutterTimeline *timeline, ClutterAlphaFunc func, gpointer data, GDestroyNotify destroy) { ClutterAlpha *retval; g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL); g_return_val_if_fail (func != NULL, NULL); retval = clutter_alpha_new (); clutter_alpha_set_timeline (retval, timeline); clutter_alpha_set_func (retval, func, data, destroy); return retval; }
static gboolean red_button_press (ClutterActor *actor, ClutterButtonEvent *event, gpointer data) { GObject *timeline; g_print ("[*] Pressed `%s'\n", clutter_get_script_id (G_OBJECT (actor))); timeline = clutter_script_get_object (script, "main-timeline"); g_assert (CLUTTER_IS_TIMELINE (timeline)); if (!clutter_timeline_is_playing (CLUTTER_TIMELINE (timeline))) clutter_timeline_start (CLUTTER_TIMELINE (timeline)); else clutter_timeline_pause (CLUTTER_TIMELINE (timeline)); return TRUE; }
/* * clutter_timeline_do_tick * @timeline: a #ClutterTimeline * @tick_time: time of advance * * Advances @timeline based on the time passed in @msecs. This * function is called by the master clock. The @timeline will use this * interval to emit the #ClutterTimeline::new-frame signal and * eventually skip frames. */ void clutter_timeline_do_tick (ClutterTimeline *timeline, GTimeVal *tick_time) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; if (priv->waiting_first_tick) { priv->last_frame_time = *tick_time; priv->waiting_first_tick = FALSE; } else { gint64 msecs; msecs = (tick_time->tv_sec - priv->last_frame_time.tv_sec) * 1000 + (tick_time->tv_usec - priv->last_frame_time.tv_usec) / 1000; /* if the clock rolled back between ticks we need to * account for it; the best course of action, since the * clock roll back can happen by any arbitrary amount * of milliseconds, is to drop a frame here */ if (msecs < 0) { priv->last_frame_time = *tick_time; return; } if (msecs != 0) { /* Avoid accumulating error */ g_time_val_add (&priv->last_frame_time, msecs * 1000L); priv->msecs_delta = msecs; clutter_timeline_do_frame (timeline); } } }
/** * clutter_timeline_set_direction: * @timeline: a #ClutterTimeline * @direction: the direction of the timeline * * Sets the direction of @timeline, either %CLUTTER_TIMELINE_FORWARD or * %CLUTTER_TIMELINE_BACKWARD. * * Since: 0.6 */ void clutter_timeline_set_direction (ClutterTimeline *timeline, ClutterTimelineDirection direction) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; if (priv->direction != direction) { priv->direction = direction; if (priv->elapsed_time == 0) priv->elapsed_time = priv->duration; g_object_notify (G_OBJECT (timeline), "direction"); } }
/** * clutter_timeline_pause: * @timeline: A #ClutterTimeline * * Pauses the #ClutterTimeline on current frame **/ void clutter_timeline_pause (ClutterTimeline *timeline) { ClutterTimelinePrivate *priv; g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); priv = timeline->priv; if (priv->delay_id == 0 && !priv->is_playing) return; if (priv->delay_id) { g_source_remove (priv->delay_id); priv->delay_id = 0; } priv->msecs_delta = 0; set_is_playing (timeline, FALSE); g_signal_emit (timeline, timeline_signals[PAUSED], 0); }