mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-05 17:09:48 +00:00
GESTimelineTitleSource/TrackTitleSource: add xpos/ypos setting
Vertical and horizontal position properties of the title source can be set and get.
This commit is contained in:
parent
8704011597
commit
237f19d63a
6 changed files with 225 additions and 0 deletions
|
@ -53,6 +53,8 @@ struct _GESTimelineTitleSourcePrivate
|
|||
GESTextHAlign valign;
|
||||
GSList *track_titles;
|
||||
guint32 color;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -64,6 +66,8 @@ enum
|
|||
PROP_HALIGNMENT,
|
||||
PROP_VALIGNMENT,
|
||||
PROP_COLOR,
|
||||
PROP_XPOS,
|
||||
PROP_YPOS,
|
||||
};
|
||||
|
||||
static GESTrackObject
|
||||
|
@ -103,6 +107,12 @@ ges_timeline_title_source_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);
|
||||
}
|
||||
|
@ -133,6 +143,12 @@ ges_timeline_title_source_set_property (GObject * object, guint property_id,
|
|||
case PROP_COLOR:
|
||||
ges_timeline_title_source_set_color (tfs, g_value_get_uint (value));
|
||||
break;
|
||||
case PROP_XPOS:
|
||||
ges_timeline_title_source_set_xpos (tfs, g_value_get_double (value));
|
||||
break;
|
||||
case PROP_YPOS:
|
||||
ges_timeline_title_source_set_ypos (tfs, g_value_get_double (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
@ -231,6 +247,25 @@ ges_timeline_title_source_class_init (GESTimelineTitleSourceClass * klass)
|
|||
g_param_spec_uint ("color", "Color", "The color of the text",
|
||||
0, G_MAXUINT32, G_MAXUINT32, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
/**
|
||||
* GESTimelineTitleSource: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));
|
||||
|
||||
/**
|
||||
* GESTimelineTitleSource: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
|
||||
|
@ -247,6 +282,8 @@ ges_timeline_title_source_init (GESTimelineTitleSource * 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -409,6 +446,54 @@ ges_timeline_title_source_set_color (GESTimelineTitleSource * self,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_title_source_set_xpos:
|
||||
* @self: the #GESTimelineTitleSource* to set
|
||||
* @position: The horizontal position @self is being set to
|
||||
*
|
||||
* Sets the horizontal position of the text.
|
||||
*
|
||||
*/
|
||||
void
|
||||
ges_timeline_title_source_set_xpos (GESTimelineTitleSource * self,
|
||||
gdouble position)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
GST_DEBUG ("self:%p, xpos:%f", self, position);
|
||||
|
||||
self->priv->xpos = position;
|
||||
|
||||
for (tmp = self->priv->track_titles; tmp; tmp = tmp->next) {
|
||||
ges_track_title_source_set_xpos (GES_TRACK_TITLE_SOURCE (tmp->data),
|
||||
self->priv->xpos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_title_source_set_ypos:
|
||||
* @self: the #GESTimelineTitleSource* to set
|
||||
* @position: The vertical position @self is being set to
|
||||
*
|
||||
* Sets the vertical position of the text.
|
||||
*
|
||||
*/
|
||||
void
|
||||
ges_timeline_title_source_set_ypos (GESTimelineTitleSource * self,
|
||||
gdouble position)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
GST_DEBUG ("self:%p, ypos:%f", self, position);
|
||||
|
||||
self->priv->ypos = position;
|
||||
|
||||
for (tmp = self->priv->track_titles; tmp; tmp = tmp->next) {
|
||||
ges_track_title_source_set_ypos (GES_TRACK_TITLE_SOURCE (tmp->data),
|
||||
self->priv->ypos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_title_source_get_text:
|
||||
* @self: a #GESTimelineTitleSource
|
||||
|
@ -499,6 +584,36 @@ ges_timeline_title_source_get_color (GESTimelineTitleSource * self)
|
|||
return self->priv->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_title_source_get_xpos:
|
||||
* @self: a #GESTimelineTitleSource
|
||||
*
|
||||
* Get the horizontal position used by @self.
|
||||
*
|
||||
* Returns: The horizontal position used by @self.
|
||||
*
|
||||
*/
|
||||
const gdouble
|
||||
ges_timeline_title_source_get_xpos (GESTimelineTitleSource * self)
|
||||
{
|
||||
return self->priv->xpos;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_title_source_get_ypos:
|
||||
* @self: a #GESTimelineTitleSource
|
||||
*
|
||||
* Get the vertical position used by @self.
|
||||
*
|
||||
* Returns: The vertical position used by @self.
|
||||
*
|
||||
*/
|
||||
const gdouble
|
||||
ges_timeline_title_source_get_ypos (GESTimelineTitleSource * self)
|
||||
{
|
||||
return self->priv->ypos;
|
||||
}
|
||||
|
||||
static void
|
||||
ges_timeline_title_source_track_object_released (GESTimelineObject * obj,
|
||||
GESTrackObject * tckobj)
|
||||
|
@ -547,6 +662,8 @@ ges_timeline_title_source_create_track_object (GESTimelineObject * obj,
|
|||
ges_track_title_source_set_valignment ((GESTrackTitleSource *) res,
|
||||
priv->valign);
|
||||
ges_track_title_source_set_color ((GESTrackTitleSource *) res, priv->color);
|
||||
ges_track_title_source_set_xpos ((GESTrackTitleSource *) res, priv->xpos);
|
||||
ges_track_title_source_set_ypos ((GESTrackTitleSource *) res, priv->ypos);
|
||||
}
|
||||
|
||||
else if (track->type == GES_TRACK_TYPE_AUDIO) {
|
||||
|
|
|
@ -97,6 +97,14 @@ void
|
|||
ges_timeline_title_source_set_color (GESTimelineTitleSource * self,
|
||||
guint32 color);
|
||||
|
||||
void
|
||||
ges_timeline_title_source_set_xpos (GESTimelineTitleSource * self,
|
||||
gdouble position);
|
||||
|
||||
void
|
||||
ges_timeline_title_source_set_ypos (GESTimelineTitleSource * self,
|
||||
gdouble position);
|
||||
|
||||
const gchar*
|
||||
ges_timeline_title_source_get_font_desc (GESTimelineTitleSource * self);
|
||||
|
||||
|
@ -109,6 +117,12 @@ ges_timeline_title_source_get_halignment (GESTimelineTitleSource * self);
|
|||
const guint32
|
||||
ges_timeline_title_source_get_color (GESTimelineTitleSource * self);
|
||||
|
||||
const gdouble
|
||||
ges_timeline_title_source_get_xpos (GESTimelineTitleSource * self);
|
||||
|
||||
const gdouble
|
||||
ges_timeline_title_source_get_ypos (GESTimelineTitleSource * self);
|
||||
|
||||
gboolean ges_timeline_title_source_is_muted (GESTimelineTitleSource * self);
|
||||
const gchar* ges_timeline_title_source_get_text (GESTimelineTitleSource * self);
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ struct _GESTrackTitleSourcePrivate
|
|||
GESTextHAlign halign;
|
||||
GESTextVAlign valign;
|
||||
guint32 color;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
GstElement *text_el;
|
||||
GstElement *background_el;
|
||||
};
|
||||
|
@ -86,6 +88,8 @@ ges_track_title_source_init (GESTrackTitleSource * 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;
|
||||
self->priv->background_el = NULL;
|
||||
}
|
||||
|
||||
|
@ -158,6 +162,8 @@ ges_track_title_source_create_element (GESTrackObject * object)
|
|||
g_object_set (background, "pattern", (gint) GES_VIDEO_TEST_PATTERN_BLACK,
|
||||
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);
|
||||
|
||||
gst_bin_add_many (GST_BIN (topbin), background, text, NULL);
|
||||
|
||||
|
@ -274,6 +280,40 @@ ges_track_title_source_set_color (GESTrackTitleSource * self, guint32 color)
|
|||
g_object_set (self->priv->text_el, "color", color, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_title_source_set_xpos:
|
||||
* @self: the #GESTrackTitleSource* to set
|
||||
* @position: the horizontal position @self is being set to
|
||||
*
|
||||
* Sets the horizontal position of the text.
|
||||
*/
|
||||
void
|
||||
ges_track_title_source_set_xpos (GESTrackTitleSource * 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_title_source_set_ypos:
|
||||
* @self: the #GESTrackTitleSource* to set
|
||||
* @position: the color @self is being set to
|
||||
*
|
||||
* Sets the vertical position of the text.
|
||||
*/
|
||||
void
|
||||
ges_track_title_source_set_ypos (GESTrackTitleSource * self, gdouble position)
|
||||
{
|
||||
GST_DEBUG ("self:%p, ypos:%d", self, position);
|
||||
|
||||
self->priv->ypos = position;
|
||||
if (self->priv->text_el)
|
||||
g_object_set (self->priv->text_el, "ypos", position, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_title_source_get_text:
|
||||
* @source: a #GESTrackTitleSource
|
||||
|
@ -345,6 +385,33 @@ ges_track_title_source_get_color (GESTrackTitleSource * source)
|
|||
return source->priv->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_title_source_get_xpos:
|
||||
* @source: a #GESTrackTitleSource
|
||||
*
|
||||
* Get the horizontal position used by @source.
|
||||
*
|
||||
* Returns: The horizontal position used by @source.
|
||||
*/
|
||||
const gdouble
|
||||
ges_track_title_source_get_xpos (GESTrackTitleSource * source)
|
||||
{
|
||||
return source->priv->xpos;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_title_source_get_ypos:
|
||||
* @source: a #GESTrackTitleSource
|
||||
*
|
||||
* Get the vertical position used by @source.
|
||||
*
|
||||
* Returns: The vertical position used by @source.
|
||||
*/
|
||||
const gdouble
|
||||
ges_track_title_source_get_ypos (GESTrackTitleSource * source)
|
||||
{
|
||||
return source->priv->ypos;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_track_title_source_new:
|
||||
|
|
|
@ -90,11 +90,18 @@ void ges_track_title_source_set_valignment (GESTrackTitleSource *self,
|
|||
|
||||
void ges_track_title_source_set_color (GESTrackTitleSource *self,
|
||||
guint32 color);
|
||||
void ges_track_title_source_set_xpos (GESTrackTitleSource *self,
|
||||
gdouble position);
|
||||
void ges_track_title_source_set_ypos (GESTrackTitleSource *self,
|
||||
gdouble position);
|
||||
|
||||
const gchar *ges_track_title_source_get_text (GESTrackTitleSource *source);
|
||||
const gchar *ges_track_title_source_get_font_desc (GESTrackTitleSource *source);
|
||||
GESTextHAlign ges_track_title_source_get_halignment (GESTrackTitleSource *source);
|
||||
GESTextVAlign ges_track_title_source_get_valignment (GESTrackTitleSource *source);
|
||||
const guint32 ges_track_title_source_get_color (GESTrackTitleSource *source);
|
||||
const gdouble ges_track_title_source_get_xpos (GESTrackTitleSource *source);
|
||||
const gdouble ges_track_title_source_get_ypos (GESTrackTitleSource *source);
|
||||
|
||||
GESTrackTitleSource* ges_track_title_source_new (void);
|
||||
|
||||
|
|
|
@ -189,6 +189,8 @@ GST_START_TEST (test_keyfile_save)
|
|||
KEY ("Object3", "halignment", "center");
|
||||
KEY ("Object3", "valignment", "baseline");
|
||||
KEY ("Object3", "color", "4294967295");
|
||||
KEY ("Object3", "xpos", "0.5");
|
||||
KEY ("Object3", "ypos", "0.5");
|
||||
COMPARE;
|
||||
|
||||
/* tear-down */
|
||||
|
|
|
@ -122,6 +122,8 @@ GST_START_TEST (test_title_source_in_layer)
|
|||
gchar *text;
|
||||
gint halign, valign;
|
||||
guint32 color;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
|
||||
ges_init ();
|
||||
|
||||
|
@ -184,6 +186,22 @@ GST_START_TEST (test_title_source_in_layer)
|
|||
color = ges_track_title_source_get_color (GES_TRACK_TITLE_SOURCE (trobj));
|
||||
assert_equals_int (color, 2147483647);
|
||||
|
||||
/* test xpos */
|
||||
g_object_set (source, "xpos", (gdouble) 0.25, NULL);
|
||||
g_object_get (source, "xpos", &xpos, NULL);
|
||||
assert_equals_int (xpos, 0.25);
|
||||
|
||||
xpos = ges_track_title_source_get_xpos (GES_TRACK_TITLE_SOURCE (trobj));
|
||||
assert_equals_int (xpos, 0.25);
|
||||
|
||||
/* test ypos */
|
||||
g_object_set (source, "ypos", (gdouble) 0.66, NULL);
|
||||
g_object_get (source, "ypos", &ypos, NULL);
|
||||
assert_equals_int (ypos, 0.66);
|
||||
|
||||
xpos = ges_track_title_source_get_xpos (GES_TRACK_TITLE_SOURCE (trobj));
|
||||
assert_equals_int (ypos, 0.66);
|
||||
|
||||
GST_DEBUG ("removing the source");
|
||||
|
||||
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) source);
|
||||
|
|
Loading…
Reference in a new issue