gst-editing-services: ges: add a function to move TimelineObject from a layer to another

Thibault Saunier tsaunier at kemper.freedesktop.org
Wed Jan 11 07:04:29 PST 2012


Module: gst-editing-services
Branch: master
Commit: 6e1a482a80423e5118f6d4205f182461aa3b7670
URL:    http://cgit.freedesktop.org/gstreamer/gst-editing-services/commit/?id=6e1a482a80423e5118f6d4205f182461aa3b7670

Author: Thibault Saunier <thibault.saunier at collabora.com>
Date:   Mon Jun  6 15:55:47 2011 -0400

ges: add a function to move TimelineObject from a layer to another

API: ges_timeline_object_move_to_layer
API: ges_timeline_object_is_moving_from_layer
API: ges_timeline_object_set_moving_from_layer

---

 docs/libs/ges-sections.txt |    3 ++
 ges/ges-timeline-object.c  |   77 ++++++++++++++++++++++++++++++++++++++++++++
 ges/ges-timeline-object.h  |   11 ++++++
 ges/ges-timeline.c         |   12 +++++++
 4 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt
index cbf549d..8269560 100644
--- a/docs/libs/ges-sections.txt
+++ b/docs/libs/ges-sections.txt
@@ -298,6 +298,7 @@ ges_timeline_object_find_track_object
 ges_timeline_object_add_track_object
 ges_timeline_object_get_top_effects
 ges_timeline_object_get_top_effect_position
+ges_timeline_object_move_to_layer
 ges_timeline_object_set_top_effect_priority
 <SUBSECTION Standard>
 GES_TIMELINE_OBJECT_DURATION
@@ -308,9 +309,11 @@ GES_TIMELINE_OBJECT_HEIGHT
 ges_timeline_object_create_track_objects
 ges_timeline_object_create_track_object
 ges_timeline_object_fill_track_object
+ges_timeline_object_is_moving_from_layer
 ges_timeline_object_release_track_object
 ges_timeline_object_get_track_objects
 ges_timeline_object_set_layer
+ges_timeline_object_set_moving_from_layer
 ges_timeline_object_set_priority
 GESTimelineObjectPrivate
 GES_IS_TIMELINE_OBJECT
diff --git a/ges/ges-timeline-object.c b/ges/ges-timeline-object.c
index 5c02ff7..27de6c6 100644
--- a/ges/ges-timeline-object.c
+++ b/ges/ges-timeline-object.c
@@ -119,6 +119,7 @@ struct _GESTimelineObjectPrivate
    * properties so we don't end up in infinite property update loops
    */
   gboolean ignore_notifies;
+  gboolean is_moving;
 
   GList *mappings;
 
@@ -319,6 +320,7 @@ ges_timeline_object_init (GESTimelineObject * self)
   self->priv->trackobjects = NULL;
   self->priv->layer = NULL;
   self->priv->nb_effects = 0;
