mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
GESTimelineTitleSource/TrackTitleSource: add color setting
Color property of the text overlay can be set and get.
This commit is contained in:
parent
18d588ff1e
commit
8704011597
6 changed files with 130 additions and 12 deletions
|
@ -52,6 +52,7 @@ struct _GESTimelineTitleSourcePrivate
|
||||||
GESTextVAlign halign;
|
GESTextVAlign halign;
|
||||||
GESTextHAlign valign;
|
GESTextHAlign valign;
|
||||||
GSList *track_titles;
|
GSList *track_titles;
|
||||||
|
guint32 color;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -62,6 +63,7 @@ enum
|
||||||
PROP_FONT_DESC,
|
PROP_FONT_DESC,
|
||||||
PROP_HALIGNMENT,
|
PROP_HALIGNMENT,
|
||||||
PROP_VALIGNMENT,
|
PROP_VALIGNMENT,
|
||||||
|
PROP_COLOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
static GESTrackObject
|
static GESTrackObject
|
||||||
|
@ -98,6 +100,9 @@ ges_timeline_title_source_get_property (GObject * object, guint property_id,
|
||||||
case PROP_VALIGNMENT:
|
case PROP_VALIGNMENT:
|
||||||
g_value_set_enum (value, priv->valign);
|
g_value_set_enum (value, priv->valign);
|
||||||
break;
|
break;
|
||||||
|
case PROP_COLOR:
|
||||||
|
g_value_set_uint (value, priv->color);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
}
|
}
|
||||||
|
@ -125,6 +130,9 @@ ges_timeline_title_source_set_property (GObject * object, guint property_id,
|
||||||
case PROP_VALIGNMENT:
|
case PROP_VALIGNMENT:
|
||||||
ges_timeline_title_source_set_valignment (tfs, g_value_get_enum (value));
|
ges_timeline_title_source_set_valignment (tfs, g_value_get_enum (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_COLOR:
|
||||||
|
ges_timeline_title_source_set_color (tfs, 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);
|
||||||
}
|
}
|
||||||
|
@ -212,6 +220,17 @@ ges_timeline_title_source_class_init (GESTimelineTitleSourceClass * klass)
|
||||||
ges_timeline_title_source_track_object_added;
|
ges_timeline_title_source_track_object_added;
|
||||||
timobj_class->track_object_released =
|
timobj_class->track_object_released =
|
||||||
ges_timeline_title_source_track_object_released;
|
ges_timeline_title_source_track_object_released;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GESTimelineTitleSource:color
|
||||||
|
*
|
||||||
|
* The color of the text
|
||||||
|
*/
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -227,6 +246,7 @@ ges_timeline_title_source_init (GESTimelineTitleSource * self)
|
||||||
self->priv->font_desc = NULL;
|
self->priv->font_desc = NULL;
|
||||||
self->priv->halign = DEFAULT_HALIGNMENT;
|
self->priv->halign = DEFAULT_HALIGNMENT;
|
||||||
self->priv->valign = DEFAULT_VALIGNMENT;
|
self->priv->valign = DEFAULT_VALIGNMENT;
|
||||||
|
self->priv->color = G_MAXUINT32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -365,6 +385,30 @@ ges_timeline_title_source_set_mute (GESTimelineTitleSource * self,
|
||||||
g_list_free (trackobjects);
|
g_list_free (trackobjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_timeline_title_source_set_color:
|
||||||
|
* @self: the #GESTimelineTitleSource* to set
|
||||||
|
* @color: The color @self is being set to
|
||||||
|
*
|
||||||
|
* Sets the color of the text.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ges_timeline_title_source_set_color (GESTimelineTitleSource * self,
|
||||||
|
guint32 color)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
GST_DEBUG ("self:%p, color:%d", self, color);
|
||||||
|
|
||||||
|
self->priv->color = color;
|
||||||
|
|
||||||
|
for (tmp = self->priv->track_titles; tmp; tmp = tmp->next) {
|
||||||
|
ges_track_title_source_set_color (GES_TRACK_TITLE_SOURCE (tmp->data),
|
||||||
|
self->priv->color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_timeline_title_source_get_text:
|
* ges_timeline_title_source_get_text:
|
||||||
* @self: a #GESTimelineTitleSource
|
* @self: a #GESTimelineTitleSource
|
||||||
|
@ -425,7 +469,6 @@ ges_timeline_title_source_get_valignment (GESTimelineTitleSource * self)
|
||||||
return self->priv->valign;
|
return self->priv->valign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_timeline_title_source_is_muted:
|
* ges_timeline_title_source_is_muted:
|
||||||
* @self: a #GESTimelineTitleSource
|
* @self: a #GESTimelineTitleSource
|
||||||
|
@ -441,6 +484,21 @@ ges_timeline_title_source_is_muted (GESTimelineTitleSource * self)
|
||||||
return self->priv->mute;
|
return self->priv->mute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_timeline_title_source_get_color:
|
||||||
|
* @self: a #GESTimelineTitleSource
|
||||||
|
*
|
||||||
|
* Get the color used by @self.
|
||||||
|
*
|
||||||
|
* Returns: The color used by @self.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const guint32
|
||||||
|
ges_timeline_title_source_get_color (GESTimelineTitleSource * self)
|
||||||
|
{
|
||||||
|
return self->priv->color;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ges_timeline_title_source_track_object_released (GESTimelineObject * obj,
|
ges_timeline_title_source_track_object_released (GESTimelineObject * obj,
|
||||||
GESTrackObject * tckobj)
|
GESTrackObject * tckobj)
|
||||||
|
@ -488,6 +546,7 @@ ges_timeline_title_source_create_track_object (GESTimelineObject * obj,
|
||||||
priv->halign);
|
priv->halign);
|
||||||
ges_track_title_source_set_valignment ((GESTrackTitleSource *) res,
|
ges_track_title_source_set_valignment ((GESTrackTitleSource *) res,
|
||||||
priv->valign);
|
priv->valign);
|
||||||
|
ges_track_title_source_set_color ((GESTrackTitleSource *) res, priv->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (track->type == GES_TRACK_TYPE_AUDIO) {
|
else if (track->type == GES_TRACK_TYPE_AUDIO) {
|
||||||
|
|
|
@ -93,6 +93,10 @@ void
|
||||||
ges_timeline_title_source_set_halignment (GESTimelineTitleSource * self,
|
ges_timeline_title_source_set_halignment (GESTimelineTitleSource * self,
|
||||||
GESTextHAlign halign);
|
GESTextHAlign halign);
|
||||||
|
|
||||||
|
void
|
||||||
|
ges_timeline_title_source_set_color (GESTimelineTitleSource * self,
|
||||||
|
guint32 color);
|
||||||
|
|
||||||
const gchar*
|
const gchar*
|
||||||
ges_timeline_title_source_get_font_desc (GESTimelineTitleSource * self);
|
ges_timeline_title_source_get_font_desc (GESTimelineTitleSource * self);
|
||||||
|
|
||||||
|
@ -102,6 +106,9 @@ ges_timeline_title_source_get_valignment (GESTimelineTitleSource * self);
|
||||||
GESTextHAlign
|
GESTextHAlign
|
||||||
ges_timeline_title_source_get_halignment (GESTimelineTitleSource * self);
|
ges_timeline_title_source_get_halignment (GESTimelineTitleSource * self);
|
||||||
|
|
||||||
|
const guint32
|
||||||
|
ges_timeline_title_source_get_color (GESTimelineTitleSource * self);
|
||||||
|
|
||||||
gboolean ges_timeline_title_source_is_muted (GESTimelineTitleSource * self);
|
gboolean ges_timeline_title_source_is_muted (GESTimelineTitleSource * self);
|
||||||
const gchar* ges_timeline_title_source_get_text (GESTimelineTitleSource * self);
|
const gchar* ges_timeline_title_source_get_text (GESTimelineTitleSource * self);
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct _GESTrackTitleSourcePrivate
|
||||||
gchar *font_desc;
|
gchar *font_desc;
|
||||||
GESTextHAlign halign;
|
GESTextHAlign halign;
|
||||||
GESTextVAlign valign;
|
GESTextVAlign valign;
|
||||||
|
guint32 color;
|
||||||
GstElement *text_el;
|
GstElement *text_el;
|
||||||
GstElement *background_el;
|
GstElement *background_el;
|
||||||
};
|
};
|
||||||
|
@ -84,6 +85,7 @@ ges_track_title_source_init (GESTrackTitleSource * self)
|
||||||
self->priv->text_el = NULL;
|
self->priv->text_el = NULL;
|
||||||
self->priv->halign = DEFAULT_HALIGNMENT;
|
self->priv->halign = DEFAULT_HALIGNMENT;
|
||||||
self->priv->valign = DEFAULT_VALIGNMENT;
|
self->priv->valign = DEFAULT_VALIGNMENT;
|
||||||
|
self->priv->color = G_MAXUINT32;
|
||||||
self->priv->background_el = NULL;
|
self->priv->background_el = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +157,7 @@ ges_track_title_source_create_element (GESTrackObject * object)
|
||||||
|
|
||||||
g_object_set (background, "pattern", (gint) GES_VIDEO_TEST_PATTERN_BLACK,
|
g_object_set (background, "pattern", (gint) GES_VIDEO_TEST_PATTERN_BLACK,
|
||||||
NULL);
|
NULL);
|
||||||
|
g_object_set (text, "color", (guint32) self->priv->color, NULL);
|
||||||
|
|
||||||
gst_bin_add_many (GST_BIN (topbin), background, text, NULL);
|
gst_bin_add_many (GST_BIN (topbin), background, text, NULL);
|
||||||
|
|
||||||
|
@ -188,6 +191,8 @@ ges_track_title_source_set_text (GESTrackTitleSource * self, const gchar * text)
|
||||||
if (self->priv->text)
|
if (self->priv->text)
|
||||||
g_free (self->priv->text);
|
g_free (self->priv->text);
|
||||||
|
|
||||||
|
GST_DEBUG ("self:%p, text:%s", self, text);
|
||||||
|
|
||||||
self->priv->text = g_strdup (text);
|
self->priv->text = g_strdup (text);
|
||||||
if (self->priv->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->priv->text_el, "text", text, NULL);
|
g_object_set (self->priv->text_el, "text", text, NULL);
|
||||||
|
@ -209,8 +214,9 @@ ges_track_title_source_set_font_desc (GESTrackTitleSource * self,
|
||||||
if (self->priv->font_desc)
|
if (self->priv->font_desc)
|
||||||
g_free (self->priv->font_desc);
|
g_free (self->priv->font_desc);
|
||||||
|
|
||||||
|
GST_DEBUG ("self:%p, font_dec:%s", self, font_desc);
|
||||||
|
|
||||||
self->priv->font_desc = g_strdup (font_desc);
|
self->priv->font_desc = g_strdup (font_desc);
|
||||||
GST_LOG ("setting font-desc to '%s'", font_desc);
|
|
||||||
if (self->priv->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->priv->text_el, "font-desc", font_desc, NULL);
|
g_object_set (self->priv->text_el, "font-desc", font_desc, NULL);
|
||||||
}
|
}
|
||||||
|
@ -226,8 +232,9 @@ void
|
||||||
ges_track_title_source_set_valignment (GESTrackTitleSource * self,
|
ges_track_title_source_set_valignment (GESTrackTitleSource * self,
|
||||||
GESTextVAlign valign)
|
GESTextVAlign valign)
|
||||||
{
|
{
|
||||||
|
GST_DEBUG ("self:%p, valign:%d", self, valign);
|
||||||
|
|
||||||
self->priv->valign = valign;
|
self->priv->valign = valign;
|
||||||
GST_LOG ("set valignment to: %d", valign);
|
|
||||||
if (self->priv->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->priv->text_el, "valignment", valign, NULL);
|
g_object_set (self->priv->text_el, "valignment", valign, NULL);
|
||||||
}
|
}
|
||||||
|
@ -243,12 +250,30 @@ void
|
||||||
ges_track_title_source_set_halignment (GESTrackTitleSource * self,
|
ges_track_title_source_set_halignment (GESTrackTitleSource * self,
|
||||||
GESTextHAlign halign)
|
GESTextHAlign halign)
|
||||||
{
|
{
|
||||||
|
GST_DEBUG ("self:%p, halign:%d", self, halign);
|
||||||
|
|
||||||
self->priv->halign = halign;
|
self->priv->halign = halign;
|
||||||
GST_LOG ("set halignment to: %d", halign);
|
|
||||||
if (self->priv->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->priv->text_el, "halignment", halign, NULL);
|
g_object_set (self->priv->text_el, "halignment", halign, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_title_source_set_color:
|
||||||
|
* @self: the #GESTrackTitleSource* to set
|
||||||
|
* @color: the color @self is being set to
|
||||||
|
*
|
||||||
|
* Sets the color of the text.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ges_track_title_source_set_color (GESTrackTitleSource * self, guint32 color)
|
||||||
|
{
|
||||||
|
GST_DEBUG ("self:%p, color:%d", self, color);
|
||||||
|
|
||||||
|
self->priv->color = color;
|
||||||
|
if (self->priv->text_el)
|
||||||
|
g_object_set (self->priv->text_el, "color", color, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_track_title_source_get_text:
|
* ges_track_title_source_get_text:
|
||||||
* @source: a #GESTrackTitleSource
|
* @source: a #GESTrackTitleSource
|
||||||
|
@ -282,9 +307,9 @@ ges_track_title_source_get_font_desc (GESTrackTitleSource * source)
|
||||||
* ges_track_title_source_get_halignment:
|
* ges_track_title_source_get_halignment:
|
||||||
* @source: a #GESTrackTitleSource
|
* @source: a #GESTrackTitleSource
|
||||||
*
|
*
|
||||||
* Get the horizontal aligment used by this source.
|
* Get the horizontal aligment used by @source.
|
||||||
*
|
*
|
||||||
* Returns: The horizontal aligment used by this source.
|
* Returns: The horizontal aligment used by @source.
|
||||||
*/
|
*/
|
||||||
GESTextHAlign
|
GESTextHAlign
|
||||||
ges_track_title_source_get_halignment (GESTrackTitleSource * source)
|
ges_track_title_source_get_halignment (GESTrackTitleSource * source)
|
||||||
|
@ -296,9 +321,9 @@ ges_track_title_source_get_halignment (GESTrackTitleSource * source)
|
||||||
* ges_track_title_source_get_valignment:
|
* ges_track_title_source_get_valignment:
|
||||||
* @source: a #GESTrackTitleSource
|
* @source: a #GESTrackTitleSource
|
||||||
*
|
*
|
||||||
* Get the vertical aligment used by this source.
|
* Get the vertical aligment used by @source.
|
||||||
*
|
*
|
||||||
* Returns: The vertical aligment used by this source.
|
* Returns: The vertical aligment used by @source.
|
||||||
*/
|
*/
|
||||||
GESTextVAlign
|
GESTextVAlign
|
||||||
ges_track_title_source_get_valignment (GESTrackTitleSource * source)
|
ges_track_title_source_get_valignment (GESTrackTitleSource * source)
|
||||||
|
@ -306,6 +331,20 @@ ges_track_title_source_get_valignment (GESTrackTitleSource * source)
|
||||||
return source->priv->valign;
|
return source->priv->valign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_title_source_get_color:
|
||||||
|
* @source: a #GESTrackTitleSource
|
||||||
|
*
|
||||||
|
* Get the color used by @source.
|
||||||
|
*
|
||||||
|
* Returns: The color used by @source.
|
||||||
|
*/
|
||||||
|
const guint32
|
||||||
|
ges_track_title_source_get_color (GESTrackTitleSource * source)
|
||||||
|
{
|
||||||
|
return source->priv->color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_track_title_source_new:
|
* ges_track_title_source_new:
|
||||||
|
|
|
@ -76,22 +76,25 @@ struct _GESTrackTitleSourceClass {
|
||||||
|
|
||||||
GType ges_track_title_source_get_type (void);
|
GType ges_track_title_source_get_type (void);
|
||||||
|
|
||||||
void ges_track_title_source_set_text(GESTrackTitleSource *self,
|
void ges_track_title_source_set_text (GESTrackTitleSource *self,
|
||||||
const gchar *text);
|
const gchar *text);
|
||||||
|
|
||||||
void ges_track_title_source_set_font_desc(GESTrackTitleSource *self,
|
void ges_track_title_source_set_font_desc (GESTrackTitleSource *self,
|
||||||
const gchar *font_desc);
|
const gchar *font_desc);
|
||||||
|
|
||||||
void ges_track_title_source_set_halignment(GESTrackTitleSource *self,
|
void ges_track_title_source_set_halignment (GESTrackTitleSource *self,
|
||||||
GESTextHAlign halign);
|
GESTextHAlign halign);
|
||||||
|
|
||||||
void ges_track_title_source_set_valignment(GESTrackTitleSource *self,
|
void ges_track_title_source_set_valignment (GESTrackTitleSource *self,
|
||||||
GESTextVAlign valign);
|
GESTextVAlign valign);
|
||||||
|
|
||||||
|
void ges_track_title_source_set_color (GESTrackTitleSource *self,
|
||||||
|
guint32 color);
|
||||||
const gchar *ges_track_title_source_get_text (GESTrackTitleSource *source);
|
const gchar *ges_track_title_source_get_text (GESTrackTitleSource *source);
|
||||||
const gchar *ges_track_title_source_get_font_desc (GESTrackTitleSource *source);
|
const gchar *ges_track_title_source_get_font_desc (GESTrackTitleSource *source);
|
||||||
GESTextHAlign ges_track_title_source_get_halignment (GESTrackTitleSource *source);
|
GESTextHAlign ges_track_title_source_get_halignment (GESTrackTitleSource *source);
|
||||||
GESTextVAlign ges_track_title_source_get_valignment (GESTrackTitleSource *source);
|
GESTextVAlign ges_track_title_source_get_valignment (GESTrackTitleSource *source);
|
||||||
|
const guint32 ges_track_title_source_get_color (GESTrackTitleSource *source);
|
||||||
|
|
||||||
GESTrackTitleSource* ges_track_title_source_new (void);
|
GESTrackTitleSource* ges_track_title_source_new (void);
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ GST_START_TEST (test_keyfile_save)
|
||||||
KEY ("Object3", "font-desc", "\"Serif\\\\ 36\"");
|
KEY ("Object3", "font-desc", "\"Serif\\\\ 36\"");
|
||||||
KEY ("Object3", "halignment", "center");
|
KEY ("Object3", "halignment", "center");
|
||||||
KEY ("Object3", "valignment", "baseline");
|
KEY ("Object3", "valignment", "baseline");
|
||||||
|
KEY ("Object3", "color", "4294967295");
|
||||||
COMPARE;
|
COMPARE;
|
||||||
|
|
||||||
/* tear-down */
|
/* tear-down */
|
||||||
|
|
|
@ -121,6 +121,7 @@ GST_START_TEST (test_title_source_in_layer)
|
||||||
GESTimelineTitleSource *source;
|
GESTimelineTitleSource *source;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
gint halign, valign;
|
gint halign, valign;
|
||||||
|
guint32 color;
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
|
||||||
|
@ -175,6 +176,14 @@ GST_START_TEST (test_title_source_in_layer)
|
||||||
assert_equals_int (ges_track_title_source_get_valignment
|
assert_equals_int (ges_track_title_source_get_valignment
|
||||||
(GES_TRACK_TITLE_SOURCE (trobj)), GES_TEXT_VALIGN_TOP);
|
(GES_TRACK_TITLE_SOURCE (trobj)), GES_TEXT_VALIGN_TOP);
|
||||||
|
|
||||||
|
/* test color */
|
||||||
|
g_object_set (source, "color", (gint) 2147483647, NULL);
|
||||||
|
g_object_get (source, "color", &color, NULL);
|
||||||
|
assert_equals_int (color, 2147483647);
|
||||||
|
|
||||||
|
color = ges_track_title_source_get_color (GES_TRACK_TITLE_SOURCE (trobj));
|
||||||
|
assert_equals_int (color, 2147483647);
|
||||||
|
|
||||||
GST_DEBUG ("removing the source");
|
GST_DEBUG ("removing the source");
|
||||||
|
|
||||||
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) source);
|
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) source);
|
||||||
|
|
Loading…
Reference in a new issue