return TRUE;
}
+static guint32
+_get_layer_priority (GESTimelineElement * element)
+{
+ GESClip *clip = GES_CLIP (element);
+
+ if (clip->priv->layer == NULL)
+ return GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY;
+
+ return ges_layer_get_priority (clip->priv->layer);
+}
+
/****************************************************
* *
* GESContainer virtual methods implementation *
element_class->paste = _paste;
element_class->deep_copy = _deep_copy;
element_class->lookup_child = _lookup_child;
+ element_class->get_layer_priority = _get_layer_priority;
container_class->add_child = _add_child;
container_class->remove_child = _remove_child;
for (tmp = GES_CONTAINER_CHILDREN (group); tmp; tmp = tmp->next) {
GESTimelineElement *child = tmp->data;
guint32 child_prio = GES_IS_CLIP (child) ?
- ges_clip_get_layer_priority (GES_CLIP (child)) : _PRIORITY (child);
+ GES_TIMELINE_ELEMENT_LAYER_PRIORITY (child) : _PRIORITY (child);
_ges_container_set_priority_offset (container,
child, min_layer_prio - child_prio);
ChildSignalIds *sigids;
gchar *signals_ids_key;
GESLayer *old_layer, *new_layer;
- gint offset, layer_prio = ges_clip_get_layer_priority (GES_CLIP (clip));
+ gint offset, layer_prio = GES_TIMELINE_ELEMENT_LAYER_PRIORITY (clip);
GESContainer *container = GES_CONTAINER (group);
offset = _ges_container_get_priority_offset (container, clip);
if (child != container->initiated_move) {
if (GES_IS_CLIP (child)) {
- guint32 layer_prio =
- ges_clip_get_layer_priority (GES_CLIP (child)) + diff;
+ guint32 layer_prio = GES_TIMELINE_ELEMENT_LAYER_PRIORITY (child) + diff;
GST_DEBUG_OBJECT (child, "moving from layer: %i to %i",
- ges_clip_get_layer_priority (GES_CLIP (child)), layer_prio);
+ GES_TIMELINE_ELEMENT_LAYER_PRIORITY (child), layer_prio);
ges_clip_move_to_layer (GES_CLIP (child),
g_list_nth_data (layers, layer_prio));
} else if (GES_IS_GROUP (child)) {
return g_object_ref (res);
}
+/**
+ * ges_timeline_element_get_layer_priority:
+ * @self: A #GESTimelineElement
+ *
+ * Returns: The priority of the first layer the element is in (note that only
+ * groups can span over several layers). %GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY
+ * means that the element is not in a layer.
+ */
+guint32
+ges_timeline_element_get_layer_priority (GESTimelineElement * self)
+{
+ g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self),
+ GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY);
+
+ if (!GES_TIMELINE_ELEMENT_GET_CLASS (self)->get_layer_priority)
+ return self->priority;
+
+ return GES_TIMELINE_ELEMENT_GET_CLASS (self)->get_layer_priority (self);
+}
+
/* Internal */
gdouble
ges_timeline_element_get_media_duration_factor (GESTimelineElement * self)
return self->priv->flags;
}
-gint32
-_layer_priority (GESTimelineElement * element)
-{
- if (GES_IS_CLIP (element))
- return ges_clip_get_layer_priority (GES_CLIP (element));
-
- if (GES_IS_TRACK_ELEMENT (element))
- return element->priority / LAYER_HEIGHT;
-
- return element->priority;
-}
-
void
ges_timeline_element_set_flags (GESTimelineElement * self,
GESTimelineElementFlags flags)
*/
#define GES_TIMELINE_ELEMENT_PRIORITY(obj) (((GESTimelineElement*)obj)->priority)
+/**
+ * GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY:
+ *
+ * Layer priority when the element is not in a layer
+ */
+#define GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY ((guint32) -1)
+
+/**
+ * GES_TIMELINE_ELEMENT_LAYER_PRIORITY:
+ * @obj: The object to retrieve the layer priority from
+ *
+ * See #ges_timeline_element_get_layer_priority
+ */
+#define GES_TIMELINE_ELEMENT_LAYER_PRIORITY(obj) (ges_timeline_element_get_layer_priority(((GESTimelineElement*)obj)))
+
/**
* GES_TIMELINE_ELEMENT_PARENT:
* @obj: a #GESTimelineElement
void (*set_child_property) (GESTimelineElement * self, GObject *child,
GParamSpec *pspec, GValue *value);
+ guint32 (*get_layer_priority) (GESTimelineElement *self);
+
/*< private > */
/* Padding for API extension */
- gpointer _ges_reserved[GES_PADDING_LARGE - 3];
+ gpointer _ges_reserved[GES_PADDING_LARGE - 4];
};
GES_API
GES_API
GESTrackType ges_timeline_element_get_track_types (GESTimelineElement * self);
+GES_API
+guint32 ges_timeline_element_get_layer_priority (GESTimelineElement * self);
+
G_END_DECLS
#endif /* _GES_TIMELINE_ELEMENT_H_ */
return FALSE;
}
+static guint32
+_get_layer_priority (GESTimelineElement * element)
+{
+ if (!element->parent)
+ return GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY;
+
+ return ges_timeline_element_get_layer_priority (element->parent);
+}
+
static void
ges_track_element_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
element_class->set_priority = _set_priority;
element_class->get_track_types = _get_track_types;
element_class->deep_copy = ges_track_element_copy_properties;
+ element_class->get_layer_priority = _get_layer_priority;
klass->create_gnl_object = ges_track_element_create_gnl_object_func;
klass->list_children_properties = default_list_children_properties;
CHECK_OBJECT_PROPS (c, 10, 0, 10);
CHECK_OBJECT_PROPS (c1, 20, 0, 10);
CHECK_OBJECT_PROPS (group, 10, 0, 20);
- assert_equals_int (ges_clip_get_layer_priority (c), 0);
- assert_equals_int (ges_clip_get_layer_priority (c1), 1);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c), 0);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c1), 1);
ges_layer_set_priority (layer2, 0);
ges_layer_set_priority (layer, 1);
ges_layer_set_priority (layer1, 2);
- assert_equals_int (ges_clip_get_layer_priority (c), 1);
- assert_equals_int (ges_clip_get_layer_priority (c1), 2);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c), 1);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c1), 2);
/* Our timeline
*
CHECK_OBJECT_PROPS (c, 10, 0, 10);
CHECK_OBJECT_PROPS (c1, 20, 0, 10);
CHECK_OBJECT_PROPS (group, 10, 0, 20);
- assert_equals_int (ges_clip_get_layer_priority (c), 0);
- assert_equals_int (ges_clip_get_layer_priority (c1), 1);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c), 0);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c1), 1);
/* Our timeline
*
CHECK_OBJECT_PROPS (c, 10, 0, 10);
CHECK_OBJECT_PROPS (c1, 20, 0, 10);
CHECK_OBJECT_PROPS (group, 10, 0, 20);
- assert_equals_int (ges_clip_get_layer_priority (c), 1);
- assert_equals_int (ges_clip_get_layer_priority (c1), 2);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c), 1);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (c1), 2);
gst_object_unref (timeline);
gst_object_unref (asset);
CHECK_OBJECT_PROPS (trackelement, 32, 5, 3);
CHECK_OBJECT_PROPS (trackelement1, 20, 0, 10);
CHECK_OBJECT_PROPS (trackelement2, 35, 0, 60);
- layer = ges_clip_get_layer (GES_CLIP (clip));
- assert_equals_int (ges_layer_get_priority (layer), 2);
- gst_object_unref (layer);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (clip), 2);
/* Roll end clip to 50
* New timeline:
GES_EDGE_END, 52) == TRUE);
CHECK_OBJECT_PROPS (trackelement, 32, 5, 20);
CHECK_OBJECT_PROPS (trackelement1, 20, 0, 10);
- CHECK_OBJECT_PROPS (trackelement2, 52, 0, 60)
- layer = ges_clip_get_layer (GES_CLIP (clip));
- assert_equals_int (ges_layer_get_priority (layer), 2);
- gst_object_unref (layer);
+ CHECK_OBJECT_PROPS (trackelement2, 52, 0, 60);
+ assert_equals_int (GES_TIMELINE_ELEMENT_LAYER_PRIORITY (clip), 2);
/* Little check that we have 4 layers in the timeline */