int
main(int argc, char **argv)
{
  TestState state;

  clutter_init(&argc, &argv);
  
  state.timeline = 
    clutter_timeline_new (TEST_TIMELINE_FRAME_COUNT,
                          TEST_TIMELINE_FPS);
  clutter_timeline_set_loop (state.timeline, TRUE);
  g_signal_connect (G_OBJECT(state.timeline),
                    "new-frame",
                    G_CALLBACK(new_frame_cb),
                    &state);
  g_signal_connect (G_OBJECT(state.timeline),
                    "completed",
                    G_CALLBACK(completed_cb),
                    &state);

  state.prev_frame = -1;
  state.completion_count = 0;
  state.passed = TRUE;

  clutter_timeline_start (state.timeline);
  
  clutter_main();
  
  return EXIT_FAILURE;
}
Exemple #2
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *coglbox;
  ClutterTimeline *tl;

  clutter_init(&argc, &argv);

  tl = clutter_timeline_new (G_N_ELEMENTS (paint_func) * 1000);
  clutter_timeline_set_loop (tl, TRUE);
  clutter_timeline_start (tl);

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 400, 400);
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test");

  coglbox = clutter_group_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
  g_signal_connect (coglbox, "paint", G_CALLBACK (paint_cb), tl);
  /* Redraw every frame of the timeline */
  g_signal_connect_swapped (tl, "new-frame",
                            G_CALLBACK (clutter_actor_queue_redraw), coglbox);

  clutter_actor_set_rotation (coglbox, CLUTTER_Y_AXIS, -30, 200, 0, 0);
  clutter_actor_set_position (coglbox, 0, 100);

  clutter_actor_show (stage);

  clutter_main ();

  g_object_unref (tl);

  return 0;
}
void
test_timeline_interpolate (TestConformSimpleFixture *fixture, 
			   gconstpointer data)
{
  TestState state;

  state.timeline = 
    clutter_timeline_new (TEST_TIMELINE_DURATION);
  clutter_timeline_set_loop (state.timeline, TRUE);
  g_signal_connect (G_OBJECT(state.timeline),
		    "new-frame",
		    G_CALLBACK(new_frame_cb),
		    &state);
  g_signal_connect (G_OBJECT(state.timeline),
		    "completed",
		    G_CALLBACK(completed_cb),
		    &state);

  state.completion_count = 0;
  state.new_frame_counter = 0;
  state.passed = TRUE;
  state.expected_frame = 0;

  g_get_current_time (&state.start_time);
  clutter_timeline_start (state.timeline);
  
  clutter_main();

  g_object_unref (state.timeline);
}
Exemple #4
0
G_MODULE_EXPORT int
test_viewport_main (int argc, char *argv[])
{
  ClutterTimeline  *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *r_behave;
  ClutterActor     *stage;
  ClutterActor     *hand;
  ClutterColor      stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
  gchar            *file;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();

  clutter_stage_set_color (CLUTTER_STAGE (stage),
		           &stage_color);

  /* Make a hand */
  file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
  hand = clutter_texture_new_from_file (file, NULL);
  if (!hand)
    g_error("Unable to load image '%s'", file);

  g_free (file);

  clutter_actor_set_position (hand, 300, 200);
  clutter_actor_set_clip (hand, 20, 21, 132, 170);
  clutter_actor_set_anchor_point (hand, 86, 125);
  clutter_actor_show (hand);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand);

  /* Make a timeline */
  timeline = clutter_timeline_new (7692);
  clutter_timeline_set_loop (timeline, TRUE);

  /* Set an alpha func to power behaviour */
  alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);

  /* Create a behaviour for that alpha */
  r_behave = clutter_behaviour_rotate_new (alpha,
					   CLUTTER_Z_AXIS,
					   CLUTTER_ROTATE_CW,
					   0.0, 360.0); 

  /* Apply it to our actor */
  clutter_behaviour_apply (r_behave, hand);

  /* start the timeline and thus the animations */
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (r_behave);

  return 0;
}
Exemple #5
0
int main(int argc,char *argv[])
{

  ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
  ClutterColor actor_color = { 0xff,0xff,0xff,0x98};

  /** 初始化clutter */
  clutter_init(&argc, &argv);

  /** 获取默认的场景stage */
  ClutterActor *stage = clutter_stage_get_default();
  /** 设置场景大小,注意场景也actor的一种,所以可以使用actor的api设置*/
  clutter_actor_set_size(stage,400,400);
  /** 设置场景背景*/
  clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_color);



  /** 载入一个图像的actor */
  //ClutterActor * image = clutter_texture_new_from_file("demo.png",NULL);
  image = clutter_texture_new_from_file("demo.png",NULL);
  if(!image){
	  printf("load image error\n");
	  exit(-1);
  }

  /** 设置actor在场景中的位置*/
  clutter_actor_set_position(image, 100,100);
  /** 缩放图像,这里设置长宽各放大了两倍*/
  clutter_actor_set_scale(image,2.0,2.0);

  /** 设置图像旋转,以y轴旋转,角度20'c */
  clutter_actor_set_rotation(image, CLUTTER_Y_AXIS, 120,0,0,0);
  /** 把actor加入场景中*/
  clutter_container_add_actor(CLUTTER_CONTAINER(stage),image);
  clutter_actor_show(image);


  /** 打开actor的事件响应*/
  clutter_actor_set_reactive(image,TRUE);

  /** 连接actor的某事件*/
  g_signal_connect(image, "button-press-event", G_CALLBACK(on_image_button_press),NULL);

  /** 加入时间线*/
  //ClutterTimeline* timeline = clutter_timeline_new(5000);
  timeline = clutter_timeline_new(5000);
  g_signal_connect(timeline, "new-frame",G_CALLBACK(on_timeline_new_frame),NULL);
  clutter_timeline_set_loop(timeline,TRUE);
  //clutter_timeline_start(timeline);

  clutter_actor_show(stage);

  clutter_main();
  
  g_object_unref(timeline);
	printf("\n");
	return 0;
}
Exemple #6
0
int
main (int   argc,
      char *argv[])
{
  ClutterActor *stage;
  ClutterPath *path;
  ClutterConstraint *constraint;
  ClutterActor *rectangle;
  ClutterTimeline *timeline;

  const ClutterColor *stage_color = clutter_color_new (51, 51, 85, 255);
  const ClutterColor *red_color = clutter_color_new (255, 0, 0, 255);

  clutter_init (&argc, &argv);

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, 360, 300);
  clutter_stage_set_color (CLUTTER_STAGE (stage), stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  /* create the path */
  path = clutter_path_new ();
  clutter_path_add_move_to (path, 30, 60);

  /* add a curve round to the top-right of the stage */
  clutter_path_add_rel_curve_to (path,
                                 120, 180,
                                 180, 120,
                                 240, 0);

  /* create a constraint based on the path */
  constraint = clutter_path_constraint_new (path, 0.0);

  /* put a rectangle at the start of the path */
  rectangle = clutter_rectangle_new_with_color (red_color);
  clutter_actor_set_size (rectangle, 60, 60);

  /* add the constraint to the rectangle */
  clutter_actor_add_constraint_with_name (rectangle, "path", constraint);

  /* add the rectangle to the stage */
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle);

  /* set up the timeline */
  timeline = clutter_timeline_new (1000);
  clutter_timeline_set_loop (timeline, TRUE);
  clutter_timeline_set_auto_reverse (timeline, TRUE);

  clutter_actor_animate_with_timeline (rectangle, CLUTTER_LINEAR, timeline,
                                       "@constraints.path.offset", 1.0,
                                       NULL);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
