container: Let subclasses decide when height change should be computed

API:
   - GESContainer.compute_height vmethod
   + _ges_container_set_height
This commit is contained in:
Thibault Saunier 2013-06-28 14:39:16 -04:00 committed by Mathieu Duponchelle
parent b5858c5b04
commit 8bc88a2ba8
3 changed files with 34 additions and 27 deletions

View file

@ -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;

View file

@ -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))

View file

@ -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,