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; }
int main (int argc, char **argv) { const ClutterColor dark_gray = { 0x40, 0x40, 0x40, 0xff }; ClutterActor *box, *stage; MxApplication *app; MxWindow *window; mex_init (&argc, &argv); app = mx_application_new (&argc, &argv, "test-mex-expander-box", 0); clutter_init (&argc, &argv); mex_style_load_default (); window = mx_application_create_window (app); stage = (ClutterActor *)mx_window_get_clutter_stage (window); clutter_stage_set_color (CLUTTER_STAGE (stage), &dark_gray); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); add_pictures (box); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); mx_window_set_has_toolbar (window, FALSE); clutter_actor_set_size (stage, 640, 480); clutter_actor_show (stage); clutter_main (); return 0; }
/* Wrapper for clutter_init() clutter_init()のラッパー関数 log result of clutter_init() clutter_init()の結果を出力する。 */ static ClutterInitError my_clutter_init( int argc, char *argv[] ) { ClutterInitError ret = clutter_init( &argc, &argv ); switch( ret ) { case CLUTTER_INIT_SUCCESS: dbglog( "Initialisation successful\n" ); break; case CLUTTER_INIT_ERROR_UNKNOWN: errlog( "Unknown error\n" ); break; case CLUTTER_INIT_ERROR_THREADS: errlog( "Thread initialisation failed\n" ); break; case CLUTTER_INIT_ERROR_BACKEND: errlog( "Backend initialisation failed\n" ); break; case CLUTTER_INIT_ERROR_INTERNAL: errlog( "Internal error\n" ); break; default: errlog( "Other error\n" ); break; } return ret; }
G_MODULE_EXPORT int test_animation_main (int argc, char *argv[]) { ClutterActor *stage, *rect; ClutterColor stage_color = { 0x66, 0x66, 0xdd, 0xff }; ClutterColor rect_color = { 0x44, 0xdd, 0x44, 0xff }; ClutterAction *action; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); rect = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); clutter_actor_set_size (rect, 50, 50); clutter_actor_set_anchor_point (rect, 25, 25); clutter_actor_set_position (rect, clutter_actor_get_width (stage) / 2, clutter_actor_get_height (stage) / 2); clutter_actor_set_opacity (rect, 0x88); clutter_actor_set_reactive (rect, TRUE); action = clutter_click_action_new (); g_signal_connect (action, "clicked", G_CALLBACK (on_clicked), NULL); clutter_actor_add_action_with_name (rect, "click", action); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *coglbox; clutter_init(&argc, &argv); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); clutter_actor_set_rotation (coglbox, CLUTTER_Y_AXIS, -30, 200, 0, 0); clutter_actor_set_position (coglbox, 0, 100); clutter_actor_show_all (stage); while (1) { clutter_actor_hide (coglbox); clutter_actor_show (coglbox); SPIN(); } return 0; }
int main (int argc, char *argv[]) { ClutterActor *stage, *scroll, *info; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; /* create a new stage */ stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Pan Action"); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); scroll = create_scroll_actor (stage); clutter_actor_add_child (stage, scroll); info = clutter_text_new_with_text (NULL, "Press <space> to reset the image position."); clutter_actor_add_child (stage, info); clutter_actor_set_position (info, 12, 12); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect (stage, "key-press-event", G_CALLBACK (on_key_press), scroll); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *pane; ClutterActor *button; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) { g_warning ("Unable to initialise Clutter"); return EXIT_FAILURE; } mx_style_load_from_file (mx_style_get_default (), THEMEDIR "/theme.css", NULL); stage = clutter_stage_get_default (); pane = mpl_content_pane_new ("Foo"); clutter_actor_set_size (pane, 480, 320); clutter_container_add_actor (CLUTTER_CONTAINER (stage), pane); button = mx_button_new_with_label ("Bar"); mpl_content_pane_set_header_actor (MPL_CONTENT_PANE (pane), button); button = mx_button_new_with_label ("Baz"); clutter_container_add_actor (CLUTTER_CONTAINER (pane), button); clutter_actor_show_all (stage); clutter_main (); return EXIT_SUCCESS; }
G_MODULE_EXPORT int test_fullscreen_main (int argc, char *argv[]) { ClutterActor *stage; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); g_signal_connect (stage, "fullscreen", G_CALLBACK (on_fullscreen), NULL); g_signal_connect (stage, "unfullscreen", G_CALLBACK (on_unfullscreen), NULL); clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE); clutter_actor_show (stage); g_debug ("stage size: %.2fx%.2f, mapped: %s", clutter_actor_get_width (stage), clutter_actor_get_height (stage), CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false"); g_timeout_add (1000, toggle_fullscreen, NULL); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { gfloat height; ClutterActor *stage, *statusbar; MxStyle *style; if (!clutter_init (&argc, &argv)) return -1; style = mx_style_get_default (); mx_style_load_from_file (style, THEMEDIR "/mutter-dawati.css", NULL); mx_style_load_from_file (mx_style_get_default (), THEMEDIR "/shared/shared.css", NULL); stage = clutter_stage_new (); clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); statusbar = mnb_statusbar_new (NULL); clutter_actor_get_preferred_height (statusbar, -1, NULL, &height); clutter_actor_set_size (statusbar, clutter_actor_get_width (stage), height); clutter_container_add_actor (CLUTTER_CONTAINER (stage), statusbar); clutter_main (); return 0; }
int main (int argc, char *argv[]) { ClutterActor *stage = NULL; g_set_application_name ("AtkEditableText"); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; cally_util_a11y_init (&argc, &argv); stage = clutter_stage_new (); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); make_ui (stage); clutter_actor_show_all (stage); test_atk_text (text_actor); test_atk_text (text_editable_actor); clutter_main (); return 0; }
void show_message (void) { ClutterActor *stage, *label; ClutterColor black = { 0, 0, 0, 255 }; ClutterColor white = { 255, 255, 255, 255 }; clutter_init (NULL, NULL); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &black); clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE); label = clutter_text_new_with_text ("Sans 20", "Cannot find suitable screen mode\n" "Media Explorer requires a 720p screen"); clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE); clutter_text_set_color (CLUTTER_TEXT (label), &white); clutter_container_add_actor (CLUTTER_CONTAINER (stage), label); /* Put the label in the middle */ clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5)); clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5)); clutter_actor_show (stage); clutter_main (); }
int main(int argc, char *argv[]) { clutter_init(&argc, &argv); ClutterActor *stage = NULL; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; ClutterColor red = { 0xff, 0x00, 0x00, 0xff }; stage = clutter_stage_get_default(); clutter_stage_set_title(CLUTTER_STAGE(stage), "Key binder proto"); clutter_stage_set_color(CLUTTER_STAGE(stage), &black); clutter_actor_set_size(stage, WIN_W, WIN_H); App *self = g_new0(App, 1); create_stuff(); self->rectangle = clutter_rectangle_new_with_color(&red); clutter_actor_set_size(self->rectangle, 200, 200); clutter_container_add_actor(CLUTTER_CONTAINER(stage), self->rectangle); g_signal_connect(stage, "key-press-event", G_CALLBACK(key_event_cb), self); clutter_actor_show(stage); clutter_main(); g_free(self); return 0; }
G_MODULE_EXPORT int test_model_main (int argc, char *argv[]) { ClutterModel *model; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; model = clutter_list_model_new (N_COLUMNS, G_TYPE_INT, "Foo", G_TYPE_STRING, "Bar"); g_timeout_add (1000, (GSourceFunc) populate_model, model); g_signal_connect (model, "row-added", G_CALLBACK (on_row_added), NULL); g_signal_connect (model, "row-removed", G_CALLBACK (on_row_removed), NULL); g_signal_connect (model, "sort-changed", G_CALLBACK (on_sort_changed), NULL); g_signal_connect (model, "filter-changed", G_CALLBACK (on_filter_changed), NULL); clutter_main(); g_object_unref (model); return 0; }
int main (int argc, char **argv) { clutter_init (&argc, &argv); show_message (); return 0; }
G_MODULE_EXPORT int test_state_script_main (int argc, char *argv[]) { ClutterActor *stage, *button; ClutterScript *script; GError *error = NULL; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; script = clutter_script_new (); clutter_script_load_from_file (script, TEST_STATE_SCRIPT_FILE, &error); if (error != NULL) g_error ("Unable to load '%s': %s\n", TEST_STATE_SCRIPT_FILE, error->message); stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "State Script"); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); clutter_actor_show (stage); button = CLUTTER_ACTOR (clutter_script_get_object (script, "button")); clutter_container_add_actor (CLUTTER_CONTAINER (stage), button); clutter_actor_add_constraint (button, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); clutter_script_connect_signals (script, NULL); clutter_main (); g_object_unref (script); return EXIT_SUCCESS; }
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; }
G_MODULE_EXPORT int test_offscreen_main (int argc, char *argv[]) { ClutterActor *stage; gboolean offscreen; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); /* Attempt to set up rendering offscreen */ g_object_set (stage, "offscreen", TRUE, NULL); /* See if it worked */ g_object_get (stage, "offscreen", &offscreen, NULL); if (offscreen == FALSE) printf ("FAIL: Unable to setup offscreen rendering\n."); else printf ("SUCCESS: Able to setup offscreen rendering\n."); clutter_actor_show_all (CLUTTER_ACTOR (stage)); clutter_main(); return 0; }
int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *button; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) { g_critical ("Could not initialize Clutter"); return EXIT_FAILURE; } /* For the icon-theme only. */ gtk_init (&argc, &argv); stage = clutter_stage_new (); button = g_object_new (MPD_TYPE_FOLDER_BUTTON, "label", "Documents", "uri", "file:///home/robsta/Documents", NULL); g_signal_connect (button, "clicked", G_CALLBACK (_folder_clicked_cb), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), button); clutter_actor_show_all (stage); clutter_main (); clutter_actor_destroy (stage); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterScript *script; ClutterActor *stage; clutter_init (&argc, &argv); script = clutter_script_new (); load_script_from_file (script, UI_FILE); clutter_script_connect_signals (script, script); clutter_script_get_objects (script, "stage", &stage, NULL); clutter_actor_show (stage); clutter_main (); g_object_unref (script); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { clutter_init(&argc, &argv); ClutterActor *stage = NULL; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; stage = clutter_stage_get_default(); clutter_stage_set_title(CLUTTER_STAGE(stage), "Mx test"); clutter_stage_set_color(CLUTTER_STAGE(stage), &black); clutter_actor_set_size(stage, WIN_W, WIN_H); Assistant *assistant = g_new0(Assistant, 1); assistant->script = require_script(GUI_SCRIPT); assistant->stage = stage; ClutterActor *root = CLUTTER_ACTOR(require_object_from_script(assistant->script, "root")); assistant->slider = CLUTTER_ACTOR(require_object_from_script(assistant->script, "slider")); assistant->combo_box = CLUTTER_ACTOR(require_object_from_script(assistant->script, "combo_box")); clutter_container_add_actor(CLUTTER_CONTAINER(stage), root); // Combo box contents: MxComboBox *combo_box = MX_COMBO_BOX(assistant->combo_box); mx_combo_box_append_text(combo_box, "Foo"); mx_combo_box_append_text(combo_box, "Spam"); mx_combo_box_append_text(combo_box, "Lorem ipsum"); mx_combo_box_set_index(combo_box, 0); // DONE g_signal_connect(stage, "key-press-event", G_CALLBACK(key_event_cb), assistant); clutter_script_connect_signals(assistant->script, assistant); assistant->ready_ = TRUE; clutter_actor_show(stage); clutter_main(); return 0; }
int main (int argc, char *argv[]) { if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return -1; gfreenect_device_new (0, GFREENECT_SUBDEVICE_CAMERA, NULL, on_new_kinect_device, NULL); signal (SIGINT, quit); clutter_main (); if (kinect != NULL) g_object_unref (kinect); if (skeleton != NULL) { g_object_unref (skeleton); } return 0; }
G_MODULE_EXPORT int test_fbo_main (int argc, char *argv[]) { ClutterColor blue = {0x33, 0x44, 0x55, 0xff}; ClutterActor *fbo; ClutterActor *onscreen_source; ClutterActor *stage; ClutterAnimation *animation; int x_pos = 200; int y_pos = 100; clutter_init (&argc, &argv); if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE) g_error("This test requires CLUTTER_FEATURE_OFFSCREEN"); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_stage_set_color (CLUTTER_STAGE (stage), &blue); /* Create the first source */ onscreen_source = make_source(); clutter_actor_show_all (onscreen_source); clutter_group_add (stage, onscreen_source); y_pos = (STAGE_HEIGHT/2.0) - (clutter_actor_get_height (onscreen_source)/2.0); clutter_actor_set_position (onscreen_source, x_pos, y_pos); x_pos += clutter_actor_get_width (onscreen_source); animation = clutter_actor_animate (onscreen_source, CLUTTER_LINEAR, 5000, /* 1 second duration */ "rotation-angle-y", 360.0f, NULL); clutter_animation_set_loop (animation, TRUE); /* Second hand = actor from onscreen_source */ if ((fbo = clutter_texture_new_from_actor (onscreen_source)) == NULL) g_error("onscreen fbo creation failed"); clutter_actor_set_position (fbo, x_pos, y_pos); x_pos += clutter_actor_get_width (fbo); clutter_group_add (stage, fbo); /* Third hand = actor from Second hand */ if ((fbo = clutter_texture_new_from_actor (fbo)) == NULL) g_error("fbo from fbo creation failed"); clutter_actor_set_position (fbo, x_pos, y_pos); x_pos += clutter_actor_get_width (fbo); clutter_group_add (stage, fbo); clutter_actor_show_all (stage); clutter_main (); return 0; }
int main (int argc, char **argv) { ClutterActor *stage, *image, *sub_image; CoglHandle texture, sub_texture; gfloat image_width, image_height; /* Initialize Clutter */ if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) return 1; /* Get the default stage */ stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Sub-texture"); /* Create a new ClutterTexture that shows smiley.png */ image = clutter_texture_new_from_file ("smiley.png", NULL); clutter_actor_get_size (image, &image_width, &image_height); clutter_actor_set_size (stage, image_width * 3 / 2 + 30, image_height + 20); /* Grab the CoglHandle of the underlying Cogl texture */ texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (image)); /* Create a new Cogl texture from the handle above. That new texture is a * rectangular region from image, more precisely the north ouest corner * of the image */ sub_texture = cogl_texture_new_from_sub_texture (texture, 0, 0, image_width / 2, image_height / 2); /* Finally, use the newly created Cogl texture to feed a new ClutterTexture * and thus create a new actor that displays sub_texture */ sub_image = clutter_texture_new (); clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (sub_image), sub_texture); /* * You could have used the more straightforward g_object_new() function that * can create an object and set some properties on it at the same time: * sub_image = g_object_new (CLUTTER_TYPE_TEXTURE, * "cogl-texture", sub_texture, * NULL); */ /* Put the original image at (10,10) and the new sub image next to it */ clutter_actor_set_position (image, 10, 10); clutter_actor_set_position (sub_image, 20 + image_width, 10); /* Add both ClutterTexture to the stage */ clutter_container_add (CLUTTER_CONTAINER (stage), image, sub_image, NULL); clutter_actor_show_all (stage); clutter_main (); return 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; }
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; }
G_MODULE_EXPORT gint test_texture_quality_main (int argc, char *argv[]) { ClutterTimeline *timeline; ClutterAlpha *alpha; ClutterBehaviour *depth_behavior; ClutterActor *stage; ClutterActor *image; ClutterColor stage_color = { 0x12, 0x34, 0x56, 0xff }; ClutterFog stage_fog = { 10.0, -50.0 }; GError *error; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_fog (CLUTTER_STAGE (stage), &stage_fog); g_signal_connect (stage, "button-press-event", G_CALLBACK (clutter_main_quit), NULL); error = NULL; image = clutter_texture_new_from_file (argv[1]?argv[1]:"redhand.png", &error); if (error) g_error ("Unable to load image: %s", error->message); if (!argv[1]) g_print ("Hint: the redhand.png isn't a good test image for this test.\n" "This test can take any clutter loadable image as an argument\n"); /* center the image */ clutter_actor_set_position (image, (clutter_actor_get_width (stage) - clutter_actor_get_width (image))/2, (clutter_actor_get_height (stage) - clutter_actor_get_height (image))/2); clutter_container_add (CLUTTER_CONTAINER (stage), image, NULL); timeline = clutter_timeline_new (5000); g_signal_connect (timeline, "completed", G_CALLBACK (timeline_completed), NULL); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 400); clutter_behaviour_apply (depth_behavior, image); clutter_actor_show (stage); clutter_timeline_start (timeline); g_timeout_add (10000, change_filter, image); clutter_main (); g_object_unref (depth_behavior); g_object_unref (timeline); return EXIT_SUCCESS; }
/** * mpl_panel_clutter_init_lib: * @argc: (inout): a pointer to the number of command line arguments * @argv: (array length=argc) (inout) (allow-none): a pointer to the array * of command line arguments * * Initialializes the libdawati-panel library when used in a Clutter-based * panel that do not use Gtk (panels that also use Gtk should use * mpl_panel_clutter_init_with_gtk() instead). * * This function calls clutter_init(). */ void mpl_panel_clutter_init_lib (gint *argc, gchar ***argv) { if (CLUTTER_INIT_SUCCESS != clutter_init (argc, argv)) { g_error ("Unable to initialize Clutter.\n"); } }
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; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *red; ClutterActor *green; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); red = clutter_rectangle_new_with_color (&red_color); clutter_actor_set_size (red, 100, 100); clutter_actor_set_position (red, 50, 150); clutter_actor_set_reactive (red, TRUE); green = clutter_rectangle_new_with_color (&green_color); clutter_actor_set_size (green, 100, 100); clutter_actor_set_position (green, 250, 150); clutter_actor_set_reactive (green, TRUE); g_signal_connect (red, "button-press-event", G_CALLBACK (button_event_cb), NULL); g_signal_connect (red, "button-release-event", G_CALLBACK (button_event_cb), NULL); g_signal_connect (green, "button-press-event", G_CALLBACK (button_event_cb), NULL); g_signal_connect (green, "button-release-event", G_CALLBACK (button_event_cb), NULL); clutter_container_add (CLUTTER_CONTAINER (stage), red, green, NULL); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
gint main (gint argc, gchar *argv[]) { ClutterContent *image; ClutterActor *stage; ClutterActor *box; GdkPixbuf *pixbuf; if (clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS) { g_printerr("Failed to initialize clutter.\n"); return 1; } stage = clutter_stage_new(); clutter_stage_set_title (CLUTTER_STAGE (stage), "Image Viewer"); clutter_actor_set_size(stage, 1400, 1200); clutter_actor_set_position(stage, 100, 100); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); clutter_actor_show(stage); pixbuf = gdk_pixbuf_new_from_file("testimage_8000.png", NULL); g_assert(pixbuf); image = clutter_image_new(); clutter_image_set_data(CLUTTER_IMAGE(image), gdk_pixbuf_get_pixels(pixbuf), gdk_pixbuf_get_has_alpha(pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), gdk_pixbuf_get_rowstride(pixbuf), NULL); g_object_unref(pixbuf); box = clutter_actor_new(); clutter_actor_set_position(box, 0, 0); clutter_actor_set_height(box, 8000); clutter_actor_set_width(box, 1200); //clutter_actor_add_constraint(box, clutter_bind_constraint_new(stage, CLUTTER_BIND_WIDTH, 0.0)); clutter_actor_set_content(box, image); clutter_actor_add_child(stage, box); clutter_actor_show(box); clutter_stage_set_fullscreen(CLUTTER_STAGE(stage), TRUE); clutter_actor_animate(box, CLUTTER_EASE_IN_OUT_QUAD, 4000, "y", -8000.0, NULL); clutter_main(); return 0; }