ges: makes "pass over" accurate and reset priority when transition is removed
authorMathieu Duponchelle <seeed@laposte.net>
Wed, 14 Sep 2011 12:58:01 +0000 (14:58 +0200)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 11 Jan 2012 14:56:15 +0000 (11:56 -0300)
ges/ges-timeline-layer.c

index 9b1213e8570e242afa43c249cc27c523dd2b8feb..cb26086ae1728bca38b2a54ede2b0363d0e471a2 100644 (file)
@@ -430,21 +430,24 @@ static void
 compare (GList * compared, GESTrackObject * track_object, gboolean ahead)
 {
   GList *tmp;
-  gint64 start, duration, compared_start, compared_duration, tr_start,
-      tr_duration;
+  gint64 start, duration, compared_start, compared_duration, end, compared_end,
+      tr_start, tr_duration;
   GESTimelineStandardTransition *tr = NULL;
   GESTrack *track;
   GESTimelineLayer *layer;
-  GESTimelineObject *object, *first_object, *second_object;
+  GESTimelineObject *object, *compared_object, *first_object, *second_object;
   gint priority;
 
   object = ges_track_object_get_timeline_object (track_object);
+  compared_object = ges_track_object_get_timeline_object (compared->data);
   layer = ges_timeline_object_get_layer (object);
 
   start = ges_track_object_get_start (track_object);
   duration = ges_track_object_get_duration (track_object);
   compared_start = ges_track_object_get_start (compared->data);
   compared_duration = ges_track_object_get_duration (compared->data);
+  end = start + duration;
+  compared_end = compared_start + compared_duration;
 
   if (ahead) {
     for (tmp = compared->next; tmp; tmp = tmp->next) {
@@ -459,19 +462,33 @@ compare (GList * compared, GESTrackObject * track_object, gboolean ahead)
         }
         }
     }
-    if (compared_start + compared_duration <= start) {
+
+    if (compared_end <= start) {
       if (tr) {
         ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (tr));
+        g_object_get (compared_object, "priority", &priority, NULL);
+        g_object_set (object, "priority", priority, NULL);
       }
       goto clean;
-    } else if (start + duration < compared_start + compared_duration) {
+    } else if (start > compared_start && end < compared_end) {
+      if (tr) {
+        ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (tr));
+      }
+      if (start - compared_start < compared_end - end) {
+        ges_track_object_set_start (track_object, compared_end - duration + 1);
+        compare (compared, track_object, FALSE);
+      } else {
+        ges_track_object_set_start (track_object, compared_start - 1);
+        compare (compared, track_object, FALSE);
+      }
+      goto clean;
+    } else if (start <= compared_start) {
       if (tr) {
         ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (tr));
       }
-      ges_track_object_set_start (track_object, compared_start - 5);
-      compare (compared, track_object, FALSE);
       goto clean;
     }
+
   } else {
     for (tmp = compared->prev; tmp; tmp = tmp->prev) {
       if GES_IS_TRACK_TRANSITION
@@ -485,15 +502,29 @@ compare (GList * compared, GESTrackObject * track_object, gboolean ahead)
         }
         }
     }
+
     if (start + duration <= compared_start) {
+      if (tr) {
+        ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (tr));
+        g_object_get (object, "priority", &priority, NULL);
+        g_object_set (compared_object, "priority", priority, NULL);
+      }
+      goto clean;
+    } else if (start > compared_start) {
       if (tr) {
         ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (tr));
       }
       goto clean;
-    } else if (start + 10 >= compared_start) {
+    } else if (start < compared_start && end > compared_end) {
       if (tr) {
         ges_timeline_layer_remove_object (layer, GES_TIMELINE_OBJECT (tr));
       }
+      if (compared_start - start < end - compared_end) {
+        ges_track_object_set_start (track_object, compared_end - duration - 1);
+        compare (compared, track_object, TRUE);
+      } else {
+        ges_track_object_set_start (track_object, compared_start + 1);
+      }
       goto clean;
     }
   }