Exemple #7
0
int
test_cairo_flowers_main (int argc, char **argv)
{
  int              i;
  ClutterActor    *stage;
  ClutterColor     stage_color = { 0x0, 0x0, 0x0, 0xff };
  ClutterTimeline *timeline;
  Flower          *flowers[N_FLOWERS];

  srand (time (NULL));

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

  stage = clutter_stage_get_default ();

  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  for (i=0; i< N_FLOWERS; i++)
    {
      flowers[i]       = g_new0(Flower, 1);
      flowers[i]->ctex = make_flower_actor();
      flowers[i]->x    = rand() % (int) clutter_actor_get_width (stage)
                       - (PETAL_MIN + PETAL_VAR) * 2;
      flowers[i]->y    = rand() % (int) clutter_actor_get_height (stage);
      flowers[i]->rv   = rand() % 5 + 1;
      flowers[i]->v    = rand() % 10 + 2;

      clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                                   flowers[i]->ctex);
      clutter_actor_set_position (flowers[i]->ctex,
				  flowers[i]->x, flowers[i]->y);
    }

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

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

  clutter_actor_show (stage);

  clutter_timeline_start (timeline);

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

  clutter_main();

  return EXIT_SUCCESS;
}
G_MODULE_EXPORT int
test_cogl_vertex_buffer_main (int argc, char *argv[])
{
  TestState       state;
  ClutterActor   *stage;
  gfloat          stage_w, stage_h;
  gint            dummy_width, dummy_height;

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

  stage = clutter_stage_new ();

  clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Vertex Buffers");
  clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
  g_signal_connect (stage, "destroy", G_CALLBACK (stop_and_quit), &state);
  clutter_actor_get_size (stage, &stage_w, &stage_h);

  dummy_width = MESH_WIDTH * QUAD_WIDTH;
  dummy_height = MESH_HEIGHT * QUAD_HEIGHT;
  state.dummy = create_dummy_actor (dummy_width, dummy_height);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), state.dummy);
  clutter_actor_set_position (state.dummy,
                              (stage_w / 2.0) - (dummy_width / 2.0),
                              (stage_h / 2.0) - (dummy_height / 2.0));

  state.timeline = clutter_timeline_new (1000);
  clutter_timeline_set_loop (state.timeline, TRUE);

  state.frame_id = g_signal_connect (state.timeline,
                                     "new-frame",
                                     G_CALLBACK (frame_cb),
                                     &state);

  g_signal_connect (state.dummy, "paint", G_CALLBACK (on_paint), &state);

  init_quad_mesh (&state);

  clutter_actor_show_all (stage);

  clutter_timeline_start (state.timeline);

  clutter_main ();

  cogl_handle_unref (state.buffer);
  cogl_handle_unref (state.indices);

  return 0;
}
int
main (int   argc,
      char *argv[])
{
  ClutterActor *stage;
  ClutterActor *actor;
  ClutterTimeline *timeline;
  ClutterAnimator *animator;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 300, 200);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  actor = clutter_rectangle_new_with_color (&red_color);
  clutter_actor_set_size (actor, 100, 100);
  clutter_actor_set_position (actor, 150, 50);

  timeline = clutter_timeline_new (2000);
  clutter_timeline_set_loop (timeline, TRUE);

  animator = clutter_animator_new ();
  clutter_animator_set_timeline (animator, timeline);

  clutter_animator_set (animator,
                        actor, "x", CLUTTER_LINEAR, 0.0, 150.0,
                        actor, "x", CLUTTER_LINEAR, 0.5, 50.0,
                        actor, "x", CLUTTER_LINEAR, 1.0, 150.0,
                        NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);

  g_signal_connect (stage,
                    "key-press-event",
                    G_CALLBACK (key_pressed_cb),
                    timeline);

  clutter_actor_show (stage);

  clutter_main ();

  g_object_unref (animator);

  return EXIT_SUCCESS;
}
Exemple #10
0
bool StageManager::initStage()
{
    stage_ = clutter_stage_get_default();

    float width = (float) getAttribute("size").getInt(0);
    float height =(float) getAttribute("size").getInt(1);
    clutter_actor_set_size(stage_, width, height);
    clutter_stage_set_color(CLUTTER_STAGE(stage_), &black);
    g_signal_connect(stage_, "destroy", G_CALLBACK(on_stage_destroyed), (gpointer) this);

    std::string filename = getAttribute("script").getString(0);

    GError *error = NULL;
    /* load JSON from a file */
    ClutterScript *script = clutter_script_new();
    clutter_script_load_from_file(script, filename.c_str(), &error);

    if (error != NULL)
    {
        std::cerr << "Unable to read file: " <<  error->message << std::endl;
        g_error_free(error);
        // TODO: fail
        g_critical("Could not load GUI");
        return false;
    }
    ClutterActor *group0 = CLUTTER_ACTOR(clutter_script_get_object(script, "group0")); // TODO: rename to root
    clutter_container_add_actor(CLUTTER_CONTAINER(stage_), group0);
    //clutter_script_connect_signals(script, this);
    clutter_script_connect_signals_full(script, tempi_clutter_connect_signals, this);

    // timeline to attach a callback for each frame that is rendered
    ClutterTimeline *timeline;
    timeline = clutter_timeline_new(60); // ms
    clutter_timeline_set_loop(timeline, TRUE);
    clutter_timeline_start(timeline);
    g_signal_connect(timeline, "new-frame", G_CALLBACK(on_frame_cb), this);
    g_signal_connect(stage_, "key-press-event", G_CALLBACK(key_event_cb), this);
    g_object_unref(script); // avoid memory leak

    clutter_actor_show(stage_);

    if (CLUTTER_IS_ACTOR(stage_))
        return true;
    else
        return false;
}
Exemple #11
0
int main(int argc, char *argv[])
{
  ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
  ClutterColor rect_color = { 0xff, 0xff, 0xff, 0x99 };

  clutter_init (&argc, &argv);

  /* Get the stage and set its size and color: */
  ClutterActor *stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 200, 200);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  /* Add a rectangle to the stage: */
  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_size (rect, 40, 40);
  clutter_actor_set_position (rect, 10, 10);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
  clutter_actor_show (rect);

  /* Show the stage: */
  clutter_actor_show (stage);

  ClutterTimeline *timeline =  clutter_timeline_new(5000 /* milliseconds */);
  clutter_timeline_set_loop(timeline, TRUE);
  clutter_timeline_start(timeline);

  /* Create a clutter alpha for the animation */
  ClutterAlpha* alpha = clutter_alpha_new_with_func (timeline, &on_alpha, NULL, NULL);
  g_object_unref (timeline);

  /* Create an animation to change the properties */
  ClutterAnimation* animation =
    clutter_actor_animate_with_alpha (rect, alpha,
      "x", 150.0,
      "y", 150.0,
      "opacity", 0,
      NULL);

  /* Start the main loop, so we can respond to events: */
  clutter_main ();

  g_object_unref (animation);

  return EXIT_SUCCESS;
}
Exemple #12
0
bool App::launch()
{
    if (osc_recv_port_ == 0)
        if (verbose_)
            std::cout << "OSC receiving disabled." << std::endl;
    else
        startOSC();
    // Poll OSC receiver only when we render a Clutter frame.

    if (stage_)
    {
        std::cerr << "cannot create stage twice" << std::endl;
        //return false;
    }
    stage_ = clutter_stage_get_default();
    clutter_actor_set_size(stage_, 1024, 768);
    ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
    clutter_stage_set_color(CLUTTER_STAGE(stage_), &black);
    g_signal_connect(stage_, "destroy", G_CALLBACK(clutter_main_quit), NULL);
    clutter_actor_set_reactive(stage_, TRUE);

    // timeline to attach a callback for each frame that is rendered
    ClutterTimeline *timeline;
    timeline = clutter_timeline_new(60); // ms
    clutter_timeline_set_loop(timeline, TRUE);
    clutter_timeline_start(timeline);

    g_signal_connect(timeline, "new-frame", G_CALLBACK(on_frame_cb), this);
    g_signal_connect(stage_, "key-press-event", G_CALLBACK(key_event_cb), this);
    g_signal_connect(stage_, "button-press-event", G_CALLBACK(button_press_cb), this);
    g_signal_connect(stage_, "button-release-event", G_CALLBACK(button_released_cb), this);
    g_signal_connect(stage_, "motion-event", G_CALLBACK(motion_event_cb), this);

    if (fullscreen_)
    {
        fullscreen_ = false;
        toggleFullscreen();
    }

    createPalette();

    clutter_actor_show(stage_);
    return true;
}
Exemple #13
0
void
tweet_animation_set_loop (TweetAnimation *animation,
                          gboolean        loop)
{
  TweetAnimationPrivate *priv;

  g_return_if_fail (TWEET_IS_ANIMATION (animation));

  priv = animation->priv;

  if (priv->loop != loop)
    {
      priv->loop = loop;

      if (priv->timeline)
        clutter_timeline_set_loop (priv->timeline, priv->loop);

      g_object_notify (G_OBJECT (animation), "loop");
    }
}
Exemple #14
0
void
on_call_activate_complete (ClutterActor *actor,
			   gpointer user_data)
{
  ClutterAlpha     *alpha;
  ClutterBehaviour *behave;
  App *app = (App*)user_data;

  clutter_actor_hide (app->screen_dialpad);

  /* Setup the pulsing 'calling..' text if need be */
  if (app->dialing_timeline == NULL)
    {
      app->dialing_timeline = clutter_timeline_new (1000);
      clutter_timeline_set_loop (app->dialing_timeline, TRUE);
      alpha = clutter_alpha_new_full (app->dialing_timeline, ALPHA_SINE);
      behave = clutter_behaviour_opacity_new (alpha, 0xff, 0);
      clutter_behaviour_apply (behave, app->dial_label);
    }
  clutter_timeline_start (app->dialing_timeline);

  app->dialing_state = TRUE;
}
Exemple #15
0
/* clutter scene */
ClutterActor *
setup_stage (ClutterStage * stage)
{
  ClutterTimeline *timeline = NULL;
  ClutterActor *texture_actor = NULL;
  ClutterColor rect_color = { 125, 50, 200, 255 };
  ClutterActor *rect_actor = NULL;

  /* texture actor */

  texture_actor = clutter_texture_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture_actor);
  clutter_actor_set_position (texture_actor, 300, 170);
  clutter_actor_set_scale (texture_actor, 0.6, 0.6);
  clutter_actor_show (texture_actor);
  g_object_set_data (G_OBJECT (texture_actor), "stage", stage);

  /* rectangle actor */

  rect_actor = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect_actor);
  clutter_actor_set_size (rect_actor, 50, 50);
  clutter_actor_set_position (rect_actor, 300, 300);
  clutter_actor_show (rect_actor);

  /* timeline */

  timeline = clutter_timeline_new (360, 60);
  g_object_set_data (G_OBJECT (timeline), "texture_actor", texture_actor);
  clutter_timeline_set_loop (timeline, TRUE);
  clutter_timeline_start (timeline);
  g_signal_connect (timeline, "new-frame", G_CALLBACK (on_new_frame),
      rect_actor);

  return texture_actor;
}
Exemple #16
0
int
main (int argc, char **argv)
{
  const ClutterColor transp = { 0x00, 0x00, 0x00, 0x00 };
  const ClutterColor bg_color = { 0xe0, 0xf2, 0xfc, 0xff };
  ClutterTimeline *timeline;
  ClutterActor *stage;
  gint i;

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

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Circles");
  clutter_stage_set_color (CLUTTER_STAGE (stage), &bg_color);
  clutter_actor_set_size (stage, SCREEN_W, SCREEN_H);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  timeline = clutter_timeline_new (5000);
  clutter_timeline_set_loop (timeline, TRUE);
  for (i = 0; i < N_CIRCLES; i++)
    {
      gint size;
      gdouble *angle;
      ClutterActor *actor;
      ClutterAlpha *alpha;
      ClutterBehaviour *behaviour;
      
      actor = clutter_rectangle_new_with_color (&transp);
      
      size = (i + 1) * (CIRCLE_W + CIRCLE_G) * 2;
      clutter_actor_set_size (actor, size, size);
      clutter_actor_set_position (actor,
                                  SCREEN_W - size / 2.0,
                                  SCREEN_H - size / 2.0);
      
      clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
      
      angle = g_slice_new (gdouble);
      *angle = g_random_double_range (0.0, 90.0);
      g_object_set_data (G_OBJECT (actor), "angle", angle);
      g_signal_connect (actor, "paint", G_CALLBACK (circle_paint_cb), NULL);
      
      /* Animate */
      alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
      behaviour = clutter_behaviour_rotate_new (alpha, CLUTTER_Z_AXIS,
                                                (i % 2) ? CLUTTER_ROTATE_CW
                                                        : CLUTTER_ROTATE_CCW,
                                                0.0, 0.0);
      clutter_behaviour_rotate_set_center (CLUTTER_BEHAVIOUR_ROTATE (behaviour),
                                           size / 2,
                                           size / 2,
                                           0);
      clutter_behaviour_apply (behaviour, actor);
    }
  
  
  
  ClutterActor *actor2 = clutter_group_new();
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor2);
  clutter_actor_set_position(actor2, 10, 10);
  
  ClutterEffect *effect2 = nineslice_effect_new_from_source(source);
  clutter_actor_add_effect(actor2, effect2);
  
  ClutterActor *actor = clutter_group_new();
  clutter_container_add_actor (CLUTTER_CONTAINER (actor2), actor);
  
  ClutterEffect *effect = nineslice_effect_new_from_source(source);
  clutter_actor_add_effect(actor, effect);
  
  ClutterActor *text = clutter_text_new_with_text("Sans 40px","Example Text");
  clutter_actor_set_position(text, 0, 0);
  clutter_container_add_actor (CLUTTER_CONTAINER (actor), text);
  
  ClutterActor *rect = clutter_rectangle_new();
  clutter_actor_set_position(rect, 10, 100);
  clutter_actor_set_size(rect, 50, 50);
  clutter_container_add_actor (CLUTTER_CONTAINER (actor), rect);
  
  clutter_actor_set_position(actor, 200, 100);
  //clutter_actor_set_rotation(actor, CLUTTER_Z_AXIS, 30.0, 130, 50, 0);
  
  /*
  GValue cvalue = G_VALUE_INIT;
  g_value_init(&cvalue, CLUTTER_TYPE_ACTOR_BOX);
  g_value_set_boxed(&cvalue, clutter_actor_box_new(0.0, 0.0, 0.0, 0.0));
  
  GValue ovalue = G_VALUE_INIT;
  g_value_init(&ovalue, CLUTTER_TYPE_ACTOR_BOX);
  g_value_set_boxed(&ovalue, clutter_actor_box_new(50.0, 50.0, 50.0, 50.0));
  
  ClutterState *transition = clutter_state_new();
  clutter_state_set_duration(transition, NULL, NULL, 5000);
  clutter_state_set_key (transition, NULL, "close", G_OBJECT(effect), "padding", CLUTTER_LINEAR, &cvalue, 0.0, 0.0);
  clutter_state_set_key (transition, NULL, "open",  G_OBJECT(effect), "padding", CLUTTER_LINEAR, &ovalue, 0.0, 0.0);
  
  //clutter_state_set(transition, NULL, "close", effect, "padding_right", CLUTTER_LINEAR,  0.0, NULL);
  //clutter_state_set(transition, NULL, "open",  effect, "padding_right", CLUTTER_LINEAR, 50.0, NULL);
  
  clutter_state_warp_to_state(transition, "close");
  clutter_state_set_state(transition, "open");
  */
  
  clutter_actor_animate(rect, CLUTTER_LINEAR, 5000, "height", 200.0, NULL);
  
  clutter_actor_show_all (stage);
  
  clutter_timeline_start (timeline);
  
  clutter_main ();
  
  return 0;
}
Exemple #17
0
int main(int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *stage;
  ClutterColor stage_color = { 0xff, 0xff, 0xff, 0xff };
  ClutterTimeline *timeline, *clock;
  GError *error = NULL;
  HandCar *all;

  clutter_init(&argc, &argv);
  clutter_gst_init(&argc, &argv);
  gst_init(&argc, &argv);
  gtk_init(&argc, &argv);

  all = handcar_new ();
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(window), "Clutter Player");
  g_signal_connect(G_OBJECT(window), "delete-event",
                   G_CALLBACK(gtk_main_quit), NULL);

  stage = gtk_clutter_embed_new();
  gtk_widget_set_size_request(stage, STAGE_WIDTH, STAGE_HEIGHT);
  gtk_container_add(GTK_CONTAINER(window), stage);

  all->stage_actor = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(stage));

  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect1);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect2);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect3);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_play);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_previous);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_next);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->label_actor);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->label_time);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->video);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->entry_actor);

  clutter_stage_set_color(CLUTTER_STAGE(all->stage_actor), &stage_color);

  timeline = clutter_timeline_new (100, 5);
  g_signal_connect(G_OBJECT(timeline), "new-frame",
                   G_CALLBACK(on_timeline_new_frame),
                   (gpointer)all);
  clutter_timeline_set_loop(timeline, TRUE);
  clutter_timeline_start(timeline);

  clock = clutter_timeline_new (60, 2);
  g_signal_connect(G_OBJECT(clock), "new-frame",
                   G_CALLBACK(on_update_clock),
                   (gpointer)all);
  clutter_timeline_set_loop(clock, TRUE);
  clutter_timeline_start(clock);

  g_signal_connect (all->stage_actor, "motion-event", G_CALLBACK(mouse_over_lighten), (gpointer) all);
  g_signal_connect (all->stage_actor, "button-press-event", G_CALLBACK(on_click), (gpointer) all);
  clutter_actor_raise_top (all->entry_actor);
  gtk_widget_show_all(window);
  gtk_main();

  return 0;
}
Exemple #18
0
G_MODULE_EXPORT int
test_shader_effects_main (int argc, char *argv[])
{
  ClutterTimeline *timeline;
  ClutterActor *stage, *hand, *label, *rect;
  gchar *file;

  clutter_init (&argc, &argv);

  /* Make a timeline */
  timeline = clutter_timeline_new (7692);
  clutter_timeline_set_loop (timeline, TRUE);

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Rotations");
  clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Aluminium3);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  /* Make a hand */
  file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
  hand = clutter_texture_new_from_file (file, NULL);
  if (!hand)
    g_error("Unable to load '%s'", file);

  g_free (file);

  clutter_actor_set_position (hand, 326, 265);
  clutter_actor_add_effect_with_name (hand, "desaturate", clutter_desaturate_effect_new (0.75));
  clutter_actor_add_effect_with_name (hand, "blur", clutter_blur_effect_new ());
  clutter_actor_animate_with_timeline (hand, CLUTTER_LINEAR, timeline,
                                       "@effects.desaturate.factor", 1.0,
                                       "rotation-angle-z", 360.0,
                                       "fixed::anchor-x", 86.0,
                                       "fixed::anchor-y", 125.0,
                                       "opacity", 128,
                                       NULL);

  rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_DarkOrange);
  clutter_actor_add_effect_with_name (rect, "blur", clutter_blur_effect_new ());
  clutter_actor_set_position (rect, 415, 215);
  clutter_actor_set_size (rect, 150, 150);
  clutter_actor_animate_with_timeline (rect, CLUTTER_LINEAR, timeline,
                                       "rotation-angle-z", 360.0,
                                       "fixed::anchor-x", 75.0,
                                       "fixed::anchor-y", 75.0,
                                       NULL);

  label = clutter_text_new_with_text ("Mono 16",
                                      "The Wonder\n"
                                      "of the\n"
                                      "Spinning Hand");
  clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER);
  clutter_actor_set_position (label, 336, 275);
  clutter_actor_set_size (label, 500, 100);
  clutter_actor_animate_with_timeline (label, CLUTTER_LINEAR, timeline,
                                       "rotation-angle-z", 360.0,
                                       "fixed::anchor-x", 86.0,
                                       "fixed::anchor-y", 125.0,
                                       NULL);

  clutter_container_add (CLUTTER_CONTAINER (stage), rect, hand, label, NULL);
  
  /* start the timeline and thus the animations */
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (timeline);

  return 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;
}
/* The marker is drawn with cairo.  It is composed of 1 static filled circle
 * and 1 stroked circle animated as an echo.
 */
