void gnibbles_worm_rescale (GnibblesWorm *worm, gint tilesize) { int i; gfloat x_pos, y_pos; gint count; ClutterActor *tmp; GError *err = NULL; if (!worm) return; if (!worm->actors) return; count = clutter_group_get_n_children (CLUTTER_GROUP (worm->actors)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (worm->actors), i); clutter_actor_get_position (tmp, &x_pos, &y_pos); clutter_actor_set_position (tmp, (x_pos / properties->tilesize) * tilesize, (y_pos / properties->tilesize) * tilesize); gtk_clutter_texture_set_from_pixbuf ( CLUTTER_TEXTURE (tmp), worm_pixmaps[properties->wormprops[worm->number]->color - 12], &err); if (err) gnibbles_error (err->message); } }
void gnibbles_board_resize (GnibblesBoard *board, gint newtile) { int i; int x_pos; int y_pos; int count; ClutterActor *tmp; ClutterActor *stage = gnibbles_board_get_stage (board); clutter_actor_set_size (stage, BOARDWIDTH * newtile, BOARDHEIGHT * newtile); clutter_actor_set_size (board->surface, BOARDWIDTH * newtile, BOARDHEIGHT * newtile); if (!board->level) return; count = clutter_group_get_n_children (CLUTTER_GROUP (board->level)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (board->level), i); clutter_actor_get_position (tmp, &x_pos, &y_pos); clutter_actor_set_position (tmp, (x_pos / properties->tilesize) * newtile, (y_pos / properties->tilesize) * newtile); clutter_actor_set_size (tmp ,newtile, newtile); } }
void gnibbles_board_rescale (GnibblesBoard *board, gint tilesize) { gint i, count; gfloat x_pos, y_pos; ClutterActor *tmp; if (!board->level) return; if (!board->surface) return; board->width = BOARDWIDTH * tilesize; board->height = BOARDHEIGHT * tilesize; clutter_actor_set_size (CLUTTER_ACTOR (board->surface), board->width, board->height); count = clutter_group_get_n_children (CLUTTER_GROUP (board->level)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (board->level), i); clutter_actor_get_position (CLUTTER_ACTOR (tmp), &x_pos, &y_pos); clutter_actor_set_position (CLUTTER_ACTOR (tmp), (x_pos / properties->tilesize) * tilesize, (y_pos / properties->tilesize) * tilesize); clutter_actor_set_size (CLUTTER_ACTOR (tmp), tilesize, tilesize); } }
static void fluttr_viewer_paint (ClutterActor *actor) { FluttrViewer *viewer; FluttrViewerPrivate *priv; viewer = FLUTTR_VIEWER(actor); priv = FLUTTR_VIEWER_GET_PRIVATE(viewer); glPushMatrix(); gint i; gint len = clutter_group_get_n_children (CLUTTER_GROUP (actor)); for (i = 0; i < len; i++) { ClutterActor* child; child = clutter_group_get_nth_child (CLUTTER_GROUP(actor), i); if (child) { clutter_actor_paint (child); } } glPopMatrix(); }
static void make_ui (ClutterActor *stage) { ClutterActor *editable = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterGeometry editable_geom = {150, 50, 100, 75}; ClutterActor *full_entry = NULL; ClutterActor *cloned_entry = NULL; clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); clutter_actor_set_size (stage, WIDTH, HEIGHT); label = clutter_text_new_full ("Sans Bold 32px", "Entry", &color_label); clutter_actor_set_position (label, 0, 50); /* editable */ editable = clutter_text_new_full ("Sans Bold 32px", "ddd", &color_text); clutter_actor_set_position (editable, 150, 50); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (editable), &color_sel); clutter_actor_grab_key_focus (editable); clutter_actor_set_reactive (editable, TRUE); /* rectangle: to create a entry "feeling" */ rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_geometry (rectangle, &editable_geom); full_entry = clutter_group_new (); clutter_actor_set_position (full_entry, 0, 50); clutter_actor_set_size (full_entry, 100, 75); clutter_group_add (CLUTTER_GROUP (full_entry), label); clutter_group_add (CLUTTER_GROUP (full_entry), editable); clutter_group_add (CLUTTER_GROUP (full_entry), rectangle); clutter_actor_show_all (full_entry); clutter_actor_set_scale (full_entry, 2, 1); clutter_group_add (CLUTTER_GROUP (stage), full_entry); /* Cloning! */ cloned_entry = clutter_clone_new (full_entry); clutter_actor_set_position (cloned_entry, 50, 200); clutter_actor_set_scale (cloned_entry, 1, 2); clutter_actor_show_all (cloned_entry); clutter_actor_set_reactive (cloned_entry, TRUE); clutter_group_add (CLUTTER_GROUP (stage), cloned_entry); }
static void fade_in_completed (G_GNUC_UNUSED ClutterAnimation *animation, ChamplainTile *self) { ChamplainTilePrivate *priv = self->priv; if (!priv->content_group) return; if (clutter_group_get_n_children (CLUTTER_GROUP (priv->content_group)) > 1) clutter_actor_destroy (clutter_group_get_nth_child (CLUTTER_GROUP (priv->content_group), 0)); }
static void make_ui (ClutterActor *stage) { gint i = 0; ClutterActor *editable = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterGeometry label_geom = {0, 50, -1, -1}; ClutterGeometry editable_geom = {150, 50, 500, 75}; clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); clutter_actor_set_size (stage, WIDTH, HEIGHT); for (i = 0; i < NUM_ENTRIES; i++) { /* label */ label = clutter_text_new_full ("Sans Bold 32px", "Entry", &color_label); clutter_actor_set_geometry (label, &label_geom); /* editable */ editable = clutter_text_new_full ("Sans Bold 32px", "ddd", &color_text); clutter_actor_set_geometry (editable, &editable_geom); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (editable), &color_sel); clutter_actor_grab_key_focus (editable); clutter_actor_set_reactive (editable, TRUE); /* rectangle: to create a entry "feeling" */ rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_geometry (rectangle, &editable_geom); clutter_group_add (CLUTTER_GROUP (stage), label); clutter_group_add (CLUTTER_GROUP (stage), editable); clutter_group_add (CLUTTER_GROUP (stage), rectangle); label_geom.y += HEIGHT_STEP; editable_geom.y += HEIGHT_STEP; } }
/** * champlain_layer_hide_all_markers: * @layer: a #ChamplainLayer * * Calls clutter_actor_hide on all markers * * Since: 0.4 */ void champlain_layer_hide_all_markers (ChamplainLayer *layer) { guint i; g_return_if_fail (CHAMPLAIN_IS_LAYER (layer)); for (i = 0; i < clutter_group_get_n_children (CLUTTER_GROUP (layer)); i++) { ClutterActor *marker = CLUTTER_ACTOR (clutter_group_get_nth_child (CLUTTER_GROUP (layer), i)); clutter_actor_hide (marker); } }
static void rc_free(void *renderer) { RendererClutter *rc = (RendererClutter *)renderer; GtkWidget *widget = gtk_bin_get_child(GTK_BIN(rc->pr)); rc_remove_pending_updates(rc); rc_overlay_free_all(rc); if (widget) { /* widget still exists */ clutter_actor_destroy(rc->group); if (clutter_group_get_n_children(CLUTTER_GROUP(rc->stage)) == 0) { DEBUG_1("destroy %p", rc->widget); /* this was the last user */ gtk_widget_destroy(rc->widget); } else { DEBUG_1("keep %p", rc->widget); g_object_unref(G_OBJECT(rc->widget)); } } g_free(rc); }
static gboolean key_group_action_activate (KeyGroup *self, const gchar *action_name, guint key_val, ClutterModifierType modifiers) { ClutterActor *child = NULL; g_debug ("%s: activated '%s' (k:%d, m:%d)", G_STRLOC, action_name, key_val, modifiers); if (self->selected_index == -1) return FALSE; child = clutter_group_get_nth_child (CLUTTER_GROUP (self), self->selected_index); if (child) { g_signal_emit (self, group_signals[ACTIVATE], 0, child); return TRUE; } else return FALSE; }
static gboolean clutter_group_real_get_paint_volume (ClutterActor *actor, ClutterPaintVolume *volume) { ClutterGroupPrivate *priv = CLUTTER_GROUP (actor)->priv; GList *l; if (priv->children == NULL) return TRUE; for (l = priv->children; l != NULL; l = l->next) { ClutterActor *child = l->data; const ClutterPaintVolume *child_volume; /* This gets the paint volume of the child transformed into the * group's coordinate space... */ child_volume = clutter_actor_get_transformed_paint_volume (child, actor); if (!child_volume) return FALSE; clutter_paint_volume_union (volume, child_volume); } return TRUE; }
static void clutter_group_dispose (GObject *object) { ClutterGroup *self = CLUTTER_GROUP (object); ClutterGroupPrivate *priv = self->priv; /* Note: we are careful to consider that destroying children could * have the side-effect of destroying other children so * priv->children may be modified during clutter_actor_destroy. */ while (priv->children) { ClutterActor *child = priv->children->data; priv->children = g_list_delete_link (priv->children, priv->children); clutter_actor_destroy (child); } if (priv->layout) { clutter_layout_manager_set_container (priv->layout, NULL); g_object_unref (priv->layout); priv->layout = NULL; } G_OBJECT_CLASS (clutter_group_parent_class)->dispose (object); }
static VALUE rbclt_group_remove_all (VALUE self) { ClutterGroup *group = CLUTTER_GROUP (RVAL2GOBJ (self)); clutter_group_remove_all (group); return self; }
static gboolean action_add_triangle (ClutterActor *action, ClutterEvent *event, gpointer userdata) { const ClutterColor transparent = { 0x00, 0x00, 0x00, 0x01 }; ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterVertex vertices[] = { { 0.5, 0.0, 0.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 } }; ClutterActor *box; box = clutter_rectangle_new_with_color (&transparent); clutter_actor_set_size (box, 50, 50); clutter_actor_set_position (box, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), box); /* Create a triangle vertex array */ clutter_box2d_child_set_outline (CLUTTER_BOX2D (group), box, vertices, 3); g_signal_connect (box, "paint", G_CALLBACK (paint_triangle), NULL); return FALSE; }
void gnibbles_worm_set_start (GnibblesWorm *worm, guint t_xhead, guint t_yhead, gint t_direction) { int i; worm->length = g_list_length (worm->list); for (i = 0; i < worm->length ; i++) worm->list = g_list_remove (worm->list, g_list_nth_data (worm->list, i)); g_list_free (worm->list); worm->list = NULL; clutter_group_remove_all (CLUTTER_GROUP (worm->actors)); worm->xhead = t_xhead; worm->yhead = t_yhead; worm->xtail = t_xhead; worm->ytail = t_yhead; worm->xstart = t_xhead; worm->ystart = t_yhead; worm->direction = t_direction; worm->direction_start = t_direction; worm->length = SLENGTH; worm->change = 0; worm->stop = FALSE; gnibbles_worm_queue_empty (worm); }
static void clutter_group_real_remove (ClutterContainer *container, ClutterActor *actor) { ClutterGroupPrivate *priv = CLUTTER_GROUP (container)->priv; g_object_ref (actor); priv->children = g_list_remove (priv->children, actor); clutter_actor_unparent (actor); /* queue a relayout, to get the correct positioning inside * the ::actor-removed signal handlers */ clutter_actor_queue_relayout (CLUTTER_ACTOR (container)); /* at this point, the actor passed to the "actor-removed" signal * handlers is not parented anymore to the container but since we * are holding a reference on it, it's still valid */ g_signal_emit_by_name (container, "actor-removed", actor); clutter_actor_queue_redraw (CLUTTER_ACTOR (container)); g_object_unref (actor); }
static VALUE rbclt_group_get_nth_child (VALUE self, VALUE n) { ClutterGroup *group = CLUTTER_GROUP (RVAL2GOBJ (self)); ClutterActor *child = clutter_group_get_nth_child (group, NUM2UINT (n)); return child ? GOBJ2RVAL (child) : Qnil; }
static void marker_position_notify (GObject *gobject, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data) { reorder_marker (CLUTTER_GROUP (user_data), CHAMPLAIN_BASE_MARKER (gobject)); }
void opt_show_add_slide (OptShow *self, OptSlide *slide) { ClutterActor *bg, *stage; self->priv->slides = g_list_append(self->priv->slides, slide); self->priv->num_slides++; stage = clutter_stage_get_default(); bg = CLUTTER_ACTOR(opt_slide_get_background_texture (slide)); if (bg == NULL) bg = clutter_clone_new(self->priv->bg); clutter_actor_set_size (bg, clutter_actor_get_width (stage), clutter_actor_get_height (stage)); clutter_group_add (CLUTTER_GROUP(slide), bg); clutter_actor_lower_bottom(bg); clutter_actor_show(bg); opt_menu_add_slide (self->priv->menu, slide); }
static void fluttr_viewer_init (FluttrViewer *self) { FluttrViewerPrivate *priv; gint width, height; ClutterActor *message; priv = FLUTTR_VIEWER_GET_PRIVATE (self); priv->mini_token = NULL; priv->popping = FALSE; width = CLUTTER_STAGE_WIDTH (); height = CLUTTER_STAGE_HEIGHT (); /* message box */ message = clutter_texture_new (); priv->texture = message; clutter_group_add (CLUTTER_GROUP (self),message); clutter_actor_set_size (message, width, height); clutter_actor_set_position (message, -(width/2),-(height/2)); /* Spinner */ priv->spinner = fluttr_spinner_new (); clutter_group_add (CLUTTER_GROUP (self),priv->spinner); clutter_actor_set_size (priv->spinner, (height/6)-11, (height/6)-11); clutter_actor_set_position (priv->spinner, width-(height/6),height-(height/6)); /* Setup the pixbuf swap */ priv->pixbuf = NULL; priv->swap_time = clutter_timeline_new (40, 40); priv->swap_alpha = clutter_alpha_new_full (priv->swap_time, alpha_linear_inc_func, NULL, NULL); priv->swap_behave = fluttr_behave_new (priv->swap_alpha, fluttr_viewer_swap_alpha_func, (gpointer)self); priv->timeline = clutter_timeline_new (40, 80); priv->alpha = clutter_alpha_new_full (priv->timeline, alpha_sine_inc_func, NULL, NULL); priv->behave = fluttr_behave_new (priv->alpha, fluttr_viewer_alpha_func, (gpointer)self); }
int main(int argc, char *argv[]) { GstElement *pipeline, *sink; ClutterTimeline *timeline; ClutterActor *stage, *texture; /* clutter-gst takes care of initializing Clutter and GStreamer */ if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) { g_error ("Failed to initialize clutter\n"); return -1; } stage = clutter_stage_get_default (); /* Make a timeline */ timeline = clutter_timeline_new (1000); g_object_set(timeline, "loop", TRUE, NULL); /* Create new texture and disable slicing so the video is properly mapped onto it */ texture = CLUTTER_ACTOR (g_object_new (CLUTTER_TYPE_TEXTURE, "disable-slicing", TRUE, NULL)); g_signal_connect (texture, "size-change", G_CALLBACK (size_change), NULL); /* Build the GStreamer pipeline */ pipeline = gst_parse_launch ("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL); /* Instantiate the Clutter sink */ sink = gst_element_factory_make ("autocluttersink", NULL); if (sink == NULL) { /* Revert to the older cluttersink, in case autocluttersink was not found */ sink = gst_element_factory_make ("cluttersink", NULL); } if (sink == NULL) { g_printerr ("Unable to find a Clutter sink.\n"); return -1; } /* Link GStreamer with Clutter by passing the Clutter texture to the Clutter sink*/ g_object_set (sink, "texture", texture, NULL); /* Add the Clutter sink to the pipeline */ g_object_set (pipeline, "video-sink", sink, NULL); /* Start playing */ gst_element_set_state (pipeline, GST_STATE_PLAYING); /* start the timeline */ clutter_timeline_start (timeline); /* Add texture to the stage, and show it */ clutter_group_add (CLUTTER_GROUP (stage), texture); clutter_actor_show_all (stage); clutter_main(); /* Free resources */ gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); return 0; }
static void clutter_group_real_sort_depth_order (ClutterContainer *container) { ClutterGroupPrivate *priv = CLUTTER_GROUP (container)->priv; priv->children = g_list_sort (priv->children, sort_by_depth); clutter_actor_queue_redraw (CLUTTER_ACTOR (container)); }
void gnibbles_worm_destroy (GnibblesWorm *worm) { while (worm->list) gnibbles_worm_remove_actor (worm); clutter_group_remove_all (CLUTTER_GROUP (worm->actors)); g_free (worm); }
static void clutter_group_real_pick (ClutterActor *actor, const ClutterColor *pick) { ClutterGroupPrivate *priv = CLUTTER_GROUP (actor)->priv; /* Chain up so we get a bounding box pained (if we are reactive) */ CLUTTER_ACTOR_CLASS (clutter_group_parent_class)->pick (actor, pick); g_list_foreach (priv->children, (GFunc) clutter_actor_paint, NULL); }
static void clutter_group_real_actor_removed (ClutterContainer *container, ClutterActor *actor) { ClutterGroupPrivate *priv = CLUTTER_GROUP (container)->priv; /* XXX - same compatibility mode of the ::actor-added implementation */ if (g_list_find (priv->children, actor) == NULL) return; priv->children = g_list_remove (priv->children, actor); }
static void glide_window_close_document (GlideWindow *w) { if (w->priv->document) g_object_unref (w->priv->document); if (w->priv->manager) g_object_unref (w->priv->manager); if (w->priv->undo_manager) g_object_unref (w->priv->undo_manager); clutter_group_remove_all (CLUTTER_GROUP (w->priv->stage)); }
static ClutterActor* _create_button (const gchar *text) { ClutterActor *button = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0xff }; ClutterColor color_label = { 0x00, 0x00, 0x00, 0xff }; button = clutter_group_new (); rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_size (rectangle, 375, 35); label = clutter_text_new_full ("Sans Bold 32px", text, &color_label); clutter_group_add (CLUTTER_GROUP (button), rectangle); clutter_group_add (CLUTTER_GROUP (button), label); clutter_actor_set_reactive (button, TRUE); return button; }
static void clutter_group_real_get_preferred_height (ClutterActor *actor, gfloat for_width, gfloat *min_height, gfloat *natural_height) { ClutterGroupPrivate *priv = CLUTTER_GROUP (actor)->priv; clutter_layout_manager_get_preferred_height (priv->layout, CLUTTER_CONTAINER (actor), for_width, min_height, natural_height); }
static void clutter_group_real_foreach (ClutterContainer *container, ClutterCallback callback, gpointer user_data) { ClutterGroupPrivate *priv = CLUTTER_GROUP (container)->priv; /* Using g_list_foreach instead of iterating the list manually because it has better protection against the current node being removed. This will happen for example if someone calls clutter_container_foreach(container, clutter_actor_destroy) */ g_list_foreach (priv->children, (GFunc) callback, user_data); }
static gboolean action_add_block_tree (ClutterActor *action, ClutterEvent *event, gpointer userdata) { ClutterActor *actor; actor = block_tree_new ("foo"); clutter_group_add (CLUTTER_GROUP (clutter_stage_get_default ()), actor); clutter_actor_set_position (actor, 20, 40); return FALSE; }