diff --git a/ges/ges-clip.c b/ges/ges-clip.c index 5351236313..e86f54d0fe 100644 --- a/ges/ges-clip.c +++ b/ges/ges-clip.c @@ -47,6 +47,7 @@ static gboolean _ripple_end (GESTimelineElement * element, GstClockTime end); static gboolean _roll_start (GESTimelineElement * element, GstClockTime start); static gboolean _roll_end (GESTimelineElement * element, GstClockTime end); static gboolean _trim (GESTimelineElement * element, GstClockTime start); +static void _compute_height (GESContainer * container); G_DEFINE_ABSTRACT_TYPE (GESClip, ges_clip, GES_TYPE_CONTAINER); @@ -204,6 +205,7 @@ _set_priority (GESTimelineElement * element, guint32 priority) _set_priority0 (child, real_tck_prio); } _ges_container_set_children_control_mode (container, GES_CHILDREN_UPDATE); + _compute_height (container); return TRUE; } @@ -214,14 +216,17 @@ _set_priority (GESTimelineElement * element, guint32 priority) * * ****************************************************/ -static guint32 +static void _compute_height (GESContainer * container) { GList *tmp; guint32 min_prio = G_MAXUINT32, max_prio = 0; - if (container->children == NULL) - return 0; + if (container->children == NULL) { + /* FIXME Why not 0! */ + _ges_container_set_height (container, 1); + return; + } /* Go over all childs and check if height has changed */ for (tmp = container->children; tmp; tmp = tmp->next) { @@ -233,7 +238,7 @@ _compute_height (GESContainer * container) max_prio = tck_priority; } - return max_prio - min_prio + 1; + _ges_container_set_height (container, max_prio - min_prio + 1); } static void @@ -312,6 +317,18 @@ _remove_child (GESContainer * container, GESTimelineElement * element) return TRUE; } +static void +_child_added (GESContainer * container, GESTimelineElement * element) +{ + _compute_height (container); +} + +static void +_child_removed (GESContainer * container, GESTimelineElement * element) +{ + _compute_height (container); +} + static void add_tlobj_to_list (gpointer key, gpointer tlobj, GList ** list) { @@ -665,9 +682,10 @@ ges_clip_class_init (GESClipClass * klass) /* TODO implement the deep_copy Virtual method */ container_class->get_priority_range = _get_priority_range; - container_class->compute_height = _compute_height; container_class->add_child = _add_child; container_class->remove_child = _remove_child; + container_class->child_removed = _child_removed; + container_class->child_added = _child_added; container_class->ungroup = _ungroup; container_class->group = _group; container_class->grouping_priority = G_MAXUINT; diff --git a/ges/ges-container.c b/ges/ges-container.c index bd8083e250..5ea7f57a09 100644 --- a/ges/ges-container.c +++ b/ges/ges-container.c @@ -93,20 +93,6 @@ static GParamSpec *properties[PROP_LAST]; /************************ * Private methods * ************************/ -static void -update_height (GESContainer * container) -{ - guint32 height; - - height = GES_CONTAINER_GET_CLASS (container)->compute_height (container); - - if (container->height != height) { - container->height = height; - GST_DEBUG_OBJECT (container, "Updating height %i", container->height); - g_object_notify (G_OBJECT (container), "height"); - } -} - static void _free_mapping (ChildMapping * mapping) { @@ -407,8 +393,6 @@ _child_priority_changed_cb (GESTimelineElement * child, if (priv->children_control_mode == GES_CHILDREN_IGNORE_NOTIFIES) return; - update_height (container); - /* Update mapping */ map = g_hash_table_lookup (priv->mappings, child); g_assert (map); @@ -444,10 +428,16 @@ _ges_container_set_children_control_mode (GESContainer * container, GESChildrenControlMode children_control_mode) { container->priv->children_control_mode = children_control_mode; +} - if (children_control_mode == GES_CHILDREN_UPDATE) - update_height (container); - +void +_ges_container_set_height (GESContainer * container, guint32 height) +{ + if (container->height != height) { + container->height = height; + GST_DEBUG_OBJECT (container, "Updating height %i", container->height); + g_object_notify (G_OBJECT (container), "height"); + } } /********************************************** @@ -519,7 +509,6 @@ ges_container_add (GESContainer * container, GESTimelineElement * child) mapping->priority_notifyid = g_signal_connect (G_OBJECT (child), "notify::priority", G_CALLBACK (_child_priority_changed_cb), container); - update_height (container); if (ges_timeline_element_set_parent (child, GES_TIMELINE_ELEMENT (container)) diff --git a/ges/ges-container.h b/ges/ges-container.h index d03894bce7..aab80a2f8d 100644 --- a/ges/ges-container.h +++ b/ges/ges-container.h @@ -104,7 +104,6 @@ struct _GESContainer * @ungroup: Ungroups the #GESTimelineElement contained in this #GESContainer, creating new * @group: Groups the #GESContainers together * #GESContainer containing those #GESTimelineElement apropriately. - * @compute_height: Return the @height of the container */ struct _GESContainerClass { @@ -120,7 +119,6 @@ struct _GESContainerClass void (*get_priority_range) (GESContainer *container, guint32 *min_prio, guint32 *max_prio); GList* (*ungroup) (GESContainer *container, gboolean recursive); GESContainer * (*group) (GList *containers); - guint32 (*compute_height) (GESContainer *container); gboolean (*edit) (GESContainer * container, GList * layers, gint new_layer_priority, GESEditMode mode, @@ -148,6 +146,8 @@ GESContainer *ges_container_group (GList *containers); /* To be used by subclasses only */ void _ges_container_set_children_control_mode (GESContainer * container, GESChildrenControlMode children_control_mode); +void _ges_container_set_height (GESContainer * container, + guint32 height); gboolean ges_container_edit (GESContainer * container, GList * layers, gint new_layer_priority, GESEditMode mode,