timeline: add auto-transition

API:
 ges_timeline_get_auto_transition
 ges_timeline_set_auto_transition
 GESTimeline::auto-transition
This commit is contained in:
Anton Belka 2013-04-24 15:18:01 +03:00 committed by Thibault Saunier
parent 51403f65be
commit 7d999c5ab8
3 changed files with 78 additions and 0 deletions

View file

@ -274,6 +274,8 @@ ges_timeline_get_layers
ges_timeline_get_track_for_pad
ges_timeline_get_duration
ges_timeline_get_project
ges_timeline_get_auto_transition
ges_timeline_set_auto_transition
<SUBSECTION Standard>
GESTimelinePrivate
GESTimelineClass

View file

@ -124,6 +124,9 @@ struct _GESTimelinePrivate
/* The duration of the timeline */
gint64 duration;
/* The auto-transition of the timeline */
gboolean auto_transition;
/* Timeline edition modes and snapping management */
guint64 snapping_distance;
@ -177,6 +180,7 @@ enum
{
PROP_0,
PROP_DURATION,
PROP_AUTO_TRANSITION,
PROP_SNAPPING_DISTANCE,
PROP_UPDATE,
PROP_LAST
@ -255,6 +259,9 @@ ges_timeline_get_property (GObject * object, guint property_id,
case PROP_DURATION:
g_value_set_uint64 (value, timeline->priv->duration);
break;
case PROP_AUTO_TRANSITION:
g_value_set_boolean (value, timeline->priv->auto_transition);
break;
case PROP_SNAPPING_DISTANCE:
g_value_set_uint64 (value, timeline->priv->snapping_distance);
break;
@ -273,6 +280,9 @@ ges_timeline_set_property (GObject * object, guint property_id,
GESTimeline *timeline = GES_TIMELINE (object);
switch (property_id) {
case PROP_AUTO_TRANSITION:
ges_timeline_set_auto_transition (timeline, g_value_get_boolean (value));
break;
case PROP_SNAPPING_DISTANCE:
timeline->priv->snapping_distance = g_value_get_uint64 (value);
break;
@ -369,6 +379,15 @@ ges_timeline_class_init (GESTimelineClass * klass)
properties[PROP_DURATION]);
/**
* GESTimeline:auto-transition:
*
* Sets whether transitions are added automagically when clips overlap.
*/
g_object_class_install_property (object_class, PROP_AUTO_TRANSITION,
g_param_spec_boolean ("auto-transition", "Auto-Transition",
"whether the transitions are added", FALSE, G_PARAM_READWRITE));
/**
* GESTimeline:snapping-distance:
*
* Distance (in nanoseconds) from which a moving object will snap
@ -512,6 +531,7 @@ ges_timeline_init (GESTimeline * self)
self->layers = NULL;
self->tracks = NULL;
self->priv->duration = 0;
self->priv->auto_transition = FALSE;
priv->snapping_distance = 0;
/* Move context initialization */
@ -2302,6 +2322,7 @@ ges_timeline_append_layer (GESTimeline * timeline)
gboolean
ges_timeline_add_layer (GESTimeline * timeline, GESLayer * layer)
{
gboolean auto_transition;
GList *objects, *tmp;
GST_DEBUG ("timeline:%p, layer:%p", timeline, layer);
@ -2318,6 +2339,14 @@ ges_timeline_add_layer (GESTimeline * timeline, GESLayer * layer)
return FALSE;
}
auto_transition = ges_layer_get_auto_transition (layer);
/* If the user doesn't explicitely set layer auto_transition, then set our */
if (!auto_transition) {
auto_transition = ges_timeline_get_auto_transition (timeline);
ges_layer_set_auto_transition (layer, auto_transition);
}
gst_object_ref_sink (layer);
timeline->layers = g_list_insert_sorted (timeline->layers, layer,
(GCompareFunc) sort_layers);
@ -2714,3 +2743,47 @@ ges_timeline_get_duration (GESTimeline * timeline)
return timeline->priv->duration;
}
/**
* ges_timeline_get_auto_transition:
* @timeline: a #GESTimeline
*
* Gets whether transitions are automatically added when objects
* overlap or not.
*
* Returns: %TRUE if transitions are automatically added, else %FALSE.
*/
gboolean
ges_timeline_get_auto_transition (GESTimeline * timeline)
{
g_return_val_if_fail (GES_IS_TIMELINE (timeline), 0);
return timeline->priv->auto_transition;
}
/**
* ges_timeline_set_auto_transition:
* @timeline: a #GESLayer
* @auto_transition: whether the auto_transition is active
*
* Sets the layer to the given @auto_transition. See the documentation of the
* property auto_transition for more information.
*/
void
ges_timeline_set_auto_transition (GESTimeline * timeline,
gboolean auto_transition)
{
GList *layers;
GESLayer *layer;
g_return_if_fail (GES_IS_TIMELINE (timeline));
timeline->priv->auto_transition = auto_transition;
g_object_notify (G_OBJECT (timeline), "auto-transition");
layers = timeline->layers;
for (; layers; layers = layers->next) {
layer = layers->data;
ges_layer_set_auto_transition (layer, auto_transition);
}
}

View file

@ -121,6 +121,9 @@ gboolean ges_timeline_is_updating (GESTimeline * timeline);
GstClockTime ges_timeline_get_duration (GESTimeline *timeline);
gboolean ges_timeline_get_auto_transition (GESTimeline * timeline);
void ges_timeline_set_auto_transition (GESTimeline * timeline, gboolean auto_transition);
G_END_DECLS
#endif /* _GES_TIMELINE */