static ClutterActor *
create_marker ()
{
  ClutterActor *marker;
  ClutterActor *bg;
  ClutterTimeline *timeline;
  cairo_t *cr;

  /* Create the marker */
  marker = champlain_custom_marker_new ();

  /* Static filled circle ----------------------------------------------- */
  bg = clutter_cairo_texture_new (MARKER_SIZE, MARKER_SIZE);
  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));

  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint(cr);
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);

  /* Draw the circle */
  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_arc (cr, MARKER_SIZE / 2.0, MARKER_SIZE / 2.0, MARKER_SIZE / 2.0, 0, 2 * M_PI);
  cairo_close_path (cr);

  /* Fill the circle */
  cairo_set_source_rgba (cr, 0.1, 0.1, 0.9, 1.0);
  cairo_fill (cr);

  cairo_destroy (cr);

  /* Add the circle to the marker */
  clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);
  clutter_actor_set_anchor_point_from_gravity (bg, CLUTTER_GRAVITY_CENTER);
  clutter_actor_set_position (bg, 0, 0);

  /* Echo circle -------------------------------------------------------- */
  bg = clutter_cairo_texture_new (2 * MARKER_SIZE, 2 * MARKER_SIZE);
  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));

  /* Draw the circle */
  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_arc (cr, MARKER_SIZE, MARKER_SIZE, 0.9 * MARKER_SIZE, 0, 2 * M_PI);
  cairo_close_path (cr);

  /* Stroke the circle */
  cairo_set_line_width (cr, 2.0);
  cairo_set_source_rgba (cr, 0.1, 0.1, 0.7, 1.0);
  cairo_stroke (cr);

  cairo_destroy (cr);

  /* Add the circle to the marker */
  clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);
  clutter_actor_lower_bottom (bg); /* Ensure it is under the previous circle */
  clutter_actor_set_position (bg, 0, 0);
  clutter_actor_set_anchor_point_from_gravity (bg, CLUTTER_GRAVITY_CENTER);

  /* Animate the echo circle */
  timeline = clutter_timeline_new (1000);
  clutter_timeline_set_loop (timeline, TRUE);
  clutter_actor_set_opacity (CLUTTER_ACTOR (bg), 255);
  clutter_actor_set_scale (CLUTTER_ACTOR (bg), 0.5, 0.5);
  clutter_actor_animate_with_timeline (CLUTTER_ACTOR (bg),
      CLUTTER_EASE_OUT_SINE, 
      timeline, 
      "opacity", 0, 
      "scale-x", 2.0, 
      "scale-y", 2.0, 
      NULL);

  clutter_timeline_start (timeline);

  return marker;
}
Exemple #21
0
G_MODULE_EXPORT int
test_behave_main (int argc, char *argv[])
{
  ClutterTimeline  *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *o_behave, *p_behave;
  ClutterActor     *stage;
  ClutterActor     *group, *rect, *hand;
  ClutterColor      stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
  ClutterColor      rect_bg_color = { 0x33, 0x22, 0x22, 0xff };
  ClutterColor      rect_border_color = { 0, 0, 0, 0 };
  int               i;
  path_t            path_type = PATH_POLY;

  const char       *knots_poly = ("M 0, 0   L 0, 300 L 300, 300 "
                                  "L 300, 0 L 0, 0");

  /* A spiral created with inkscake */
  const char       *knots_bspline =
    "M 34.285713,35.219326 "
    "C 44.026891,43.384723 28.084874,52.378758 20.714286,51.409804 "
    "C 0.7404474,48.783999 -4.6171866,23.967448 1.904757,8.0764719 "
    "C 13.570984,-20.348756 49.798303,-26.746504 74.999994,-13.352108 "
    "C 111.98449,6.3047056 119.56591,55.259271 99.047626,89.505034 "
    "C 71.699974,135.14925 9.6251774,143.91924 -33.571422,116.17172 "
    "C -87.929934,81.254291 -97.88804,5.8941057 -62.857155,-46.209236 "
    "C -20.430061,-109.31336 68.300385,-120.45954 129.2857,-78.114021 "
    "C 201.15479,-28.21129 213.48932,73.938876 163.80954,143.79074 "
    "C 106.45226,224.43749 -9.1490153,237.96076 -87.85713,180.93363 "
    "C -177.29029,116.13577 -192.00272,-12.937817 -127.61907,-100.49494 "
    "C -55.390344,-198.72081 87.170553,-214.62275 183.57141,-142.87593 "
    "C 290.59464,-63.223369 307.68641,92.835839 228.57145,198.07645";

  for (i = 0; i < argc; ++i)
    {
      if (!strncmp (argv[i], "--path", 6))
	{
	  if (!strncmp (argv[i] + 7, "poly", 4))
	    path_type  = PATH_POLY;
	  else if (!strncmp (argv[i] + 7, "bspline", 7))
	    path_type  = PATH_BSPLINE;
	  else if (!strncmp (argv[i] + 7, "ellipse", 7))
	    path_type  = PATH_ELLIPSE;
	}
      else if (!strncmp (argv[i], "--help", 6))
	{
	  printf ("behave [--path=poly|ellipse|bspline]\n");
	  exit (0);
	}
    }
  
  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_hide_cursor (CLUTTER_STAGE (stage));

  g_signal_connect (stage, "button-press-event",
                    G_CALLBACK (button_press_cb),
                    NULL);
  g_signal_connect (stage, "scroll-event",
                    G_CALLBACK (scroll_event_cb),
                    NULL);
  g_signal_connect (stage, "key-press-event",
                    G_CALLBACK (clutter_main_quit),
                    NULL);

  clutter_stage_set_color (CLUTTER_STAGE (stage),
		           &stage_color);

  /* Make a hand */
  group = clutter_group_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
  clutter_actor_show (group);
  
  hand = clutter_texture_new_from_file ("redhand.png", NULL);
  if (hand == NULL)
    {
      g_error("pixbuf load failed");
      return 1;
    }
  clutter_actor_set_position (hand, 0, 0);
  clutter_actor_show (hand);

  rect = clutter_rectangle_new ();
  clutter_actor_set_position (rect, 0, 0);
  clutter_actor_set_size (rect,
                          clutter_actor_get_width (hand),
			  clutter_actor_get_height (hand));
  clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect),
                               &rect_bg_color);
  clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (rect), 10);
  clutter_color_from_string (&rect_border_color, "DarkSlateGray");
  clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (rect),
                                      &rect_border_color);
  clutter_actor_show (rect);
  
  clutter_container_add (CLUTTER_CONTAINER (group), rect, hand, NULL);
  
  /* Make a timeline */
  timeline = clutter_timeline_new (4000); /* num frames, fps */
  clutter_timeline_set_loop (timeline, TRUE);
  g_signal_connect (timeline,
                    "completed", G_CALLBACK (timeline_completed),
                    NULL);

  /* Set an alpha func to power behaviour - ramp is constant rise */
  alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);

  /* Create a behaviour for that alpha */
  o_behave = clutter_behaviour_opacity_new (alpha, 0X33, 0xff); 

  /* Apply it to our actor */
  clutter_behaviour_apply (o_behave, group);

  /* Make a path behaviour and apply that too */
  switch (path_type)
    {
    case PATH_POLY:
      {
        ClutterPath *path = clutter_path_new ();
        clutter_path_set_description (path, knots_poly);
        p_behave = clutter_behaviour_path_new (alpha, path);
      }
      break;
    case PATH_ELLIPSE:
      p_behave =
	clutter_behaviour_ellipse_new (alpha, 200, 200, 400, 300,
				       CLUTTER_ROTATE_CW,
				       0.0, 360.0);

      clutter_behaviour_ellipse_set_angle_tilt (CLUTTER_BEHAVIOUR_ELLIPSE (p_behave),
 						CLUTTER_X_AXIS,
 						45.0);
      clutter_behaviour_ellipse_set_angle_tilt (CLUTTER_BEHAVIOUR_ELLIPSE (p_behave),
 						CLUTTER_Z_AXIS,
 						45.0);
      break;

    case PATH_BSPLINE:
      {
        ClutterPath *path = clutter_path_new ();
        clutter_path_set_description (path, knots_bspline);
        p_behave = clutter_behaviour_path_new (alpha, path);
      }
      break;
    }

  clutter_behaviour_apply (p_behave, group);

  /* start the timeline and thus the animations */
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (o_behave);
  g_object_unref (p_behave);

  return 0;
}
EaseCloseConfirmDialog* ease_close_confirm_dialog_construct (GType object_type, const char* filename, gint seconds) {
#line 99 "ease-close-confirm-dialog.c"
	EaseCloseConfirmDialog * self;
	GtkImage* image;
	GtkLabel* top_label;
	char* _tmp0_;
	char* _tmp1_;
	char* _tmp2_;
	GtkLabel* _tmp3_;
	GtkVBox* vbox;
	GtkHBox* hbox;
	GtkWidget* _tmp4_;
	ClutterTimeline* _tmp5_;
#line 56 "ease-close-confirm-dialog.vala"
	g_return_val_if_fail (filename != NULL, NULL);
#line 113 "ease-close-confirm-dialog.c"
	self = g_object_newv (object_type, 0, NULL);
#line 58 "ease-close-confirm-dialog.vala"
	gtk_window_set_title ((GtkWindow*) self, _ ("Save before closing?"));
#line 59 "ease-close-confirm-dialog.vala"
	gtk_dialog_set_has_separator ((GtkDialog*) self, FALSE);
#line 60 "ease-close-confirm-dialog.vala"
	self->elapsed_seconds = seconds;
#line 63 "ease-close-confirm-dialog.vala"
	image = g_object_ref_sink ((GtkImage*) gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG));
