static void mex_telepathy_channel_create_incoming_video (MexTelepathyChannel *self) { MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv; ClutterActor *video_incoming_area; /* Setup the incoming surface to draw to */ priv->incoming_texture = clutter_texture_new (); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->incoming_texture), TRUE); video_incoming_area = mx_stack_new (); clutter_container_add (CLUTTER_CONTAINER (video_incoming_area), mex_telepathy_channel_create_static_image(), priv->incoming_texture, NULL); /* Create a frame for it with a styled border */ priv->full_frame = mx_frame_new(); clutter_actor_set_name (priv->full_frame, "Incoming Frame"); mx_bin_set_fill (MX_BIN (priv->full_frame), TRUE, TRUE); mx_stylable_set_style_class (MX_STYLABLE (priv->full_frame), "CallWindow"); clutter_actor_add_effect (priv->full_frame, CLUTTER_EFFECT ( mex_telepathy_channel_create_shadow ())); clutter_container_add_actor (CLUTTER_CONTAINER (priv->full_frame), video_incoming_area); priv->incoming_sink = clutter_gst_video_sink_new (CLUTTER_TEXTURE (priv->incoming_texture)); }
static void mex_telepathy_channel_create_preview (MexTelepathyChannel *self) { MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv; ClutterActor *video_preview_area; priv->video_outgoing = clutter_texture_new (); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_outgoing), TRUE); priv->outgoing_sink = clutter_gst_video_sink_new (CLUTTER_TEXTURE (priv->video_outgoing)); video_preview_area = mx_stack_new (); clutter_container_add (CLUTTER_CONTAINER (video_preview_area), mex_telepathy_channel_create_static_image(), priv->video_outgoing, NULL); mx_stylable_set_style_class (MX_STYLABLE (video_preview_area), "PreviewStack"); clutter_actor_set_height (video_preview_area, 150.0); clutter_actor_add_effect (video_preview_area, CLUTTER_EFFECT ( mex_telepathy_channel_create_shadow ())); priv->preview_area = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->preview_area), "PreviewPadding"); mx_bin_set_child (MX_BIN (priv->preview_area), video_preview_area); }
void Animation::loadShader(const char *fragment_path) { std::string fragShaderStr = readFile(fragment_path); const gchar *fragShaderSrc = fragShaderStr.c_str(); // Pop off the old shader: unloadShader(); printf("Loading shader: '%s' \n", fragment_path); // Setup the GLSL Fragment shaders that we'll use to generate colors // Build a GLSL Fragment shader to affect the color output (to the screen at least for now) shaderEffect = clutter_shader_effect_new(CLUTTER_FRAGMENT_SHADER); clutter_shader_effect_set_shader_source(CLUTTER_SHADER_EFFECT(shaderEffect), fragShaderSrc); // Start fuckups: // ClutterEffect *effect = clutter_blur_effect_new (); // works // ClutterEffect *effect = clutter_sensatron_effect_new (); // clutter_sensatron_effect_set_shader_source(CLUTTER_SENSATRON_EFFECT(effect), fragShaderSrc); // Now, let's try attaching a texture to this bitch!! // CoglTexture *texture = cogl_texture_new_from_file(textureFile, // COGL_TEXTURE_NONE, // COGL_PIXEL_FORMAT_ANY, // &error); // Try attaching the texture to the effect (on the 1th layer?): // cogl_pipeline_set_layer_texture (priv->pipeline, 1, texture); // CoglPipeline *target; // target = COGL_PIPELINE (clutter_offscreen_effect_get_target ((ClutterOffscreenEffect)shaderEffect)); // End fuckups // Bind uniforms to the shader so we can hand variables into them animationTime = 0.0; currentSpeed = 100; clutter_shader_effect_set_uniform(CLUTTER_SHADER_EFFECT(shaderEffect), "iGlobalTime", G_TYPE_FLOAT, 1, animationTime); clutter_shader_effect_set_uniform(CLUTTER_SHADER_EFFECT(shaderEffect), "iResolution", G_TYPE_FLOAT, 2, HEIGHT*osd_scale, WIDTH*osd_scale); clutter_shader_effect_set_uniform(CLUTTER_SHADER_EFFECT(shaderEffect), "iMouse", G_TYPE_FLOAT, 2, input_x*osd_scale, input_y*osd_scale); // clutter_shader_effect_set_uniform(CLUTTER_SHADER_EFFECT(shaderEffect), "iChannel0", CLUTTER_TYPE_SHADER_FLOAT, 1, audioTexture); // clutter_shader_effect_set_uniform(CLUTTER_SHADER_EFFECT(shaderEffect), "iChannel1", CLUTTER_TYPE_SHADER_FLOAT, 1, noiseTexture); // Set the effect live on the on screen display actor... clutter_actor_add_effect(shaderOutput, shaderEffect); // clutter_actor_add_effect(shaderOutput, effect); shaderLoaded = true; }
static void mex_action_button_init (MexActionButton *self) { ClutterColor shadow_color = {0, 0, 0, 64}; MexActionButtonPrivate *priv; priv = self->priv = ACTION_BUTTON_PRIVATE (self); mx_button_set_icon_position (MX_BUTTON (self), MX_POSITION_RIGHT); mx_bin_set_fill (MX_BIN (self), TRUE, TRUE); priv->shadow = mex_shadow_new (); mex_shadow_set_radius_x (priv->shadow, 15); mex_shadow_set_radius_y (priv->shadow, 15); mex_shadow_set_color (priv->shadow, &shadow_color); clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (priv->shadow), FALSE); clutter_actor_add_effect (CLUTTER_ACTOR (self), CLUTTER_EFFECT (priv->shadow)); }
static void mx_label_init (MxLabel *label) { MxLabelPrivate *priv; const ClutterColor opaque = { 0xff, 0xff, 0xff, 0xff }; label->priv = priv = MX_LABEL_GET_PRIVATE (label); priv->label = g_object_new (CLUTTER_TYPE_TEXT, "ellipsize", PANGO_ELLIPSIZE_END, NULL); clutter_actor_set_parent (priv->label, CLUTTER_ACTOR (label)); priv->fade_effect = mx_fade_effect_new (); mx_fade_effect_set_color (MX_FADE_EFFECT (priv->fade_effect), &opaque); clutter_actor_add_effect (priv->label, priv->fade_effect); clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (priv->fade_effect), FALSE); g_signal_connect (label, "style-changed", G_CALLBACK (mx_label_style_changed), NULL); g_signal_connect (priv->label, "notify::single-line-mode", G_CALLBACK (mx_label_single_line_mode_cb), label); g_signal_connect_swapped (priv->label, "queue-redraw", G_CALLBACK (mx_label_label_changed_cb), label); priv->fade_timeline = clutter_timeline_new (250); priv->fade_alpha = clutter_alpha_new_full (priv->fade_timeline, CLUTTER_EASE_OUT_QUAD); g_signal_connect (priv->fade_timeline, "new-frame", G_CALLBACK (mx_label_fade_new_frame_cb), label); g_signal_connect (priv->fade_timeline, "started", G_CALLBACK (mx_label_fade_started_cb), label); g_signal_connect (priv->fade_timeline, "completed", G_CALLBACK (mx_label_fade_completed_cb), label); }
int main (int argc, char **argv) { const ClutterColor transp = { 0x00, 0x00, 0x00, 0x00 }; const ClutterColor bg_color = { 0xe0, 0xf2, 0xfc, 0xff }; ClutterTimeline *timeline; ClutterActor *stage; gint i; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Circles"); clutter_stage_set_color (CLUTTER_STAGE (stage), &bg_color); clutter_actor_set_size (stage, SCREEN_W, SCREEN_H); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); timeline = clutter_timeline_new (5000); clutter_timeline_set_loop (timeline, TRUE); for (i = 0; i < N_CIRCLES; i++) { gint size; gdouble *angle; ClutterActor *actor; ClutterAlpha *alpha; ClutterBehaviour *behaviour; actor = clutter_rectangle_new_with_color (&transp); size = (i + 1) * (CIRCLE_W + CIRCLE_G) * 2; clutter_actor_set_size (actor, size, size); clutter_actor_set_position (actor, SCREEN_W - size / 2.0, SCREEN_H - size / 2.0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); angle = g_slice_new (gdouble); *angle = g_random_double_range (0.0, 90.0); g_object_set_data (G_OBJECT (actor), "angle", angle); g_signal_connect (actor, "paint", G_CALLBACK (circle_paint_cb), NULL); /* Animate */ alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); behaviour = clutter_behaviour_rotate_new (alpha, CLUTTER_Z_AXIS, (i % 2) ? CLUTTER_ROTATE_CW : CLUTTER_ROTATE_CCW, 0.0, 0.0); clutter_behaviour_rotate_set_center (CLUTTER_BEHAVIOUR_ROTATE (behaviour), size / 2, size / 2, 0); clutter_behaviour_apply (behaviour, actor); } ClutterActor *actor2 = clutter_group_new(); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor2); clutter_actor_set_position(actor2, 10, 10); ClutterEffect *effect2 = nineslice_effect_new_from_source(source); clutter_actor_add_effect(actor2, effect2); ClutterActor *actor = clutter_group_new(); clutter_container_add_actor (CLUTTER_CONTAINER (actor2), actor); ClutterEffect *effect = nineslice_effect_new_from_source(source); clutter_actor_add_effect(actor, effect); ClutterActor *text = clutter_text_new_with_text("Sans 40px","Example Text"); clutter_actor_set_position(text, 0, 0); clutter_container_add_actor (CLUTTER_CONTAINER (actor), text); ClutterActor *rect = clutter_rectangle_new(); clutter_actor_set_position(rect, 10, 100); clutter_actor_set_size(rect, 50, 50); clutter_container_add_actor (CLUTTER_CONTAINER (actor), rect); clutter_actor_set_position(actor, 200, 100); //clutter_actor_set_rotation(actor, CLUTTER_Z_AXIS, 30.0, 130, 50, 0); /* GValue cvalue = G_VALUE_INIT; g_value_init(&cvalue, CLUTTER_TYPE_ACTOR_BOX); g_value_set_boxed(&cvalue, clutter_actor_box_new(0.0, 0.0, 0.0, 0.0)); GValue ovalue = G_VALUE_INIT; g_value_init(&ovalue, CLUTTER_TYPE_ACTOR_BOX); g_value_set_boxed(&ovalue, clutter_actor_box_new(50.0, 50.0, 50.0, 50.0)); ClutterState *transition = clutter_state_new(); clutter_state_set_duration(transition, NULL, NULL, 5000); clutter_state_set_key (transition, NULL, "close", G_OBJECT(effect), "padding", CLUTTER_LINEAR, &cvalue, 0.0, 0.0); clutter_state_set_key (transition, NULL, "open", G_OBJECT(effect), "padding", CLUTTER_LINEAR, &ovalue, 0.0, 0.0); //clutter_state_set(transition, NULL, "close", effect, "padding_right", CLUTTER_LINEAR, 0.0, NULL); //clutter_state_set(transition, NULL, "open", effect, "padding_right", CLUTTER_LINEAR, 50.0, NULL); clutter_state_warp_to_state(transition, "close"); clutter_state_set_state(transition, "open"); */ clutter_actor_animate(rect, CLUTTER_LINEAR, 5000, "height", 200.0, NULL); clutter_actor_show_all (stage); clutter_timeline_start (timeline); clutter_main (); return 0; }
/* Update effects of actor with string of list of effect IDs */ static void _xfdashboard_actor_update_effects(XfdashboardActor *self, const gchar *inEffects) { XfdashboardActorPrivate *priv; XfdashboardTheme *theme; XfdashboardThemeEffects *themeEffects; gchar **effectIDs; gchar **iter; gchar *effectsList; g_return_if_fail(XFDASHBOARD_IS_ACTOR(self)); priv=self->priv; effectIDs=NULL; effectsList=NULL; /* Get theme effect instance which is needed to create effect objects. * Also take a reference on theme effect instance as it needs to be alive * while iterating through list of effect IDs and creating these effects. */ theme=xfdashboard_application_get_theme(NULL); themeEffects=xfdashboard_theme_get_effects(theme); g_object_ref(themeEffects); /* Get array of effect ID to create */ if(inEffects) effectIDs=xfdashboard_split_string(inEffects, " \t\r\n"); /* Remove all effects from actor */ clutter_actor_clear_effects(CLUTTER_ACTOR(self)); /* Create effects by their ID, add them to actor and * build result string with new list of effect IDs */ iter=effectIDs; while(iter && *iter) { ClutterEffect *effect; /* Create effect and if it was created successfully * add it to actor and update final string with list * of effect IDs. */ effect=xfdashboard_theme_effects_create_effect(themeEffects, *iter); if(effect) { clutter_actor_add_effect(CLUTTER_ACTOR(self), effect); if(effectsList) { gchar *tempEffectsList; tempEffectsList=g_strconcat(effectsList, " ", *iter, NULL); g_free(effectsList); effectsList=tempEffectsList; } else effectsList=g_strdup(*iter); } /* Continue with next ID */ iter++; } /* Set new string with list of effects */ if(priv->effects) g_free(priv->effects); priv->effects=g_strdup(effectsList); /* Release allocated resources */ if(effectsList) g_free(effectsList); if(effectIDs) g_strfreev(effectIDs); g_object_unref(themeEffects); }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *texture; ClutterEffect *effect; ClutterState *transitions; GError *error = NULL; gchar *filename; if (argc < 2) { g_print ("Usage: %s <path to image file>\n", argv[0]); return EXIT_FAILURE; } filename = argv[1]; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 300); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); texture = clutter_texture_new (); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE); clutter_actor_set_width (texture, 400); clutter_actor_set_reactive (texture, TRUE); clutter_texture_set_from_file (CLUTTER_TEXTURE (texture), filename, &error); if (error != NULL) { g_critical ("Error loading texture from file %s; error was:\n%s", filename, error->message); return EXIT_FAILURE; } /* create the page fold effect instance with destination fold angle * of 180 degrees and starting period of 0 (no folding) */ effect = cb_page_fold_effect_new (180.0, 0.0); /* add the effect to the texture actor */ clutter_actor_add_effect (texture, effect); clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture); /* animation for the period property of the effect, * to animate its value between 0.0 and 1.0 and back */ transitions = clutter_state_new (); clutter_state_set_duration (transitions, NULL, NULL, 500); clutter_state_set_duration (transitions, "partially-folded", "folded", 375); clutter_state_set (transitions, NULL, "folded", effect, "period", CLUTTER_LINEAR, 1.0, NULL); clutter_state_set (transitions, NULL, "partially-folded", effect, "period", CLUTTER_LINEAR, 0.25, NULL); clutter_state_set (transitions, NULL, "unfolded", effect, "period", CLUTTER_LINEAR, 0.0, NULL); clutter_state_warp_to_state (transitions, "partially-folded"); g_signal_connect (texture, "button-press-event", G_CALLBACK (button_pressed_cb), transitions); clutter_actor_show (stage); clutter_main (); g_object_unref (transitions); return EXIT_SUCCESS; }
static void mex_media_controls_init (MexMediaControls *self) { ClutterActor *actor; ClutterScript *script; GError *err = NULL; MxAdjustment *adjustment; ClutterActor *related_box; gchar *tmp; MexMediaControlsPrivate *priv = self->priv = MEDIA_CONTROLS_PRIVATE (self); priv->script = script = clutter_script_new (); tmp = g_build_filename (mex_get_data_dir (), "json", "media-controls.json", NULL); clutter_script_load_from_file (script, tmp, &err); g_free (tmp); if (err) g_error ("Could not load media controls interface: %s", err->message); priv->vbox = (ClutterActor*) clutter_script_get_object (script, "media-controls"); clutter_actor_set_parent (priv->vbox, CLUTTER_ACTOR (self)); /* add shadow to media controls box */ actor = (ClutterActor *) clutter_script_get_object (script, "media-controls-box"); clutter_actor_add_effect (actor, CLUTTER_EFFECT (mex_shadow_new ())); /* vertical fade effect */ priv->vertical_effect = mx_fade_effect_new (); clutter_actor_add_effect (priv->vbox, priv->vertical_effect); mx_scrollable_get_adjustments (MX_SCROLLABLE (mx_bin_get_child (MX_BIN (priv->vbox))), NULL, &adjustment); g_signal_connect (adjustment, "changed", G_CALLBACK (notify_vertical_changed_cb), self); g_signal_connect (adjustment, "notify::value", G_CALLBACK (notify_vertical_value_cb), self); /* horizontal fade effect */ priv->horizontal_effect = mx_fade_effect_new (); related_box = (ClutterActor *) clutter_script_get_object (priv->script, "related-box"); clutter_actor_add_effect (related_box, priv->horizontal_effect); mx_scrollable_get_adjustments (MX_SCROLLABLE (related_box), &adjustment, NULL); g_signal_connect (adjustment, "changed", G_CALLBACK (notify_horizontal_changed_cb), self); g_signal_connect (adjustment, "notify::value", G_CALLBACK (notify_horizontal_value_cb), self); /* slider setup */ priv->slider = (ClutterActor*) clutter_script_get_object (script, "slider"); g_signal_connect (priv->slider, "notify::value", G_CALLBACK (slider_value_changed_cb), self); g_signal_connect (priv->slider, "captured-event", G_CALLBACK (slider_captured_event), self); priv->play_pause_action = (MxAction*) clutter_script_get_object (script, "play-pause-action"); priv->stop_action = (MxAction*) clutter_script_get_object (script, "stop-action"); priv->add_to_queue_action = (MxAction*) clutter_script_get_object (script, "add-to-queue-action"); priv->queue_button = (ClutterActor *) clutter_script_get_object (script, "add-to-queue-button"); g_signal_connect (priv->play_pause_action, "activated", G_CALLBACK (mex_media_controls_play_cb), self); g_signal_connect (priv->stop_action, "activated", G_CALLBACK (mex_media_controls_stop_cb), self); #if 0 g_signal_connect (priv->add_to_queue_action, "activated", G_CALLBACK (mex_media_controls_add_to_queue_cb), self); #endif /* proxy setup */ priv->proxy_model = MEX_VIEW_MODEL (mex_view_model_new (NULL)); /* FIXME: Set an arbitrary 200-item limit as we can't handle large * amounts of actors without massive slow-down. */ mex_view_model_set_limit (priv->proxy_model, 200); priv->proxy = mex_content_proxy_new (MEX_MODEL (priv->proxy_model), CLUTTER_CONTAINER (related_box), MEX_TYPE_CONTENT_TILE); g_signal_connect (priv->proxy, "object-created", G_CALLBACK (tile_created_cb), self); priv->is_disabled = TRUE; }