diff --git a/ges/ges-container.c b/ges/ges-container.c index 149393e51f..caf4f509f8 100644 --- a/ges/ges-container.c +++ b/ges/ges-container.c @@ -519,6 +519,13 @@ _ges_container_sort_children (GESContainer * container) (GCompareFunc) element_start_compare); } +void +_ges_container_sort_children_by_end (GESContainer * container) +{ + container->children = g_list_sort (container->children, + (GCompareFunc) element_end_compare); +} + void _ges_container_set_ignore_notifies (GESContainer * container, gboolean ignore_notifies) diff --git a/ges/ges-internal.h b/ges/ges-internal.h index d5bec274bc..2dd2cdbd5a 100644 --- a/ges/ges-internal.h +++ b/ges/ges-internal.h @@ -224,13 +224,17 @@ G_GNUC_INTERNAL void _init_formatter_assets (void); /* Utilities */ G_GNUC_INTERNAL gint element_start_compare (GESTimelineElement * a, - GESTimelineElement * b); + GESTimelineElement * b); +G_GNUC_INTERNAL gint element_end_compare (GESTimelineElement * a, + GESTimelineElement * b); + /**************************************************** * GESContainer * ****************************************************/ -G_GNUC_INTERNAL void _ges_container_sort_children (GESContainer *container); -G_GNUC_INTERNAL void _ges_container_set_ignore_notifies (GESContainer *container, - gboolean ignore_notifies); +G_GNUC_INTERNAL void _ges_container_sort_children (GESContainer *container); +G_GNUC_INTERNAL void _ges_container_sort_children_by_end (GESContainer *container); +G_GNUC_INTERNAL void _ges_container_set_ignore_notifies (GESContainer *container, + gboolean ignore_notifies); /**************************************************** * GESClip * diff --git a/ges/ges-utils.c b/ges/ges-utils.c index 26245dd384..1ce0bbf265 100644 --- a/ges/ges-utils.c +++ b/ges/ges-utils.c @@ -73,10 +73,27 @@ element_start_compare (GESTimelineElement * a, GESTimelineElement * b) if (a->duration > b->duration) return 1; return 0; - } - if (a->start < b->start) + } else if (a->start < b->start) return -1; - if (a->start > b->start) - return 1; - return 0; + + return 1; +} + +gint +element_end_compare (GESTimelineElement * a, GESTimelineElement * b) +{ + if (GES_TIMELINE_ELEMENT_END (a) == GES_TIMELINE_ELEMENT_END (b)) { + if (a->priority < b->priority) + return -1; + if (a->priority > b->priority) + return 1; + if (a->duration < b->duration) + return -1; + if (a->duration > b->duration) + return 1; + return 0; + } else if (GES_TIMELINE_ELEMENT_END (a) < (GES_TIMELINE_ELEMENT_END (b))) + return -1; + + return 1; }