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_clone_no_map (TestConformSimpleFixture *fixture, gconstpointer data) { ClutterActor *stage; ClutterActor *group; ClutterActor *actor; ClutterActor *clone; stage = clutter_stage_get_default (); group = clutter_group_new (); actor = clutter_rectangle_new (); clutter_actor_hide (group); clutter_container_add_actor (CLUTTER_CONTAINER (group), actor); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); g_assert (!(CLUTTER_ACTOR_IS_MAPPED (group))); g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); clone = clutter_clone_new (group); clutter_container_add_actor (CLUTTER_CONTAINER (stage), clone); g_assert (CLUTTER_ACTOR_IS_MAPPED (clone)); g_assert (!(CLUTTER_ACTOR_IS_MAPPED (group))); g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); clutter_actor_destroy (CLUTTER_ACTOR (clone)); clutter_actor_destroy (CLUTTER_ACTOR (group)); }
void test_cogl_multitexture (TestConformSimpleFixture *fixture, gconstpointer data) { TestState state; ClutterActor *stage; ClutterActor *group; guint idle_source; state.frame = 0; stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); group = clutter_group_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); /* We force continuous redrawing of the stage, since we need to skip * the first few frames, and we wont be doing anything else that * will trigger redrawing. */ idle_source = g_idle_add (queue_redraw, stage); g_signal_connect (group, "paint", G_CALLBACK (on_paint), &state); clutter_actor_show_all (stage); clutter_main (); g_source_remove (idle_source); if (g_test_verbose ()) g_print ("OK\n"); }
void opt_show_add_slide (OptShow *self, OptSlide *slide) { ClutterActor *bg, *stage; self->priv->slides = g_list_append(self->priv->slides, slide); self->priv->num_slides++; stage = clutter_stage_get_default(); bg = CLUTTER_ACTOR(opt_slide_get_background_texture (slide)); if (bg == NULL) bg = clutter_clone_new(self->priv->bg); clutter_actor_set_size (bg, clutter_actor_get_width (stage), clutter_actor_get_height (stage)); clutter_group_add (CLUTTER_GROUP(slide), bg); clutter_actor_lower_bottom(bg); clutter_actor_show(bg); opt_menu_add_slide (self->priv->menu, slide); }
static void transition_completed_cb (OptTransition *trans, gpointer data) { OptShow *show = (OptShow *)data; OptSlide *from; OptShowPrivate *priv; ClutterActor *stage; priv = show->priv; from = opt_transition_get_from (trans); stage = clutter_stage_get_default(); /* Remove as to free up resources. */ clutter_actor_hide_all (CLUTTER_ACTOR(from)); clutter_container_remove_actor (CLUTTER_CONTAINER(stage), CLUTTER_ACTOR(from)); /* Reset any tranforms to be safe */ clutter_actor_set_rotation (CLUTTER_ACTOR(from), CLUTTER_X_AXIS, 0, 0, 0, 0); clutter_actor_set_rotation (CLUTTER_ACTOR(from), CLUTTER_Y_AXIS, 0, 0, 0, 0); clutter_actor_set_rotation (CLUTTER_ACTOR(from), CLUTTER_Z_AXIS, 0, 0, 0, 0); /* If needed, update the position */ if (priv->position_label_visible) opt_show_update_position_label (show); /* Disconnect the handler */ g_signal_handler_disconnect (trans, priv->trans_signal_id); priv->trans_signal_id = 0; }
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; }
static void am_ready_cb (GObject *source_object, GAsyncResult *result, gpointer userdata) { TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object); AnerleyFeed *feed; ClutterActor *stage; ClutterActor *scroll_view; ClutterActor *icon_view; ClutterModel *model; GError *error = NULL; if (!tp_account_manager_prepare_finish (account_manager, result, &error)) { g_warning ("Failed to make account manager ready: %s", error->message); g_error_free (error); return; } feed = ANERLEY_FEED (anerley_aggregate_tp_feed_new ()); model = CLUTTER_MODEL (anerley_feed_model_new (feed)); stage = clutter_stage_get_default (); icon_view = anerley_tile_view_new (ANERLEY_FEED_MODEL (model)); scroll_view = mx_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (scroll_view)); clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view), CLUTTER_ACTOR (icon_view)); clutter_actor_set_size (CLUTTER_ACTOR (scroll_view), 640, 480); clutter_actor_show_all (stage); }
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; }
static void tick (ClutterTimeline *timeline, gint msecs, gpointer data) { Flower **flowers = (Flower**)data; gint i = 0; for (i = 0; i < N_FLOWERS; i++) { ClutterActor *stage; flowers[i]->y += flowers[i]->v; flowers[i]->rot += flowers[i]->rv; stage = clutter_stage_get_default (); if (flowers[i]->y > (gint) clutter_actor_get_height (stage)) flowers[i]->y = -clutter_actor_get_height (flowers[i]->ctex); clutter_actor_set_position (flowers[i]->ctex, flowers[i]->x, flowers[i]->y); clutter_actor_set_rotation (flowers[i]->ctex, CLUTTER_Z_AXIS, flowers[i]->rot, clutter_actor_get_width (flowers[i]->ctex)/2, clutter_actor_get_height (flowers[i]->ctex)/2, 0); } }
void test_realized (TestConformSimpleFixture *fixture, gconstpointer data) { ClutterActor *actor; ClutterActor *stage; stage = clutter_stage_get_default (); actor = clutter_rectangle_new (); g_assert (!(CLUTTER_ACTOR_IS_REALIZED (actor))); clutter_actor_hide (actor); /* don't show, so won't map */ clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); clutter_actor_realize (actor); g_assert (CLUTTER_ACTOR_IS_REALIZED (actor)); g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor))); clutter_actor_destroy (actor); }
/* NOTE: actor is not used with MOD_MODULE */ void lib_object_prepare(obj_t *obj, manager_actor_t *actor) { ClutterActor *stage; uint i; assert( obj != NULL ); /* RENDERING ! */ stage = clutter_stage_get_default(); obj->group = clutter_group_new(); clutter_container_add_actor(CLUTTER_CONTAINER(stage), obj->group); /* create box */ for ( i = 0; i < obj->beatcount; i++ ) { obj->beatbox[i] = clutter_round_rectangle_new(); clutter_actor_set_width(obj->beatbox[i], obj->boxsize); clutter_actor_set_height(obj->beatbox[i], obj->boxsize); clutter_actor_set_x(obj->beatbox[i], obj->boxdx + (i * (obj->boxsize + obj->boxmx))); clutter_actor_set_y(obj->beatbox[i], obj->boxdy); clutter_round_rectangle_set_color(CLUTTER_ROUND_RECTANGLE(obj->beatbox[i]), &obj->beat_background); clutter_round_rectangle_set_border_color(CLUTTER_ROUND_RECTANGLE(obj->beatbox[i]), &obj->beat_border); clutter_round_rectangle_set_border_width(CLUTTER_ROUND_RECTANGLE(obj->beatbox[i]), obj->boxborderwidth); clutter_container_add_actor(CLUTTER_CONTAINER(obj->group), obj->beatbox[i]); } na_event_observe(NA_EV_BPM, metronome_bpm, obj); }
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; }
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 }; 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[]) { 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; }
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_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[]) { 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 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; }
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; }
void test_cogl_simple_rig (void) { ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); }
int main(int argc, char *argv[]) { GstElement *pipeline, *sink; ClutterTimeline *timeline; ClutterActor *stage, *texture; /* clutter-gst takes care of initializing Clutter and GStreamer */ if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) { g_error ("Failed to initialize clutter\n"); return -1; } stage = clutter_stage_get_default (); /* Make a timeline */ timeline = clutter_timeline_new (1000); g_object_set(timeline, "loop", TRUE, NULL); /* Create new texture and disable slicing so the video is properly mapped onto it */ texture = CLUTTER_ACTOR (g_object_new (CLUTTER_TYPE_TEXTURE, "disable-slicing", TRUE, NULL)); g_signal_connect (texture, "size-change", G_CALLBACK (size_change), NULL); /* Build the GStreamer pipeline */ pipeline = gst_parse_launch ("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL); /* Instantiate the Clutter sink */ sink = gst_element_factory_make ("autocluttersink", NULL); if (sink == NULL) { /* Revert to the older cluttersink, in case autocluttersink was not found */ sink = gst_element_factory_make ("cluttersink", NULL); } if (sink == NULL) { g_printerr ("Unable to find a Clutter sink.\n"); return -1; } /* Link GStreamer with Clutter by passing the Clutter texture to the Clutter sink*/ g_object_set (sink, "texture", texture, NULL); /* Add the Clutter sink to the pipeline */ g_object_set (pipeline, "video-sink", sink, NULL); /* Start playing */ gst_element_set_state (pipeline, GST_STATE_PLAYING); /* start the timeline */ clutter_timeline_start (timeline); /* Add texture to the stage, and show it */ clutter_group_add (CLUTTER_GROUP (stage), texture); clutter_actor_show_all (stage); clutter_main(); /* Free resources */ gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); return 0; }
/*** Object functions ***/ IO_METHOD(IoClutterStage, getDefault) { ClutterActor *default_stage = clutter_stage_get_default(); IoClutterStage *stage = IoClutterStage_newWithActor(IOSTATE, default_stage); IoClutterActor *actor = IoClutterActor_newWithActor(IOSTATE, default_stage); IoObject_setSlot_to_(stage, IOSYMBOL("actor"), actor); return actor; }
ClutterActor * new_stage(void){ static const ClutterColor black = {0, 0, 0, 255}; ClutterActor *stage = clutter_stage_get_default(); clutter_stage_set_color(CLUTTER_STAGE(stage), &black); clutter_stage_set_fullscreen(CLUTTER_STAGE(stage), TRUE); clutter_stage_hide_cursor(CLUTTER_STAGE(stage)); return stage; }
static VALUE rbclt_stage_get_default () { ClutterActor *actor = clutter_stage_get_default (); if (actor == NULL) return Qnil; else return GOBJ2RVAL (actor); }
G_MODULE_EXPORT gint test_text_main (gint argc, gchar **argv) { ClutterActor *stage; ClutterActor *text; ClutterColor text_color = { 0x33, 0xff, 0x33, 0xff }; ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff }; ClutterColor background_color = { 0x00, 0x00, 0x00, 0xff }; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color); text = clutter_text_new_full (FONT, "·", &text_color); clutter_container_add (CLUTTER_CONTAINER (stage), text, NULL); clutter_actor_set_position (text, 40, 30); clutter_actor_set_width (text, 1024); clutter_text_set_line_wrap (CLUTTER_TEXT (text), TRUE); clutter_actor_set_reactive (text, TRUE); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), text); clutter_text_set_editable (CLUTTER_TEXT (text), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE); clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color); if (argv[1]) { GError *error = NULL; gchar *utf8; g_file_get_contents (argv[1], &utf8, NULL, &error); if (error) { utf8 = g_strconcat ("Unable to open '", argv[1], "':\n", error->message, NULL); g_error_free (error); } clutter_text_set_text (CLUTTER_TEXT (text), utf8); } else clutter_text_set_text (CLUTTER_TEXT (text), runes); clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
G_MODULE_EXPORT int test_easing_main (int argc, char *argv[]) { ClutterActor *stage, *rect, *label; ClutterColor stage_color = { 0x88, 0x88, 0xdd, 0xff }; ClutterColor rect_color = { 0xee, 0x33, 0, 0xff }; gchar *text; gfloat stage_width, stage_height; gfloat label_width, label_height; clutter_init_with_args (&argc, &argv, NULL, test_easing_entries, NULL, NULL); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); main_stage = stage; clutter_actor_get_size (stage, &stage_width, &stage_height); rect = make_bouncer (&rect_color, 50, 50); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); clutter_actor_set_position (rect, stage_width / 2, stage_height / 2); text = g_strdup_printf ("Easing mode: %s (%d of %d)\n" "Right click to change the easing mode", easing_modes[current_mode].name, current_mode + 1, n_easing_modes); label = clutter_text_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), label); clutter_text_set_font_name (CLUTTER_TEXT (label), "Sans 18px"); clutter_text_set_text (CLUTTER_TEXT (label), text); clutter_actor_get_size (label, &label_width, &label_height); clutter_actor_set_position (label, stage_width - label_width - 10, stage_height - label_height - 10); easing_mode_label = label; g_free (text); g_signal_connect (stage, "button-press-event", G_CALLBACK (on_button_press), rect); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
int main(int argc, char **argv) { ClutterActor *stage; ClutterColor stage_clr = { 0x00, 0x00, 0x00, 0xff }; const gchar *stage_title = { "potassium music player" }; struct sigaction action; g_set_application_name("potassium music player"); clutter_init(&argc, &argv); stage = clutter_stage_get_default(); clutter_actor_set_size(stage, 512, 128); clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_clr); clutter_stage_set_title(CLUTTER_STAGE(stage), stage_title); clutter_actor_set_name(stage, "stage"); clutter_actor_show(stage); /* Setup signal handler for USR1 to dump player state */ memset(&action, 0, sizeof(&action)); sigemptyset(&action.sa_mask); action.sa_handler = dump_data; action.sa_flags = SA_RESTART; sigaction(SIGUSR1, &action, NULL); /* Handle keyboard/mouse events */ g_signal_connect(stage, "event", G_CALLBACK(input_events_cb), NULL); mozart_init(argc, argv); if (argc == 2) { /* * strdup() argv[1] here, as it seems to get mangled by * generate_playlist() */ generate_playlist(strdup(argv[1]), strdup(argv[1])); mozart_switch_playlist(argv[1]); } else { read_checkpoint_data(); } init_icons(stage); g_timeout_add(500, (GSourceFunc)update_display, stage); g_timeout_add_seconds(1, (GSourceFunc)write_checkpoint_data, NULL); g_signal_connect(mozart_bus, "message::state-changed", G_CALLBACK(set_status_icons), stage); clutter_main(); mozart_destroy(); exit(0); }