Exemplo n.º 1
0
/**
 * clutter_score_remove:
 * @score: a #ClutterScore
 * @id: the id of the timeline to remove
 *
 * Removes the #ClutterTimeline with the given id inside @score. If
 * the timeline has other timelines attached to it, those are removed
 * as well.
 *
 * Since: 0.6
 */
void
clutter_score_remove (ClutterScore *score,
                      gulong        id)
{
  ClutterScorePrivate *priv;
  TraverseClosure closure;

  g_return_if_fail (CLUTTER_IS_SCORE (score));
  g_return_if_fail (id > 0);

  priv = score->priv;

  closure.action = REMOVE_BY_ID;
  closure.score = score;
  closure.d.id = id;
  closure.result = NULL;

  g_node_traverse (priv->root,
                   G_POST_ORDER,
                   G_TRAVERSE_ALL,
                   -1,
                   traverse_children, &closure);

  if (closure.result)
    g_node_destroy (closure.result);
}
Exemplo n.º 2
0
/**
 * clutter_score_start:
 * @score: A #ClutterScore
 *
 * Starts the score.
 *
 * Since: 0.6
 */
void
clutter_score_start (ClutterScore *score)
{
  ClutterScorePrivate *priv;

  g_return_if_fail (CLUTTER_IS_SCORE (score));

  priv = score->priv;

  if (priv->is_paused)
    {
      g_hash_table_foreach (priv->running_timelines,
			    foreach_running_timeline,
			    GINT_TO_POINTER (ACTION_START));
      priv->is_paused = FALSE;
    }
  else
    {
      g_signal_emit (score, score_signals[STARTED], 0);
      g_node_children_foreach (priv->root,
                               G_TRAVERSE_ALL,
                               start_children_entries,
                               NULL);
    }
}
Exemplo n.º 3
0
/**
 * clutter_score_get_loop:
 * @score: a #ClutterScore
 *
 * Gets whether @score is looping
 *
 * Return value: %TRUE if the score is looping
 *
 * Since: 0.6
 */
gboolean
clutter_score_get_loop (ClutterScore *score)
{
  g_return_val_if_fail (CLUTTER_IS_SCORE (score), FALSE);

  return score->priv->loop;
}
Exemplo n.º 4
0
/**
 * 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;
}
Exemplo n.º 5
0
/**
 * clutter_score_is_playing:
 * @score: A #ClutterScore
 *
 * Query state of a #ClutterScore instance.
 *
 * Return Value: %TRUE if score is currently playing
 *
 * Since: 0.6
 */
gboolean
clutter_score_is_playing (ClutterScore *score)
{
  g_return_val_if_fail (CLUTTER_IS_SCORE (score), FALSE);

  if (score->priv->is_paused)
    return FALSE;

  return score->priv->running_timelines
    && g_hash_table_size (score->priv->running_timelines) != 0;
}
Exemplo n.º 6
0
/**
 * 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;
}
Exemplo n.º 7
0
/**
 * clutter_score_set_loop:
 * @score: a #ClutterScore
 * @loop: %TRUE for enable looping
 *
 * Sets whether @score should loop. A looping #ClutterScore will start
 * from its initial state after the ::complete signal has been fired.
 *
 * Since: 0.6
 */
void
clutter_score_set_loop (ClutterScore *score,
			   gboolean         loop)
{
  g_return_if_fail (CLUTTER_IS_SCORE (score));

  if (score->priv->loop != loop)
    {
      score->priv->loop = loop;

      g_object_notify (G_OBJECT (score), "loop");
    }
}
Exemplo n.º 8
0
/**
 * clutter_score_rewind:
 * @score: A #ClutterScore
 *
 * Rewinds a #ClutterScore to its initial state.
 *
 * Since: 0.6
 */
