ClutterActor * make_source (void) { ClutterActor *source, *actor; GError *error = NULL; gchar *file; ClutterColor yellow = {0xff, 0xff, 0x00, 0xff}; source = clutter_group_new (); file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); actor = clutter_texture_new_from_file (file, &error); if (!actor) g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); g_free (file); clutter_group_add (source, actor); actor = clutter_text_new_with_text ("Sans Bold 50px", "Clutter"); clutter_text_set_color (CLUTTER_TEXT (actor), &yellow); clutter_actor_set_y (actor, clutter_actor_get_height(source) + 5); clutter_group_add (source, actor); return source; }
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; }
static void make_ui (ClutterActor *stage) { ClutterActor *editable = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterGeometry editable_geom = {150, 50, 100, 75}; ClutterActor *full_entry = NULL; ClutterActor *cloned_entry = NULL; clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); clutter_actor_set_size (stage, WIDTH, HEIGHT); label = clutter_text_new_full ("Sans Bold 32px", "Entry", &color_label); clutter_actor_set_position (label, 0, 50); /* editable */ editable = clutter_text_new_full ("Sans Bold 32px", "ddd", &color_text); clutter_actor_set_position (editable, 150, 50); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (editable), &color_sel); clutter_actor_grab_key_focus (editable); clutter_actor_set_reactive (editable, TRUE); /* rectangle: to create a entry "feeling" */ rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_geometry (rectangle, &editable_geom); full_entry = clutter_group_new (); clutter_actor_set_position (full_entry, 0, 50); clutter_actor_set_size (full_entry, 100, 75); clutter_group_add (CLUTTER_GROUP (full_entry), label); clutter_group_add (CLUTTER_GROUP (full_entry), editable); clutter_group_add (CLUTTER_GROUP (full_entry), rectangle); clutter_actor_show_all (full_entry); clutter_actor_set_scale (full_entry, 2, 1); clutter_group_add (CLUTTER_GROUP (stage), full_entry); /* Cloning! */ cloned_entry = clutter_clone_new (full_entry); clutter_actor_set_position (cloned_entry, 50, 200); clutter_actor_set_scale (cloned_entry, 1, 2); clutter_actor_show_all (cloned_entry); clutter_actor_set_reactive (cloned_entry, TRUE); clutter_group_add (CLUTTER_GROUP (stage), cloned_entry); }
static void make_ui (ClutterActor *stage) { gint i = 0; ClutterActor *editable = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterGeometry label_geom = {0, 50, -1, -1}; ClutterGeometry editable_geom = {150, 50, 500, 75}; clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); clutter_actor_set_size (stage, WIDTH, HEIGHT); for (i = 0; i < NUM_ENTRIES; i++) { /* label */ label = clutter_text_new_full ("Sans Bold 32px", "Entry", &color_label); clutter_actor_set_geometry (label, &label_geom); /* editable */ editable = clutter_text_new_full ("Sans Bold 32px", "ddd", &color_text); clutter_actor_set_geometry (editable, &editable_geom); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (editable), &color_sel); clutter_actor_grab_key_focus (editable); clutter_actor_set_reactive (editable, TRUE); /* rectangle: to create a entry "feeling" */ rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_geometry (rectangle, &editable_geom); clutter_group_add (CLUTTER_GROUP (stage), label); clutter_group_add (CLUTTER_GROUP (stage), editable); clutter_group_add (CLUTTER_GROUP (stage), rectangle); label_geom.y += HEIGHT_STEP; editable_geom.y += HEIGHT_STEP; } }
static gboolean action_add_triangle (ClutterActor *action, ClutterEvent *event, gpointer userdata) { const ClutterColor transparent = { 0x00, 0x00, 0x00, 0x01 }; ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterVertex vertices[] = { { 0.5, 0.0, 0.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 } }; ClutterActor *box; box = clutter_rectangle_new_with_color (&transparent); clutter_actor_set_size (box, 50, 50); clutter_actor_set_position (box, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), box); /* Create a triangle vertex array */ clutter_box2d_child_set_outline (CLUTTER_BOX2D (group), box, vertices, 3); g_signal_connect (box, "paint", G_CALLBACK (paint_triangle), NULL); return FALSE; }
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 fluttr_viewer_init (FluttrViewer *self) { FluttrViewerPrivate *priv; gint width, height; ClutterActor *message; priv = FLUTTR_VIEWER_GET_PRIVATE (self); priv->mini_token = NULL; priv->popping = FALSE; width = CLUTTER_STAGE_WIDTH (); height = CLUTTER_STAGE_HEIGHT (); /* message box */ message = clutter_texture_new (); priv->texture = message; clutter_group_add (CLUTTER_GROUP (self),message); clutter_actor_set_size (message, width, height); clutter_actor_set_position (message, -(width/2),-(height/2)); /* Spinner */ priv->spinner = fluttr_spinner_new (); clutter_group_add (CLUTTER_GROUP (self),priv->spinner); clutter_actor_set_size (priv->spinner, (height/6)-11, (height/6)-11); clutter_actor_set_position (priv->spinner, width-(height/6),height-(height/6)); /* Setup the pixbuf swap */ priv->pixbuf = NULL; priv->swap_time = clutter_timeline_new (40, 40); priv->swap_alpha = clutter_alpha_new_full (priv->swap_time, alpha_linear_inc_func, NULL, NULL); priv->swap_behave = fluttr_behave_new (priv->swap_alpha, fluttr_viewer_swap_alpha_func, (gpointer)self); priv->timeline = clutter_timeline_new (40, 80); priv->alpha = clutter_alpha_new_full (priv->timeline, alpha_sine_inc_func, NULL, NULL); priv->behave = fluttr_behave_new (priv->alpha, fluttr_viewer_alpha_func, (gpointer)self); }
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; }
static ClutterActor* _create_button (const gchar *text) { ClutterActor *button = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0xff }; ClutterColor color_label = { 0x00, 0x00, 0x00, 0xff }; button = clutter_group_new (); rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_size (rectangle, 375, 35); label = clutter_text_new_full ("Sans Bold 32px", text, &color_label); clutter_group_add (CLUTTER_GROUP (button), rectangle); clutter_group_add (CLUTTER_GROUP (button), label); clutter_actor_set_reactive (button, TRUE); return button; }
static gboolean action_add_block_tree (ClutterActor *action, ClutterEvent *event, gpointer userdata) { ClutterActor *actor; actor = block_tree_new ("foo"); clutter_group_add (CLUTTER_GROUP (clutter_stage_get_default ()), actor); clutter_actor_set_position (actor, 20, 40); return FALSE; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; App *app; clutter_init (&argc, &argv); ALPHA_SINE = clutter_alpha_register_func (alpha_sine_func, NULL); clutter_interval_register_progress_func (G_TYPE_BOOLEAN, boolean_progress); app = g_new0(App, 1); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, CSW, CSH); make_ui (app); clutter_group_add (CLUTTER_GROUP(stage), app->screen_dial); clutter_group_add (CLUTTER_GROUP(stage), app->screen_dialpad); clutter_actor_hide_all (app->screen_dial); clutter_actor_show_all (stage); g_signal_connect (stage, "event", G_CALLBACK (on_input), app); printf("\n..Press '*' to dial..\n\n"); clutter_main (); return 0; }
static gboolean action_add_image (ClutterActor *action, ClutterEvent *event, gpointer userdata) { ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterActor *actor; actor = clutter_texture_new_from_file (ASSETS_DIR "redhand.png", NULL); clutter_actor_set_position (actor, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), actor); return FALSE; }
static gboolean action_add_rectangle (ClutterActor *action, ClutterEvent *event, gpointer userdata) { ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterActor *box; box = clutter_rectangle_new (); clutter_actor_set_size (box, 100, 100); clutter_actor_set_position (box, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), box); return FALSE; }
void test_show_on_set_parent (TestConformSimpleFixture *fixture, gconstpointer data) { ClutterActor *actor, *group; gboolean show_on_set_parent; ClutterActor *stage; stage = clutter_stage_get_default (); group = clutter_group_new (); g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (group))); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); actor = clutter_rectangle_new (); g_object_get (G_OBJECT (actor), "show-on-set-parent", &show_on_set_parent, NULL); g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor))); g_assert (show_on_set_parent == TRUE); clutter_group_add (group, actor); g_object_get (G_OBJECT (actor), "show-on-set-parent", &show_on_set_parent, NULL); g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor)); g_assert (show_on_set_parent == TRUE); g_object_ref (actor); clutter_actor_unparent (actor); g_object_get (G_OBJECT (actor), "show-on-set-parent", &show_on_set_parent, NULL); g_assert (!CLUTTER_ACTOR_IS_REALIZED (actor)); g_assert (!CLUTTER_ACTOR_IS_MAPPED (actor)); g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor)); g_assert (show_on_set_parent == TRUE); clutter_actor_destroy (actor); clutter_actor_destroy (group); }
ClutterActor * add_hand (ClutterActor *group, gint x, gint y) { ClutterActor *actor; actor = clutter_texture_new_from_file (ASSETS_DIR "redhand.png", NULL); clutter_group_add (CLUTTER_GROUP (group), actor); clutter_actor_set_opacity (actor, 1.0 * 255); clutter_actor_set_position (actor, x, y); clutter_container_child_set (CLUTTER_CONTAINER (group), actor, "manipulatable", TRUE, "mode", CLUTTER_BOX2D_DYNAMIC, NULL); return actor; }
void opt_show_run (OptShow *self) { OptSlide *slide; OptShowPrivate *priv; ClutterActor *stage; ClutterColor col = { 0x22, 0x22, 0x22, 0xff }; priv = self->priv; priv->current_slide_num = 0; slide = g_list_nth_data (priv->slides, 0); stage = clutter_stage_get_default(); clutter_stage_set_color (CLUTTER_STAGE(stage), &col); clutter_group_add (CLUTTER_GROUP(stage), CLUTTER_ACTOR(slide)); clutter_actor_show_all (stage); }
static void add_static_box (ClutterActor *group, gint x, gint y, gint width, gint height) { ClutterActor *box; box = clutter_rectangle_new (); clutter_actor_set_size (box, width, height); clutter_actor_set_position (box, x, y); clutter_group_add (CLUTTER_GROUP (group), box); clutter_container_child_set (CLUTTER_CONTAINER (group), box, "mode", CLUTTER_BOX2D_STATIC, NULL); }
static gboolean action_add_text (ClutterActor *action, ClutterEvent *event, gpointer userdata) { ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterActor *title; ClutterColor color; clutter_color_from_string (&color, "#888"); title = clutter_text_new_full ("Sans 30px", "fnord", &color); clutter_actor_set_position (title, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), title); return FALSE; }
Preview::Preview(): width(0), height(0), blocknr(-1), color(-1), themeID(0), cell_size(20), cache(NULL), enabled(true) { blocks = new Block*[PREVIEW_WIDTH]; for (int i = 0; i < PREVIEW_WIDTH; i++) { blocks[i] = new Block [PREVIEW_HEIGHT]; } w = gtk_clutter_embed_new(); g_signal_connect (w, "size_allocate", G_CALLBACK (resize), this); /* FIXME: We should scale with the rest of the UI, but that requires * changes to the widget layout - i.e. wrap the preview in an * fixed-aspect box. */ gtk_widget_set_size_request (w, 120, 120); ClutterActor *stage; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (w)); ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); piece = clutter_group_new (); clutter_group_add (CLUTTER_GROUP (stage), piece); piece_timeline = clutter_timeline_new (180); alpha = clutter_alpha_new_full (piece_timeline, CLUTTER_EASE_IN_OUT_SINE); piece_behav = clutter_behaviour_scale_new (alpha, 0.6, 0.6, 1.0, 1.0); clutter_actor_set_anchor_point (piece, 60, 60); clutter_actor_set_position (CLUTTER_ACTOR(piece), 60, 60); clutter_behaviour_apply (piece_behav, piece); }
static gboolean action_add_circle (ClutterActor *action, ClutterEvent *event, gpointer userdata) { const ClutterColor transparent = { 0x00, 0x00, 0x00, 0x01 }; ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterActor *box; box = clutter_rectangle_new_with_color (&transparent); clutter_actor_set_size (box, 50, 50); clutter_actor_set_position (box, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), box); clutter_container_child_set (CLUTTER_CONTAINER (group), box, "is-circle", TRUE, NULL); g_signal_connect (box, "paint", G_CALLBACK (paint_circle), NULL); return FALSE; }
void scene_chain (Scene *scene) { ClutterActor *stage; ClutterActor *group; ClutterActor *box; stage = clutter_stage_get_default (); group = clutter_box2d_new (); clutter_group_add (CLUTTER_GROUP (stage), group); scene->group = group; add_cage (group, TRUE); { gint i; gint y; gint numlinks = 32; ClutterActor *prev_actor; y = 50; box = clutter_rectangle_new (); clutter_actor_set_size (box, 18, 5); clutter_actor_set_position (box, clutter_actor_get_width(stage)/2, y); clutter_group_add (CLUTTER_GROUP (group), box); clutter_container_child_set (CLUTTER_CONTAINER (group), box, "mode", CLUTTER_BOX2D_STATIC, NULL); prev_actor = box; numlinks = clutter_actor_get_height (stage)/20; if (clutter_actor_get_width (stage)/20 < numlinks) { numlinks = clutter_actor_get_width (stage)/20; } for (i = 0; i < numlinks; ++i) { box = clutter_rectangle_new (); clutter_actor_set_size (box, 18, 5); clutter_actor_set_position (box, 20 + 20 * i, y+=1); clutter_group_add (CLUTTER_GROUP (group), box); clutter_container_child_set (CLUTTER_CONTAINER (group), box, "manipulatable", TRUE, "mode", CLUTTER_BOX2D_DYNAMIC, NULL); { ClutterVertex anchor1 = { (18.0), (0.0) }; ClutterVertex anchor2 = { (0.0), (0.0) }; clutter_box2d_add_revolute_joint (CLUTTER_BOX2D (group), prev_actor, box, &anchor1, &anchor2); } prev_actor = box; } } clutter_box2d_set_simulating (CLUTTER_BOX2D (group), simulating); }
G_MODULE_EXPORT int test_scale_main (int argc, char *argv[]) { ClutterActor *stage, *rect; ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; ClutterColor rect_color = { 0xff, 0xff, 0xff, 0x99 }; ClutterColor white_color = { 0xff, 0xff, 0xff, 0xFF }; ClutterTimeline *timeline; ClutterAlpha *alpha; ClutterBehaviour *behave; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 300, 300); rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (rect, 100, 100); clutter_actor_set_position (rect, 100, 100); clutter_group_add (CLUTTER_GROUP (stage), rect); label = clutter_text_new_with_text ("Sans 20px", ""); clutter_text_set_color (CLUTTER_TEXT (label), &white_color); clutter_actor_set_position (label, clutter_actor_get_x (rect), clutter_actor_get_y (rect) + clutter_actor_get_height (rect)); clutter_group_add (CLUTTER_GROUP (stage), label); rect_color.alpha = 0xff; rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_position (rect, 100, 100); clutter_actor_set_size (rect, 100, 100); set_next_gravity (rect); clutter_group_add (CLUTTER_GROUP (stage), rect); timeline = clutter_timeline_new (750); alpha = clutter_alpha_new_with_func (timeline, my_ramp_func, NULL, NULL); behave = clutter_behaviour_scale_new (alpha, 0.0, 0.0, /* scale start */ 1.0, 1.0); /* scale end */ clutter_behaviour_apply (behave, rect); clutter_timeline_set_loop (timeline, TRUE); g_signal_connect_swapped (timeline, "completed", G_CALLBACK (set_next_gravity), rect); clutter_timeline_start (timeline); clutter_actor_show_all (stage); clutter_main(); g_object_unref (timeline); g_object_unref (behave); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage = NULL; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *button1 = NULL; ClutterActor *button2 = NULL; ClutterActor *button3 = NULL; ClutterActor *button4 = NULL; ClutterActor *group[4]; ClutterGeometry geom = {0, 0, SIZE, SIZE}; gint i = 0; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; cally_util_a11y_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &color); clutter_actor_set_size (stage, WIDTH, HEIGHT); button1 = clutter_rectangle_new_with_color (&color1); clutter_actor_set_geometry (button1, &geom); button2 = clutter_rectangle_new_with_color (&color2); geom.x = 2*SIZE; geom.y = 0; clutter_actor_set_geometry (button2, &geom); geom.x = 0; geom.y = 2*SIZE; button3 = clutter_rectangle_new_with_color (&color3); clutter_actor_set_geometry (button3, &geom); clutter_actor_set_depth( button3, DEPTH); /* a nested hierarchy, to check that the relative positions are computed properly */ geom.x = SIZE/2; geom.y = SIZE/2; button4 = clutter_rectangle_new_with_color (&color4); clutter_actor_set_geometry (button4, &geom); clutter_actor_show (button4); for (i = 0; i < 4; i++) { group[i] = clutter_group_new (); clutter_actor_set_geometry (group[i], &geom); if (i > 0) clutter_group_add (CLUTTER_GROUP (group[i]), group [i - 1]); clutter_actor_show_all (group[i]); } clutter_group_add (CLUTTER_GROUP (stage), button1); clutter_group_add (CLUTTER_GROUP (stage), button2); clutter_group_add (CLUTTER_GROUP (stage), button3); clutter_group_add (CLUTTER_GROUP (stage), group[3]); clutter_group_add (CLUTTER_GROUP (group[0]), button4); clutter_actor_show_all (stage); clutter_main (); return 0; }
gint main (gint argc, gchar *argv[]) { /* initialization */ gst_init (&argc, &argv); gtk_init(&argc, &argv); clutter_init(&argc, &argv); /* herein we count windows and map them to sinks */ windows_t windows; windows.n = 0; GMainLoop *loop = g_main_loop_new(NULL, FALSE); GtkWidget *window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect (window1, "realize", G_CALLBACK (video_widget_realize_cb), &windows); g_signal_connect (window2, "realize", G_CALLBACK (video_widget_realize_cb), &windows); /* Make a timeline */ ClutterTimeline *timeline = clutter_timeline_new(1000); g_object_set(timeline, "loop", TRUE, NULL); ClutterActor *stage1 = new_stage(); ClutterTexture *texture1 = g_object_new (CLUTTER_TYPE_TEXTURE, "sync-size", FALSE, "disable-slicing", TRUE, NULL); GstElement *sink1 = clutter_gst_video_sink_new(CLUTTER_TEXTURE(texture1)); ClutterActor *stage2 = new_stage(); ClutterTexture *texture2 = g_object_new (CLUTTER_TYPE_TEXTURE, "sync-size", FALSE, "disable-slicing", TRUE, NULL); GstElement *sink2 = clutter_gst_video_sink_new(CLUTTER_TEXTURE(texture2)); /*To avoid flickering on show, you should call gtk_widget_show() or gtk_widget_realize() before calling clutter_actor_show() */ //GstElement *sink1 = gst_element_factory_make("ximagesink", "sink1"); //GstElement *sink2 = gst_element_factory_make("ximagesink", "sink2"); GstElement *pipeline = (GstElement *)make_dual_pipeline(sink1, sink2); windows.sinks[0] = sink1; windows.sinks[1] = sink2; windows.stages[0] = stage1; windows.stages[1] = stage2; set_up_window(loop, window1); set_up_window(loop, window2); GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); gst_bus_add_watch(bus, (GstBusFunc)bus_call, &windows); gst_object_unref(bus); gst_element_set_state(pipeline, GST_STATE_PLAYING); /* start the timeline */ clutter_timeline_start(timeline); clutter_group_add(CLUTTER_GROUP(stage1), texture1); clutter_group_add(CLUTTER_GROUP(stage2), texture2); clutter_actor_show_all(stage1); clutter_actor_show_all(stage2); g_main_loop_run(loop); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); return 0; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterColor stage_color = { 0x34, 0x39, 0x39, 0xff }; ClutterColor white = { 0x72, 0x9f, 0xcf, 0xff }; gint i = 0; Item *item; App *app; gdouble ang = 0.0; ClutterBehaviour *behave; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 800, 600); app = g_new0(App, 1); app->off = 0.0; app->timeline = clutter_timeline_new (300); app->alpha_sine_inc = clutter_alpha_new_full (app->timeline, CLUTTER_EASE_OUT_SINE); app->alpha_ramp = clutter_alpha_new_with_func (app->timeline, label_opacity_alpha_func, NULL, NULL); for (i=0; i<N_ITEMS; i++) { item = g_new0 (Item, 1); item->actor = clutter_texture_new_from_file (ItemDetails[i].img, NULL); if (!item->actor) g_error ("Unable to load '%s'", ItemDetails[i].img); clutter_group_add (CLUTTER_GROUP(stage), item->actor); item->ellipse_behave = clutter_behaviour_ellipse_new (app->alpha_sine_inc, CSW()/4, /* center x */ CSH() - (CSH()/3), /* center y */ CSW()/2, /* width */ CSH() - (CSH()/4), /* height */ CLUTTER_ROTATE_CW, ang, ang + STEP); item->opacity_behave = clutter_behaviour_opacity_new (app->alpha_sine_inc, 0x66, 0x66); item->scale_behave = clutter_behaviour_scale_new (app->alpha_sine_inc, 0.6, 0.6, 0.6, 0.6); clutter_behaviour_apply (item->ellipse_behave, item->actor); clutter_behaviour_apply (item->opacity_behave, item->actor); clutter_behaviour_apply (item->scale_behave, item->actor); app->items = g_slist_append (app->items, item); ang += STEP; } app->label = clutter_text_new_full ("Bitstream Vera Sans 60px", "", &white); clutter_actor_set_position (app->label, CSW()/2 - 30, CSH()/3 - 40); clutter_group_add (CLUTTER_GROUP(stage), app->label); behave = clutter_behaviour_opacity_new (app->alpha_ramp, 0xff, 0); clutter_behaviour_apply (behave, app->label); g_signal_connect (app->timeline, "new-frame", G_CALLBACK(on_timeline_new_frame), app); g_signal_connect (stage, "event", G_CALLBACK (on_input), app); introduce_items (app); clutter_actor_show_all (stage); clutter_main(); return 0; }
void scene_prismatic_joint (Scene *scene) { ClutterActor *ground; ClutterActor *group; ClutterActor *prev_hand = NULL; ClutterActor *first_hand = NULL; ClutterActor *stage; stage = clutter_stage_get_default (); first_hand = ground = clutter_rectangle_new (); clutter_actor_set_size (ground, 500, 120); group = clutter_box2d_new (); clutter_group_add (CLUTTER_GROUP (stage), group); clutter_group_add (CLUTTER_GROUP (group), ground); clutter_actor_set_position (ground, clutter_actor_get_width ( ground) * -0.3, 568); /* this is wrong */ add_cage (group, TRUE); ground = clutter_rectangle_new (); clutter_actor_set_size (ground, 256, 3); clutter_actor_set_position (ground, -100, 310); clutter_actor_set_rotation (ground, CLUTTER_Z_AXIS, 30, 128, 16, 0); clutter_group_add (CLUTTER_GROUP (group), ground); clutter_container_child_set (CLUTTER_CONTAINER (group), ground, "mode", CLUTTER_BOX2D_STATIC, NULL); ground = clutter_rectangle_new (); clutter_actor_set_size (ground, 256, 3); clutter_actor_set_position (ground, 200, 200); clutter_actor_set_rotation (ground, CLUTTER_Z_AXIS, -30, 0, 0, 0); clutter_group_add (CLUTTER_GROUP (group), ground); clutter_container_child_set (CLUTTER_CONTAINER (group), ground, "mode", CLUTTER_BOX2D_STATIC, NULL); /*add_hand (group, 100, 100);*/ prev_hand = add_hand (group, 200, 100); if(0){ ClutterVertex anchor1 = { (0), (0) }; ClutterVertex anchor2 = { (0), (0) }; ClutterVertex axis = { (100.0), (20.0) }; clutter_box2d_add_prismatic_joint (CLUTTER_BOX2D (group), first_hand, prev_hand, &anchor1, &anchor2, 200.0, 220.0, &axis); } clutter_actor_set_depth (group, -600); clutter_actor_set_position (group, 0, -100); clutter_actor_set_reactive (group, TRUE); clutter_box2d_set_simulating (CLUTTER_BOX2D (group), simulating); scene->group = group; }
void opt_show_step (OptShow *self, gint step) { OptSlide *from, *to; OptShowPrivate *priv; OptTransition *trans; ClutterActor *stage; priv = self->priv; /* transition already running */ if (priv->trans_signal_id != 0) return; stage = clutter_stage_get_default(); from = g_list_nth_data (priv->slides, priv->current_slide_num); to = g_list_nth_data (priv->slides, priv->current_slide_num + step); if (from == NULL) from = priv->slides->data; /* Nowhere to go */ if (to == NULL) return; /* Add next slide to stage */ clutter_group_add (CLUTTER_GROUP(stage), CLUTTER_ACTOR(to)); trans = opt_slide_get_transition ( step < 0 ? to : from); /* * Make sure any textures are loaded before the transitions is started . */ clutter_container_foreach (CLUTTER_CONTAINER (to), (ClutterCallback)clutter_actor_realize, NULL); if (trans != NULL) { if (step < 0) opt_transition_set_direction (trans, OPT_TRANSITION_BACKWARD); else opt_transition_set_direction (trans, OPT_TRANSITION_FORWARD); /* Set up transition and start it */ opt_transition_set_to (trans, to); opt_transition_set_from (trans, from); priv->trans_signal_id = g_signal_connect (trans, "completed", G_CALLBACK (transition_completed_cb), self); /* lower it out of view */ clutter_actor_lower_bottom (CLUTTER_ACTOR(to)); clutter_timeline_start (CLUTTER_TIMELINE(trans)); } else { /* No transition just hide current slide*/ clutter_group_remove (CLUTTER_GROUP(stage), CLUTTER_ACTOR(from)); clutter_actor_hide_all (CLUTTER_ACTOR(from)); } /* Advance */ priv->current_slide_num += step; priv->current_slide_num = CLAMP(priv->current_slide_num, 0, priv->num_slides-1); if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (priv->menu))) opt_menu_popdown (priv->menu); opt_menu_set_current_slide (priv->menu, priv->current_slide_num); }
static void make_ui (ClutterActor *stage) { ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterActor *button = NULL; clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); clutter_actor_set_size (stage, WIDTH, HEIGHT); /* text */ text_actor = clutter_text_new_full ("Sans Bold 32px", "Lorem ipsum dolor sit amet", &color_text); clutter_group_add (CLUTTER_GROUP (stage), text_actor); /* text_editable */ text_editable_actor = clutter_text_new_full ("Sans Bold 32px", "consectetur adipisicing elit", &color_text); clutter_actor_set_position (text_editable_actor, 0, 100); clutter_text_set_editable (CLUTTER_TEXT (text_editable_actor), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text_editable_actor), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (text_editable_actor), &color_sel); clutter_text_set_activatable (CLUTTER_TEXT (text_editable_actor), TRUE); clutter_text_set_line_wrap (CLUTTER_TEXT (text_editable_actor), TRUE); clutter_actor_grab_key_focus (text_editable_actor); clutter_actor_set_reactive (text_editable_actor, TRUE); clutter_group_add (CLUTTER_GROUP (stage), text_editable_actor); g_signal_connect (text_editable_actor, "activate", G_CALLBACK (activate_cb), NULL); /* test buttons */ button = _create_button ("Set"); clutter_actor_set_position (button, 100, 200); g_signal_connect_after (button, "button-press-event", G_CALLBACK (set_text_press_cb), NULL); clutter_group_add (CLUTTER_GROUP (stage), button); button = _create_button ("Delete"); clutter_actor_set_position (button, 100, 250); g_signal_connect_after (button, "button-press-event", G_CALLBACK (delete_text_press_cb), NULL); clutter_group_add (CLUTTER_GROUP (stage), button); button = _create_button ("Insert"); clutter_actor_set_position (button, 100, 300); g_signal_connect_after (button, "button-press-event", G_CALLBACK (insert_text_press_cb), NULL); clutter_group_add (CLUTTER_GROUP (stage), button); button = _create_button ("Activate/Deactivate"); clutter_actor_set_position (button, 100, 350); g_signal_connect_after (button, "button-press-event", G_CALLBACK (activate_deactivate_press_cb), NULL); clutter_group_add (CLUTTER_GROUP (stage), button); button = _create_button ("Cursor position"); clutter_actor_set_position (button, 100, 450); g_signal_connect_after (button, "button-press-event", G_CALLBACK (print_cursor_position_press_cb), NULL); clutter_group_add (CLUTTER_GROUP (stage), button); }
int main (int argc, char **argv) { AainaLibrary *library; AainaSource *source; ClutterActor *stage; ClutterAlpha *alpha; ClutterBehaviour *behave; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; GError *error = NULL; g_thread_init (NULL); g_set_application_name ("Aaina Image Slideshow"); clutter_init_with_args (&argc, &argv, " - Aaina Image Slideshow", entries, NULL, &error); if (error) { g_print ("Unable to run Aaina: %s", error->message); g_error_free (error); return EXIT_FAILURE; } stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 720, 480); clutter_stage_hide_cursor (CLUTTER_STAGE (stage)); if (fullscreen) clutter_stage_fullscreen (CLUTTER_STAGE (stage)); clutter_stage_set_color (CLUTTER_STAGE (stage), &black); /* Load the test source */ library = aaina_library_new (); if (directories && directories[0]) { gint n_directories, i; n_directories = g_strv_length (directories); for (i = 0; i < n_directories; i++) source = aaina_source_directory_new (library, directories[i]); } else if (flickr_tags) source = aaina_source_flickr_new (library, flickr_tags); else { g_print ("Usage: aaina -d <path>\n" " aaina -t <tag>[,<tag>,....]\n"); return EXIT_FAILURE; } show = aaina_slide_show_get_default (); clutter_group_add (CLUTTER_GROUP (stage), CLUTTER_ACTOR (show)); clutter_actor_set_position (CLUTTER_ACTOR (show), 0, 0); clutter_actor_set_size (CLUTTER_ACTOR (show), CLUTTER_STAGE_WIDTH (), CLUTTER_STAGE_HEIGHT ()) ; clutter_actor_show_all (CLUTTER_ACTOR (show)); g_object_set (G_OBJECT (show), "library", library, NULL); clutter_actor_show_all (stage); /*clutter_actor_set_scale (stage, 0.25, 0.25);*/ g_signal_connect (G_OBJECT (stage), "key-release-event", G_CALLBACK (on_key_release_event), (gpointer)stage); timeline = clutter_timeline_new (60, 30); alpha = clutter_alpha_new_full (timeline, alpha_sine_inc_func, NULL, NULL); behave = aaina_behave_new (alpha, (AainaBehaveAlphaFunc)spin_me, (gpointer)stage); clutter_actor_set_rotation (stage, CLUTTER_Y_AXIS, 0, CLUTTER_STAGE_WIDTH ()/2, 0, CLUTTER_STAGE_HEIGHT ()); g_timeout_add (120000, (GSourceFunc)im_spinning_around, timeline); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { gchar *txt; ClutterActor *rect, *stage, *label0; int i, rotate_x = 0, rotate_y = 60, rotate_z = 0; ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff }, white = { 0xff, 0xff, 0xff, 0xff }, blue = { 0, 0xff, 0xff, 0xff }; for (i = 0; i < argc; ++i) { if (!strncmp (argv[i], "--rotate-x", 10)) { rotate_x = atoi (argv[i] + 11); } else if (!strncmp (argv[i], "--rotate-y", 10)) { rotate_y = atoi (argv[i] + 11); } else if (!strncmp (argv[i], "--rotate-z", 10)) { rotate_z = atoi (argv[i] + 11); } else if (!strncmp (argv[i], "--help", 6)) { printf ("%s [--rotage-x=degrees] [--rotage-y=degrees] " "[--rotage-z=degrees]\n", argv[0]); exit (0); } } clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr); clutter_actor_set_size (stage, 640, 480); rect = clutter_rectangle_new_with_color (&white); clutter_actor_set_size (rect, RECT_W, RECT_H); clutter_actor_set_position (rect, RECT_L, RECT_T); clutter_actor_set_rotation (rect, CLUTTER_X_AXIS, rotate_x, 0, 0, 0); clutter_actor_set_rotation (rect, CLUTTER_Y_AXIS, rotate_y, 0, 0, 0); clutter_actor_set_rotation (rect, CLUTTER_Z_AXIS, rotate_z, 0, 0, 0); clutter_group_add (CLUTTER_GROUP (stage), rect); txt = g_strdup_printf ("Rectangle: L %d, R %d, T %d, B %d\n" "Rotation : x %d, y %d, z %d", RECT_L, RECT_L + RECT_W, RECT_T, RECT_T + RECT_H, rotate_x, rotate_y, rotate_z); label0 = clutter_label_new_with_text ("Mono 8pt", txt); clutter_label_set_color (CLUTTER_LABEL (label0), &white); clutter_actor_set_position (label0, 10, 10); clutter_group_add (CLUTTER_GROUP (stage), label0); g_free (txt); label = clutter_label_new_with_text ("Mono 8pt", "Click around!"); clutter_label_set_color (CLUTTER_LABEL (label), &blue); clutter_actor_set_position (label, 10, 50); clutter_group_add (CLUTTER_GROUP (stage), label); clutter_actor_show_all (stage); g_signal_connect (stage, "event", G_CALLBACK (on_event), NULL); clutter_main(); return EXIT_SUCCESS; }