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; }
static void draw_marker (ChamplainMarker *marker) { BixiMarkerPrivate *priv = BIXI_MARKER (marker)->priv; ClutterText *label; gfloat width = 0, height = 0; gint radius = 10 + priv->value / 3; g_free (priv->text); priv->text = g_strdup_printf ("%u", priv->value); if (priv->text_actor == NULL) { priv->text_actor = clutter_text_new_with_text ("Sans 11", priv->text); g_object_ref (priv->text_actor); } label = CLUTTER_TEXT (priv->text_actor); clutter_text_set_font_name (label, "Sans 11"); clutter_text_set_text (label, priv->text); clutter_actor_get_size (CLUTTER_ACTOR (label), &width, &height); clutter_actor_set_position (CLUTTER_ACTOR (label), radius - width / 2, radius - height / 2); clutter_text_set_color (CLUTTER_TEXT (priv->text_actor), &default_text_color); if (clutter_actor_get_parent (priv->text_actor) == NULL) clutter_container_add_actor (CLUTTER_CONTAINER (marker), priv->text_actor); draw_shadow (BIXI_MARKER (marker), radius); draw_background (BIXI_MARKER (marker), radius); clutter_actor_raise (priv->text_actor, priv->background); clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), radius, radius); }
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; }
/* on double click, zoom in on the clicked point; * also keeps scale in the range 0.1 to 20 */ static gboolean clicked_cb (ClutterActor *actor, ClutterEvent *event, gpointer user_data) { gdouble scale; gfloat click_x, click_y; gfloat click_target_x, click_target_y; guint32 button; /* don't do anything unless there was a double click */ if (clutter_event_get_click_count (event) < 2) return TRUE; /* work out new scale */ button = clutter_event_get_button (event); clutter_actor_get_scale (actor, &scale, NULL); if (button == CLUTTER_BUTTON_PRIMARY) scale *= 1.2; else if (button == CLUTTER_BUTTON_SECONDARY) scale /= 1.2; /* don't do anything if scale is outside bounds */ if (scale < 0.1 || scale > 20.0) return TRUE; /* get the location of the click on the scaled actor */ clutter_event_get_coords (event, &click_x, &click_y); clutter_actor_transform_stage_point (actor, click_x, click_y, &click_target_x, &click_target_y); /* anchor the actor on the clicked point on its surface */ clutter_actor_set_anchor_point (actor, click_target_x, click_target_y); /* set the actor's position to the click coords: it won't move, * because the anchor point is already there; but * the scale will now be centered on these coords (as the * scale center defaults to the anchor point); so the anchor point * on the actor won't move from under the pointer */ clutter_actor_set_position (actor, click_x, click_y); clutter_actor_animate (actor, CLUTTER_LINEAR, 500, "scale-x", scale, "scale-y", scale, NULL); return TRUE; }
static ClutterActor * make_bouncer (const ClutterColor *base_color, gfloat width, gfloat height) { ClutterActor *retval; cairo_t *cr; cairo_pattern_t *pattern; gfloat radius = MAX (width, height); retval = clutter_cairo_texture_new (width, height); cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (retval)); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_ADD); cairo_arc (cr, radius / 2, radius / 2, radius / 2, 0.0, 2.0 * G_PI); pattern = cairo_pattern_create_radial (radius / 2, radius / 2, 0, radius, radius, radius); cairo_pattern_add_color_stop_rgba (pattern, 0, base_color->red / 255.0, base_color->green / 255.0, base_color->blue / 255.0, base_color->alpha / 255.0); cairo_pattern_add_color_stop_rgba (pattern, 0.9, base_color->red / 255.0, base_color->green / 255.0, base_color->blue / 255.0, 0.1); cairo_set_source (cr, pattern); cairo_fill_preserve (cr); cairo_pattern_destroy (pattern); cairo_destroy (cr); clutter_actor_set_name (retval, "bouncer"); clutter_actor_set_size (retval, width, height); clutter_actor_set_anchor_point (retval, width / 2, height / 2); clutter_actor_set_reactive (retval, TRUE); return retval; }
/* on key press, center the actor on the stage; * useful if you drag it off-stage accidentally */ static gboolean key_press_cb (ClutterActor *actor, ClutterEvent *event, gpointer user_data) { gfloat width, height; clutter_actor_get_size (actor, &width, &height); clutter_actor_set_anchor_point (actor, width / 2, height / 2); clutter_actor_set_position (actor, STAGE_SIDE / 2, STAGE_SIDE / 2); return TRUE; }
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); }
void Preview::previewBlock(gint bnr, gint bcol) { ClutterActor *stage; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (w)); int x, y; blocknr = bnr; color = bcol; for (x = 0; x < PREVIEW_WIDTH; x++) { for (y = 0; y < PREVIEW_HEIGHT; y++) { if ((blocknr != -1) && blockTable[blocknr][0][x][y]) { blocks[x][y].emptyCell (); blocks[x][y].what = LAYING; blocks[x][y].createActor (piece, blocks_cache_get_block_texture_by_id (cache, color), cell_size, cell_size); clutter_actor_set_position (CLUTTER_ACTOR(blocks[x][y].actor), x*cell_size, y*cell_size); } else { blocks[x][y].what = EMPTY; if (blocks[x][y].actor) blocks[x][y].emptyCell (); } } } gint center_x, center_y; center_x = (sizeTable[blocknr][0][1] * cell_size / 2) + (offsetTable[blocknr][0][1] * cell_size); center_y = (sizeTable[blocknr][0][0] * cell_size / 2) + (offsetTable[blocknr][0][0] * cell_size); clutter_actor_set_anchor_point (piece, center_x, center_y); clutter_actor_set_position (CLUTTER_ACTOR(piece), width / 2, height / 2); clutter_timeline_start (piece_timeline); }
G_MODULE_EXPORT int test_cogl_multitexture_main (int argc, char *argv[]) { GError *error = NULL; ClutterActor *stage; ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff }; TestMultiLayerMaterialState *state = g_new0 (TestMultiLayerMaterialState, 1); gfloat stage_w, stage_h; gchar **files; gfloat tex_coords[] = { /* tx1 ty1 tx2 ty2 */ 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 }; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_get_size (stage, &stage_w, &stage_h); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl: Multi-texturing"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* We create a non-descript actor that we know doesn't have a * default paint handler, so that we can easily control * painting in a paint signal handler, without having to * sub-class anything etc. */ state->group = clutter_group_new (); clutter_actor_set_position (state->group, stage_w / 2, stage_h / 2); g_signal_connect (state->group, "paint", G_CALLBACK(material_rectangle_paint), state); files = g_new (gchar*, 4); files[0] = g_build_filename (TESTS_DATADIR, "redhand_alpha.png", NULL); files[1] = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); files[2] = g_build_filename (TESTS_DATADIR, "light0.png", NULL); files[3] = NULL; state->alpha_tex = cogl_texture_new_from_file (files[0], COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); if (!state->alpha_tex) g_critical ("Failed to load redhand_alpha.png: %s", error->message); state->redhand_tex = cogl_texture_new_from_file (files[1], COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); if (!state->redhand_tex) g_critical ("Failed to load redhand.png: %s", error->message); state->light_tex0 = cogl_texture_new_from_file (files[2], COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); if (!state->light_tex0) g_critical ("Failed to load light0.png: %s", error->message); state->light_tex1 = cogl_texture_new_from_file (files[2], COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); if (!state->light_tex1) g_critical ("Failed to load light0.png: %s", error->message); g_strfreev (files); state->material0 = cogl_material_new (); cogl_material_set_layer (state->material0, 0, state->alpha_tex); cogl_material_set_layer (state->material0, 1, state->redhand_tex); cogl_material_set_layer (state->material0, 2, state->light_tex0); state->material1 = cogl_material_new (); cogl_material_set_layer (state->material1, 0, state->alpha_tex); cogl_material_set_layer (state->material1, 1, state->redhand_tex); cogl_material_set_layer (state->material1, 2, state->light_tex1); state->tex_coords = tex_coords; cogl_matrix_init_identity (&state->tex_matrix0); cogl_matrix_init_identity (&state->tex_matrix1); cogl_matrix_init_identity (&state->rot_matrix0); cogl_matrix_init_identity (&state->rot_matrix1); cogl_matrix_translate (&state->rot_matrix0, 0.5, 0.5, 0); cogl_matrix_rotate (&state->rot_matrix0, 10.0, 0, 0, 1.0); cogl_matrix_translate (&state->rot_matrix0, -0.5, -0.5, 0); cogl_matrix_translate (&state->rot_matrix1, 0.5, 0.5, 0); cogl_matrix_rotate (&state->rot_matrix1, -10.0, 0, 0, 1.0); cogl_matrix_translate (&state->rot_matrix1, -0.5, -0.5, 0); clutter_actor_set_anchor_point (state->group, 86, 125); clutter_container_add_actor (CLUTTER_CONTAINER(stage), state->group); state->timeline = clutter_timeline_new (2812); g_signal_connect (state->timeline, "new-frame", G_CALLBACK (frame_cb), state); clutter_actor_animate_with_timeline (state->group, CLUTTER_LINEAR, state->timeline, "rotation-angle-y", 30.0, "signal-after::completed", animation_completed_cb, state, NULL); /* start the timeline and thus the animations */ clutter_timeline_start (state->timeline); clutter_actor_show_all (stage); clutter_main(); cogl_handle_unref (state->material1); cogl_handle_unref (state->material0); cogl_handle_unref (state->alpha_tex); cogl_handle_unref (state->redhand_tex); cogl_handle_unref (state->light_tex0); cogl_handle_unref (state->light_tex1); g_free (state); return 0; }
static void switch_workspace (MetaPlugin *plugin, gint from, gint to, MetaMotionDirection direction) { MetaScreen *screen; MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (plugin)->priv; GList *l; ClutterActor *workspace0 = clutter_group_new (); ClutterActor *workspace1 = clutter_group_new (); ClutterActor *stage; int screen_width, screen_height; ClutterAnimation *animation; screen = meta_plugin_get_screen (plugin); stage = meta_get_stage_for_screen (screen); meta_screen_get_size (screen, &screen_width, &screen_height); clutter_actor_set_anchor_point (workspace1, screen_width, screen_height); clutter_actor_set_position (workspace1, screen_width, screen_height); clutter_actor_set_scale (workspace1, 0.0, 0.0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace1); clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace0); if (from == to) { meta_plugin_switch_workspace_completed (plugin); return; } l = g_list_last (meta_get_window_actors (screen)); while (l) { MetaWindowActor *window_actor = l->data; MetaWindow *window = meta_window_actor_get_meta_window (window_actor); MetaWorkspace *workspace; ActorPrivate *apriv = get_actor_private (window_actor); ClutterActor *actor = CLUTTER_ACTOR (window_actor); gint win_workspace; workspace = meta_window_get_workspace (window); win_workspace = meta_workspace_index (workspace); if (win_workspace == to || win_workspace == from) { apriv->orig_parent = clutter_actor_get_parent (actor); clutter_actor_reparent (actor, win_workspace == to ? workspace1 : workspace0); clutter_actor_show_all (actor); clutter_actor_raise_top (actor); } else if (win_workspace < 0) { /* Sticky window */ apriv->orig_parent = NULL; } else { /* Window on some other desktop */ clutter_actor_hide (actor); apriv->orig_parent = NULL; } l = l->prev; } priv->desktop1 = workspace0; priv->desktop2 = workspace1; animation = clutter_actor_animate (workspace0, CLUTTER_EASE_IN_SINE, SWITCH_TIMEOUT, "scale-x", 1.0, "scale-y", 1.0, NULL); priv->tml_switch_workspace1 = clutter_animation_get_timeline (animation); g_signal_connect (priv->tml_switch_workspace1, "completed", G_CALLBACK (on_switch_workspace_effect_complete), plugin); animation = clutter_actor_animate (workspace1, CLUTTER_EASE_IN_SINE, SWITCH_TIMEOUT, "scale-x", 0.0, "scale-y", 0.0, NULL); priv->tml_switch_workspace2 = clutter_animation_get_timeline (animation); }
static void tweet_window_constructed (GObject *gobject) { TweetWindow *window = TWEET_WINDOW (gobject); TweetWindowPrivate *priv = window->priv; ClutterActor *stage; ClutterActor *view; ClutterActor *img; ClutterColor stage_color = { 0, 0, 0, 255 }; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->canvas)); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); view = tweet_status_view_new (priv->status_model); g_signal_connect (view, "button-press-event", G_CALLBACK (on_status_view_button_press), window); g_signal_connect (view, "button-release-event", G_CALLBACK (on_status_view_button_release), window); priv->scroll = tidy_finger_scroll_new (TIDY_FINGER_SCROLL_MODE_KINETIC); clutter_container_add_actor (CLUTTER_CONTAINER (priv->scroll), view); clutter_actor_show (view); clutter_actor_set_reactive (view, TRUE); priv->status_view = view; clutter_actor_set_size (priv->scroll, CANVAS_WIDTH, CANVAS_HEIGHT); clutter_actor_set_position (priv->scroll, CANVAS_PADDING, CANVAS_PADDING); clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->scroll); clutter_actor_set_reactive (priv->scroll, TRUE); clutter_actor_show (priv->scroll); img = tweet_texture_new_from_stock (GTK_WIDGET (window), GTK_STOCK_REFRESH, GTK_ICON_SIZE_DIALOG); if (!img) g_warning ("Unable to load the `%s' stock icon", GTK_STOCK_REFRESH); priv->spinner = tweet_spinner_new (); tweet_spinner_set_image (TWEET_SPINNER (priv->spinner), img); clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->spinner); clutter_actor_set_size (priv->spinner, 128, 128); clutter_actor_set_anchor_point (priv->spinner, 64, 64); clutter_actor_set_position (priv->spinner, WINDOW_WIDTH / 2, CANVAS_HEIGHT / 2); clutter_actor_show (priv->spinner); tweet_spinner_start (TWEET_SPINNER (priv->spinner)); tweet_actor_animate (priv->spinner, TWEET_LINEAR, 500, "opacity", tweet_interval_new (G_TYPE_UCHAR, 0, 127), NULL); clutter_actor_show (stage); gtk_widget_show (GTK_WIDGET (window)); twitter_client_get_user_timeline (priv->client, NULL, 0, NULL); priv->refresh_id = g_timeout_add_seconds (tweet_config_get_refresh_time (priv->config), refresh_timeout, window); }
G_MODULE_EXPORT gint test_animator_main (gint argc, gchar **argv) { ClutterActor *stage; ClutterActor *rects[COUNT]; gint i; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); for (i=0; i<COUNT; i++) { rects[i]=new_rect (255 *(i * 1.0/COUNT), 50, 160, 255); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rects[i]); clutter_actor_set_anchor_point (rects[i], 64, 64); clutter_actor_set_position (rects[i], 320.0, 240.0); clutter_actor_set_opacity (rects[i], 0x70); } g_timeout_add (10000, nuke_one, rects[2]); animator = clutter_animator_new (); /* Note: when both animations are active for the same actor at the same * time there is a race, such races should be handled by avoiding * controlling the same properties from multiple animations. This is * an intentional design flaw of this test for testing the corner case. */ clutter_animator_set (animator, rects[0], "x", 1, 0.0, 180.0, rects[0], "x", CLUTTER_LINEAR, 0.25, 450.0, rects[0], "x", CLUTTER_LINEAR, 0.5, 450.0, rects[0], "x", CLUTTER_LINEAR, 0.75, 180.0, rects[0], "x", CLUTTER_LINEAR, 1.0, 180.0, rects[0], "y", -1, 0.0, 100.0, rects[0], "y", CLUTTER_LINEAR, 0.25, 100.0, rects[0], "y", CLUTTER_LINEAR, 0.5, 380.0, rects[0], "y", CLUTTER_LINEAR, 0.75, 380.0, rects[0], "y", CLUTTER_LINEAR, 1.0, 100.0, rects[3], "x", 0, 0.0, 180.0, rects[3], "x", CLUTTER_LINEAR, 0.25, 180.0, rects[3], "x", CLUTTER_LINEAR, 0.5, 450.0, rects[3], "x", CLUTTER_LINEAR, 0.75, 450.0, rects[3], "x", CLUTTER_LINEAR, 1.0, 180.0, rects[3], "y", 0, 0.0, 100.0, rects[3], "y", CLUTTER_LINEAR, 0.25, 380.0, rects[3], "y", CLUTTER_LINEAR, 0.5, 380.0, rects[3], "y", CLUTTER_LINEAR, 0.75, 100.0, rects[3], "y", CLUTTER_LINEAR, 1.0, 100.0, rects[2], "rotation-angle-y", 0, 0.0, 0.0, rects[2], "rotation-angle-y", CLUTTER_LINEAR, 1.0, 360.0, rects[1], "scale-x", 0, 0.0, 1.0, rects[1], "scale-x", CLUTTER_LINEAR, 1.0, 2.0, rects[1], "scale-y", 0, 0.0, 1.0, rects[1], "scale-y", CLUTTER_LINEAR, 1.0, 2.0, NULL); clutter_actor_set_scale (rects[0], 1.4, 1.4); clutter_animator_property_set_ease_in (animator, G_OBJECT (rects[0]), "x", TRUE); clutter_animator_property_set_ease_in (animator, G_OBJECT (rects[0]), "y", TRUE); clutter_animator_property_set_interpolation (animator, G_OBJECT (rects[0]), "x", CLUTTER_INTERPOLATION_CUBIC); clutter_animator_property_set_interpolation (animator, G_OBJECT (rects[0]), "y", CLUTTER_INTERPOLATION_CUBIC); clutter_stage_hide_cursor(CLUTTER_STAGE (stage)); clutter_actor_show (stage); clutter_animator_set_duration (animator, 5000); g_signal_connect (clutter_animator_start (animator), "completed", G_CALLBACK (reverse_timeline), NULL); clutter_main (); g_object_unref (animator); return EXIT_SUCCESS; }
static void rc_sync_actor(RendererClutter *rc) { PixbufRenderer *pr = rc->pr; gint anchor_x = 0; gint anchor_y = 0; gint rot_z = 0; gint rot_y = 0; clutter_actor_set_anchor_point(CLUTTER_ACTOR(rc->texture), 0, 0); DEBUG_3("scale %d %d", rc->pr->width, rc->pr->height); DEBUG_3("pos %d %d", rc->pr->x_offset, rc->pr->y_offset); clutter_actor_set_scale(CLUTTER_ACTOR(rc->texture), (gfloat)pr->width / pr->image_width, (gfloat)pr->height / pr->image_height); switch (pr->orientation) { case EXIF_ORIENTATION_TOP_LEFT: /* 1 - Horizontal (normal) */ break; case EXIF_ORIENTATION_TOP_RIGHT: /* 2 - Mirror horizontal */ rot_y = 180; anchor_x = pr->width; break; case EXIF_ORIENTATION_BOTTOM_RIGHT: /* 3 - Rotate 180 */ rot_z = 180; anchor_x = pr->width; anchor_y = pr->height; break; case EXIF_ORIENTATION_BOTTOM_LEFT: /* 4 - Mirror vertical */ rot_z = 180; rot_y = 180; anchor_y = pr->height; break; case EXIF_ORIENTATION_LEFT_TOP: /* 5 - Mirror horizontal and rotate 270 CW */ rot_z = 270; rot_y = 180; break; case EXIF_ORIENTATION_RIGHT_TOP: /* 6 - Rotate 90 CW */ rot_z = 90; anchor_x = pr->width; break; case EXIF_ORIENTATION_RIGHT_BOTTOM: /* 7 - Mirror horizontal and rotate 90 CW */ rot_z = 90; rot_y = 180; anchor_x = pr->width; anchor_y = pr->height; break; case EXIF_ORIENTATION_LEFT_BOTTOM: /* 8 - Rotate 270 CW */ rot_z = 270; anchor_y = pr->height; break; default: /* The other values are out of range */ break; } clutter_actor_set_rotation( CLUTTER_ACTOR(rc->texture), CLUTTER_Z_AXIS, rot_z, 0, 0, 0); clutter_actor_set_rotation( CLUTTER_ACTOR(rc->texture), CLUTTER_Y_AXIS, rot_y, 0, 0, 0); clutter_actor_set_position(CLUTTER_ACTOR(rc->texture), pr->x_offset - pr->x_scroll + anchor_x, pr->y_offset - pr->y_scroll + anchor_y); }
int main (int argc, char *argv[]) { ClutterActor *stage0, *stage1, *stage2, *tex1, *tex2; GtkWidget *window, *clutter0, *clutter1, *clutter2; GtkWidget *notebook, *vbox; ClutterColor col0 = { 0xdd, 0xff, 0xdd, 0xff }; ClutterColor col1 = { 0xff, 0xff, 0xff, 0xff }; ClutterColor col2 = { 0, 0, 0, 0xff }; if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) g_error ("Unable to initialize GtkClutter"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); notebook = gtk_notebook_new (); gtk_container_add (GTK_CONTAINER (window), notebook); clutter0 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter0, 320, 320); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), clutter0, gtk_label_new ("One stage")); stage0 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter0)); clutter_stage_set_color (CLUTTER_STAGE (stage0), &col0); vbox = gtk_vbox_new (FALSE, 6); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, gtk_label_new ("Two stages")); clutter1 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter1, 320, 240); stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1)); clutter_stage_set_color (CLUTTER_STAGE(stage1), &col1); tex1 = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_stock (GTK_CLUTTER_TEXTURE (tex1), clutter1, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG, NULL); clutter_actor_set_anchor_point (tex1, clutter_actor_get_width (tex1) / 2, clutter_actor_get_height (tex1) / 2); clutter_actor_set_position (tex1, 160, 120); clutter_stage_add (stage1, tex1); clutter_actor_show (tex1); gtk_container_add (GTK_CONTAINER (vbox), clutter1); clutter2 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter2, 320, 120); stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2)); clutter_stage_set_color (CLUTTER_STAGE(stage2), &col2); tex2 = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (tex2), clutter1, "user-info", GTK_ICON_SIZE_BUTTON, NULL); clutter_actor_set_anchor_point (tex2, clutter_actor_get_width (tex2) / 2, clutter_actor_get_height (tex2) / 2); clutter_actor_set_position (tex2, 160, 60); clutter_stage_add (stage2, tex2); gtk_container_add (GTK_CONTAINER (vbox), clutter2); g_signal_connect (stage2, "allocation-changed", G_CALLBACK (on_stage2_allocation_changed), tex2); gtk_widget_show_all (window); gtk_main(); return 0; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *rect; ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterColor rect_color = { 0xee, 0x55, 0x55, 0x99 }; ClutterColor progress_color = { 0x55, 0xee, 0x55, 0xbb }; ClutterBehaviour *r_behaviour, *p_behaviour; const ClutterKnot knots[] = { { 75, 150 }, { 400, 150 } }; g_thread_init (NULL); clutter_threads_init (); clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 600, 300); count_label = clutter_label_new_with_text ("Mono 12", "Counter"); clutter_actor_set_position (count_label, 350, 50); help_label = clutter_label_new_with_text ("Mono 12", "Press 's' to start"); clutter_actor_set_position (help_label, 50, 50); rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_position (rect, 75, 150); clutter_actor_set_size (rect, 50, 50); clutter_actor_set_anchor_point (rect, 25, 25); progress_rect = clutter_rectangle_new_with_color (&progress_color); clutter_actor_set_position (progress_rect, 50, 225); clutter_actor_set_size (progress_rect, 350, 50); clutter_container_add (CLUTTER_CONTAINER (stage), count_label, help_label, rect, progress_rect, NULL); timeline = clutter_timeline_new (150, 50); clutter_timeline_set_loop (timeline, TRUE); r_behaviour = clutter_behaviour_rotate_new (clutter_alpha_new_full (timeline, CLUTTER_ALPHA_RAMP_INC, NULL, NULL), CLUTTER_Z_AXIS, CLUTTER_ROTATE_CW, 0.0, 360.0); clutter_behaviour_apply (r_behaviour, rect); p_behaviour = clutter_behaviour_path_new (clutter_alpha_new_full (timeline, CLUTTER_ALPHA_SINE, NULL, NULL), knots, G_N_ELEMENTS (knots)); clutter_behaviour_apply (p_behaviour, rect); g_signal_connect (stage, "button-press-event", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect (stage, "key-press-event", G_CALLBACK (on_key_press_event), NULL); clutter_actor_show (stage); clutter_threads_enter (); clutter_main (); clutter_threads_leave (); g_object_unref (p_behaviour); g_object_unref (r_behaviour); g_object_unref (timeline); return EXIT_SUCCESS; }