mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
GESTimelineLayer: Add a 'priority' property
This commit is contained in:
parent
dafe3d2bb4
commit
9b1a434e95
3 changed files with 87 additions and 2 deletions
|
@ -123,6 +123,7 @@ GESTimelineLayerClass
|
||||||
ges_timeline_layer_add_object
|
ges_timeline_layer_add_object
|
||||||
ges_timeline_layer_new
|
ges_timeline_layer_new
|
||||||
ges_timeline_layer_remove_object
|
ges_timeline_layer_remove_object
|
||||||
|
ges_timeline_layer_set_priority
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
ges_timeline_layer_set_timeline
|
ges_timeline_layer_set_timeline
|
||||||
ges_timeline_layer_get_type
|
ges_timeline_layer_get_type
|
||||||
|
|
|
@ -32,6 +32,12 @@
|
||||||
|
|
||||||
G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_PRIORITY,
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
OBJECT_ADDED,
|
OBJECT_ADDED,
|
||||||
|
@ -45,7 +51,12 @@ static void
|
||||||
ges_timeline_layer_get_property (GObject * object, guint property_id,
|
ges_timeline_layer_get_property (GObject * object, guint property_id,
|
||||||
GValue * value, GParamSpec * pspec)
|
GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
|
GESTimelineLayer *layer = GES_TIMELINE_LAYER (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
|
case PROP_PRIORITY:
|
||||||
|
g_value_set_uint (value, layer->priority);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +66,12 @@ static void
|
||||||
ges_timeline_layer_set_property (GObject * object, guint property_id,
|
ges_timeline_layer_set_property (GObject * object, guint property_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
|
GESTimelineLayer *layer = GES_TIMELINE_LAYER (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
|
case PROP_PRIORITY:
|
||||||
|
ges_timeline_layer_set_priority (layer, g_value_get_uint (value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +106,16 @@ ges_timeline_layer_class_init (GESTimelineLayerClass * klass)
|
||||||
object_class->dispose = ges_timeline_layer_dispose;
|
object_class->dispose = ges_timeline_layer_dispose;
|
||||||
object_class->finalize = ges_timeline_layer_finalize;
|
object_class->finalize = ges_timeline_layer_finalize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GESTimelineLayer:priority
|
||||||
|
*
|
||||||
|
* The priority of the layer in the #GESTimeline. 0 is the highest
|
||||||
|
* priority.
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (object_class, PROP_PRIORITY,
|
||||||
|
g_param_spec_uint ("priority", "Priority",
|
||||||
|
"The priority of the layer", 0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GESTimelineLayer::object-added
|
* GESTimelineLayer::object-added
|
||||||
* @layer: the #GESTimelineLayer
|
* @layer: the #GESTimelineLayer
|
||||||
|
@ -121,6 +147,10 @@ ges_timeline_layer_class_init (GESTimelineLayerClass * klass)
|
||||||
static void
|
static void
|
||||||
ges_timeline_layer_init (GESTimelineLayer * self)
|
ges_timeline_layer_init (GESTimelineLayer * self)
|
||||||
{
|
{
|
||||||
|
/* TODO : Keep those 3 values in sync */
|
||||||
|
self->priority = 0;
|
||||||
|
self->min_gnl_priority = 0;
|
||||||
|
self->max_gnl_priority = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,6 +223,9 @@ ges_timeline_layer_add_object (GESTimelineLayer * layer,
|
||||||
/* Inform the object it's now in this layer */
|
/* Inform the object it's now in this layer */
|
||||||
ges_timeline_object_set_layer (object, layer);
|
ges_timeline_object_set_layer (object, layer);
|
||||||
|
|
||||||
|
/* Set the priority. */
|
||||||
|
ges_timeline_object_set_priority (object, layer->min_gnl_priority);
|
||||||
|
|
||||||
/* emit 'object-added' */
|
/* emit 'object-added' */
|
||||||
g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_ADDED], 0, object);
|
g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_ADDED], 0, object);
|
||||||
|
|
||||||
|
@ -236,3 +269,44 @@ ges_timeline_layer_remove_object (GESTimelineLayer * layer,
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_timeline_layer_resync_priorities:
|
||||||
|
* @layer: a #GESTimelineLayer
|
||||||
|
*
|
||||||
|
* Resyncs the priorities of the objects controlled by @layer.
|
||||||
|
* This method */
|
||||||
|
gboolean
|
||||||
|
ges_timeline_layer_resync_priorities (GESTimelineLayer * layer)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
/* TODO : Inhibit composition updates while doing this.
|
||||||
|
* Ideally we want to do it from an even higher level, but here will
|
||||||
|
* do in the meantime. */
|
||||||
|
|
||||||
|
/* TODO : This is the dumb version where we put everything linearly,
|
||||||
|
* will need to be adjusted for more complex usages (like with
|
||||||
|
* transitions). */
|
||||||
|
for (tmp = layer->objects_start; tmp; tmp = tmp->next) {
|
||||||
|
ges_timeline_object_set_priority ((GESTimelineObject *) tmp->data,
|
||||||
|
layer->min_gnl_priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority)
|
||||||
|
{
|
||||||
|
GST_DEBUG ("layer:%p, priority:%d", layer, priority);
|
||||||
|
|
||||||
|
if (priority != layer->priority) {
|
||||||
|
layer->priority = priority;
|
||||||
|
layer->min_gnl_priority = (priority * 10);
|
||||||
|
layer->max_gnl_priority = ((priority + 1) * 10) - 1;
|
||||||
|
|
||||||
|
/* FIXME : Update controlled object's gnl priority accordingly */
|
||||||
|
ges_timeline_layer_resync_priorities (layer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -46,9 +46,17 @@ G_BEGIN_DECLS
|
||||||
struct _GESTimelineLayer {
|
struct _GESTimelineLayer {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
GESTimeline *timeline; /* The timeline where this layer is being used */
|
GESTimeline *timeline; /* The timeline where this layer is being used
|
||||||
|
*/
|
||||||
|
|
||||||
GSList * objects_start; /* The TimelineObjects sorted by start and priority */
|
GSList * objects_start; /* The TimelineObjects sorted by start and
|
||||||
|
* priority */
|
||||||
|
|
||||||
|
guint32 priority; /* The priority of the layer within the
|
||||||
|
* containing timeline */
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
guint32 min_gnl_priority, max_gnl_priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GESTimelineLayerClass {
|
struct _GESTimelineLayerClass {
|
||||||
|
@ -67,6 +75,8 @@ void ges_timeline_layer_set_timeline (GESTimelineLayer * layer, GESTimeline * ti
|
||||||
gboolean ges_timeline_layer_add_object (GESTimelineLayer * layer, GESTimelineObject * object);
|
gboolean ges_timeline_layer_add_object (GESTimelineLayer * layer, GESTimelineObject * object);
|
||||||
gboolean ges_timeline_layer_remove_object (GESTimelineLayer * layer, GESTimelineObject * object);
|
gboolean ges_timeline_layer_remove_object (GESTimelineLayer * layer, GESTimelineObject * object);
|
||||||
|
|
||||||
|
void ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _GES_TIMELINE_LAYER */
|
#endif /* _GES_TIMELINE_LAYER */
|
||||||
|
|
Loading…
Reference in a new issue