marker: add color meta

Support optionally coloring markers by reserving GES_META_MARKER_COLOR
for an ARGB guint.
This commit is contained in:
Henry Wilkes 2019-10-16 19:26:55 +01:00 committed by Thibault Saunier
parent e53b3fadf1
commit 44420b2e56
3 changed files with 45 additions and 0 deletions

View file

@ -24,6 +24,8 @@
* @short_description: implements a list of markers with metadata asociated to time positions
* @see_also: #GESMarker
*
* A #GESMarker can be colored by setting the #GES_META_MARKER_COLOR meta.
*
* Since: 1.18
*/
@ -80,6 +82,8 @@ ges_marker_get_property (GObject * object, guint property_id,
static void
ges_marker_init (GESMarker * self)
{
ges_meta_container_register_static_meta (GES_META_CONTAINER (self),
GES_META_READ_WRITE, GES_META_MARKER_COLOR, G_TYPE_UINT);
}
static void

View file

@ -109,6 +109,13 @@ G_BEGIN_DECLS
*/
#define GES_META_FORMAT_VERSION "format-version"
/**
* GES_META_MARKER_COLOR:
*
* The ARGB color of a #GESMarker (an AARRGGBB hex as a guint)
*/
#define GES_META_MARKER_COLOR "marker-color"
typedef struct _GESMetaContainer GESMetaContainer;
typedef struct _GESMetaContainerInterface GESMetaContainerInterface;

View file

@ -343,6 +343,39 @@ GST_START_TEST (test_serialize_deserialize)
GST_END_TEST;
GST_START_TEST (test_marker_color)
{
GESMarkerList *mlist;
GESMarker *marker;
const guint yellow_rgb = 16776960;
guint color;
ges_init ();
mlist = ges_marker_list_new ();
marker = ges_marker_list_add (mlist, 0);
/* getting the color should fail since no value should be set yet */
fail_unless (ges_meta_container_get_meta (GES_META_CONTAINER (marker),
GES_META_MARKER_COLOR) == NULL);
/* trying to set the color field to something other than a uint should
* fail */
fail_unless (ges_meta_container_set_float (GES_META_CONTAINER (marker),
GES_META_MARKER_COLOR, 0.0) == FALSE);
fail_unless (ges_meta_container_set_uint (GES_META_CONTAINER (marker),
GES_META_MARKER_COLOR, yellow_rgb));
fail_unless (ges_meta_container_get_uint (GES_META_CONTAINER (marker),
GES_META_MARKER_COLOR, &color));
fail_unless_equals_int (color, yellow_rgb);
g_object_unref (mlist);
ges_deinit ();
}
GST_END_TEST;
static Suite *
ges_suite (void)
{
@ -359,6 +392,7 @@ ges_suite (void)
tcase_add_test (tc_chain, test_get_markers);
tcase_add_test (tc_chain, test_move_marker);
tcase_add_test (tc_chain, test_serialize_deserialize);
tcase_add_test (tc_chain, test_marker_color);
return s;
}