#line 65 "ease-close-confirm-dialog.vala"
	gtk_misc_set_alignment ((GtkMisc*) image, 0.5f, (float) 0);
#line 68 "ease-close-confirm-dialog.vala"
	top_label = g_object_ref_sink ((GtkLabel*) gtk_label_new (""));
#line 69 "ease-close-confirm-dialog.vala"
	g_object_set (top_label, "wrap", TRUE, NULL);
#line 70 "ease-close-confirm-dialog.vala"
	gtk_label_set_use_markup (top_label, TRUE);
#line 71 "ease-close-confirm-dialog.vala"
	gtk_misc_set_alignment ((GtkMisc*) top_label, (float) 0, 0.5f);
#line 72 "ease-close-confirm-dialog.vala"
	gtk_label_set_selectable (top_label, TRUE);
#line 73 "ease-close-confirm-dialog.vala"
	g_object_set ((GtkWidget*) top_label, "can-focus", FALSE, NULL);
#line 74 "ease-close-confirm-dialog.vala"
	gtk_label_set_markup (top_label, _tmp1_ = g_strdup_printf (EASE_CLOSE_CONFIRM_DIALOG_TOP_FORMAT, _tmp0_ = ease_close_confirm_dialog_top_label_text (filename)));
#line 139 "ease-close-confirm-dialog.c"
	_g_free0 (_tmp1_);
	_g_free0 (_tmp0_);
