mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 10:40:34 +00:00
GESTimelineTextOverlay/TrackTextOverlay: add xpos/ypos setting
Vertical and horizontal position properties of the text overlay can be set and get.
This commit is contained in:
parent
09ef6dbeac
commit
63a82c5274
5 changed files with 241 additions and 1 deletions
|
@ -47,6 +47,8 @@ struct _GESTimelineTextOverlayPrivate
|
|||
GESTextHAlign halign;
|
||||
GESTextVAlign valign;
|
||||
guint32 color;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -57,6 +59,8 @@ enum
|
|||
PROP_HALIGNMENT,
|
||||
PROP_VALIGNMENT,
|
||||
PROP_COLOR,
|
||||
PROP_XPOS,
|
||||
PROP_YPOS,
|
||||
};
|
||||
|
||||
static GESTrackObject
|
||||
|
@ -86,6 +90,12 @@ ges_timeline_text_overlay_get_property (GObject * object, guint property_id,
|
|||
case PROP_COLOR:
|
||||
g_value_set_uint (value, priv->color);
|
||||
break;
|
||||
case PROP_XPOS:
|
||||
g_value_set_double (value, priv->xpos);
|
||||
break;
|
||||
case PROP_YPOS:
|
||||
g_value_set_double (value, priv->ypos);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
@ -113,6 +123,12 @@ ges_timeline_text_overlay_set_property (GObject * object, guint property_id,
|
|||
case PROP_COLOR:
|
||||
ges_timeline_text_overlay_set_color (tfs, g_value_get_uint (value));
|
||||
break;
|
||||
case PROP_XPOS:
|
||||
ges_timeline_text_overlay_set_xpos (tfs, g_value_get_double (value));
|
||||
break;
|
||||
case PROP_YPOS:
|
||||
ges_timeline_text_overlay_set_ypos (tfs, g_value_get_double (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
@ -201,6 +217,26 @@ ges_timeline_text_overlay_class_init (GESTimelineTextOverlayClass * klass)
|
|||
g_object_class_install_property (object_class, PROP_COLOR,
|
||||
g_param_spec_uint ("color", "Color", "The color of the text",
|
||||
0, G_MAXUINT32, G_MAXUINT32, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
/**
|
||||
* GESTimelineTextOverlay:xpos
|
||||
*
|
||||
* The horizontal position of the text
|
||||
*/
|
||||
|
||||
g_object_class_install_property (object_class, PROP_XPOS,
|
||||
g_param_spec_double ("xpos", "Xpos", "The horizontal position",
|
||||
0, 1, 0.5, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
/**
|
||||
* GESTimelineTextOverlay:ypos
|
||||
*
|
||||
* The vertical position of the text
|
||||
*/
|
||||
|
||||
g_object_class_install_property (object_class, PROP_YPOS,
|
||||
g_param_spec_double ("ypos", "Ypos", "The vertical position",
|
||||
0, 1, 0.5, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -216,6 +252,8 @@ ges_timeline_text_overlay_init (GESTimelineTextOverlay * self)
|
|||
self->priv->halign = DEFAULT_PROP_HALIGNMENT;
|
||||
self->priv->valign = DEFAULT_PROP_VALIGNMENT;
|
||||
self->priv->color = G_MAXUINT32;
|
||||
self->priv->xpos = 0.5;
|
||||
self->priv->ypos = 0.5;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,6 +426,70 @@ ges_timeline_text_overlay_set_color (GESTimelineTextOverlay * self,
|
|||
g_list_free (trackobjects);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_text_overlay_set_xpos:
|
||||
* @self: the #GESTimelineTextOverlay* to set
|
||||
* @position: The horizontal position @self is being set to
|
||||
*
|
||||
* Sets the horizontal position of the text.
|
||||
*
|
||||
*/
|
||||
void
|
||||
ges_timeline_text_overlay_set_xpos (GESTimelineTextOverlay * self,
|
||||
gdouble position)
|
||||
{
|
||||
GList *tmp, *trackobjects;
|
||||
GESTimelineObject *object = (GESTimelineObject *) self;
|
||||
|
||||
GST_DEBUG ("self:%p, xpos:%f", self, position);
|
||||
|
||||
self->priv->xpos = position;
|
||||
|
||||
trackobjects = ges_timeline_object_get_track_objects (object);
|
||||
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
||||
GESTrackObject *trackobject = (GESTrackObject *) tmp->data;
|
||||
|
||||
if (ges_track_object_get_track (trackobject)->type == GES_TRACK_TYPE_VIDEO)
|
||||
ges_track_text_overlay_set_xpos (GES_TRACK_TEXT_OVERLAY
|
||||
(trackobject), self->priv->xpos);
|
||||
|
||||
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
||||
}
|
||||
g_list_free (trackobjects);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_text_overlay_set_ypos:
|
||||
* @self: the #GESTimelineTextOverlay* to set
|
||||
* @position: The vertical position @self is being set to
|
||||
*
|
||||
* Sets the vertical position of the text.
|
||||
*
|
||||
*/
|
||||
void
|
||||
ges_timeline_text_overlay_set_ypos (GESTimelineTextOverlay * self,
|
||||
gdouble position)
|
||||
{
|
||||
GList *tmp, *trackobjects;
|
||||
GESTimelineObject *object = (GESTimelineObject *) self;
|
||||
|
||||
GST_DEBUG ("self:%p, ypos:%f", self, position);
|
||||
|
||||
self->priv->ypos = position;
|
||||
|
||||
trackobjects = ges_timeline_object_get_track_objects (object);
|
||||
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
||||
GESTrackObject *trackobject = (GESTrackObject *) tmp->data;
|
||||
|
||||
if (ges_track_object_get_track (trackobject)->type == GES_TRACK_TYPE_VIDEO)
|
||||
ges_track_text_overlay_set_ypos (GES_TRACK_TEXT_OVERLAY
|
||||
(trackobject), self->priv->ypos);
|
||||
|
||||
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
||||
}
|
||||
g_list_free (trackobjects);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_text_overlay_get_text:
|
||||
* @self: a #GESTimelineTextOverlay
|
||||
|
@ -460,6 +562,35 @@ ges_timeline_text_overlay_get_color (GESTimelineTextOverlay * self)
|
|||
return self->priv->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_text_overlay_get_xpos:
|
||||
* @self: a #GESTimelineTextOverlay
|
||||
*
|
||||
* Get the horizontal position used by @source.
|
||||
*
|
||||
* Returns: The horizontal position used by @source.
|
||||
*/
|
||||
|
||||
const gdouble
|
||||
ges_timeline_text_overlay_get_xpos (GESTimelineTextOverlay * self)
|
||||
{
|
||||
return self->priv->xpos;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_text_overlay_get_ypos:
|
||||
* @self: a #GESTimelineTextOverlay
|
||||
*
|
||||
* Get the vertical position used by @source.
|
||||
*
|
||||
* Returns: The vertical position used by @source.
|
||||
*/
|
||||
|
||||
const gdouble
|
||||
ges_timeline_text_overlay_get_ypos (GESTimelineTextOverlay * self)
|
||||
{
|
||||
return self->priv->ypos;
|
||||
}
|
||||
|
||||
static GESTrackObject *
|
||||
ges_timeline_text_overlay_create_track_object (GESTimelineObject * obj,
|
||||
|
@ -482,6 +613,8 @@ ges_timeline_text_overlay_create_track_object (GESTimelineObject * obj,
|
|||
ges_track_text_overlay_set_valignment ((GESTrackTextOverlay *) res,
|
||||
priv->valign);
|
||||
ges_track_text_overlay_set_color ((GESTrackTextOverlay *) res, priv->color);
|
||||
ges_track_text_overlay_set_xpos ((GESTrackTextOverlay *) res, priv->xpos);
|
||||
ges_track_text_overlay_set_ypos ((GESTrackTextOverlay *) res, priv->ypos);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
@ -92,6 +92,14 @@ void
|
|||
ges_timeline_text_overlay_set_color (GESTimelineTextOverlay * self,
|
||||
guint32 color);
|
||||
|
||||
void
|
||||
ges_timeline_text_overlay_set_xpos (GESTimelineTextOverlay * self,
|
||||
gdouble position);
|
||||
|
||||
void
|
||||
ges_timeline_text_overlay_set_ypos (GESTimelineTextOverlay * self,
|
||||
gdouble position);
|
||||
|
||||
const gchar *ges_timeline_text_overlay_get_text (GESTimelineTextOverlay * self);
|
||||
|
||||
const gchar *ges_timeline_text_overlay_get_font_desc (GESTimelineTextOverlay *
|
||||
|
@ -103,6 +111,12 @@ ges_timeline_text_overlay_get_valignment (GESTimelineTextOverlay * self);
|
|||
const guint32
|
||||
ges_timeline_text_overlay_get_color (GESTimelineTextOverlay * self);
|
||||
|
||||
const gdouble
|
||||
ges_timeline_text_overlay_get_xpos (GESTimelineTextOverlay * self);
|
||||
|
||||
const gdouble
|
||||
ges_timeline_text_overlay_get_ypos (GESTimelineTextOverlay * self);
|
||||
|
||||
GESTextHAlign
|
||||
ges_timeline_text_overlay_get_halignment (GESTimelineTextOverlay * self);
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ struct _GESTrackTextOverlayPrivate
|
|||
GESTextHAlign halign;
|
||||
GESTextVAlign valign;
|
||||
guint32 color;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
GstElement *text_el;
|
||||
};
|
||||
|
||||
|
@ -89,6 +91,8 @@ ges_track_text_overlay_init (GESTrackTextOverlay * self)
|
|||
self->priv->halign = DEFAULT_HALIGNMENT;
|
||||
self->priv->valign = DEFAULT_VALIGNMENT;
|
||||
self->priv->color = G_MAXUINT32;
|
||||
self->priv->xpos = 0.5;
|
||||
self->priv->ypos = 0.5;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -159,6 +163,8 @@ ges_track_text_overlay_create_element (GESTrackObject * object)
|
|||
g_object_set (text, "halignment", (gint) self->priv->halign, "valignment",
|
||||
(gint) self->priv->valign, NULL);
|
||||
g_object_set (text, "color", (guint32) self->priv->color, NULL);
|
||||
g_object_set (text, "xpos", (gdouble) self->priv->xpos, NULL);
|
||||
g_object_set (text, "ypos", (gdouble) self->priv->ypos, NULL);
|
||||
|
||||
ret = gst_bin_new ("overlay-bin");
|
||||
gst_bin_add_many (GST_BIN (ret), text, iconv, oconv, NULL);
|
||||
|
@ -282,6 +288,42 @@ ges_track_text_overlay_set_color (GESTrackTextOverlay * self, guint32 color)
|
|||
g_object_set (self->priv->text_el, "color", color, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_text_overlay_set_xpos:
|
||||
* @self: the #GESTrackTextOverlay* to set
|
||||
* @position: The horizontal position @self is being set to
|
||||
*
|
||||
* Sets the horizontal position of the text.
|
||||
*
|
||||
*/
|
||||
void
|
||||
ges_track_text_overlay_set_xpos (GESTrackTextOverlay * self, gdouble position)
|
||||
{
|
||||
GST_DEBUG ("self:%p, xpos:%f", self, position);
|
||||
|
||||
self->priv->xpos = position;
|
||||
if (self->priv->text_el)
|
||||
g_object_set (self->priv->text_el, "xpos", position, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_text_overlay_set_ypos:
|
||||
* @self: the #GESTrackTextOverlay* to set
|
||||
* @position: The vertical position @self is being set to
|
||||
*
|
||||
* Sets the vertical position of the text.
|
||||
*
|
||||
*/
|
||||
void
|
||||
ges_track_text_overlay_set_ypos (GESTrackTextOverlay * self, gdouble position)
|
||||
{
|
||||
GST_DEBUG ("self:%p, ypos:%f", self, position);
|
||||
|
||||
self->priv->ypos = position;
|
||||
if (self->priv->text_el)
|
||||
g_object_set (self->priv->text_el, "ypos", position, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_text_overlay_get_text:
|
||||
* @self: a GESTrackTextOverlay
|
||||
|
@ -346,13 +388,40 @@ ges_track_text_overlay_get_valignment (GESTrackTextOverlay * self)
|
|||
*
|
||||
* Returns: The color used by @source.
|
||||
*/
|
||||
|
||||
const guint32
|
||||
ges_track_text_overlay_get_color (GESTrackTextOverlay * self)
|
||||
{
|
||||
return self->priv->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_text_overlay_get_xpos:
|
||||
* @self: a GESTrackTextOverlay
|
||||
*
|
||||
* Get the horizontal position used by @source.
|
||||
*
|
||||
* Returns: The horizontal position used by @source.
|
||||
*/
|
||||
const gdouble
|
||||
ges_track_text_overlay_get_xpos (GESTrackTextOverlay * self)
|
||||
{
|
||||
return self->priv->xpos;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_text_overlay_get_ypos:
|
||||
* @self: a GESTrackTextOverlay
|
||||
*
|
||||
* Get the vertical position used by @source.
|
||||
*
|
||||
* Returns: The vertical position used by @source.
|
||||
*/
|
||||
const gdouble
|
||||
ges_track_text_overlay_get_ypos (GESTrackTextOverlay * self)
|
||||
{
|
||||
return self->priv->ypos;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_text_overlay_new:
|
||||
*
|
||||
|
|
|
@ -78,6 +78,10 @@ void ges_track_text_overlay_set_valignment (GESTrackTextOverlay * self,
|
|||
GESTextVAlign valign);
|
||||
void ges_track_text_overlay_set_color (GESTrackTextOverlay * self,
|
||||
guint32 color);
|
||||
void ges_track_text_overlay_set_xpos (GESTrackTextOverlay * self,
|
||||
gdouble position);
|
||||
void ges_track_text_overlay_set_ypos (GESTrackTextOverlay * self,
|
||||
gdouble position);
|
||||
|
||||
const gchar *ges_track_text_overlay_get_text (GESTrackTextOverlay * self);
|
||||
const char *ges_track_text_overlay_get_font_desc (GESTrackTextOverlay * self);
|
||||
|
@ -86,6 +90,8 @@ GESTextHAlign ges_track_text_overlay_get_halignment (GESTrackTextOverlay *
|
|||
GESTextVAlign ges_track_text_overlay_get_valignment (GESTrackTextOverlay *
|
||||
self);
|
||||
const guint32 ges_track_text_overlay_get_color (GESTrackTextOverlay * self);
|
||||
const gdouble ges_track_text_overlay_get_xpos (GESTrackTextOverlay * self);
|
||||
const gdouble ges_track_text_overlay_get_ypos (GESTrackTextOverlay * self);
|
||||
|
||||
GESTrackTextOverlay *ges_track_text_overlay_new (void);
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@ GST_START_TEST (test_overlay_in_layer)
|
|||
gchar *text;
|
||||
gint halign, valign;
|
||||
guint32 color;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
|
||||
ges_init ();
|
||||
|
||||
|
@ -173,6 +175,22 @@ GST_START_TEST (test_overlay_in_layer)
|
|||
color = ges_track_text_overlay_get_color (GES_TRACK_TEXT_OVERLAY (trobj));
|
||||
assert_equals_int (color, 2147483647);
|
||||
|
||||
/* test xpos */
|
||||
g_object_set (source, "xpos", (gdouble) 0.5, NULL);
|
||||
g_object_get (source, "xpos", &xpos, NULL);
|
||||
assert_equals_int (xpos, 0.5);
|
||||
|
||||
xpos = ges_track_text_overlay_get_xpos (GES_TRACK_TEXT_OVERLAY (trobj));
|
||||
assert_equals_int (xpos, 0.5);
|
||||
|
||||
/* test ypos */
|
||||
g_object_set (source, "ypos", (gdouble) 0.33, NULL);
|
||||
g_object_get (source, "ypos", &ypos, NULL);
|
||||
assert_equals_int (ypos, 0.33);
|
||||
|
||||
ypos = ges_track_text_overlay_get_ypos (GES_TRACK_TEXT_OVERLAY (trobj));
|
||||
assert_equals_int (ypos, 0.33);
|
||||
|
||||
GST_DEBUG ("removing the source");
|
||||
|
||||
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) source);
|
||||
|
|
Loading…
Reference in a new issue