2007-07-26 07:04:04 -04:00
|
|
|
#include <stdlib.h>
|
2008-11-07 14:32:28 -05:00
|
|
|
#include <gmodule.h>
|
2010-11-06 11:54:21 -04:00
|
|
|
|
|
|
|
#undef CLUTTER_DISABLE_DEPRECATED
|
2007-05-25 06:56:09 -04:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
2008-02-04 17:35:38 -05:00
|
|
|
static const ClutterGravity gravities[] = {
|
2007-05-25 06:56:09 -04: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 17:35:38 -05:00
|
|
|
static gint gindex = 0;
|
2008-12-18 12:40:36 -05:00
|
|
|
static ClutterActor *label;
|
2007-05-25 06:56:09 -04:00
|
|
|
|
2008-02-04 17:35:38 -05:00
|
|
|
static void
|
2008-12-18 12:40:36 -05:00
|
|
|
set_next_gravity (ClutterActor *actor)
|
2007-05-25 06:56:09 -04:00
|
|
|
{
|
2008-12-18 12:40:36 -05: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 07:17:09 -05:00
|
|
|
clutter_text_set_text (CLUTTER_TEXT (label), evalue->value_nick);
|
2008-12-18 12:40:36 -05:00
|
|
|
g_type_class_unref (eclass);
|
2007-05-25 06:56:09 -04:00
|
|
|
|
2008-01-07 12:17:43 -05:00
|
|
|
if (++gindex >= G_N_ELEMENTS (gravities))
|
2007-05-25 06:56:09 -04:00
|
|
|
gindex = 0;
|
|
|
|
}
|
|
|
|
|
2009-01-20 11:42:49 -05: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 14:32:28 -05:00
|
|
|
G_MODULE_EXPORT int
|
|
|
|
test_scale_main (int argc, char *argv[])
|
2007-05-25 06:56:09 -04:00
|
|
|
{
|
|
|
|
ClutterActor *stage, *rect;
|
|
|
|
ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff };
|
|
|
|
ClutterColor rect_color = { 0xff, 0xff, 0xff, 0x99 };
|
2009-03-31 08:43:12 -04:00
|
|
|
ClutterColor white_color = { 0xff, 0xff, 0xff, 0xFF };
|
2007-05-25 06:56:09 -04:00
|
|
|
ClutterTimeline *timeline;
|
|
|
|
ClutterAlpha *alpha;
|
|
|
|
ClutterBehaviour *behave;
|
|
|
|
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
|
|
|
|
stage = clutter_stage_get_default ();
|
|
|
|
|
|
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
|
|
|
clutter_actor_set_size (stage, 300, 300);
|
|
|
|
|
2008-01-14 08:13:23 -05:00
|
|
|
rect = clutter_rectangle_new_with_color (&rect_color);
|
2007-05-25 06:56:09 -04:00
|
|
|
clutter_actor_set_size (rect, 100, 100);
|
|
|
|
clutter_actor_set_position (rect, 100, 100);
|
|
|
|
|
2008-01-14 08:13:23 -05:00
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), rect);
|
2007-05-25 06:56:09 -04:00
|
|
|
|
2009-01-07 07:17:09 -05:00
|
|
|
label = clutter_text_new_with_text ("Sans 20px", "");
|
|
|
|
clutter_text_set_color (CLUTTER_TEXT (label),
|
2009-03-31 08:43:12 -04:00
|
|
|
&white_color);
|
2008-12-18 12:40:36 -05:00
|
|
|
clutter_actor_set_position (label,
|
|
|
|
clutter_actor_get_x (rect),
|
|
|
|
clutter_actor_get_y (rect)
|
|
|
|
+ clutter_actor_get_height (rect));
|
|
|
|
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), label);
|
|
|
|
|
2007-05-25 06:56:09 -04:00
|
|
|
rect_color.alpha = 0xff;
|
2008-01-14 08:13:23 -05:00
|
|
|
rect = clutter_rectangle_new_with_color (&rect_color);
|
2008-01-30 07:13:26 -05:00
|
|
|
clutter_actor_set_position (rect, 100, 100);
|
2007-05-25 06:56:09 -04:00
|
|
|
clutter_actor_set_size (rect, 100, 100);
|
2008-12-18 12:40:36 -05:00
|
|
|
set_next_gravity (rect);
|
2007-05-25 06:56:09 -04:00
|
|
|
|
2008-01-14 08:13:23 -05:00
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), rect);
|
2007-05-25 06:56:09 -04:00
|
|
|
|
2009-06-04 08:05:12 -04:00
|
|
|
timeline = clutter_timeline_new (750);
|
2009-01-16 08:42:06 -05:00
|
|
|
alpha = clutter_alpha_new_with_func (timeline,
|
2009-01-20 11:42:49 -05:00
|
|
|
my_ramp_func,
|
2009-01-16 08:42:06 -05:00
|
|
|
NULL, NULL);
|
2007-05-25 06:56:09 -04:00
|
|
|
|
|
|
|
behave = clutter_behaviour_scale_new (alpha,
|
2008-01-30 07:13:26 -05:00
|
|
|
0.0, 0.0, /* scale start */
|
|
|
|
1.0, 1.0); /* scale end */
|
2007-05-25 06:56:09 -04:00
|
|
|
|
2008-01-30 07:13:26 -05:00
|
|
|
clutter_behaviour_apply (behave, rect);
|
2007-05-25 06:56:09 -04:00
|
|
|
|
|
|
|
clutter_timeline_set_loop (timeline, TRUE);
|
2008-12-18 12:40:36 -05:00
|
|
|
g_signal_connect_swapped (timeline, "completed",
|
|
|
|
G_CALLBACK (set_next_gravity), rect);
|
2007-05-25 06:56:09 -04:00
|
|
|
clutter_timeline_start (timeline);
|
|
|
|
|
|
|
|
clutter_actor_show_all (stage);
|
|
|
|
|
|
|
|
clutter_main();
|
2007-07-26 07:04:04 -04:00
|
|
|
|
2008-02-04 17:35:38 -05:00
|
|
|
g_object_unref (timeline);
|
|
|
|
g_object_unref (behave);
|
|
|
|
|
2007-07-26 07:04:04 -04:00
|
|
|
return EXIT_SUCCESS;
|
2007-05-25 06:56:09 -04:00
|
|
|
}
|