#line 77 "ease-close-confirm-dialog.vala"
	self->priv->bottom_label = (_tmp3_ = g_object_ref_sink ((GtkLabel*) gtk_label_new (_tmp2_ = ease_close_confirm_dialog_bottom_label_text (seconds))), _g_object_unref0 (self->priv->bottom_label), _tmp3_);
#line 144 "ease-close-confirm-dialog.c"
	_g_free0 (_tmp2_);
#line 78 "ease-close-confirm-dialog.vala"
	g_object_set (self->priv->bottom_label, "wrap", TRUE, NULL);
#line 79 "ease-close-confirm-dialog.vala"
	gtk_misc_set_alignment ((GtkMisc*) self->priv->bottom_label, (float) 0, 0.5f);
#line 80 "ease-close-confirm-dialog.vala"
	gtk_label_set_selectable (self->priv->bottom_label, TRUE);
#line 81 "ease-close-confirm-dialog.vala"
	g_object_set ((GtkWidget*) self->priv->bottom_label, "can-focus", FALSE, NULL);
#line 84 "ease-close-confirm-dialog.vala"
	vbox = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 12));
#line 85 "ease-close-confirm-dialog.vala"
	gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) top_label, FALSE, FALSE, (guint) 0);
#line 86 "ease-close-confirm-dialog.vala"
	gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) self->priv->bottom_label, FALSE, FALSE, (guint) 0);
