コード例 #1
0
static VALUE
rbclt_behaviour_scale_initialize (VALUE self, VALUE alpha,
                                  VALUE x_scale_start, VALUE y_scale_start,
                                  VALUE x_scale_end, VALUE y_scale_end)
{
  ClutterBehaviour *behaviour;

  behaviour = clutter_behaviour_scale_new (RVAL2GOBJ (alpha),
                                           NUM2DBL (x_scale_start),
                                           NUM2DBL (y_scale_start),
                                           NUM2DBL (x_scale_end),
                                           NUM2DBL (y_scale_end));

  G_INITIALIZE (self, behaviour);

  return Qnil;
}
コード例 #2
0
ファイル: preview.cpp プロジェクト: gfunkmonk2/mate-games
Preview::Preview():
	width(0),
	height(0),
	blocknr(-1),
	color(-1),
	themeID(0),
	cell_size(20),
	cache(NULL),
	enabled(true)
{
	blocks = new Block*[PREVIEW_WIDTH];
	for (int i = 0; i < PREVIEW_WIDTH; i++) {
		blocks[i] = new Block [PREVIEW_HEIGHT];
	}

	w = gtk_clutter_embed_new();

	g_signal_connect (w, "size_allocate", G_CALLBACK (resize), this);

	/* FIXME: We should scale with the rest of the UI, but that requires
	 * changes to the widget layout - i.e. wrap the preview in an
	 * fixed-aspect box. */
	gtk_widget_set_size_request (w, 120, 120);
	ClutterActor *stage;
	stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (w));

	ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff };
	clutter_stage_set_color (CLUTTER_STAGE (stage),
				 &stage_color);
	piece = clutter_group_new ();
	clutter_group_add (CLUTTER_GROUP (stage),
			   piece);

	piece_timeline = clutter_timeline_new (180);
	alpha = clutter_alpha_new_full (piece_timeline,
			CLUTTER_EASE_IN_OUT_SINE);
	piece_behav = clutter_behaviour_scale_new (alpha,
			0.6, 0.6, 1.0, 1.0);
	clutter_actor_set_anchor_point (piece, 60, 60);
	clutter_actor_set_position (CLUTTER_ACTOR(piece), 60, 60);
	clutter_behaviour_apply (piece_behav, piece);
}
コード例 #3
0
G_MODULE_EXPORT int
test_paint_wrapper_main (int argc, char *argv[])
{
    ClutterAlpha *alpha;
    ClutterActor *stage;
    ClutterColor  stage_color = { 0x61, 0x64, 0x8c, 0xff };
    SuperOH      *oh;
    gint          i;
    GError       *error;
    ClutterActor *real_hand;

    error = NULL;

#ifdef HAVE_CLUTTER_GLX
    clutter_x11_set_use_argb_visual (TRUE);
#endif

    clutter_init_with_args (&argc, &argv,
                            NULL,
                            super_oh_entries,
                            NULL,
                            &error);
    if (error)
    {
        g_warning ("Unable to initialise Clutter:\n%s",
                   error->message);
        g_error_free (error);

        return EXIT_FAILURE;
    }

    stage = clutter_stage_get_default ();
    clutter_actor_set_size (stage, 800, 600);

    if (use_alpha != 255)
    {
        clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE);
        clutter_actor_set_opacity (stage, use_alpha);
    }

    clutter_stage_set_title (CLUTTER_STAGE (stage), "Paint Test");
    clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

    oh = g_new(SuperOH, 1);
    oh->stage = stage;

    /* Create a timeline to manage animation */
    oh->timeline = clutter_timeline_new (6000);
    clutter_timeline_set_loop (oh->timeline, TRUE);

    /* fire a callback for frame change */
    g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh);

    /* Set up some behaviours to handle scaling  */
    alpha = clutter_alpha_new_with_func (oh->timeline, my_sine_wave, NULL, NULL);

    oh->scaler_1 = clutter_behaviour_scale_new (alpha, 0.5, 0.5, 1.0, 1.0);
    oh->scaler_2 = clutter_behaviour_scale_new (alpha, 1.0, 1.0, 0.5, 0.5);

    real_hand = clutter_texture_new_from_file (TESTS_DATADIR
                G_DIR_SEPARATOR_S
                "redhand.png",
                &error);
    if (real_hand == NULL)
    {
        g_error ("image load failed: %s", error->message);
        return EXIT_FAILURE;
    }

    /* create a new group to hold multiple actors in a group */
    oh->group = clutter_group_new();

    oh->hand = g_new (ClutterActor*, n_hands);

    oh->stage_width = clutter_actor_get_width (stage);
    oh->stage_height = clutter_actor_get_height (stage);
    oh->radius = (oh->stage_width + oh->stage_height)
                 / n_hands;

    for (i = 0; i < n_hands; i++)
    {
        gint x, y, w, h;

        if (i == 0)
            oh->hand[i] = real_hand;
        else
            oh->hand[i] = clutter_clone_new (real_hand);

        clutter_actor_set_reactive (oh->hand[i], TRUE);

        clutter_actor_set_size (oh->hand[i], 200, 213);

        /* Place around a circle */
        w = clutter_actor_get_width (oh->hand[i]);
        h = clutter_actor_get_height (oh->hand[i]);

        x = oh->stage_width / 2
            + oh->radius
            * cos (i * G_PI / (n_hands / 2))
            - w / 2;

        y = oh->stage_height / 2
            + oh->radius
            * sin (i * G_PI / (n_hands / 2))
            - h / 2;

        clutter_actor_set_position (oh->hand[i], x, y);

        clutter_actor_move_anchor_point_from_gravity (oh->hand[i],
                CLUTTER_GRAVITY_CENTER);

        g_signal_connect (oh->hand[i], "button-press-event",
                          G_CALLBACK (on_button_press_event),
                          oh);

        /* paint something before each hand */
        g_signal_connect (oh->hand[i],
                          "paint", G_CALLBACK (hand_pre_paint),
                          oh);

        /* paint something after each hand */
        g_signal_connect_after (oh->hand[i],
                                "paint", G_CALLBACK (hand_post_paint),
                                oh);

        /* Add to our group group */
        clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]);

        if (i % 2)
            clutter_behaviour_apply (oh->scaler_1, oh->hand[i]);
        else
            clutter_behaviour_apply (oh->scaler_2, oh->hand[i]);
    }

    oh->paint_guards = g_malloc0 (sizeof (gboolean) * n_hands);

    /* Add the group to the stage */
    clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                                 CLUTTER_ACTOR (oh->group));

    /* Show everying ( and map window ) */
    clutter_actor_show (stage);

    g_signal_connect (stage, "key-release-event",
                      G_CALLBACK (input_cb),
                      oh);

    /* and start it */
    clutter_timeline_start (oh->timeline);

    clutter_main ();

    g_object_unref (oh->scaler_1);
    g_object_unref (oh->scaler_2);
    g_object_unref (oh->timeline);
    g_free (oh->paint_guards);
    g_free (oh->hand);
    g_free (oh);

    return 0;
}
コード例 #4
0
ファイル: courasel.c プロジェクト: UIKit0/toys
int
main (int argc, char *argv[])
{
  ClutterActor    *stage;
  ClutterColor     stage_color = { 0x34, 0x39, 0x39, 0xff };
  ClutterColor     white = { 0x72, 0x9f, 0xcf, 0xff };
  gint             i = 0;
  Item            *item;
  App             *app;
  gdouble          ang = 0.0;
  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, 800, 600);

  app = g_new0(App, 1);
  app->off = 0.0;
  app->timeline = clutter_timeline_new (300);
  app->alpha_sine_inc
    = clutter_alpha_new_full (app->timeline, CLUTTER_EASE_OUT_SINE);

  app->alpha_ramp
    = clutter_alpha_new_with_func (app->timeline, label_opacity_alpha_func,
                                   NULL, NULL);

  for (i=0; i<N_ITEMS; i++)
    {
      item = g_new0 (Item, 1);

      item->actor = clutter_texture_new_from_file (ItemDetails[i].img, NULL);
      if (!item->actor)
	g_error ("Unable to load '%s'", ItemDetails[i].img);

      clutter_group_add (CLUTTER_GROUP(stage), item->actor);

      item->ellipse_behave
	= clutter_behaviour_ellipse_new (app->alpha_sine_inc,
					 CSW()/4,   /* center x */
					 CSH() - (CSH()/3),   /* center y */
					 CSW()/2,   /* width */
					 CSH() - (CSH()/4),   /* height */
					 CLUTTER_ROTATE_CW,
					 ang,
					 ang + STEP);
      item->opacity_behave
	= clutter_behaviour_opacity_new (app->alpha_sine_inc, 0x66, 0x66);

      item->scale_behave
	= clutter_behaviour_scale_new (app->alpha_sine_inc,
				       0.6, 0.6, 0.6, 0.6);

      clutter_behaviour_apply (item->ellipse_behave, item->actor);
      clutter_behaviour_apply (item->opacity_behave, item->actor);
      clutter_behaviour_apply (item->scale_behave, item->actor);

      app->items = g_slist_append (app->items, item);

      ang += STEP;
    }

  app->label = clutter_text_new_full ("Bitstream Vera Sans 60px", "", &white);
  clutter_actor_set_position (app->label, CSW()/2 - 30, CSH()/3 - 40);
  clutter_group_add (CLUTTER_GROUP(stage), app->label);

  behave = clutter_behaviour_opacity_new (app->alpha_ramp, 0xff, 0);
  clutter_behaviour_apply (behave, app->label);

  g_signal_connect (app->timeline,
		    "new-frame",
		    G_CALLBACK(on_timeline_new_frame),
		    app);

  g_signal_connect (stage,
		    "event",
		    G_CALLBACK (on_input),
		    app);

  introduce_items (app);

  clutter_actor_show_all (stage);

  clutter_main();

  return 0;
}
コード例 #5
0
ファイル: test-scale.c プロジェクト: ChrisCummins/clutter
G_MODULE_EXPORT int
test_scale_main (int argc, char *argv[])
{
  ClutterActor    *stage, *rect;
  ClutterColor     rect_color = { 0xff, 0xff, 0xff, 0x99 };
  ClutterTimeline *timeline;
  ClutterAlpha    *alpha;
  ClutterBehaviour *behave;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Scaling");
  clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black);
  clutter_actor_set_size (stage, 300, 300);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_size (rect, 100, 100);
  clutter_actor_set_position (rect, 100, 100);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);

  label = clutter_text_new_with_text ("Sans 20px", "");
  clutter_text_set_color (CLUTTER_TEXT (label), CLUTTER_COLOR_White);
  clutter_actor_set_position (label,
                              clutter_actor_get_x (rect),
                              clutter_actor_get_y (rect)
                              + clutter_actor_get_height (rect));

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);

  rect_color.alpha = 0xff;
  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_position (rect, 100, 100);
  clutter_actor_set_size (rect, 100, 100);
  set_next_gravity (rect);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);

  timeline = clutter_timeline_new (750);
  alpha    = clutter_alpha_new_with_func (timeline,
				          my_ramp_func,
				          NULL, NULL);

  behave = clutter_behaviour_scale_new (alpha,
					0.0, 0.0,  /* scale start */
					1.0, 1.0); /* scale end */

  clutter_behaviour_apply (behave, rect);

  clutter_timeline_set_repeat_count (timeline, -1);
  g_signal_connect_swapped (timeline, "completed",
                            G_CALLBACK (set_next_gravity), rect);
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (timeline);
  g_object_unref (behave);

  return EXIT_SUCCESS;
}
コード例 #6
0
int
main (int argc, char *argv[])
{
  ClutterTimeline *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *scaler_1, *scaler_2;
  ClutterActor    *stage;
  ClutterColor     stage_color = { 0x61, 0x64, 0x8c, 0xff };
  SuperOH         *oh;
  gint             i;
  GError          *error;

#ifdef REQ_NON_COMPOSITION
  Window           xwin;
  Atom             non_comp_atom;
  Display         *dpy;
  int              one = 1;
#endif

  error = NULL;

  clutter_init_with_args (&argc, &argv,
                          NULL,
                          super_oh_entries,
                          NULL,
                          &error);
  if (error)
    {
      g_warning ("Unable to initialise Clutter:\n%s",
                 error->message);
      g_error_free (error);

      exit (1);
    }

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 800, 600);

  clutter_stage_set_title (CLUTTER_STAGE (stage), "Actors Test");
  clutter_stage_set_color (CLUTTER_STAGE (stage),
		           &stage_color);

