Esempio n. 1
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *rect;
  ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
  ClutterColor rect_color = { 0xee, 0x55, 0x55, 0x99 };
  ClutterColor progress_color = { 0x55, 0xee, 0x55, 0xbb };
  ClutterBehaviour *r_behaviour, *p_behaviour;
  const ClutterKnot knots[] = {
    {  75, 150 },
    { 400, 150 }
  };

  g_thread_init (NULL);
  clutter_threads_init ();
  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_actor_set_size (stage, 600, 300);
  
  count_label = clutter_label_new_with_text ("Mono 12", "Counter");
  clutter_actor_set_position (count_label, 350, 50);

  help_label = clutter_label_new_with_text ("Mono 12", "Press 's' to start");
  clutter_actor_set_position (help_label, 50, 50);

  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_position (rect, 75, 150);
  clutter_actor_set_size (rect, 50, 50);
  clutter_actor_set_anchor_point (rect, 25, 25);

  progress_rect = clutter_rectangle_new_with_color (&progress_color);
  clutter_actor_set_position (progress_rect, 50, 225);
  clutter_actor_set_size (progress_rect, 350, 50);

  clutter_container_add (CLUTTER_CONTAINER (stage),
                         count_label, help_label,
                         rect, progress_rect,
                         NULL);

  timeline = clutter_timeline_new (150, 50);
  clutter_timeline_set_loop (timeline, TRUE);
  r_behaviour = clutter_behaviour_rotate_new (clutter_alpha_new_full (timeline,
                                                                      CLUTTER_ALPHA_RAMP_INC,
                                                                      NULL, NULL),
                                              CLUTTER_Z_AXIS,
                                              CLUTTER_ROTATE_CW,
                                              0.0, 360.0);
  clutter_behaviour_apply (r_behaviour, rect);

  p_behaviour = clutter_behaviour_path_new (clutter_alpha_new_full (timeline,
                                                                    CLUTTER_ALPHA_SINE,
                                                                    NULL, NULL),
                                            knots,
                                            G_N_ELEMENTS (knots));
  clutter_behaviour_apply (p_behaviour, rect);

  g_signal_connect (stage,
                    "button-press-event", G_CALLBACK (clutter_main_quit),
                    NULL);
  g_signal_connect (stage,
                    "key-press-event", G_CALLBACK (on_key_press_event),
                    NULL);

  clutter_actor_show (stage);

  clutter_threads_enter ();
  clutter_main ();
  clutter_threads_leave ();

  g_object_unref (p_behaviour);
  g_object_unref (r_behaviour);
  g_object_unref (timeline);

  return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
  gchar *txt;
  ClutterActor *rect, *stage, *label0;
  int i, rotate_x = 0, rotate_y = 60, rotate_z = 0;
  ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff },
               white     = { 0xff, 0xff, 0xff, 0xff },
               blue      = { 0, 0xff, 0xff, 0xff };

  for (i = 0; i < argc; ++i)
    {
      if (!strncmp (argv[i], "--rotate-x", 10))
	{
	  rotate_x = atoi (argv[i] + 11);
	}
      else if (!strncmp (argv[i], "--rotate-y", 10))
	{
	  rotate_y = atoi (argv[i] + 11);
	}
      else if (!strncmp (argv[i], "--rotate-z", 10))
	{
	  rotate_z = atoi (argv[i] + 11);
	}
      else if (!strncmp (argv[i], "--help", 6))
	{
	  printf ("%s [--rotage-x=degrees] [--rotage-y=degrees] "
		  "[--rotage-z=degrees]\n",
		  argv[0]);

	  exit (0);
	}
    }

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();

  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr);
  clutter_actor_set_size (stage, 640, 480);

  rect = clutter_rectangle_new_with_color (&white);
  clutter_actor_set_size (rect, RECT_W, RECT_H);
  clutter_actor_set_position (rect, RECT_L, RECT_T);
  clutter_actor_set_rotation (rect, CLUTTER_X_AXIS, rotate_x, 0, 0, 0);
  clutter_actor_set_rotation (rect, CLUTTER_Y_AXIS, rotate_y, 0, 0, 0);
  clutter_actor_set_rotation (rect, CLUTTER_Z_AXIS, rotate_z, 0, 0, 0);
  clutter_group_add (CLUTTER_GROUP (stage), rect);

  txt = g_strdup_printf ("Rectangle: L %d, R %d, T %d, B %d\n"
			 "Rotation : x %d, y %d, z %d",
			 RECT_L, RECT_L + RECT_W,
			 RECT_T, RECT_T + RECT_H,
			 rotate_x, rotate_y, rotate_z);

  label0 = clutter_label_new_with_text ("Mono 8pt", txt);
  clutter_label_set_color (CLUTTER_LABEL (label0), &white);

  clutter_actor_set_position (label0, 10, 10);
  clutter_group_add (CLUTTER_GROUP (stage), label0);

  g_free (txt);

  label =
    clutter_label_new_with_text ("Mono 8pt", "Click around!");

  clutter_label_set_color (CLUTTER_LABEL (label), &blue);

  clutter_actor_set_position (label, 10, 50);
  clutter_group_add (CLUTTER_GROUP (stage), label);

  clutter_actor_show_all (stage);

  g_signal_connect (stage, "event", G_CALLBACK (on_event), NULL);

  clutter_main();

  return EXIT_SUCCESS;
}
Esempio n. 3
0
void lib_object_prepare(obj_t *obj, manager_actor_t *actor)
{
	ClutterColor	obj_background,
					obj_border;
	ClutterActor	*ac;
	char			number[5];
	guint			radius;
	int				i, d;

	assert( obj != NULL );
	assert( actor != NULL );

	/* save actor
	 */
	obj->actor = actor;

	/* send events
	 */
	na_event_send_ex(&obj->observers, NA_EV_ACTOR_PREPARE, obj->actor, sizeof(manager_actor_t));
	na_event_send_ex(&obj->observers, NA_EV_AUDIO_PLAY, obj->audio, sizeof(na_audio_t));

	/* we want to be played !
	 */
	na_audio_wantplay(obj->audio);
	na_audio_set_loop(obj->audio, actor->scene_actor->is_loop);

	/* RENDERING !
	 */

	obj->group_cube = clutter_group_new();
	clutter_container_add_actor(CLUTTER_CONTAINER(actor->rotate_actor), obj->group_cube);

	/* create object
	 */
	radius = actor->scene_actor->width >> 1;

	memcpy(&obj_background, &actor->scene_actor->background_color, sizeof(obj_background));
	memcpy(&obj_border, &actor->scene_actor->border_color, sizeof(obj_border));
	ac = clutter_circle_new_with_color(&obj_background);
	clutter_circle_set_angle_stop(CLUTTER_CIRCLE(ac), 360);
	clutter_circle_set_border_color((ClutterRectangle *)ac, &obj_border);
//	clutter_rectangle_set_border_width((ClutterRectangle *)ac, actor->scene_actor->border_width);
	clutter_actor_set_width(ac, actor->scene_actor->width);
	clutter_actor_set_height(ac, actor->scene_actor->height);
	clutter_circle_set_radius(CLUTTER_CIRCLE(ac), radius);
	clutter_container_add_actor(CLUTTER_CONTAINER(obj->group_cube), ac);

	ac = clutter_circle_new_with_color(&obj_border);
	clutter_actor_set_width(ac, actor->scene_actor->width);
	clutter_actor_set_height(ac, actor->scene_actor->height);
	clutter_circle_set_radius(CLUTTER_CIRCLE(ac), radius);
	clutter_circle_set_width(CLUTTER_CIRCLE(ac), 10);
	clutter_container_add_actor(CLUTTER_CONTAINER(actor->clutter_actor), ac);
	obj->circle_position = ac;

	ac = clutter_circle_new_with_color(&obj_border);
	clutter_actor_set_width(ac, actor->scene_actor->width);
	clutter_actor_set_height(ac, actor->scene_actor->height);
	clutter_circle_set_radius(CLUTTER_CIRCLE(ac), radius + 10);
	clutter_circle_set_width(CLUTTER_CIRCLE(ac), 10);
	clutter_container_add_actor(CLUTTER_CONTAINER(actor->clutter_actor), ac);
	obj->circle_volume = ac;

	if ( ! (obj->flags & OBJ_FL_HIDE_BARGRAPH) )
	{
		for ( i = 0; i < BAR_COUNT; i++ )
		{
			ac = clutter_circle_new_with_color(&obj_border);
			clutter_actor_set_width(ac, actor->scene_actor->width);
			clutter_actor_set_height(ac, actor->scene_actor->height);
			clutter_circle_set_radius(CLUTTER_CIRCLE(ac), radius);
			clutter_circle_set_width(CLUTTER_CIRCLE(ac), 10);
			d = 360 / BAR_COUNT;
			clutter_circle_set_angle_start(CLUTTER_CIRCLE(ac), i * d);
			clutter_circle_set_angle_stop(CLUTTER_CIRCLE(ac), i * d + d);
			clutter_container_add_actor(CLUTTER_CONTAINER(actor->clutter_actor), ac);
			obj->bars[i] = ac;
		}
	}

	/* create text
	 */
	snprintf(number, sizeof(number), "%d", actor->tuio->f_id);
	ac = clutter_label_new_with_text("Lucida 12", number);
	clutter_actor_set_position(ac, actor->scene_actor->width / 2 -6, actor->scene_actor->height / 2 -10);

	clutter_container_add_actor(CLUTTER_CONTAINER(obj->group_cube), ac);
}