#line 89 "ease-close-confirm-dialog.vala"
	hbox = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 12));
#line 90 "ease-close-confirm-dialog.vala"
	gtk_container_set_border_width ((GtkContainer*) hbox, (guint) 5);
#line 91 "ease-close-confirm-dialog.vala"
	gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) image, FALSE, FALSE, (guint) 0);
#line 92 "ease-close-confirm-dialog.vala"
	gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) vbox, TRUE, TRUE, (guint) 0);
#line 94 "ease-close-confirm-dialog.vala"
	gtk_box_pack_start ((_tmp4_ = gtk_dialog_get_content_area ((GtkDialog*) self), GTK_IS_BOX (_tmp4_) ? ((GtkBox*) _tmp4_) : NULL), (GtkWidget*) hbox, TRUE, TRUE, (guint) 0);
#line 95 "ease-close-confirm-dialog.vala"
	gtk_widget_show_all ((GtkWidget*) hbox);
#line 98 "ease-close-confirm-dialog.vala"
	gtk_dialog_add_buttons ((GtkDialog*) self, _ ("Close _without Saving"), GTK_RESPONSE_NO, "gtk-cancel", GTK_RESPONSE_CANCEL, "gtk-save", GTK_RESPONSE_YES, NULL);
#line 103 "ease-close-confirm-dialog.vala"
	gtk_dialog_set_default_response ((GtkDialog*) self, (gint) GTK_RESPONSE_YES);
