G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
klass->need_fill_track = TRUE;
+ klass->snaps = FALSE;
}
static void
GList *tmp;
GESTrackObject *tr;
ObjectMapping *map;
+ GESTimeline *timeline = NULL;
+ GESTimelineObjectPrivate *priv = object->priv;
+ gboolean snap = FALSE;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
GST_DEBUG ("object:%p, start:%" GST_TIME_FORMAT,
object, GST_TIME_ARGS (start));
+ /* If the class has snapping enabled and the object is in a timeline,
+ * we snap */
+ if (priv->layer && GES_TIMELINE_OBJECT_GET_CLASS (object)->snaps)
+ timeline = ges_timeline_layer_get_timeline (object->priv->layer);
+ snap = timeline && priv->initiated_move == NULL ? TRUE : FALSE;
+
object->priv->ignore_notifies = TRUE;
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
continue;
}
- ges_track_object_set_start (tr, new_start);
+ /* Make the snapping happen if in a timeline */
+ if (snap)
+ ges_timeline_move_object_simple (timeline, tr, NULL, GES_EDGE_NONE,
+ start);
+ else
+ ges_track_object_set_start (tr, start);
} else {
/* ... or update the offset */
map->start_offset = start - tr->start;
* @start: the position in #GstClockTime
*
* Set the position of the object in its containing layer
+ *
+ * Note that if the timeline snap-distance property of the timeline containing
+ * @object is set, @object will properly snap to its neighboors.
*/
void
ges_timeline_object_set_start (GESTimelineObject * object, guint64 start)
{
GList *tmp;
GESTrackObject *tr;
+ GESTimeline *timeline = NULL;
+ GESTimelineObjectPrivate *priv = object->priv;
+ gboolean snap = FALSE;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
GST_DEBUG ("object:%p, duration:%" GST_TIME_FORMAT,
object, GST_TIME_ARGS (duration));
+ /* If the class has snapping enabled and the object is in a timeline,
+ * we snap */
+ if (priv->layer && GES_TIMELINE_OBJECT_GET_CLASS (object)->snaps)
+ timeline = ges_timeline_layer_get_timeline (object->priv->layer);
+
+ snap = timeline && priv->initiated_move == NULL ? TRUE : FALSE;
+
for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
tr = (GESTrackObject *) tmp->data;
- if (ges_track_object_is_locked (tr))
- /* call set_duration on each trackobject */
- ges_track_object_set_duration (tr, duration);
+ if (ges_track_object_is_locked (tr)) {
+ /* call set_duration on each trackobject
+ * and make the snapping happen if in a timeline */
+ if (G_LIKELY (snap))
+ ges_timeline_trim_object_simple (timeline, tr, NULL, GES_EDGE_END,
+ tr->start + duration, TRUE);
+ else
+ ges_track_object_set_duration (tr, duration);
+ }
}
object->duration = duration;
* @duration: the duration in #GstClockTime
*
* Set the duration of the object
+ *
+ * Note that if the timeline snap-distance property of the timeline containing
+ * @object is set, @object will properly snap to its neighboors.
*/
void
ges_timeline_object_set_duration (GESTimelineObject * object, guint64 duration)
priority_offset = new_layer_priority -
ges_timeline_layer_get_priority (layer);
- ret &= timeline_context_to_layer (layer->timeline, object, priority_offset);
+ ret &= timeline_context_to_layer (layer->timeline, priority_offset);
}
return ret;
* #GESTrack.
* @fill_track_object: method to fill an associated #GESTrackObject.
* @need_fill_track: Set to TRUE if @fill_track_object needs to be called.
+ * @snaps: Set to %TRUE if the objects of this type snap with
+ * other objects in a timeline %FALSE otherwise (default is %FALSE). Basically only
+ * sources snap.
* @track_object_added: Should be overridden by subclasses if they need to perform an
* operation when a #GESTrackObject is added. Since: 0.10.2
* @track_object_released: Should be overridden by subclasses if they need to perform
/* FIXME : might need a release_track_object */
GESFillTrackObjectFunc fill_track_object;
gboolean need_fill_track;
+ gboolean snaps;
void (*track_object_added) (GESTimelineObject *object,
GESTrackObject *tck_object);
/*< private >*/
/* Padding for API extension */
- gpointer _ges_reserved[GES_PADDING - 3];
+ gpointer _ges_reserved[GES_PADDING - 4];
};
GType ges_timeline_object_get_type (void);