#ifdef REQ_NON_COMPOSITION
  /* request non-composited mode */
  clutter_stage_fullscreen (stage);
  xwin = clutter_x11_get_stage_window (stage);
  dpy = XOpenDisplay(NULL);
  non_comp_atom = XInternAtom(dpy, "_HILDON_NON_COMPOSITED_WINDOW", False);
  XChangeProperty (dpy, xwin, non_comp_atom,
                   XA_INTEGER, 32, PropModeReplace,
                   (unsigned char *) &one, 1);
  printf ("stage win is %lx\n", xwin);
  XSync (dpy, False);
#endif

  oh = g_new(SuperOH, 1);

  /* Create a timeline to manage animation */
  timeline = clutter_timeline_new (360, 60); /* num frames, fps */
  g_object_set (timeline, "loop", TRUE, NULL);   /* have it loop */

  /* fire a callback for frame change */
  g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh);

  /* Set up some behaviours to handle scaling  */
  alpha = clutter_alpha_new_full (timeline, CLUTTER_ALPHA_SINE, NULL, NULL);

  scaler_1 = clutter_behaviour_scale_new (alpha,
					  0.5, 0.5,
					  1.0, 1.0);

  scaler_2 = clutter_behaviour_scale_new (alpha,
					  1.0, 1.0,
					  0.5, 0.5);

  /* create a new group to hold multiple actors in a group */
  oh->group = clutter_group_new();

  oh->hand = g_new (ClutterActor*, n_hands);
  for (i = 0; i < n_hands; i++)
    {
      gint x, y, w, h;
      gint radius = get_radius ();

      /* Create a texture from file, then clone in to same resources */
      if (i == 0)
	{
	  if ((oh->hand[i] = clutter_texture_new_from_file ("redhand.png",
							    &error)) == NULL)
	    {
	      g_error ("image load failed: %s", error->message);
	      exit (1);
	    }
	}
      else
	oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE(oh->hand[0]));

      /* Place around a circle */
      w = clutter_actor_get_width (oh->hand[0]);
      h = clutter_actor_get_height (oh->hand[0]);

      x = CLUTTER_STAGE_WIDTH () / 2
	+ radius
	* cos (i * M_PI / (n_hands / 2))
	- w / 2;

      y = CLUTTER_STAGE_HEIGHT () / 2
	+ radius
	* sin (i * M_PI / (n_hands / 2))
	- h / 2;

      clutter_actor_set_position (oh->hand[i], x, y);

      clutter_actor_move_anchor_point_from_gravity (oh->hand[i],
						   CLUTTER_GRAVITY_CENTER);

      /* Add to our group group */
      clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]);

