2011-11-28 12:42:49 -05:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
2019-07-03 07:43:25 -04:00
|
|
|
#include "tests/clutter-test-utils.h"
|
|
|
|
|
2011-11-28 12:42:49 -05:00
|
|
|
static void
|
2013-12-12 09:51:00 -05:00
|
|
|
actor_basic_layout (void)
|
2011-11-28 12:42:49 -05:00
|
|
|
{
|
2013-12-12 09:51:00 -05:00
|
|
|
ClutterActor *stage = clutter_test_get_stage ();
|
2011-11-28 12:42:49 -05:00
|
|
|
ClutterActor *vase;
|
|
|
|
ClutterActor *flower[3];
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_t p;
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
vase = clutter_actor_new ();
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_actor_set_name (vase, "Vase");
|
2011-12-06 11:09:53 -05:00
|
|
|
clutter_actor_set_layout_manager (vase, clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
|
2011-12-02 10:38:25 -05:00
|
|
|
clutter_actor_add_child (stage, vase);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
flower[0] = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (flower[0], CLUTTER_COLOR_Red);
|
2011-11-28 12:42:49 -05:00
|
|
|
clutter_actor_set_size (flower[0], 100, 100);
|
|
|
|
clutter_actor_set_name (flower[0], "Red Flower");
|
2011-12-02 06:51:15 -05:00
|
|
|
clutter_actor_add_child (vase, flower[0]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
flower[1] = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (flower[1], CLUTTER_COLOR_Yellow);
|
2011-11-28 12:42:49 -05:00
|
|
|
clutter_actor_set_size (flower[1], 100, 100);
|
|
|
|
clutter_actor_set_name (flower[1], "Yellow Flower");
|
2011-12-02 06:51:15 -05:00
|
|
|
clutter_actor_add_child (vase, flower[1]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
flower[2] = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (flower[2], CLUTTER_COLOR_Green);
|
2011-11-28 12:42:49 -05:00
|
|
|
clutter_actor_set_size (flower[2], 100, 100);
|
|
|
|
clutter_actor_set_name (flower[2], "Green Flower");
|
2011-12-02 06:51:15 -05:00
|
|
|
clutter_actor_add_child (vase, flower[2]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_init (&p, 50, 50);
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_test_assert_actor_at_point (stage, &p, flower[0]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_init (&p, 150, 50);
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_test_assert_actor_at_point (stage, &p, flower[1]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_init (&p, 250, 50);
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_test_assert_actor_at_point (stage, &p, flower[2]);
|
2020-08-13 08:39:13 -04:00
|
|
|
|
|
|
|
clutter_actor_destroy (vase);
|
2011-11-28 12:42:49 -05:00
|
|
|
}
|
|
|
|
|
2013-12-12 09:51:00 -05:00
|
|
|
static void
|
|
|
|
actor_margin_layout (void)
|
2011-11-28 12:42:49 -05:00
|
|
|
{
|
2013-12-12 09:51:00 -05:00
|
|
|
ClutterActor *stage = clutter_test_get_stage ();
|
2011-11-28 12:42:49 -05:00
|
|
|
ClutterActor *vase;
|
|
|
|
ClutterActor *flower[3];
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_t p;
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
vase = clutter_actor_new ();
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_actor_set_name (vase, "Vase");
|
|
|
|
clutter_actor_set_layout_manager (vase, clutter_box_layout_new ());
|
2011-12-02 10:38:25 -05:00
|
|
|
clutter_actor_add_child (stage, vase);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
flower[0] = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (flower[0], CLUTTER_COLOR_Red);
|
2011-11-28 12:42:49 -05:00
|
|
|
clutter_actor_set_size (flower[0], 100, 100);
|
|
|
|
clutter_actor_set_name (flower[0], "Red Flower");
|
2011-12-02 06:51:15 -05:00
|
|
|
clutter_actor_add_child (vase, flower[0]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
flower[1] = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (flower[1], CLUTTER_COLOR_Yellow);
|
2011-11-28 12:42:49 -05:00
|
|
|
clutter_actor_set_size (flower[1], 100, 100);
|
|
|
|
clutter_actor_set_name (flower[1], "Yellow Flower");
|
|
|
|
clutter_actor_set_margin_right (flower[1], 6);
|
|
|
|
clutter_actor_set_margin_left (flower[1], 6);
|
2011-12-02 06:51:15 -05:00
|
|
|
clutter_actor_add_child (vase, flower[1]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2011-12-06 11:09:53 -05:00
|
|
|
flower[2] = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (flower[2], CLUTTER_COLOR_Green);
|
2011-11-28 12:42:49 -05:00
|
|
|
clutter_actor_set_size (flower[2], 100, 100);
|
|
|
|
clutter_actor_set_name (flower[2], "Green Flower");
|
|
|
|
clutter_actor_set_margin_top (flower[2], 6);
|
|
|
|
clutter_actor_set_margin_bottom (flower[2], 6);
|
2011-12-02 06:51:15 -05:00
|
|
|
clutter_actor_add_child (vase, flower[2]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_init (&p, 0, 7);
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_test_assert_actor_at_point (stage, &p, flower[0]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_init (&p, 106, 50);
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_test_assert_actor_at_point (stage, &p, flower[1]);
|
2011-11-28 12:42:49 -05:00
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_init (&p, 212, 7);
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_test_assert_actor_at_point (stage, &p, flower[2]);
|
2020-08-13 08:39:13 -04:00
|
|
|
|
|
|
|
clutter_actor_destroy (vase);
|
2011-11-28 12:42:49 -05:00
|
|
|
}
|
2013-12-12 09:51:00 -05:00
|
|
|
|
|
|
|
CLUTTER_TEST_SUITE (
|
|
|
|
CLUTTER_TEST_UNIT ("/actor/layout/basic", actor_basic_layout)
|
|
|
|
CLUTTER_TEST_UNIT ("/actor/layout/margin", actor_margin_layout)
|
|
|
|
)
|