2010-08-19 16:17:58 +00:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
|
|
|
static const ClutterColor stage_color = { 0x33, 0x33, 0x55, 0xff };
|
|
|
|
static const ClutterColor rectangle_color = { 0xaa, 0x99, 0x00, 0xff };
|
|
|
|
|
|
|
|
static gboolean
|
2010-08-19 16:50:25 +00:00
|
|
|
_pointer_motion_cb (ClutterActor *actor,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer user_data)
|
2010-08-19 16:17:58 +00:00
|
|
|
{
|
2010-08-20 10:25:40 +00:00
|
|
|
gfloat stage_x, stage_y;
|
2010-11-12 09:32:04 +00:00
|
|
|
gfloat actor_x, actor_y;
|
|
|
|
|
2010-08-20 10:25:40 +00:00
|
|
|
clutter_event_get_coords (event, &stage_x, &stage_y);
|
2010-08-19 16:17:58 +00:00
|
|
|
|
|
|
|
clutter_actor_transform_stage_point (actor,
|
|
|
|
stage_x, stage_y,
|
|
|
|
&actor_x, &actor_y);
|
|
|
|
|
|
|
|
g_debug ("pointer @ stage x %.0f, y %.0f; actor x %.0f, y %.0f",
|
|
|
|
stage_x, stage_y,
|
|
|
|
actor_x, actor_y);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
ClutterActor *stage;
|
|
|
|
ClutterActor *rectangle;
|
|
|
|
|
2011-02-22 00:44:55 +00:00
|
|
|
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
|
|
|
return 1;
|
2010-08-19 16:17:58 +00:00
|
|
|
|
2011-11-09 17:49:25 +00:00
|
|
|
stage = clutter_stage_new ();
|
2010-08-19 16:17:58 +00:00
|
|
|
clutter_actor_set_size (stage, 400, 400);
|
|
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
2011-11-09 17:49:25 +00:00
|
|
|
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
2010-08-19 16:17:58 +00:00
|
|
|
|
|
|
|
rectangle = clutter_rectangle_new_with_color (&rectangle_color);
|
|
|
|
clutter_actor_set_size (rectangle, 300, 300);
|
|
|
|
clutter_actor_set_position (rectangle, 50, 50);
|
|
|
|
clutter_actor_set_reactive (rectangle, TRUE);
|
|
|
|
|
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle);
|
|
|
|
|
|
|
|
g_signal_connect (rectangle,
|
|
|
|
"motion-event",
|
2010-08-19 16:50:25 +00:00
|
|
|
G_CALLBACK (_pointer_motion_cb),
|
2010-08-19 16:17:58 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
clutter_actor_show (stage);
|
|
|
|
|
|
|
|
clutter_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|