#if 1 /* FIXME: disabled as causes drift? - see comment above */
      if (i % 2)
	clutter_behaviour_apply (scaler_1, oh->hand[i]);
      else
	clutter_behaviour_apply (scaler_2, oh->hand[i]);
#endif
    }

  /* Add the group to the stage */
  clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                               CLUTTER_ACTOR (oh->group));

  /* Show everying ( and map window ) */
  clutter_actor_show (stage);


  g_signal_connect (stage, "button-press-event",
		    G_CALLBACK (input_cb),
		    oh);
  g_signal_connect (stage, "key-release-event",
		    G_CALLBACK (input_cb),
		    oh);

  /* and start it */
  clutter_timeline_start (timeline);

  clutter_main ();

  g_free (oh->hand);
  g_free (oh);

  return 0;
}
コード例 #7
0
ファイル: test-scale.c プロジェクト: Docworld/chromiumos
G_MODULE_EXPORT int
test_scale_main (int argc, char *argv[])
{
  ClutterActor    *stage, *rect;
  ClutterColor     stage_color = { 0x0, 0x0, 0x0, 0xff };
  ClutterColor     rect_color = { 0xff, 0xff, 0xff, 0x99 };
  ClutterColor     white_color = { 0xff, 0xff, 0xff, 0xFF };
  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);

  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_size (rect, 100, 100);
  clutter_actor_set_position (rect, 100, 100);

  clutter_group_add (CLUTTER_GROUP (stage), rect);

  label = clutter_text_new_with_text ("Sans 20px", "");
  clutter_text_set_color (CLUTTER_TEXT (label),
                           &white_color);
  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);

  rect_color.alpha = 0xff;
  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_position (rect, 100, 100);
  clutter_actor_set_size (rect, 100, 100);
  set_next_gravity (rect);

  clutter_group_add (CLUTTER_GROUP (stage), rect);

  timeline = clutter_timeline_new (750);
  alpha    = clutter_alpha_new_with_func (timeline,
				          my_ramp_func,
				          NULL, NULL);

  behave = clutter_behaviour_scale_new (alpha,
					0.0, 0.0,  /* scale start */
					1.0, 1.0); /* scale end */

  clutter_behaviour_apply (behave, rect);

  clutter_timeline_set_loop (timeline, TRUE);
  g_signal_connect_swapped (timeline, "completed",
                            G_CALLBACK (set_next_gravity), rect);
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (timeline);
  g_object_unref (behave);

  return EXIT_SUCCESS;
}