void
clutter_score_rewind (ClutterScore *score)
{
  gboolean was_playing;

  g_return_if_fail (CLUTTER_IS_SCORE (score));

  was_playing = clutter_score_is_playing (score);

  clutter_score_stop (score);

  if (was_playing)
    clutter_score_start (score);
}
Exemplo n.º 9
0
/**
 * clutter_score_stop:
 * @score: A #ClutterScore
 *
 * Stops and rewinds a playing #ClutterScore instance.
 *
 * Since: 0.6
 */
void
clutter_score_stop (ClutterScore *score)
{
  ClutterScorePrivate *priv;

  g_return_if_fail (CLUTTER_IS_SCORE (score));

  priv = score->priv;

  if (priv->running_timelines)
    {
      g_hash_table_foreach (priv->running_timelines,
                            foreach_running_timeline,
                            GINT_TO_POINTER (ACTION_STOP));
      g_hash_table_destroy (priv->running_timelines);
      priv->running_timelines = NULL;
    }
}
Exemplo n.º 10
0
/**
 * clutter_score_get_timeline:
 * @score: a #ClutterScore
 * @id: the id of the timeline
 *
 * Retrieves the #ClutterTimeline for @id inside @score.
 *
 * Return value: (transfer none): the requested timeline, or %NULL. This
 *   function does not increase the reference count on the returned
 *   #ClutterTimeline
 *
 * Since: 0.6
 */
ClutterTimeline *
clutter_score_get_timeline (ClutterScore *score,
                            gulong        id)
{
  GNode *node;
  ClutterScoreEntry *entry;

  g_return_val_if_fail (CLUTTER_IS_SCORE (score), NULL);
  g_return_val_if_fail (id > 0, NULL);

  node = find_entry_by_id (score, id);
  if (G_UNLIKELY (!node))
    return NULL;

  entry = node->data;

  return entry->timeline;
}
Exemplo n.º 11
0
/**
 * clutter_score_remove_all:
 * @score: a #ClutterScore
 *
 * Removes all the timelines inside @score.
 *
 * Since: 0.6
 */
void
clutter_score_remove_all (ClutterScore *score)
{
  ClutterScorePrivate *priv;

  g_return_if_fail (CLUTTER_IS_SCORE (score));

  priv = score->priv;

  /* this will take care of the running timelines */
  clutter_score_stop (score);

  /* destroy all the contents of the tree */
  clutter_score_clear (score);

  /* recreate the sentinel */
  priv->root = g_node_new (NULL);
}
Exemplo n.º 12
0
/**
 * clutter_score_pause:
 * @score: a #ClutterScore
 *
 * Pauses a playing score @score.
 *
 * Since: 0.6
 */
void
clutter_score_pause (ClutterScore *score)
{
  ClutterScorePrivate *priv;

  g_return_if_fail (CLUTTER_IS_SCORE (score));

  priv = score->priv;

  if (!clutter_score_is_playing (score)) 
    return;

  g_hash_table_foreach (priv->running_timelines,
			foreach_running_timeline,
			GINT_TO_POINTER (ACTION_PAUSE));

  priv->is_paused = TRUE;

  g_signal_emit (score, score_signals[PAUSED], 0);
}
Exemplo n.º 13
0
/**
 * clutter_score_list_timelines:
 * @score: a #ClutterScore
 *
 * Retrieves a list of all the #ClutterTimelines managed by @score.
 *
 * Return value: (transfer container) (element-type ClutterTimeline): a #GSList
 *   containing all the timelines in the score. This function does not increase
 *   the reference count of the returned timelines. Use g_slist_free() on the
 *   returned list to deallocate its resources.
 *
 * Since: 0.6
 */
GSList *
clutter_score_list_timelines (ClutterScore *score)
{
  ClutterScorePrivate *priv;
  TraverseClosure closure;
  GSList *retval;

  g_return_val_if_fail (CLUTTER_IS_SCORE (score), NULL);

  priv = score->priv;

  closure.action = LIST_TIMELINES;
  closure.result = NULL;

  g_node_traverse (priv->root,
                   G_POST_ORDER,
                   G_TRAVERSE_ALL,
                   -1,
                   traverse_children, &closure);

  retval = closure.result;

  return retval;
}