#line 106 "ease-close-confirm-dialog.vala"
	self->priv->counter = (_tmp5_ = clutter_timeline_new (EASE_CLOSE_CONFIRM_DIALOG_TICK), _g_object_unref0 (self->priv->counter), _tmp5_);
#line 107 "ease-close-confirm-dialog.vala"
	clutter_timeline_set_loop (self->priv->counter, TRUE);
#line 108 "ease-close-confirm-dialog.vala"
	g_signal_connect_object (self->priv->counter, "completed", (GCallback) _ease_close_confirm_dialog_increment_clutter_timeline_completed, self, 0);
#line 109 "ease-close-confirm-dialog.vala"
	clutter_timeline_start (self->priv->counter);
#line 184 "ease-close-confirm-dialog.c"
	_g_object_unref0 (hbox);
	_g_object_unref0 (vbox);
	_g_object_unref0 (top_label);
	_g_object_unref0 (image);
	return self;
}
int
main (int argc, char *argv[])
{
  ClutterActor *stage, *actor;
  ClutterContainer *container;
  ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
  ClutterColor rect_color = { 0, 0, 0, 0xdd };

  clutter_init (&argc, &argv);

  timeline = clutter_timeline_new_for_duration (5000);
  clutter_timeline_set_loop (timeline, TRUE);
  tmpl =
    clutter_effect_template_new (timeline, CLUTTER_ALPHA_RAMP_INC);

  stage = clutter_stage_get_default ();
  container = CLUTTER_CONTAINER (stage);
  g_signal_connect (stage,
                    "button-press-event", G_CALLBACK (clutter_main_quit), 
                    NULL);

  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE);
  clutter_actor_set_size (stage, 800, 600);
  clutter_actor_show_all (stage);

  actor = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (container, actor);
  clutter_actor_set_size (actor, 50, 50);
  clutter_actor_set_position (actor, 50, 10);
  clutter_effect_fade (tmpl, actor, 0x22, NULL, NULL);
  clutter_actor_show (actor);

  actor = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (container, actor);
  clutter_actor_set_size (actor, 50, 50);
  clutter_actor_set_position (actor, 750, 70);
  clutter_effect_depth (tmpl, actor, -500, NULL, NULL);
  clutter_actor_show (actor);

  actor = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (container, actor);
  clutter_actor_set_size (actor, 50, 50);
  clutter_actor_set_position (actor, 50, 140);
  clutter_effect_move (tmpl, actor, 750, 140, NULL, NULL); 
  clutter_actor_show (actor);

  actor = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (container, actor);
  clutter_actor_set_size (actor, 50, 50);
  clutter_actor_set_position (actor, 750, 210);
  {
    ClutterKnot knots[2];

    knots[0].x = 750; knots[0].y = 210;
    knots[1].x = 350; knots[1].y = 210;

    clutter_effect_path (tmpl, actor, knots, 2, NULL, NULL);
  }
  clutter_actor_show (actor);

  actor = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (container, actor);
  clutter_actor_set_size (actor, 50, 50);
  clutter_actor_set_position (actor, 50, 280);
  clutter_actor_set_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER);
  
  clutter_effect_scale (tmpl, actor, 2.0, 2.0, NULL, NULL);
  clutter_actor_show (actor);

  actor = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (container, actor);
  clutter_actor_set_size (actor, 50, 50);
  clutter_actor_set_position (actor, 750, 350);
  clutter_effect_rotate (tmpl, actor,
                         CLUTTER_Z_AXIS, 180.0,
                         25, 25, 0,
                         CLUTTER_ROTATE_CW,
                         NULL, NULL);
  clutter_actor_show (actor);

  clutter_main ();

  g_object_unref (tmpl);
  g_object_unref (timeline);

  return EXIT_SUCCESS;
}
Exemple #24
0
int main(int argc,char *argv[])
{

  ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };

  clutter_init(&argc, &argv);

  ClutterActor *stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 521, 577);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  //ClutterActor * _group = clutter_group_new();
   _group = clutter_group_new();
  clutter_actor_set_position(_group, 0,0);
  clutter_container_add_actor(CLUTTER_CONTAINER(stage),_group);
  clutter_actor_show(_group);

  /** 加载棋盘图片*/
  ClutterActor* _board = clutter_texture_new_from_file("./wood/wood.png",NULL);

  clutter_actor_set_position(_board,0,0);
  //clutter_actor_set_rotation(_board, CLUTTER_Y_AXIS, 20,0,0,0);
  //clutter_actor_set_rotation(_board, CLUTTER_X_AXIS, 20,0,0,0);
  //clutter_actor_set_rotation(_board, CLUTTER_Z_AXIS, 20,0,0,0);


  //clutter_container_add_actor(CLUTTER_CONTAINER(stage),_board);
  clutter_container_add_actor(CLUTTER_CONTAINER(_group),_board);
  clutter_actor_show(_board);



