#include #include #include #include #define STAGE_WIDTH 1024 #define STAGE_HEIGHT 768 #define ACTOR_WIDTH 128 #define ACTOR_HEIGHT 128 #define COLS (STAGE_WIDTH/ACTOR_WIDTH) #define ROWS (STAGE_HEIGHT/ACTOR_HEIGHT) #define TOTAL (ROWS*COLS) static gboolean press_event (ClutterActor *actor, ClutterEvent *event, gpointer user_data) { ClutterState *state = CLUTTER_STATE (user_data); clutter_grab_pointer (actor); clutter_state_change (state, "right", TRUE); return TRUE; } static gboolean release_event (ClutterActor *actor, ClutterEvent *event, gpointer user_data) { ClutterState *state = CLUTTER_STATE (user_data); clutter_state_change (state, "active", TRUE); clutter_ungrab_pointer (); return TRUE; } static gboolean enter_event (ClutterActor *actor, ClutterEvent *event, gpointer user_data) { ClutterState *state = CLUTTER_STATE (user_data); clutter_state_change (state, "hover", TRUE); return TRUE; } static gboolean leave_event (ClutterActor *actor, ClutterEvent *event, gpointer user_data) { ClutterState *state = CLUTTER_STATE (user_data); clutter_state_change (state, "normal", TRUE); return TRUE; } static void completed (ClutterState *state, gpointer data) { g_print ("Completed transitioning to state: %s\n", clutter_state_get_target_state (state)); if (g_str_equal (clutter_state_get_target_state (state), "right")) { /* skip straight to left state when reaching right */ clutter_state_change (state, "left", FALSE); } } static ClutterActor *new_rect (gint r, gint g, gint b, gint a) { GError *error = NULL; ClutterColor *color = clutter_color_new (r, g, b, a); ClutterActor *group = clutter_group_new (); ClutterActor *rectangle = clutter_rectangle_new_with_color (color); ClutterActor *hand = NULL; gchar *file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); hand = clutter_texture_new_from_file (file, &error); if (rectangle == NULL) g_error ("image load failed: %s", error->message); g_free (file); clutter_actor_set_size (hand, ACTOR_WIDTH,ACTOR_HEIGHT); clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT); clutter_color_free (color); clutter_container_add (CLUTTER_CONTAINER (group), rectangle, hand, NULL); return group; } G_MODULE_EXPORT gint test_state_main (gint argc, gchar **argv) { ClutterColor black={0,0,0,0xff}; ClutterActor *stage; ClutterState *layout_state; gint i; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); layout_state = clutter_state_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &black); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); for (i=0; i