static ClutterActor* create_clutter_texture(EmpathyVideoWidget *object) { EmpathyVideoWidgetPriv *priv = GET_PRIV (object); ClutterActor *texture, *stage, *box; ClutterLayoutManager *layout; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (object)); g_assert (stage != NULL); clutter_stage_set_color (CLUTTER_STAGE(stage), CLUTTER_COLOR_Black); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); g_assert (layout != NULL); box = clutter_box_new (layout); g_assert (box != NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); priv->notify_allocation_id = g_signal_connect (stage, "notify::allocation", G_CALLBACK(on_stage_allocation_changed), box); texture = clutter_texture_new (); g_assert (texture != NULL); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE); g_object_ref (G_OBJECT (texture)); clutter_box_pack (CLUTTER_BOX (box), texture, NULL, NULL); return texture; }
int main (int argc, char **argv) { ClutterActor *stage; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); clutter_actor_set_size (stage, 640, 480); #if 1 layout = penge_block_layout_new (); penge_block_layout_set_min_tile_size (PENGE_BLOCK_LAYOUT (layout), 140, 92); penge_block_layout_set_spacing (PENGE_BLOCK_LAYOUT (layout), 6); #else layout = clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL); #endif box = clutter_box_new (layout); bridge = g_object_new (PENGE_TYPE_MODEL_BRIDGE, NULL); penge_model_bridge_set_container (bridge, CLUTTER_CONTAINER (box)); penge_model_bridge_set_factory (bridge, factory_func); client = sw_client_new (); sw_client_get_services (client, _client_get_services_cb, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_set_size (box, clutter_actor_get_width (stage), clutter_actor_get_height (stage)); clutter_actor_show (stage); g_signal_connect (stage, "allocation-changed", G_CALLBACK (stage_allocation_changed_cb), box); clutter_main (); return EXIT_SUCCESS; }
/* object init: create a private structure and pack * composed ClutterActors into it */ static void cb_button_init (CbButton *self) { CbButtonPrivate *priv; ClutterLayoutManager *layout; priv = self->priv = CB_BUTTON_GET_PRIVATE (self); clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); /* the only child of this actor is a ClutterBox with a * ClutterBinLayout: painting and allocation of the actor basically * involves painting and allocating this child box */ layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); priv->child = clutter_box_new (layout); /* set the parent of the ClutterBox to this instance */ clutter_actor_set_parent (priv->child, CLUTTER_ACTOR (self)); /* add text label to the button; see the ClutterText API docs * for more information about available properties */ priv->label = g_object_new (CLUTTER_TYPE_TEXT, "line-alignment", PANGO_ALIGN_CENTER, "ellipsize", PANGO_ELLIPSIZE_END, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (priv->child), priv->label); /* add a ClutterClickAction on this actor, so we can proxy its * "clicked" signal into a signal from this actor */ priv->click_action = clutter_click_action_new (); clutter_actor_add_action (CLUTTER_ACTOR (self), priv->click_action); g_signal_connect (priv->click_action, "clicked", G_CALLBACK (cb_button_clicked), NULL); }
G_MODULE_EXPORT int test_texture_material_main (int argc, char *argv[]) { ClutterActor *stage, *box; ClutterLayoutManager *manager; int i; g_thread_init (NULL); clutter_threads_init (); clutter_init (&argc, &argv); stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Texture Material"); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); manager = clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL); box = clutter_box_new (manager); clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, -25.0)); clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_HEIGHT, -25.0)); clutter_actor_set_position (box, 25.0, 25.0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); for (i = 0; i < 48; i++) { ClutterActor *texture = clutter_texture_new (); clutter_texture_set_load_data_async (CLUTTER_TEXTURE (texture), TRUE); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE); clutter_texture_set_from_file (CLUTTER_TEXTURE (texture), TESTS_DATADIR "/redhand.png", NULL); clutter_actor_set_width (texture, 96); clutter_container_add_actor (CLUTTER_CONTAINER (box), texture); } clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { ClutterTimeline *timeline; ClutterActor *stage; if (argc < 1) { g_error ("Usage: %s", argv[0]); return EXIT_FAILURE; } else { GError *error = NULL; GOptionContext *context; context = g_option_context_new (PROGRAM_DESC); g_option_context_add_main_entries (context, entries, NULL); //GETTEXT_PACKAGE); //g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (! g_option_context_parse (context, &argc, &argv, &error)) { g_print ("option parsing failed: %s\n", error->message); return EXIT_FAILURE; // exit (1); } } if (option_version) { g_print("contextize version %s\n", PACKAGE_VERSION); return 0; } g_thread_init(NULL); // to load images asynchronously. must be called before clutter_init if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) { g_error ("Failed to initialize clutter\n"); return EXIT_FAILURE; } gst_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_actor_set_size(stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_stage_set_color(CLUTTER_STAGE(stage), &black); clutter_stage_set_title(CLUTTER_STAGE(stage), STAGE_TITLE); /* Make a timeline */ timeline = clutter_timeline_new (1000); g_object_set(timeline, "loop", TRUE, NULL); ClutterActor *texture_live = setup_camera_texture(stage); // create the layout ClutterLayoutManager *layout; ClutterActor *box; layout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new(layout); /* then the container */ clutter_actor_set_name(box, BOX_ACTOR); /* we can use the layout object to add actors */ clutter_bin_layout_add(CLUTTER_BIN_LAYOUT(layout), texture_live, CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL); clutter_container_add_actor(CLUTTER_CONTAINER(stage), box); clutter_actor_set_size(box, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_show_all(box); g_signal_connect(G_OBJECT(stage), "fullscreen", G_CALLBACK(on_fullscreen), NULL); g_signal_connect(G_OBJECT(stage), "unfullscreen", G_CALLBACK(on_unfullscreen), NULL); g_signal_connect(G_OBJECT(stage), "key-press-event", G_CALLBACK(key_press_event), NULL); /* start the timeline */ clutter_timeline_start (timeline); clutter_actor_show_all (stage); if (option_fullscreen) clutter_stage_set_fullscreen(CLUTTER_STAGE(stage), TRUE); // OSC server lo_server_thread osc_server = NULL; if (option_osc_receive_port != 0) { gchar *osc_port_str = g_strdup_printf("%i", option_osc_receive_port); if (option_verbose) g_print("Listening on osc.udp://localhost:%s\n", osc_port_str); osc_server = lo_server_thread_new(osc_port_str, on_osc_error); g_free(osc_port_str); lo_server_thread_start(osc_server); } clutter_main(); if (option_osc_receive_port != 0) lo_server_thread_free(osc_server); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { ClutterActor *stage; WebKitWebView *web_view; ClutterConstraint *width_binding; ClutterConstraint *height_binding; ClutterConstraint *web_view_height_binding; gfloat stageWidth, stageHeight; ClutterActorBox stageAllocation; ClutterLayoutManager *mainLayout; ClutterActor *mainLayoutContainer; ClutterLayoutManager *toolbarLayout; ClutterActor *toolbarContainer; ClutterLayoutManager *toolbarBinLayout; ClutterActor *toolbarBinContainer; ClutterActor *toolbarBgr; ClutterActor *statusBar; ClutterActor *backFwdBtns; ClutterActor *backBtn; ClutterActor *fwdBtn; ClutterActor *uriGroup; ClutterActor *uriBgr; ClutterActor *uriText; ClutterActor *spacer; GError *error = NULL; ClutterColor whiteColor = { 255, 255, 255, 255 }; ClutterColor blackColor = { 0, 0, 0, 255 }; ClutterColor grayColor = { 200, 200, 200, 255 }; ClutterColor transparentColor = { 0, 0, 0, 0 }; gchar *toolbarBgrPath = clutter_launcher_file_path("toolbar_bgr.png"); gchar *backBtnPath = clutter_launcher_file_path("back_btn.png"); gchar *fwdBtnPath = clutter_launcher_file_path("fwd_btn.png"); g_thread_init(NULL); clutter_threads_init(); clutter_init(&argc, &argv); stage = clutter_stage_get_default(); clutter_actor_set_size(stage, 1024, 768); clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK(clutter_main_quit), NULL); /* make the stage resizable */ clutter_stage_set_user_resizable(CLUTTER_STAGE(stage), TRUE); clutter_actor_show(stage); mainLayout = clutter_box_layout_new(); clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(mainLayout), TRUE); clutter_actor_get_allocation_box(stage, &stageAllocation); stageWidth = stageAllocation.x2 - stageAllocation.x1; stageHeight = stageAllocation.y2 - stageAllocation.y1; web_view = WEBKIT_WEB_VIEW(webkit_web_view_new((guint)stageWidth, (guint)stageHeight - (toolbarHeight + statusBarHeight))); g_object_set(web_view, "reactive", TRUE, NULL); mainLayoutContainer = clutter_box_new(mainLayout); clutter_actor_set_size(mainLayoutContainer, stageWidth, stageHeight); width_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_WIDTH, 0); height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, 0); /* web_view_height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, -(toolbarHeight + statusBarHeight)); */ clutter_actor_add_constraint(mainLayoutContainer, width_binding); clutter_actor_add_constraint(mainLayoutContainer, height_binding); /* clutter_actor_add_constraint(CLUTTER_ACTOR(web_view), web_view_height_binding); */ toolbarBinLayout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_CENTER); toolbarBinContainer = clutter_box_new(toolbarBinLayout); toolbarBgr = clutter_texture_new_from_file(toolbarBgrPath, &error); if (toolbarBgr == NULL) { fprintf(stderr, "Can't load file: %s. Aborting...\n", toolbarBgrPath); exit(1); } clutter_actor_set_height(toolbarBgr, toolbarHeight); clutter_texture_set_repeat(CLUTTER_TEXTURE(toolbarBgr), TRUE, FALSE); clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarBgr, NULL, NULL); toolbarLayout = clutter_box_layout_new(); clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(toolbarLayout), FALSE); clutter_box_layout_set_spacing(CLUTTER_BOX_LAYOUT(toolbarLayout), 16); toolbarContainer = clutter_box_new(toolbarLayout); spacer = clutter_rectangle_new_with_color(&transparentColor); clutter_actor_set_size(spacer, 1, 1); clutter_box_pack(CLUTTER_BOX(toolbarContainer), spacer, NULL, NULL); backFwdBtns = clutter_group_new(); backBtn = clutter_texture_new_from_file(backBtnPath, &error); if (backBtn == NULL) { fprintf(stderr, "Can't load file: %s. Aborting...\n", backBtnPath); exit(1); } clutter_actor_set_reactive(backBtn, TRUE); /* connect the release event */ g_signal_connect (backBtn, "button-release-event", G_CALLBACK (on_back_release_cb), web_view); fwdBtn = clutter_texture_new_from_file(fwdBtnPath, &error); if (fwdBtn == NULL) { fprintf(stderr, "Can't load file: %s. Aborting...\n", fwdBtnPath); exit(1); } clutter_actor_set_reactive(fwdBtn, TRUE); /* connect the release event */ g_signal_connect (fwdBtn, "button-release-event", G_CALLBACK (on_fwd_release_cb), web_view); clutter_actor_set_position(fwdBtn, clutter_actor_get_width(backBtn), 0); clutter_container_add(CLUTTER_CONTAINER(backFwdBtns), backBtn, fwdBtn, NULL); clutter_box_pack(CLUTTER_BOX(toolbarContainer), backFwdBtns, NULL, NULL); uriGroup = clutter_group_new(); uriBgr = clutter_rectangle_new_with_color(&whiteColor); clutter_rectangle_set_border_color(CLUTTER_RECTANGLE(uriBgr), &blackColor); clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(uriBgr), 1); clutter_actor_set_size(uriBgr, 400, 25); uriText = clutter_text_new_full("Helvetica 11px", "http://www.google.com", &blackColor); clutter_text_set_editable(CLUTTER_TEXT(uriText), TRUE); clutter_text_set_single_line_mode(CLUTTER_TEXT(uriText), TRUE); clutter_actor_set_position(uriText, 5, 7); clutter_actor_set_size(uriText, 390, 17); clutter_actor_set_reactive(uriText, TRUE); g_signal_connect(uriText, "activate", G_CALLBACK(on_uri_activate_cb), web_view); clutter_container_add(CLUTTER_CONTAINER(uriGroup), uriBgr, uriText, NULL); clutter_box_pack(CLUTTER_BOX(toolbarContainer), uriGroup, NULL, NULL); clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarContainer, NULL, NULL); clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), toolbarBinContainer, "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL); clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE); clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE, FALSE); statusBar = clutter_rectangle_new_with_color(&grayColor); clutter_actor_set_height(statusBar, statusBarHeight); clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), statusBar, "y-align", CLUTTER_BOX_ALIGNMENT_END, NULL); clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE); clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE, FALSE); clutter_box_pack_after(CLUTTER_BOX(mainLayoutContainer), CLUTTER_ACTOR(web_view), toolbarBinContainer, "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL); clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE); clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE, TRUE); clutter_container_add(CLUTTER_CONTAINER(stage), mainLayoutContainer, NULL); g_signal_connect(web_view, "webkit-load-finished", G_CALLBACK(load_finished_cb), web_view); g_signal_connect(web_view, "notify::progress", G_CALLBACK (notify_progress_cb), web_view); /* g_signal_connect(stage, "delete-event", G_CALLBACK(delete_cb), web_view);*/ g_signal_connect(web_view, "notify::uri", G_CALLBACK(notify_uri_cb), uriText); gchar *uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/"); gchar *fileURL = filenameToURL(uri); webkit_web_view_load_uri(web_view, fileURL ? fileURL : uri); printf("%s\n", fileURL ? fileURL : uri); g_free(fileURL); g_timeout_add_full(G_PRIORITY_DEFAULT, 3000, timeout_cb, web_view, 0); clutter_threads_enter (); clutter_main(); clutter_threads_leave (); return EXIT_SUCCESS; }
int main (int argc, char **argv) { ClutterActor *stage = stage; ClutterActor *side_box; ClutterActor *button_box; ClutterActor *box; ClutterAnimation *anim; MashLightSet *light_set; MxStyle *style; GError *error = NULL; Data data; int i; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; style = mx_style_get_default (); if (!mx_style_load_from_file (style, "lights.css", &error)) { g_warning ("Error setting style: %s", error->message); g_clear_error (&error); } stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 800, 600); side_box = mx_table_new (); clutter_actor_set_name (side_box, "side-box"); clutter_container_add_actor (CLUTTER_CONTAINER (stage), side_box); clutter_actor_set_size (side_box, 300, clutter_actor_get_height (stage)); clutter_actor_set_x (side_box, clutter_actor_get_width (stage) - clutter_actor_get_width (side_box)); button_box = mx_table_new (); mx_table_add_actor (MX_TABLE (side_box), button_box, 0, 0); data.notebook = mx_notebook_new (); mx_table_add_actor (MX_TABLE (side_box), data.notebook, 1, 0); data.model = mash_model_new_from_file (MASH_DATA_NONE, argc > 1 ? argv[1] : "suzanne.ply", &error); if (data.model == NULL) { g_warning ("Error loading model: %s", error->message); g_clear_error (&error); return 1; } light_set = mash_light_set_new (); box = clutter_box_new (clutter_fixed_layout_new ()); clutter_actor_set_size (data.model, 400, 400); clutter_actor_set_position (data.model, 50.0, 100.0); clutter_container_add_actor (CLUTTER_CONTAINER (box), data.model); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); g_signal_connect_swapped (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (TRUE)); g_signal_connect_data (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (FALSE), NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED); data.light_marker_material = cogl_material_new (); { CoglColor color; cogl_color_set_from_4ub (&color, 255, 0, 0, 255); /* Use the layer state to ignore the vertex color from the shader so that the light marker won't itself be lit */ cogl_material_set_layer_combine_constant (data.light_marker_material, 0, &color); cogl_material_set_layer_combine (data.light_marker_material, 0, "RGBA = REPLACE(CONSTANT)", NULL); } clutter_actor_set_rotation (data.model, CLUTTER_Y_AXIS, 0.0f, clutter_actor_get_width (data.model) / 2.0f, 0.0f, 0.0f); anim = clutter_actor_animate (data.model, CLUTTER_LINEAR, 3000, "rotation-angle-y", 360.0f, NULL); clutter_animation_set_loop (anim, TRUE); for (i = 0; i < N_LIGHTS; i++) { ClutterActor *table = mx_table_new (); ClutterActor *button; static ClutterActor *(* constructors[N_LIGHTS]) (void) = { mash_directional_light_new, mash_point_light_new, mash_spot_light_new }; static const ClutterColor black = { 0, 0, 0, 255 }; data.lights[i] = constructors[i] (); button = mx_button_new_with_label (G_OBJECT_TYPE_NAME (data.lights[i])); mx_table_add_actor (MX_TABLE (button_box), button, i, 0); /* Default to disable all of the lights */ g_object_set (data.lights[i], "ambient", &black, "diffuse", &black, "specular", &black, NULL); data.notebook_buttons[i] = button; clutter_container_add_actor (CLUTTER_CONTAINER (box), data.lights[i]); mash_light_set_add_light (light_set, MASH_LIGHT (data.lights[i])); add_color_prop (table, "ambient light", G_OBJECT (data.lights[i]), "ambient"); add_color_prop (table, "diffuse light", G_OBJECT (data.lights[i]), "diffuse"); add_color_prop (table, "specular light", G_OBJECT (data.lights[i]), "specular"); if (MASH_IS_POINT_LIGHT (data.lights[i])) { add_float_prop (table, "constant attenuation", G_OBJECT (data.lights[i]), "constant-attenuation", 0.0f, 10.0f); add_float_prop (table, "linear attenuation", G_OBJECT (data.lights[i]), "linear-attenuation", 0.0f, 10.0f); add_float_prop (table, "quadratic attenuation", G_OBJECT (data.lights[i]), "quadratic-attenuation", 0.0f, 10.0f); } if (MASH_IS_SPOT_LIGHT (data.lights[i])) { clutter_actor_set_x (data.lights[i], 250); add_float_prop (table, "spot cutoff", G_OBJECT (data.lights[i]), "spot-cutoff", 0.0f, 90.0f); add_float_prop (table, "spot exponent", G_OBJECT (data.lights[i]), "spot-exponent", 0.0f, 128.0f); } clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); data.notebook_pages[i] = table; } { ClutterActor *button; ClutterActor *table; CoglHandle material; float maximum_shininess; material = mash_model_get_pipeline (MASH_MODEL (data.model)); /* Before version 1.3.10 on the 1.3 branch and 1.2.14 on the 1.2 branch Cogl would remap the shininess property to the range [0,1]. After this it is just a value greater or equal to zero (but GL imposes a limit of 128.0) */ if (clutter_check_version (1, 3, 9) || (clutter_major_version == 1 && clutter_minor_version == 2 && clutter_micro_version >= 13)) maximum_shininess = 128.0f; else maximum_shininess = 1.0f; cogl_material_set_shininess (material, maximum_shininess); button = mx_button_new_with_label ("Material"); data.notebook_buttons[i] = button; mx_table_add_actor (MX_TABLE (button_box), button, i, 0); table = mx_table_new (); data.notebook_pages[i] = table; clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); add_material_color_prop (table, "emission", material, cogl_material_set_emission, cogl_material_get_emission); add_material_color_prop (table, "diffuse", material, cogl_material_set_diffuse, cogl_material_get_diffuse); add_material_color_prop (table, "ambient", material, cogl_material_set_ambient, cogl_material_get_ambient); add_material_color_prop (table, "specular", material, cogl_material_set_specular, cogl_material_get_specular); add_material_float_prop (table, "shininess", material, 0.0f, maximum_shininess, cogl_material_set_shininess, cogl_material_get_shininess); } mash_model_set_light_set (MASH_MODEL (data.model), light_set); g_object_unref (light_set); for (i = 0; i < N_PAGES; i++) { g_signal_connect (data.notebook_buttons[i], "notify::toggled", G_CALLBACK (notebook_button_cb), &data); mx_button_set_is_toggle (MX_BUTTON (data.notebook_buttons[i]), TRUE); } mx_button_set_toggled (MX_BUTTON (data.notebook_buttons[0]), TRUE); g_signal_connect (stage, "motion-event", G_CALLBACK (motion_event_cb), &data); clutter_actor_show (stage); clutter_main (); cogl_handle_unref (data.light_marker_material); return 0; }
int main (int argc, char *argv[]) { GError *error = NULL; /* UI */ ClutterActor *stage; ClutterLayoutManager *layout; ClutterActor *box; ClutterActor *top, *bottom; ClutterState *transitions; clutter_init_with_args (&argc, &argv, " - cross-fade", entries, NULL, NULL); if (source == NULL || target == NULL) { g_print ("Usage: %s -s <source> -t <target> [-d <duration>]\n", argv[0]); exit (EXIT_FAILURE); } clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "cross-fade"); clutter_actor_set_size (stage, 400, 300); clutter_actor_show (stage); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new (layout); clutter_actor_set_size (box, 400, 300); bottom = clutter_texture_new (); top = clutter_texture_new (); clutter_container_add_actor (CLUTTER_CONTAINER (box), bottom); clutter_container_add_actor (CLUTTER_CONTAINER (box), top); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); /* load the first image into the bottom */ load_image (CLUTTER_TEXTURE (bottom), source); /* load the second image into the top */ load_image (CLUTTER_TEXTURE (top), target); /* animations */ transitions = clutter_state_new (); clutter_state_set (transitions, NULL, "show-bottom", top, "opacity", CLUTTER_LINEAR, 0, bottom, "opacity", CLUTTER_LINEAR, 255, NULL); clutter_state_set (transitions, NULL, "show-top", top, "opacity", CLUTTER_EASE_IN_CUBIC, 255, bottom, "opacity", CLUTTER_EASE_IN_CUBIC, 0, NULL); clutter_state_set_duration (transitions, NULL, NULL, duration); /* make the bottom opaque and top transparent */ clutter_state_warp_to_state (transitions, "show-bottom"); /* on key press, fade in the top texture and fade out the bottom texture */ g_signal_connect (stage, "key-press-event", G_CALLBACK (start_animation), transitions); clutter_actor_show (stage); clutter_main (); g_object_unref (transitions); if (error != NULL) g_error_free (error); return EXIT_SUCCESS; }
G_MODULE_EXPORT int test_bin_layout_main (int argc, char *argv[]) { ClutterActor *stage, *box, *rect; ClutterLayoutManager *layout; ClutterColor stage_color = { 0xe0, 0xf2, 0xfc, 0xff }; ClutterColor bg_color = { 0xcc, 0xcc, 0xcc, 0x99 }; ClutterColor *color; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Box test"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 640, 480); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new (layout); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_set_anchor_point_from_gravity (box, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (box, 320, 240); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_name (box, "box"); rect = make_background (&bg_color, 200, 200); /* first method: use clutter_box_pack() */ clutter_box_pack (CLUTTER_BOX (box), rect, "x-align", CLUTTER_BIN_ALIGNMENT_FILL, "y-align", CLUTTER_BIN_ALIGNMENT_FILL, NULL); clutter_actor_lower_bottom (rect); clutter_actor_set_name (rect, "background"); { ClutterActor *tex; GError *error; gchar *file; error = NULL; file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); tex = clutter_texture_new_from_file (file, &error); if (error) g_error ("Unable to create texture: %s", error->message); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (tex), TRUE); /* second method: use clutter_bin_layout_add() */ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), tex, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); clutter_actor_raise (tex, rect); clutter_actor_set_width (tex, 175); clutter_actor_set_name (tex, "texture"); g_free (file); } color = clutter_color_new (g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255), 224); rect = clutter_rectangle_new_with_color (color); /* third method: container_add() and set_alignment() */ clutter_container_add_actor (CLUTTER_CONTAINER (box), rect); clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect, CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END); clutter_actor_set_size (rect, 50, 50); clutter_actor_set_opacity (rect, 0); clutter_actor_raise_top (rect); clutter_actor_set_name (rect, "emblem"); g_signal_connect (box, "enter-event", G_CALLBACK (on_box_enter), rect); g_signal_connect (box, "leave-event", G_CALLBACK (on_box_leave), rect); clutter_actor_show_all (stage); clutter_main (); clutter_color_free (color); return EXIT_SUCCESS; }
static void load_controls (UserInterface * ui) { // Check icon files exist gchar *vid_panel_png; gchar *icon_files[6]; gchar *duration_str; gint c; ClutterColor control_color1 = { 0x12, 0x12, 0x12, 0xff }; ClutterColor control_color2 = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterLayoutManager *controls_layout; ClutterLayoutManager *main_box_layout; ClutterLayoutManager *info_box_layout; ClutterLayoutManager *bottom_box_layout; ClutterLayoutManager *volume_box_layout; ClutterLayoutManager *seek_box_layout; ClutterLayoutManager *vol_int_box_layout; ClutterActor *seek_box; ClutterActor *bottom_box; ClutterActor *vol_int_box; GError *error = NULL; vid_panel_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/vid-panel.png"); ui->play_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/media-actions-start.png"); ui->pause_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/media-actions-pause.png"); ui->volume_low_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/audio-volume-low.png"); ui->volume_high_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/audio-volume-high.png"); ui->segment_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/media-actions-segment-point.png"); icon_files[0] = vid_panel_png; icon_files[1] = ui->play_png; icon_files[2] = ui->pause_png; icon_files[3] = ui->volume_low_png; icon_files[4] = ui->volume_high_png; icon_files[5] = ui->segment_png; for (c = 0; c < 6; c++) { if (!g_file_test (icon_files[c], G_FILE_TEST_EXISTS)) { g_print ("Icon file doesn't exist, are you sure you have " " installed snappy correctly?\nThis file needed is: %s\n", icon_files[c]); } } // Controls layout management controls_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); ui->control_box = clutter_box_new (controls_layout); // Controls background ui->control_bg = clutter_texture_new_from_file (vid_panel_png, &error); if (!ui->control_bg && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } g_free (vid_panel_png); clutter_container_add_actor (CLUTTER_CONTAINER (ui->control_box), ui->control_bg); // Controls play toggle main_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (main_box_layout), FALSE); ui->main_box = clutter_box_new (main_box_layout); ui->control_play_toggle = clutter_texture_new_from_file (ui->pause_png, &error); if (!ui->control_play_toggle && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (main_box_layout), ui->control_play_toggle, FALSE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_START, /* x-align */ CLUTTER_BOX_ALIGNMENT_CENTER); /* y-align */ clutter_container_add_actor (CLUTTER_CONTAINER (ui->control_box), ui->main_box); g_assert (ui->control_bg && ui->control_play_toggle); // Controls title info_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (info_box_layout), TRUE); ui->info_box = clutter_box_new (info_box_layout); ui->control_title = clutter_text_new_full ("Sans 32px", cut_long_filename (ui->filename, ui->title_length), &control_color1); clutter_text_set_max_length (CLUTTER_TEXT (ui->control_title), ui->title_length); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), ui->control_title, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ // Controls seek seek_box_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); seek_box = clutter_box_new (seek_box_layout); // In point ui->in_point = clutter_texture_new_from_file (ui->segment_png, &error); if (!ui->in_point && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->in_point); // background box rectangle shows as the border ui->control_seek1 = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seek1); // smaller background rectangle inside seek1 to create a border ui->control_seek2 = clutter_rectangle_new_with_color (&control_color2); clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seek2); // progress rectangle ui->control_seekbar = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seekbar); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), seek_box, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_CENTER); /* y-align */ // Out point ui->out_point = clutter_texture_new_from_file (ui->segment_png, &error); if (!ui->out_point && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->out_point); // Controls bottom box bottom_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (bottom_box_layout), FALSE); bottom_box = clutter_box_new (bottom_box_layout); // Controls volume box volume_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (volume_box_layout), FALSE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (volume_box_layout), 0); ui->volume_box = clutter_box_new (volume_box_layout); clutter_box_pack (CLUTTER_BOX (bottom_box), ui->volume_box, "x-align", CLUTTER_BOX_ALIGNMENT_START, "expand", TRUE, NULL); // Controls volume low ui->volume_low = clutter_texture_new_from_file (ui->volume_low_png, &error); if (!ui->volume_low && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_box_pack (CLUTTER_BOX (ui->volume_box), ui->volume_low, "x-align", CLUTTER_BOX_ALIGNMENT_START, NULL); // Controls volume intensity vol_int_box_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); vol_int_box = clutter_box_new (vol_int_box_layout); ui->vol_int_bg = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (vol_int_box), ui->vol_int_bg); ui->vol_int = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (vol_int_box), ui->vol_int); clutter_box_pack (CLUTTER_BOX (ui->volume_box), vol_int_box, "x-fill", FALSE, "y-fill", FALSE, "y-align", CLUTTER_BOX_ALIGNMENT_CENTER, NULL); // Controls volume high ui->volume_high = clutter_texture_new_from_file (ui->volume_high_png, &error); if (!ui->volume_high && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_box_pack (CLUTTER_BOX (ui->volume_box), ui->volume_high, "x-align", CLUTTER_BOX_ALIGNMENT_END, NULL); // Controls position text duration_str = g_strdup_printf (" 0:00:00/%s", ui->duration_str); ui->control_pos = clutter_text_new_full ("Sans 22px", duration_str, &control_color1); clutter_box_pack (CLUTTER_BOX (bottom_box), ui->control_pos, "x-align", CLUTTER_BOX_ALIGNMENT_END, "expand", TRUE, NULL); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), bottom_box, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_END); /* y-align */ clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (main_box_layout), ui->info_box, FALSE, /* expand */ TRUE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_END, /* x-align */ CLUTTER_BOX_ALIGNMENT_CENTER); /* y-align */ clutter_actor_lower_bottom (ui->control_bg); size_change (CLUTTER_STAGE (ui->stage), ui); }
WindowPanel::WindowPanel() : auto_hide_(false) { ClutterLayoutManager * main_layout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); actor_ = clutter_box_new(main_layout); ClutterActor * menu = clutter_cairo_texture_new(110, 22); clutter_actor_set_position(menu, 10.0f, 0.0f); cairo_t * context = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(menu)); cairo_move_to(context, 0.0, 0.0); cairo_line_to(context, 0.0, 19.0); cairo_curve_to(context, 1.0, 21.0, 2.0, 22.0, 3.0, 22.0); cairo_line_to(context, 107.0, 22.0); cairo_curve_to(context, 108.0, 22.0, 109.0, 21.0, 110.0, 19.0); cairo_line_to(context, 110.0, 0.0); cairo_close_path(context); cairo_set_source_rgb(context, 0.8, 0.8, 0.8); cairo_fill_preserve(context); cairo_set_line_width(context, 1.0); cairo_set_source_rgb(context, 0.0, 0.0, 0.0); cairo_stroke(context); cairo_select_font_face(context, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(context, 12.0); cairo_text_extents_t extents; cairo_text_extents(context, DISPLAY_NAME, &extents); cairo_move_to(context, 55.0 - ((extents.width / 2.0) + extents.x_bearing), 11.0 - ((extents.height / 2.0) + extents.y_bearing)); cairo_text_path(context, DISPLAY_NAME); cairo_set_source_rgb(context, 0.0, 0.0, 0.0); cairo_fill(context); cairo_destroy(context); clutter_box_pack(CLUTTER_BOX(actor_), menu, NULL, NULL); ClutterLayoutManager * controls_layout = clutter_box_layout_new(); clutter_box_layout_set_spacing(CLUTTER_BOX_LAYOUT(controls_layout), 10u); ClutterActor * controls = clutter_box_new(controls_layout); clutter_actor_add_constraint(controls, clutter_align_constraint_new(clutter_stage_get_default(), CLUTTER_ALIGN_X_AXIS, 0.95f)); clutter_actor_add_constraint(controls, clutter_bind_constraint_new(clutter_stage_get_default(), CLUTTER_BIND_Y, 5.0f)); fullscreen_button_ = clutter_cairo_texture_new(18, 16); clutter_actor_set_reactive(fullscreen_button_, TRUE); g_signal_connect(fullscreen_button_, "button-press-event", G_CALLBACK(fullscreen_clicked_cb), this); g_signal_connect(fullscreen_button_, "enter-event", G_CALLBACK(actor_highlight_on_cb), fullscreen_button_); g_signal_connect(fullscreen_button_, "leave-event", G_CALLBACK(actor_highlight_off_cb), fullscreen_button_); clutter_box_pack(CLUTTER_BOX(controls), fullscreen_button_, NULL, NULL); close_button_ = clutter_cairo_texture_new(15, 15); context = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(close_button_)); cairo_move_to(context, 1.0, 3.0); cairo_line_to(context, 3.0, 1.0); cairo_line_to(context, 8.0, 6.0); cairo_line_to(context, 13.0, 1.0); cairo_line_to(context, 15.0, 3.0); cairo_line_to(context, 10.0, 8.0); cairo_line_to(context, 15.0, 13.0); cairo_line_to(context, 13.0, 15.0); cairo_line_to(context, 8.0, 10.0); cairo_line_to(context, 3.0, 15.0); cairo_line_to(context, 1.0, 13.0); cairo_line_to(context, 6.0, 8.0); cairo_close_path(context); cairo_set_source_rgb(context, 1.0, 1.0, 1.0); cairo_fill_preserve(context); cairo_set_line_width(context, 1.0); cairo_set_source_rgb(context, 0.0, 0.0, 0.0); cairo_stroke(context); cairo_destroy(context); clutter_actor_set_reactive(close_button_, TRUE); g_signal_connect(close_button_, "button-press-event", G_CALLBACK(close_clicked_cb), NULL); g_signal_connect(close_button_, "enter-event", G_CALLBACK(actor_highlight_on_cb), close_button_); g_signal_connect(close_button_, "leave-event", G_CALLBACK(actor_highlight_off_cb), close_button_); clutter_box_pack(CLUTTER_BOX(controls), close_button_, NULL, NULL); draw_window_controls(); clutter_box_pack(CLUTTER_BOX(actor_), controls, NULL, NULL); g_signal_connect(clutter_stage_get_default(), "fullscreen", G_CALLBACK(fullscreen_status_changed_cb), this); g_signal_connect(clutter_stage_get_default(), "unfullscreen", G_CALLBACK(fullscreen_status_changed_cb), this); g_signal_connect(clutter_stage_get_default(), "motion-event", G_CALLBACK(show_panel_cb), this); }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterLayoutManager *layout; ClutterActor *box; ClutterActor *rect; ClutterActor *text; ClutterState *transitions; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_title (CLUTTER_STAGE (stage), "btn"); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL); box = clutter_box_new (layout); clutter_actor_set_position (box, 25, 25); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_size (box, 100, 30); /* background for the button */ rect = clutter_rectangle_new_with_color (&yellow); clutter_container_add_actor (CLUTTER_CONTAINER (box), rect); /* text for the button */ text = clutter_text_new_full ("Sans 10pt", "Hover me", &white); clutter_text_set_line_alignment (CLUTTER_TEXT (text), PANGO_ALIGN_CENTER); /* * NB don't set the height, so the actor assumes the height of the text; * then when added to the bin layout, it gets centred on it; * also if you don't set the width, the layout goes gets really wide; * the 10pt text fits inside the 30px height of the rectangle */ clutter_actor_set_width (text, 100); clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), text, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); /* animations */ transitions = clutter_state_new (); clutter_state_set (transitions, NULL, "fade-out", box, "opacity", CLUTTER_LINEAR, 180, NULL); /* * NB you can't use an easing mode where alpha > 1.0 if you're * animating to a value of 255, as the value you're animating * to will possibly go > 255 */ clutter_state_set (transitions, NULL, "fade-in", box, "opacity", CLUTTER_LINEAR, 255, NULL); clutter_state_set_duration (transitions, NULL, NULL, 50); clutter_state_warp_to_state (transitions, "fade-out"); g_signal_connect (box, "enter-event", G_CALLBACK (_pointer_enter_cb), transitions); g_signal_connect (box, "leave-event", G_CALLBACK (_pointer_leave_cb), transitions); /* bind the stage size to the box size + 50px in each axis */ clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_HEIGHT, 50.0)); clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_WIDTH, 50.0)); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_show (stage); clutter_main (); g_object_unref (transitions); return 0; }
int main (int argc, char *argv[]) { ClutterLayoutManager *layout; ClutterActor *box; ClutterActor *stage; ClutterActor *texture; CoglHandle *cogl_texture; GError *error = NULL; gfloat width; gchar *filename = TESTS_DATA_DIR "/redhand.png"; if (argc > 1) filename = argv[1]; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new (layout); clutter_box_set_color (CLUTTER_BOX (box), &box_color); texture = clutter_texture_new_from_file (filename, &error); if (error != NULL) g_error ("Error loading file %s; message was:\n%s", filename, error->message); /* * get a reference to the underlying Cogl texture * for copying onto each Clutter texture placed into the layout */ cogl_texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (texture)); /* * add gradually turning and shrinking textures, * smallest one last; each actor ends up on top * of the one added just before it */ for (width = STAGE_SIDE * 0.75; width >= STAGE_SIDE * 0.0625; width -= STAGE_SIDE * 0.0625) { ClutterActor *texture_copy = clutter_texture_new (); clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (texture_copy), cogl_texture); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture_copy), TRUE); clutter_actor_set_z_rotation_from_gravity (texture_copy, (gfloat)(width * 0.5) - (STAGE_SIDE * 0.03125), CLUTTER_GRAVITY_CENTER); clutter_actor_set_width (texture_copy, width); clutter_container_add_actor (CLUTTER_CONTAINER (box), texture_copy); } clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5)); clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5)); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_show (stage); clutter_main (); return 0; }