static void impl_constructed (GObject *object) { RBVisualizerPage *page; ClutterInitError err; GstElement *colorspace; GstElement *realsink; GstElement *capsfilter; GstCaps *caps; GstPad *pad; RB_CHAIN_GOBJECT_METHOD (rb_visualizer_page_parent_class, constructed, object); page = RB_VISUALIZER_PAGE (object); err = gtk_clutter_init (NULL, NULL); if (err != CLUTTER_INIT_SUCCESS) { /* maybe do something more sensible here. not sure if there are any user-recoverable * conditions that would cause clutter init to fail, though, so it may not be worth it. * as it is, we just won't add the page to the page tree. */ g_warning ("Unable to display visual effects due to Clutter init failure"); return; } page->texture = clutter_texture_new (); clutter_texture_set_sync_size (CLUTTER_TEXTURE (page->texture), TRUE); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (page->texture), TRUE); page->sink = gst_bin_new (NULL); g_object_ref (page->sink); /* actual sink */ realsink = gst_element_factory_make ("cluttersink", NULL); g_object_set (realsink, "texture", page->texture, NULL); colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL); /* capsfilter to force rgb format (without this we end up using ayuv) */ capsfilter = gst_element_factory_make ("capsfilter", NULL); caps = gst_caps_from_string ("video/x-raw-rgb,bpp=(int)24,depth=(int)24," "endianness=(int)4321,red_mask=(int)16711680," "green_mask=(int)65280,blue_mask=(int)255"); g_object_set (capsfilter, "caps", caps, NULL); gst_caps_unref (caps); gst_bin_add_many (GST_BIN (page->sink), colorspace, capsfilter, realsink, NULL); gst_element_link (colorspace, capsfilter); gst_element_link (capsfilter, realsink); pad = gst_element_get_static_pad (colorspace, "sink"); gst_element_add_pad (page->sink, gst_ghost_pad_new ("sink", pad)); gst_object_unref (pad); g_signal_connect_object (page->fullscreen_action, "toggled", G_CALLBACK (toggle_fullscreen_cb), page, 0); }
static void clutter_cairo_texture_init (ClutterCairoTexture *self) { ClutterCairoTexturePrivate *priv; self->priv = priv = CLUTTER_CAIRO_TEXTURE_GET_PRIVATE (self); /* FIXME - we are hardcoding the format; it would be good to have * a :surface-format construct-only property for creating * textures with a different format and have the cairo surface * match that format * * priv->format = CAIRO_FORMAT_ARGB32; */ /* the Cairo surface is responsible for driving the size of * the texture; if we let sync_size to its default of TRUE, * the Texture will try to queue a relayout every time we * change the size of the Cairo surface - which is not what * we want */ clutter_texture_set_sync_size (CLUTTER_TEXTURE (self), FALSE); }
static void mpd_folder_button_init (MpdFolderButton *self) { MpdFolderButtonPrivate *priv = GET_PRIVATE (self); ClutterActor *vbox; ClutterText *text; /* Box */ vbox = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL); mx_bin_set_child (MX_BIN (self), vbox); /* Icon */ priv->icon = clutter_texture_new (); clutter_texture_set_sync_size (CLUTTER_TEXTURE (priv->icon), true); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->icon); clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->icon, "expand", false, "x-align", MX_ALIGN_MIDDLE, "x-fill", false, "y-align", MX_ALIGN_START, "y-fill", false, NULL); /* Label */ priv->label = mx_label_new (); text = (ClutterText *) mx_label_get_clutter_text (MX_LABEL (priv->label)); clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD_CHAR); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->label); clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->label, "expand", false, "x-align", MX_ALIGN_MIDDLE, "x-fill", false, "y-align", MX_ALIGN_START, "y-fill", false, NULL); }
static void pp_super_aa_init (PPSuperAA *self) { self->priv = SUPER_AA_PRIVATE (self); clutter_texture_set_sync_size (CLUTTER_TEXTURE (self), FALSE); }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *texture; ClutterState *transitions; GError *error = NULL; gfloat texture_width, texture_height; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); texture = clutter_texture_new (); clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5)); clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5)); clutter_texture_set_sync_size (CLUTTER_TEXTURE (texture), TRUE); clutter_texture_set_from_file (CLUTTER_TEXTURE (texture), TESTS_DATA_DIR "/redhand.png", &error); if (error != NULL) { g_error ("Problem loading image into texture - %s", error->message); g_error_free (error); return 1; } clutter_actor_get_size (texture, &texture_width, &texture_height); clutter_actor_set_size (stage, texture_width * 2, texture_height * 2); /* set all centres of rotation to the centre of the texture */ clutter_actor_set_rotation (texture, CLUTTER_X_AXIS, 0.0, texture_width * 0.5, texture_height * 0.5, 0.0); clutter_actor_set_rotation (texture, CLUTTER_Y_AXIS, 0.0, texture_width * 0.5, texture_height * 0.5, 0.0); clutter_actor_set_z_rotation_from_gravity (texture, 0.0, CLUTTER_GRAVITY_CENTER); clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture); /* set up the animations */ transitions = clutter_state_new (); clutter_state_set (transitions, NULL, "start", texture, "rotation-angle-x", CLUTTER_LINEAR, 0.0, texture, "rotation-angle-y", CLUTTER_LINEAR, 0.0, texture, "rotation-angle-z", CLUTTER_LINEAR, 0.0, NULL); clutter_state_set (transitions, NULL, "x-cw", texture, "rotation-angle-x", CLUTTER_LINEAR, ROTATION_ANGLE, NULL); clutter_state_set (transitions, NULL, "x-ccw", texture, "rotation-angle-x", CLUTTER_LINEAR, -ROTATION_ANGLE, NULL); clutter_state_set (transitions, NULL, "x-after", texture, "rotation-angle-x", CLUTTER_LINEAR, 0.0, NULL); clutter_state_set (transitions, NULL, "y-cw", texture, "rotation-angle-y", CLUTTER_LINEAR, ROTATION_ANGLE, NULL); clutter_state_set (transitions, NULL, "y-ccw", texture, "rotation-angle-y", CLUTTER_LINEAR, -ROTATION_ANGLE, NULL); clutter_state_set (transitions, NULL, "y-after", texture, "rotation-angle-y", CLUTTER_LINEAR, 0.0, NULL); clutter_state_set (transitions, NULL, "z-cw", texture, "rotation-angle-z", CLUTTER_LINEAR, ROTATION_ANGLE, NULL); clutter_state_set (transitions, NULL, "z-ccw", texture, "rotation-angle-z", CLUTTER_LINEAR, -ROTATION_ANGLE, NULL); clutter_state_set_duration (transitions, NULL, NULL, DURATION); clutter_state_set_duration (transitions, "start", NULL, DURATION * 0.5); clutter_state_set_duration (transitions, NULL, "start", DURATION * 0.5); clutter_state_set_duration (transitions, NULL, "x-after", DURATION * 0.5); clutter_state_set_duration (transitions, NULL, "y-after", DURATION * 0.5); clutter_state_warp_to_state (transitions, "start"); g_signal_connect (transitions, "completed", G_CALLBACK (_set_next_state), NULL); clutter_state_set_state (transitions, "x-cw"); clutter_actor_show (stage); clutter_main (); return 0; }
static void on_gesture_end(ClutterGestureAction *action, ClutterActor *stage, gpointer data) { ClutterActor *new_actor, *texture, *actor; gfloat x, y, w, h; GError *error = NULL; GdkColor color; guint16 alpha; gint iw = 125; gint ih = 126; gboolean repeat_x = FALSE; gboolean repeat_y = TRUE; guint bgr; new_actor = tmpRect; gtk_color_button_get_color(GTK_COLOR_BUTTON(app.colorpicker), &color); alpha = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(app.colorpicker)); ClutterColor col = { CLAMP(((color.red / 65535.0) * 255), 0, 255), CLAMP(((color.green / 65535.0) * 255), 0, 255), CLAMP(((color.blue / 65535.0) * 255), 0, 255), CLAMP(((alpha / 65535.0) * 255), 0, 255), }; clutter_rectangle_set_color(CLUTTER_RECTANGLE(new_actor), &col); clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(new_actor), 0); tmpRect = NULL; clutter_actor_get_position(new_actor, &x, &y); clutter_actor_get_size(new_actor, &w, &h); if (background_image_file != NULL){ texture = clutter_texture_new_from_file(background_image_file, &error); if (error != NULL){ g_print("Loading image failed\n"); g_error_free(error); } clutter_actor_set_position(texture, x, y); clutter_actor_set_size(texture, w, h); clutter_actor_add_child(stage, texture); clutter_actor_show(texture); bgr = gtk_combo_box_get_active(GTK_COMBO_BOX(app.background_repeat_select)); switch (bgr){ case 0: repeat_x = repeat_y = FALSE; break; case 1: repeat_x = TRUE; repeat_y = FALSE; break; case 2: repeat_x = FALSE; repeat_y = TRUE; break; case 3: repeat_x = repeat_y = TRUE; break; } clutter_texture_get_base_size(CLUTTER_TEXTURE(texture), &iw, &ih); clutter_actor_set_clip(texture, 0, 0, repeat_x ? w : iw, repeat_y ? h : ih); clutter_texture_set_sync_size(CLUTTER_TEXTURE(texture), TRUE); clutter_texture_set_repeat(CLUTTER_TEXTURE(texture), TRUE, TRUE); clutter_texture_set_keep_aspect_ratio(CLUTTER_TEXTURE(texture), TRUE); actor = texture; clutter_actor_destroy(new_actor); } else { actor = new_actor; } tool = TOOL_SELECT; clutter_actor_add_action(actor, clutter_drag_action_new()); clutter_actor_set_reactive(actor, TRUE); actors = g_list_append(actors, actor); GdkWindow *gdk_window; gdk_window = gtk_widget_get_window(app.stage); gdk_window_set_cursor(gdk_window, NULL); }