actor: Add a custom scriptable "margin" property

The property uses an array with the following CSS style syntax

 [ top, right, bottom, left ] or
 [ top, left/right, bottom ] or
 [ top/bottom, left/right ] or
 [ top/right/bottom/left ]

https://bugzilla.gnome.org/show_bug.cgi?id=676367
This commit is contained in:
Bastian Winkler
2012-05-19 14:37:08 +02:00
parent a2d40fcf8c
commit aeea9ee778
5 changed files with 156 additions and 0 deletions

View File

@@ -398,3 +398,47 @@ script_layout_property (TestConformSimpleFixture *fixture,
g_object_unref (script);
}
script_margin (TestConformSimpleFixture *fixture,
gpointer dummy)
{
ClutterScript *script = clutter_script_new ();
ClutterActor *actor;
gchar *test_file;
GError *error = NULL;
test_file = clutter_test_get_data_file ("test-script-margin.json");
clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error)
g_print ("Error: %s", error->message);
g_assert_no_error (error);
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-1"));
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 10.0f);
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 10.0f);
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 10.0f);
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-2"));
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 20.0f);
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 10.0f);
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 20.0f);
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-3"));
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 20.0f);
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 30.0f);
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 20.0f);
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-4"));
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 20.0f);
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 30.0f);
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 40.0f);
g_object_unref (script);
g_free (test_file);
}

View File

@@ -221,6 +221,7 @@ main (int argc, char **argv)
TEST_CONFORM_SIMPLE ("/script", animator_properties);
TEST_CONFORM_SIMPLE ("/script", animator_multi_properties);
TEST_CONFORM_SIMPLE ("/script", state_base);
TEST_CONFORM_SIMPLE ("/script", script_margin);
TEST_CONFORM_SIMPLE ("/timeline", timeline_base);
TEST_CONFORM_SIMPLE ("/timeline", timeline_markers_from_script);

View File

@@ -16,6 +16,7 @@ json_files = \
test-animator-3.json \
test-state-1.json \
test-script-timeline-markers.json \
test-script-margin.json \
$(NULL)
png_files = \

View File

@@ -0,0 +1,22 @@
[
{
"id" : "actor-1",
"type" : "ClutterActor",
"margin" : [ 10 ]
},
{
"id" : "actor-2",
"type" : "ClutterActor",
"margin" : [ 10, 20 ]
},
{
"id" : "actor-3",
"type" : "ClutterActor",
"margin" : [ 10, 20, 30 ]
},
{
"id" : "actor-4",
"type" : "ClutterActor",
"margin" : [ 10, 20, 30, 40]
}
]