2007-07-26 11:04:04 +00:00
|
|
|
#include <stdlib.h>
|
2008-11-07 19:32:28 +00:00
|
|
|
#include <gmodule.h>
|
2007-05-25 10:56:09 +00:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
2008-02-04 22:35:38 +00:00
|
|
|
static const ClutterGravity gravities[] = {
|
2007-05-25 10:56:09 +00:00
|
|
|
CLUTTER_GRAVITY_NORTH_EAST,
|
|
|
|
CLUTTER_GRAVITY_NORTH,
|
|
|
|
CLUTTER_GRAVITY_NORTH_WEST,
|
|
|
|
CLUTTER_GRAVITY_WEST,
|
|
|
|
CLUTTER_GRAVITY_SOUTH_WEST,
|
|
|
|
CLUTTER_GRAVITY_SOUTH,
|
|
|
|
CLUTTER_GRAVITY_SOUTH_EAST,
|
|
|
|
CLUTTER_GRAVITY_EAST,
|
|
|
|
CLUTTER_GRAVITY_CENTER,
|
|
|
|
CLUTTER_GRAVITY_NONE
|
|
|
|
};
|
|
|
|
|
2008-02-04 22:35:38 +00:00
|
|
|
static gint gindex = 0;
|
2008-12-18 17:40:36 +00:00
|
|
|
static ClutterActor *label;
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2019-01-20 08:03:50 +00:00
|
|
|
int
|
|
|
|
test_scale_main (int argc, char *argv[]);
|
|
|
|
|
|
|
|
const char *
|
|
|
|
test_scale_describe (void);
|
|
|
|
|
2008-02-04 22:35:38 +00:00
|
|
|
static void
|
2008-12-18 17:40:36 +00:00
|
|
|
set_next_gravity (ClutterActor *actor)
|
2007-05-25 10:56:09 +00:00
|
|
|
{
|
2008-12-18 17:40:36 +00:00
|
|
|
ClutterGravity gravity = gravities[gindex];
|
|
|
|
GEnumClass *eclass;
|
|
|
|
GEnumValue *evalue;
|
|
|
|
|
|
|
|
clutter_actor_move_anchor_point_from_gravity (actor, gravities[gindex]);
|
|
|
|
|
|
|
|
eclass = g_type_class_ref (CLUTTER_TYPE_GRAVITY);
|
|
|
|
evalue = g_enum_get_value (eclass, gravity);
|
2009-01-07 12:17:09 +00:00
|
|
|
clutter_text_set_text (CLUTTER_TEXT (label), evalue->value_nick);
|
2008-12-18 17:40:36 +00:00
|
|
|
g_type_class_unref (eclass);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2008-01-07 17:17:43 +00:00
|
|
|
if (++gindex >= G_N_ELEMENTS (gravities))
|
2007-05-25 10:56:09 +00:00
|
|
|
gindex = 0;
|
|
|
|
}
|
|
|
|
|
2009-01-20 16:42:49 +00:00
|
|
|
static gdouble
|
|
|
|
my_ramp_func (ClutterAlpha *alpha,
|
|
|
|
gpointer unused)
|
|
|
|
{
|
|
|
|
ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
|
|
|
|
|
|
|
|
return clutter_timeline_get_progress (timeline);
|
|
|
|
}
|
|
|
|
|
2008-11-07 19:32:28 +00:00
|
|
|
G_MODULE_EXPORT int
|
|
|
|
test_scale_main (int argc, char *argv[])
|
2007-05-25 10:56:09 +00:00
|
|
|
{
|
|
|
|
ClutterActor *stage, *rect;
|
|
|
|
ClutterColor rect_color = { 0xff, 0xff, 0xff, 0x99 };
|
|
|
|
ClutterTimeline *timeline;
|
|
|
|
ClutterAlpha *alpha;
|
|
|
|
ClutterBehaviour *behave;
|
|
|
|
|
2011-02-22 00:19:35 +00:00
|
|
|
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
|
|
|
return 1;
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2011-11-09 13:41:15 +00:00
|
|
|
stage = clutter_stage_new ();
|
|
|
|
clutter_stage_set_title (CLUTTER_STAGE (stage), "Scaling");
|
2012-02-13 16:47:17 +00:00
|
|
|
clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black);
|
2007-05-25 10:56:09 +00:00
|
|
|
clutter_actor_set_size (stage, 300, 300);
|
2011-11-09 13:41:15 +00:00
|
|
|
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2008-01-14 13:13:23 +00:00
|
|
|
rect = clutter_rectangle_new_with_color (&rect_color);
|
2007-05-25 10:56:09 +00:00
|
|
|
clutter_actor_set_size (rect, 100, 100);
|
|
|
|
clutter_actor_set_position (rect, 100, 100);
|
|
|
|
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2009-01-07 12:17:09 +00:00
|
|
|
label = clutter_text_new_with_text ("Sans 20px", "");
|
2012-02-13 16:47:17 +00:00
|
|
|
clutter_text_set_color (CLUTTER_TEXT (label), CLUTTER_COLOR_White);
|
2008-12-18 17:40:36 +00:00
|
|
|
clutter_actor_set_position (label,
|
|
|
|
clutter_actor_get_x (rect),
|
|
|
|
clutter_actor_get_y (rect)
|
|
|
|
+ clutter_actor_get_height (rect));
|
|
|
|
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
|
2008-12-18 17:40:36 +00:00
|
|
|
|
2007-05-25 10:56:09 +00:00
|
|
|
rect_color.alpha = 0xff;
|
2008-01-14 13:13:23 +00:00
|
|
|
rect = clutter_rectangle_new_with_color (&rect_color);
|
2008-01-30 12:13:26 +00:00
|
|
|
clutter_actor_set_position (rect, 100, 100);
|
2007-05-25 10:56:09 +00:00
|
|
|
clutter_actor_set_size (rect, 100, 100);
|
2008-12-18 17:40:36 +00:00
|
|
|
set_next_gravity (rect);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2009-06-04 12:05:12 +00:00
|
|
|
timeline = clutter_timeline_new (750);
|
2009-01-16 13:42:06 +00:00
|
|
|
alpha = clutter_alpha_new_with_func (timeline,
|
2009-01-20 16:42:49 +00:00
|
|
|
my_ramp_func,
|
2009-01-16 13:42:06 +00:00
|
|
|
NULL, NULL);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
|
|
|
behave = clutter_behaviour_scale_new (alpha,
|
2008-01-30 12:13:26 +00:00
|
|
|
0.0, 0.0, /* scale start */
|
|
|
|
1.0, 1.0); /* scale end */
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2008-01-30 12:13:26 +00:00
|
|
|
clutter_behaviour_apply (behave, rect);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2012-02-13 16:47:17 +00:00
|
|
|
clutter_timeline_set_repeat_count (timeline, -1);
|
2008-12-18 17:40:36 +00:00
|
|
|
g_signal_connect_swapped (timeline, "completed",
|
|
|
|
G_CALLBACK (set_next_gravity), rect);
|
2007-05-25 10:56:09 +00:00
|
|
|
clutter_timeline_start (timeline);
|
|
|
|
|
|
|
|
clutter_actor_show_all (stage);
|
|
|
|
|
|
|
|
clutter_main();
|
2007-07-26 11:04:04 +00:00
|
|
|
|
2008-02-04 22:35:38 +00:00
|
|
|
g_object_unref (timeline);
|
|
|
|
g_object_unref (behave);
|
|
|
|
|
2007-07-26 11:04:04 +00:00
|
|
|
return EXIT_SUCCESS;
|
2007-05-25 10:56:09 +00:00
|
|
|
}
|
2011-11-09 13:41:15 +00:00
|
|
|
|
|
|
|
G_MODULE_EXPORT const char *
|
|
|
|
test_scale_describe (void)
|
|
|
|
{
|
|
|
|
return "Scaling animation and scaling center changes";
|
|
|
|
}
|