2009-01-22 08:14:02 -05:00
|
|
|
#include <stdlib.h>
|
2009-01-23 10:57:20 -05:00
|
|
|
#include <string.h>
|
2009-01-22 08:14:02 -05:00
|
|
|
|
2013-12-12 09:51:00 -05:00
|
|
|
#include <clutter/clutter.h>
|
2009-01-22 08:14:02 -05:00
|
|
|
|
2019-07-03 07:43:25 -04:00
|
|
|
#include "tests/clutter-test-utils.h"
|
|
|
|
|
2013-12-12 09:51:00 -05:00
|
|
|
static void
|
|
|
|
actor_pivot (void)
|
|
|
|
{
|
|
|
|
ClutterActor *stage, *actor_implicit, *actor_explicit;
|
2020-09-11 14:57:28 -04:00
|
|
|
graphene_matrix_t transform, result_implicit, result_explicit;
|
2013-12-12 09:51:00 -05:00
|
|
|
ClutterActorBox allocation = CLUTTER_ACTOR_BOX_INIT (0, 0, 90, 30);
|
|
|
|
gfloat angle = 30;
|
|
|
|
|
|
|
|
stage = clutter_test_get_stage ();
|
|
|
|
|
|
|
|
actor_implicit = clutter_actor_new ();
|
|
|
|
actor_explicit = clutter_actor_new ();
|
|
|
|
|
|
|
|
clutter_actor_add_child (stage, actor_implicit);
|
|
|
|
clutter_actor_add_child (stage, actor_explicit);
|
|
|
|
|
2020-07-10 07:05:21 -04:00
|
|
|
clutter_actor_show (stage);
|
|
|
|
|
2013-12-12 09:51:00 -05:00
|
|
|
/* Fake allocation or pivot-point will not have any effect */
|
2020-05-09 15:09:43 -04:00
|
|
|
clutter_actor_allocate (actor_implicit, &allocation);
|
|
|
|
clutter_actor_allocate (actor_explicit, &allocation);
|
2013-12-12 09:51:00 -05:00
|
|
|
|
|
|
|
clutter_actor_set_pivot_point (actor_implicit, 0.5, 0.5);
|
|
|
|
clutter_actor_set_pivot_point (actor_explicit, 0.5, 0.5);
|
|
|
|
|
2020-08-26 05:49:50 -04:00
|
|
|
/* Implicit transformation */
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_actor_set_rotation_angle (actor_implicit, CLUTTER_Z_AXIS, angle);
|
|
|
|
|
2020-08-26 05:49:50 -04:00
|
|
|
/* Explicit transformation */
|
2020-09-11 18:46:48 -04:00
|
|
|
graphene_matrix_init_rotate (&transform, angle, graphene_vec3_z_axis ());
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_actor_set_transform (actor_explicit, &transform);
|
2009-01-22 08:14:02 -05:00
|
|
|
|
2013-12-12 09:51:00 -05:00
|
|
|
clutter_actor_get_transform (actor_implicit, &result_implicit);
|
|
|
|
clutter_actor_get_transform (actor_explicit, &result_explicit);
|
2009-01-22 08:14:02 -05:00
|
|
|
|
2020-09-11 18:46:48 -04:00
|
|
|
g_assert (graphene_matrix_equal (&result_implicit, &result_explicit));
|
2020-08-13 08:39:13 -04:00
|
|
|
|
|
|
|
clutter_actor_destroy (actor_implicit);
|
|
|
|
clutter_actor_destroy (actor_explicit);
|
2009-01-22 08:14:02 -05:00
|
|
|
}
|
|
|
|
|
2013-12-12 09:51:00 -05:00
|
|
|
CLUTTER_TEST_SUITE (
|
|
|
|
CLUTTER_TEST_UNIT ("/actor/transforms/pivot-point", actor_pivot)
|
|
|
|
)
|