+  self->priv->is_moving = FALSE;
 }
 
 /**
@@ -823,6 +825,81 @@ ges_timeline_object_set_priority_internal (GESTimelineObject * object,
 }
 
 /**
+ * ges_timeline_object_set_moving_from_layer:
+ * @object: a #GESTimelineObject
+ * @is_moving: %TRUE if you want to start moving @object to another layer
+ * %FALSE when you finished moving it.
+ *
+ * Sets the object in a moving to layer state. You might rather use the
+ * ges_timeline_object_move_to_layer function to move #GESTimelineObject-s
+ * from a layer to another.
+ **/
+void
+ges_timeline_object_set_moving_from_layer (GESTimelineObject * object,
+    gboolean is_moving)
+{
+  object->priv->is_moving = is_moving;
+}
+
+/**
+ * ges_timeline_object_is_moving_from_layer:
+ * @object: a #GESTimelineObject
+ *
+ * Tells you if the object is currently moving from a layer to another.
+ * You might rather use the ges_timeline_object_move_to_layer function to
+ * move #GESTimelineObject-s from a layer to another.
+ *
+ *
+ * Returns: %TRUE if @object is currently moving from its current layer
+ * %FALSE otherwize
+ **/
+gboolean
+ges_timeline_object_is_moving_from_layer (GESTimelineObject * object)
+{
+  return object->priv->is_moving;
+}
+
+/**
+ * ges_timeline_object_move_to_layer:
+ * @object: a #GESTimelineObject
+ * @layer: the new #GESTimelineLayer
+ *
+ * Moves @object to @layer. If @object is not in any layer, it adds it to
+ * @layer, else, it removes it from its current layer, and adds it to @layer.
+ *
+ * Returns: %TRUE if @object could be moved %FALSE otherwize
+ */
+gboolean
+ges_timeline_object_move_to_layer (GESTimelineObject * object, GESTimelineLayer
+    * layer)
+{
+  gboolean ret;
+  GESTimelineLayer *current_layer = object->priv->layer;
+
+  if (current_layer == NULL) {
+    GST_DEBUG ("Not moving %p, only adding it to %p", object, layer);
+
+    return ges_timeline_layer_add_object (layer, object);
+  }
+
+  object->priv->is_moving = TRUE;
+  g_object_ref (object);
+  ret = ges_timeline_layer_remove_object (current_layer, object);
+
+  if (!ret) {
+    g_object_unref (object);
+    return FALSE;
+  }
+
+  ret = ges_timeline_layer_add_object (layer, object);
+  object->priv->is_moving = FALSE;
+
+  g_object_unref (object);
+
+  return ret;
+}
+
+/**
  * ges_timeline_object_set_priority:
  * @object: a #GESTimelineObject
  * @priority: the priority
diff --git a/ges/ges-timeline-object.h b/ges/ges-timeline-object.h
index e0ff486..2f02017 100644
--- a/ges/ges-timeline-object.h
+++ b/ges/ges-timeline-object.h
@@ -258,6 +258,17 @@ ges_timeline_object_add_track_object     (GESTimelineObject *object,
 GESTimelineLayer *
 ges_timeline_object_get_layer            (GESTimelineObject *object);
 
+gboolean
+ges_timeline_object_move_to_layer        (GESTimelineObject *object,
+					     GESTimelineLayer *layer);
+
+gboolean
+ges_timeline_object_is_moving_from_layer (GESTimelineObject *object);
+
+void
+ges_timeline_object_set_moving_from_layer (GESTimelineObject * object,
+					     gboolean is_moving);
+
 /* Effects */
 GList *
 ges_timeline_object_get_top_effects      (GESTimelineObject *object);
diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c
index ea88390..eb8c9f7 100644
--- a/ges/ges-timeline.c
+++ b/ges/ges-timeline.c
@@ -599,6 +599,12 @@ static void
 layer_object_added_cb (GESTimelineLayer * layer, GESTimelineObject * object,
     GESTimeline * timeline)
 {
+  if (ges_timeline_object_is_moving_from_layer (object)) {
+    GST_DEBUG ("TimelineObject %p is moving from a layer to another, not doing"
+        " anything on it", object);
+    return;
+  }
+
   GST_DEBUG ("New TimelineObject %p added to layer %p", object, layer);
 
   if (GES_IS_TIMELINE_FILE_SOURCE (object)) {
@@ -647,6 +653,12 @@ layer_object_removed_cb (GESTimelineLayer * layer, GESTimelineObject * object,
 {
   GList *tmp, *trackobjects;
 
+  if (ges_timeline_object_is_moving_from_layer (object)) {
+    GST_DEBUG ("TimelineObject %p is moving from a layer to another, not doing"
+        " anything on it", object);
+    return;
+  }
+
   GST_DEBUG ("TimelineObject %p removed from layer %p", object, layer);
 
   /* Go over the object's track objects and figure out which one belongs to



More information about the gstreamer-commits mailing list