#if 0
  load_chess();
#else 
  /** 加载棋子*/
  ClutterActor* _rking = clutter_texture_new_from_file("./wood/red_king.png",NULL);
  clutter_actor_set_position(_rking,235,8);
  clutter_container_add_actor(CLUTTER_CONTAINER(_group),_rking);
  clutter_actor_show(_rking);

  clutter_actor_set_reactive(_rking,TRUE);
  g_signal_connect(_rking, "button-press-event",G_CALLBACK(on_rking_button_press),NULL);

  timeline=clutter_timeline_new(3000);
  //g_signal_connect(timeline,"new-frame",G_CALLBACK(on_timeline_new_frame),_rking);
  clutter_timeline_set_loop(timeline,TRUE);

  ClutterAlpha* alpha_ = clutter_alpha_new_full(timeline,
         CLUTTER_EASE_IN_OUT_QUAD);//CLUTTER_EASE_IN_SINE);

  ClutterBehaviour* behaviour_ = clutter_behaviour_rotate_new(alpha_, 
		  CLUTTER_Y_AXIS,
		CLUTTER_ROTATE_CW,
		0,
		360);
  clutter_behaviour_rotate_set_center(CLUTTER_BEHAVIOUR_ROTATE(behaviour_), clutter_actor_get_width(_rking)/2,0,0);
  clutter_behaviour_apply(behaviour_, _rking);

  clutter_actor_set_rotation(_group, CLUTTER_X_AXIS, 40,2,600,0);
  //clutter_actor_set_rotation(_group, CLUTTER_Y_AXIS, 40,221,200,0);


#endif

  clutter_actor_show(stage);
  clutter_main();

  g_object_unref(timeline);

	printf("\n");
	return 0;
}
Exemple #25
0
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;

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

  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_container_add_actor (CLUTTER_CONTAINER (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_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_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;
}
Exemple #26
0
static void
mnb_spinner_constructed (GObject *self)
{
  MnbSpinnerPrivate *priv = MNB_SPINNER (self)->priv;
  MxWidget          *widget = MX_WIDGET (self);
  ClutterTexture    *background;
  ClutterTimeline   *timeline;

  /*
   * Mx does not seem to load the style info until the first show, but we want
   * to get hold of the background asset here to work out the frame count, so
   * we need to force the style loading.
   *
   * NB: mx_widget_ensure_style() does not work here, because the MxWidget
   *     is_style_dirty flag is cleared at this point.
   */
  mx_stylable_style_changed (MX_STYLABLE (widget), MX_STYLE_CHANGED_FORCE);

  if ((background = (ClutterTexture *) mx_widget_get_background_image (widget)))
    {
      gint  tx_w, tx_h;
      guint duration;

      if (!CLUTTER_IS_TEXTURE (background))
        {
          g_critical ("Expected ClutterTexture, but got %s",
                      G_OBJECT_TYPE_NAME (background));
          return;
        }

      /*
       * The background texture is a strip of squares making up the individual
       * frames in the animation, so the width matches the height of the
       * texture.
       */
      clutter_texture_get_base_size (background, &tx_w, &tx_h);

      priv->n_frames = tx_w / tx_h;

      if (tx_w % tx_h)
        g_warning (G_STRLOC ": Expected texture size %d x %d, got %d x %d",
                   tx_h * priv->n_frames, tx_h, tx_w, tx_h);

      /*
       * Setup a looped timeline with a marker that fires everytime we should
       * advance to a new frame.
       *
       * Assume the whole animation is to last 1s.
       */
      duration = 1000/ priv->n_frames;

      timeline = priv->timeline = clutter_timeline_new (duration);

      clutter_timeline_set_loop (timeline, TRUE);
      clutter_timeline_add_marker_at_time (timeline, "next", duration);
      clutter_timeline_stop (timeline);

      g_signal_connect (timeline, "marker-reached",
                        G_CALLBACK (mnb_spinner_marker_reached_cb),
                        self);
    }
  else
    g_warning ("%s did not have background-image set in style !!!",
               G_OBJECT_TYPE_NAME (self));
}
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;
}