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; }
static int lcs_taskbar (int *argc, char ***argv) { gdk_init (argc, argv); lcs_clutter_enable_transparency (TRUE); gtk_init (argc, argv); if (!clutter_init (argc, argv)) { fprintf (stderr, "error initializing clutter"); exit (1); } ClutterActor *stage = clutter_stage_new (); clutter_actor_set_layout_manager ( stage, clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_START)); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_actor_set_background_color (stage, clutter_color_new (255, 255, 255, 96)); ClutterActor *taskbar = lcs_taskbar_new (); clutter_actor_set_margin (taskbar, lcs_clutter_margin_new_full (4, 4, 4, 4)); clutter_actor_add_child (stage, taskbar); g_signal_connect (stage, "destroy", G_CALLBACK (on_stage_destroy), NULL); ClutterAction *drag = clutter_drag_action_new (); g_signal_connect (drag, "drag-motion", G_CALLBACK (on_stage_drag_motion), NULL); clutter_actor_add_action_with_name (stage, "drag", drag); clutter_actor_show (stage); long stagexid = lcs_wm_get_stage_xid (CLUTTER_STAGE(stage)); g_object_set_data (G_OBJECT (stage), "xid", GINT_TO_POINTER (stagexid)); lcs_wm_xwindow_set_decorated (stagexid, FALSE); lcs_wm_xwindow_set_above (stagexid); lcs_wm_xwindow_set_dock (stagexid); clutter_main (); return (0); }
/* 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); }
static void st_icon_init (StIcon *self) { ClutterLayoutManager *layout_manager; self->priv = ST_ICON_GET_PRIVATE (self); layout_manager = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL); clutter_actor_set_layout_manager (CLUTTER_ACTOR (self), layout_manager); self->priv->icon_size = DEFAULT_ICON_SIZE; self->priv->prop_icon_size = -1; self->priv->shadow_pipeline = NULL; self->priv->shadow_width = -1; self->priv->shadow_height = -1; }
static void slider_init(Slider *self) { SliderPrivate *priv; ClutterLayoutManager *layout; priv = self->priv = SLIDER_GET_PRIVATE(self); priv->pos = 0.5; layout = clutter_bin_layout_new( CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); ClutterColor col = {127, 127, 127, 255}; priv->box = clutter_actor_new(); clutter_actor_set_background_color(priv->box, &col); clutter_actor_set_layout_manager(priv->box, layout); clutter_actor_set_reactive(CLUTTER_ACTOR(priv->box), TRUE); clutter_actor_add_child(CLUTTER_ACTOR(self), priv->box); col.red = 40; col.green = 40; col.blue = 70; priv->handle = clutter_actor_new(); clutter_actor_set_background_color(priv->handle, &col); clutter_actor_set_layout_manager(priv->handle, layout); clutter_actor_set_reactive(CLUTTER_ACTOR(priv->handle), TRUE); clutter_actor_add_child(CLUTTER_ACTOR(self), priv->handle); priv->track_clicked = clutter_click_action_new(); clutter_actor_add_action(CLUTTER_ACTOR(priv->box), priv->track_clicked); g_signal_connect( priv->track_clicked, "clicked", G_CALLBACK(slider_clicked), self); priv->handle_dragged = clutter_drag_action_new(); clutter_actor_add_action(CLUTTER_ACTOR(priv->handle), priv->handle_dragged); g_signal_connect( priv->handle_dragged, "drag-motion", G_CALLBACK(handle_dragged), self); g_signal_connect(priv->box, "scroll-event", G_CALLBACK(scrolled), self); g_signal_connect(priv->handle, "scroll-event", G_CALLBACK(scrolled), self); }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *bg, *icon, *emblem, *label; ClutterLayoutManager *layout; ClutterContent *canvas, *image; ClutterColor *color; ClutterAction *action; GdkPixbuf *pixbuf; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; /* prepare the stage */ stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "BinLayout"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_Aluminium2); clutter_actor_set_size (stage, 640, 480); clutter_actor_show (stage); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* this is our BinLayout, with its default alignments */ layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); /* the main container; this actor will use the BinLayout to lay * out its children; we use the anchor point to keep it centered * on the same position even when we change its size */ box = clutter_actor_new (); clutter_actor_set_layout_manager (box, layout); clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); clutter_actor_set_position (box, 320, 240); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_name (box, "box"); clutter_actor_add_child (stage, box); /* the background is drawn using a canvas content */ canvas = clutter_canvas_new (); g_signal_connect (canvas, "draw", G_CALLBACK (on_canvas_draw), NULL); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 200, 200); /* this is the background actor; we want it to fill the whole * of the allocation given to it by its parent */ bg = clutter_actor_new (); clutter_actor_set_name (bg, "background"); clutter_actor_set_size (bg, 200, 200); clutter_actor_set_content (bg, canvas); clutter_actor_set_x_expand (bg, TRUE); clutter_actor_set_y_expand (bg, TRUE); clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (bg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_add_child (box, bg); /* we use the ::transitions-completed signal to get notification * of the end of the sizing animation; this allows us to redraw * the canvas only once the animation has stopped */ g_signal_connect (box, "transitions-completed", G_CALLBACK (redraw_canvas), canvas); /* we use GdkPixbuf to load an image from our data directory */ pixbuf = gdk_pixbuf_new_from_file (TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), NULL); g_object_unref (pixbuf); /* this is the icon; it's going to be centered inside the box actor. * we use the content gravity to keep the aspect ratio of the image, * and the scaling filters to get a better result when scaling the * image down. */ icon = clutter_actor_new (); clutter_actor_set_name (icon, "icon"); clutter_actor_set_size (icon, 196, 196); clutter_actor_set_x_expand (icon, TRUE); clutter_actor_set_y_expand (icon, TRUE); clutter_actor_set_x_align (icon, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (icon, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_content_gravity (icon, CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT); clutter_actor_set_content_scaling_filters (icon, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR); clutter_actor_set_content (icon, image); clutter_actor_add_child (box, icon); color = clutter_color_new (g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255), 224); /* this is the emblem: a small rectangle with a random color, that we * want to put in the bottom right corner */ emblem = clutter_actor_new (); clutter_actor_set_name (emblem, "emblem"); clutter_actor_set_size (emblem, 48, 48); clutter_actor_set_background_color (emblem, color); clutter_actor_set_x_expand (emblem, TRUE); clutter_actor_set_y_expand (emblem, TRUE); clutter_actor_set_x_align (emblem, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (emblem, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_reactive (emblem, TRUE); clutter_actor_set_opacity (emblem, 0); clutter_actor_add_child (box, emblem); clutter_color_free (color); /* when clicking on the emblem, we want to perform an action */ action = clutter_click_action_new (); clutter_actor_add_action (emblem, action); g_signal_connect (action, "clicked", G_CALLBACK (on_emblem_clicked), box); g_signal_connect (action, "long-press", G_CALLBACK (on_emblem_long_press), box); /* whenever the pointer enters the box, we show the emblem; we hide * the emblem when the pointer leaves the box */ g_signal_connect (box, "enter-event", G_CALLBACK (on_box_enter), emblem); g_signal_connect (box, "leave-event", G_CALLBACK (on_box_leave), emblem); /* a label, that we want to position at the top and center of the box */ label = clutter_text_new (); clutter_actor_set_name (label, "text"); clutter_text_set_text (CLUTTER_TEXT (label), "A simple test"); clutter_actor_set_x_expand (label, TRUE); clutter_actor_set_x_align (label, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_expand (label, TRUE); clutter_actor_set_y_align (label, CLUTTER_ACTOR_ALIGN_START); clutter_actor_add_child (box, label); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *video; /* So we can fade out at the end. */ clutter_x11_set_use_argb_visual (TRUE); if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; if (argc < 2) { g_print ("Usage: %s [OPTIONS] <video file>\n", argv[0]); return EXIT_FAILURE; } if (!clutter_color_from_string (&bg_color, BG_COLOR)) { g_warning ("Invalid BG_COLOR"); exit (1); } stage = clutter_stage_new (); /* Clutter's full-screening code does not allow us to * set both that and _NET_WM_STATE_ABOVE, so do the state * management ourselves for now. */ #if 0 clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE); #endif /* Clutter will set maximum size restrictions (meaning not * full screen) unless I set this. */ clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_actor_set_background_color (stage, &bg_color); clutter_actor_set_layout_manager (stage, clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED)); clutter_actor_realize (stage); set_above_and_fullscreen (); video = clutter_gst_video_texture_new (); clutter_actor_set_x_expand (video, TRUE); clutter_actor_set_y_expand (video, TRUE); clutter_actor_set_x_align (video, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (video, CLUTTER_ACTOR_ALIGN_CENTER); set_idle_material (CLUTTER_GST_VIDEO_TEXTURE (video)); g_signal_connect (video, "eos", G_CALLBACK (on_video_texture_eos), NULL); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); clutter_media_set_filename (CLUTTER_MEDIA (video), argv[1]); clutter_stage_hide_cursor (CLUTTER_STAGE (stage)); clutter_actor_add_child (stage, video); g_signal_connect (stage, "key-press-event", G_CALLBACK (key_press_cb), NULL); clutter_media_set_playing (CLUTTER_MEDIA (video), TRUE); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *bg, *bg2, *inset, *labelContainer, *contentContainer, *labelbg, *fixed, *upper, *lower, *lowerInner; ClutterLayoutManager *layout, *labelContainer_l, *layoutFixed; ClutterTimeline *timeline; ClutterContent *canvas, *canvas1; ClutterColor color_with_trans = {0,0,0,0}; clutter_x11_set_use_argb_visual (TRUE); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return (1); /* prepare the stage */ stage = clutter_stage_new (); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_color (CLUTTER_STAGE (stage), &color_with_trans); clutter_stage_set_title (CLUTTER_STAGE (stage), "IPLocation Database"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_WHITE); clutter_actor_set_size (stage, 648, 246); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); 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_actor_new (); clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0)); clutter_actor_set_background_color (box, CLUTTER_COLOR_WHITE); clutter_actor_set_layout_manager (box, layout); clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 1)); clutter_actor_set_name (box, "box"); clutter_actor_add_child (stage, box); bg = clutter_actor_new (); //clutter_actor_set_background_color (bg, clutter_color_new (50, 50, 50, 255)); clutter_actor_set_name (bg, "background"); clutter_actor_set_reactive (bg, TRUE); //clutter_actor_set_x_expand (bg, TRUE); //clutter_actor_set_y_expand (bg, TRUE); clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (bg, CLUTTER_ACTOR_ALIGN_FILL); canvas1 = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas1), 300, 300); clutter_actor_set_content (bg, canvas1); /*clutter_actor_set_content_scaling_filters (bg2, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR);*/ g_object_unref (canvas1); clutter_actor_add_child (box, bg); bg2 = clutter_actor_new (); //clutter_actor_set_background_color (bg2, clutter_color_new (0, 100, 100, 255*.5)); clutter_actor_set_name (bg2, "background"); clutter_actor_set_reactive (bg2, TRUE); clutter_actor_set_size (bg2, 0, 0); //clutter_actor_set_x_expand (bg2, TRUE); //clutter_actor_set_y_expand (bg2, TRUE); clutter_actor_set_x_align (bg2, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (bg2, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_clip_to_allocation(bg2, TRUE); clutter_actor_add_child (box, bg2); clutter_actor_set_layout_manager (bg2, clutter_box_layout_new ()); canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 300, 300); clutter_actor_set_content (bg2, canvas); /*clutter_actor_set_content_scaling_filters (bg2, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR);*/ g_object_unref (canvas); inset = clutter_actor_new (); //clutter_actor_set_background_color (inset, clutter_color_new (255, 0, 0, 255)); clutter_actor_set_name (inset, "inset"); clutter_actor_set_reactive (inset, TRUE); clutter_actor_set_margin_top (inset, 18); clutter_actor_set_margin_right (inset, 18); clutter_actor_set_margin_bottom (inset, 18); clutter_actor_set_margin_left (inset, 48); //clutter_actor_set_x_expand (inset, TRUE); //clutter_actor_set_y_expand (inset, TRUE); clutter_actor_set_x_align (inset, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (inset, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_clip_to_allocation(inset, TRUE); clutter_actor_add_child (bg2, inset); layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layout), TRUE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layout), 5); clutter_actor_set_layout_manager (inset, layout); labelContainer = clutter_actor_new (); clutter_actor_set_size (labelContainer, 0, 35); //clutter_actor_set_background_color (labelContainer, clutter_color_new (34, 134, 158, 255)); clutter_actor_set_name (labelContainer, "labelContainer"); clutter_actor_set_reactive (labelContainer, TRUE); //clutter_actor_set_x_expand (labelContainer, TRUE); //clutter_actor_set_y_expand (labelContainer, TRUE); clutter_actor_add_child (inset, labelContainer); labelContainer_l = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); clutter_actor_set_layout_manager (labelContainer, labelContainer_l); labelbg = clutter_actor_new (); clutter_actor_set_background_color (labelbg, clutter_color_new (34, 134, 158, 255)); clutter_actor_set_name (labelbg, "labelbg"); //clutter_actor_set_x_expand (labelbg, TRUE); clutter_actor_set_size (labelbg, 0, 35); clutter_actor_set_x_align (labelbg, CLUTTER_ACTOR_ALIGN_START); clutter_actor_set_y_align (labelbg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_add_child (labelContainer, labelbg); contentContainer = clutter_actor_new (); clutter_actor_set_size (contentContainer, 0, 0); clutter_actor_set_background_color (contentContainer, clutter_color_new (0.290196*255, 0.427451*255, 0.462745*255, 255)); clutter_actor_set_name (contentContainer, "labelContainer"); //clutter_actor_set_x_expand (contentContainer, TRUE); //clutter_actor_set_y_expand (contentContainer, TRUE); clutter_actor_set_layout_manager (contentContainer, clutter_fixed_layout_new ()); clutter_actor_add_child (inset, contentContainer); fixed = clutter_actor_new (); clutter_actor_set_background_color (fixed, clutter_color_new (9, 53, 71, 255)); clutter_actor_set_name (fixed, "fixed"); clutter_actor_set_size (fixed, 582, 210-40); clutter_actor_set_position (fixed, 582, 0); layoutFixed = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layoutFixed), TRUE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layoutFixed), 8); clutter_actor_set_layout_manager (fixed, layoutFixed); clutter_actor_add_child (contentContainer, fixed); //------------------------------------------------------------------------// lower = clutter_actor_new (); clutter_actor_set_size (lower, 0, 0); clutter_actor_set_name (lower, "lower"); //clutter_actor_set_x_expand (lower, TRUE); //clutter_actor_set_y_expand (lower, TRUE); clutter_actor_set_margin_right (lower, 8); clutter_actor_set_margin_top (lower, 8); clutter_actor_set_margin_left (lower, 8); clutter_actor_set_layout_manager (lower, clutter_fixed_layout_new ()); clutter_actor_set_clip_to_allocation(lower, TRUE); clutter_actor_add_child (fixed, lower); lowerInner = clutter_actor_new (); clutter_actor_set_background_color (lowerInner, clutter_color_new (255, 255, 255, 30)); clutter_actor_set_name (lowerInner, "fixed"); clutter_actor_set_size (lowerInner, 566, 113); clutter_actor_set_position (lowerInner, 566, 0); clutter_actor_add_child (lower, lowerInner); upper = clutter_actor_new (); clutter_actor_set_size (upper, 0, 33); clutter_actor_set_name (upper, "upper"); clutter_actor_set_x_expand (upper, TRUE); //clutter_actor_set_y_expand (upper, TRUE); clutter_actor_set_margin_bottom (upper, 8); clutter_actor_set_margin_right (upper, 8); clutter_actor_set_margin_left (upper, 8); //clutter_actor_set_layout_manager (upper, clutter_fixed_layout_new ()); clutter_actor_add_child (fixed, upper); timeline = clutter_timeline_new (57/24.*1000); clutter_timeline_add_marker_at_time(timeline, "first", (40-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "second", (46-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "third", (51-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "fourth", (52-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "fifth", (58-35)/24.*1000); g_signal_connect (timeline, "marker-reached::first", G_CALLBACK (plate1anim), bg); g_signal_connect (timeline, "marker-reached::second", G_CALLBACK (plate2anim), bg2); g_signal_connect (timeline, "marker-reached::third", G_CALLBACK (plate3anim), labelbg); g_signal_connect (timeline, "marker-reached::fourth", G_CALLBACK (plate4anim), fixed); g_signal_connect (timeline, "marker-reached::fifth", G_CALLBACK (plate5anim), lowerInner); g_signal_connect (canvas1, "draw", G_CALLBACK (draw_1), NULL); g_signal_connect (bg, "paint", G_CALLBACK (on_actor_resize), canvas); g_signal_connect (canvas, "draw", G_CALLBACK (draw), NULL); g_signal_connect (bg2, "paint", G_CALLBACK (on_actor_resize), canvas); clutter_content_invalidate (canvas); clutter_timeline_start (timeline); clutter_main (); return (EXIT_SUCCESS); }
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; }
int main (int argc, char *argv[]) { ClutterLayoutManager *layout; ClutterActor *box; ClutterActor *stage; ClutterActor *texture; CoglHandle *cogl_texture; GError *error = NULL; gfloat width; const gchar *filename = "redhand.png"; if (argc > 1) filename = argv[1]; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE); 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_actor_new (); clutter_actor_set_layout_manager (box, layout); clutter_actor_set_background_color (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_actor_add_child (box, texture_copy); } clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); clutter_actor_add_child (stage, box); clutter_actor_show (stage); clutter_main (); return 0; }
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); }
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); }
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_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "btn"); clutter_actor_set_background_color (stage, &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL); box = clutter_actor_new (); clutter_actor_set_layout_manager (box, 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_actor_add_child (box, rect); /* text for the button */ text = clutter_text_new_full ("Sans 10pt", "Hover me", &white); /* * 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_actor_add_child (stage, box); clutter_actor_show (stage); clutter_main (); g_object_unref (transitions); return 0; }
static void add_actor (ClutterActor *box, gint left, gint top, gint width, gint height) { ClutterLayoutManager *layout; ClutterActor *rect, *text; ClutterColor color; clutter_color_from_hls (&color, g_random_double_range (0.0, 360.0), 0.5, 0.5); color.alpha = 255; rect = clutter_actor_new (); clutter_actor_set_layout_manager (rect, clutter_bin_layout_new ()); clutter_actor_set_background_color (rect, &color); clutter_actor_set_reactive (rect, TRUE); if (random_size) clutter_actor_set_size (rect, g_random_int_range (40, 80), g_random_int_range (40, 80)); else clutter_actor_set_size (rect, 60, 60); clutter_actor_set_x_expand (rect, default_expand); clutter_actor_set_y_expand (rect, default_expand); if (!default_expand) { clutter_actor_set_x_align (rect, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (rect, CLUTTER_ACTOR_ALIGN_CENTER); } if (random_align) { clutter_actor_set_x_align (rect, g_random_int_range (0, 3)); clutter_actor_set_y_align (rect, g_random_int_range (0, 3)); } text = clutter_text_new_with_text ("Sans 8px", NULL); clutter_text_set_line_alignment (CLUTTER_TEXT (text), PANGO_ALIGN_CENTER); clutter_actor_add_child (rect, text); g_signal_connect (rect, "button-release-event", G_CALLBACK (button_release_cb), NULL); g_signal_connect (rect, "notify::x-expand", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::y-expand", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::x-align", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::y-align", G_CALLBACK (changed_cb), text); layout = clutter_actor_get_layout_manager (box); if (use_box) clutter_actor_add_child (box, rect); else clutter_grid_layout_attach (CLUTTER_GRID_LAYOUT (layout), rect, left, top, width, height); changed_cb (rect, NULL, text); }
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; }
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; }
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[]) { 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; }