コード例 #1
0
ファイル: st-scroll-view.c プロジェクト: aldatsa/Cinnamon
/**
 * st_scroll_view_update_vfade_effect:
 * @self: a #StScrollView
 * @fade_offset: The length of the fade effect, in pixels.
 *
 * Sets the height of the fade area area in pixels. A value of 0
 * disables the effect.
 */
static void
st_scroll_view_update_vfade_effect (StScrollView *self,
                                    float fade_offset)
{
  StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;

  /* A fade amount of more than 0 enables the effect. */
  if (fade_offset > 0.)
    {
      if (priv->vfade_effect == NULL) {
        priv->vfade_effect = g_object_new (ST_TYPE_SCROLL_VIEW_FADE, NULL);

        clutter_actor_add_effect_with_name (CLUTTER_ACTOR (self), "vfade",
                                            CLUTTER_EFFECT (priv->vfade_effect));
      }

      g_object_set (priv->vfade_effect,
                    "fade-offset", fade_offset,
                    NULL);
    }
   else
    {
      if (priv->vfade_effect != NULL) {
        clutter_actor_remove_effect (CLUTTER_ACTOR (self), CLUTTER_EFFECT (priv->vfade_effect));
        priv->vfade_effect = NULL;
      }
    }

  clutter_actor_queue_redraw (CLUTTER_ACTOR (self));
}
コード例 #2
0
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));
}
コード例 #3
0
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);
}
コード例 #4
0
static void
st_scroll_view_fade_set_actor (ClutterActorMeta *meta,
                               ClutterActor *actor)
{
  StScrollViewFade *self = ST_SCROLL_VIEW_FADE (meta);
  ClutterActorMetaClass *parent;

  g_return_if_fail (actor == NULL || ST_IS_SCROLL_VIEW (actor));

  if (self->shader == COGL_INVALID_HANDLE)
    {
      clutter_actor_meta_set_enabled (meta, FALSE);
      return;
    }

  if (self->vadjustment)
    {
      g_signal_handlers_disconnect_by_func (self->vadjustment,
                                            (gpointer)on_adjustment_changed,
                                            self);
      self->vadjustment = NULL;
    }

  if (self->hadjustment)
    {
      g_signal_handlers_disconnect_by_func (self->hadjustment,
                                            (gpointer)on_adjustment_changed,
                                            self);
      self->hadjustment = NULL;
    }


  if (actor)
    {
        StScrollView *scroll_view = ST_SCROLL_VIEW (actor);
        StScrollBar *vscroll = ST_SCROLL_BAR (st_scroll_view_get_vscroll_bar (scroll_view));
        StScrollBar *hscroll = ST_SCROLL_BAR (st_scroll_view_get_hscroll_bar (scroll_view));
        self->vadjustment = ST_ADJUSTMENT (st_scroll_bar_get_adjustment (vscroll));
        self->hadjustment = ST_ADJUSTMENT (st_scroll_bar_get_adjustment (hscroll));

        g_signal_connect (self->vadjustment, "changed",
                          G_CALLBACK (on_adjustment_changed),
                          self);

        g_signal_connect (self->hadjustment, "changed",
                          G_CALLBACK (on_adjustment_changed),
                          self);

        on_adjustment_changed (NULL, CLUTTER_EFFECT (self));
    }

  parent = CLUTTER_ACTOR_META_CLASS (st_scroll_view_fade_parent_class);
  parent->set_actor (meta, actor);

  /* we keep a back pointer here, to avoid going through the ActorMeta */
  self->actor = clutter_actor_meta_get_actor (meta);
}
コード例 #5
0
void
shell_anamorphosis_effect_update (ShellAnamorphosisEffect *self, float x, float y, float z)

{
  ShellAnamorphosisEffectPrivate *priv = shell_anamorphosis_effect_get_instance_private (self);
  priv->_x = x;
  priv->_y = y;
  priv->_z = z;
  
  update_uniforms (self);
  clutter_effect_queue_repaint (CLUTTER_EFFECT (self));
}
コード例 #6
0
/**
 * clutter_colorize_effect_set_tint:
 * @effect: a #ClutterColorizeEffect
 * @tint: the color to be used
 *
 * Sets the tint to be used when colorizing
 *
 * Since: 1.4
 */
void
clutter_colorize_effect_set_tint (ClutterColorizeEffect *effect,
                                  const ClutterColor    *tint)
{
  g_return_if_fail (CLUTTER_IS_COLORIZE_EFFECT (effect));

  effect->tint = *tint;

  update_tint_uniform (effect);

  clutter_effect_queue_repaint (CLUTTER_EFFECT (effect));

  g_object_notify_by_pspec (G_OBJECT (effect), obj_props[PROP_TINT]);
}
コード例 #7
0
/**
 * clutter_deform_effect_invalidate:
 * @effect: a #ClutterDeformEffect
 *
 * Invalidates the @effect<!-- -->'s vertices and, if it is associated
 * to an actor, it will queue a redraw
 *
 * Since: 1.4
 */
void
clutter_deform_effect_invalidate (ClutterDeformEffect *effect)
{
  ClutterActor *actor;

  g_return_if_fail (CLUTTER_IS_DEFORM_EFFECT (effect));

  if (effect->priv->is_dirty)
    return;

  effect->priv->is_dirty = TRUE;

  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
  if (actor != NULL)
    clutter_effect_queue_repaint (CLUTTER_EFFECT (effect));
}
コード例 #8
0
/**
 * shell_grid_desaturate_effect_set_unshaded_rect:
 * @effect: a #ShellGridDesaturateEffect
 * @rect: (allow-none): the unshaded area
 *
 * Sets an unshaded area to the effect
 */
void
shell_grid_desaturate_effect_set_unshaded_rect (ShellGridDesaturateEffect *effect,
                                                ClutterRect               *rect)
{
  g_return_if_fail (SHELL_IS_GRID_DESATURATE_EFFECT (effect));

  if (!clutter_rect_equals (rect, effect->unshaded_rect))
    {
      clutter_rect_free (effect->unshaded_rect);
      effect->unshaded_rect = clutter_rect_copy (rect);
      effect->unshaded_uniform_dirty = TRUE;

      clutter_effect_queue_repaint (CLUTTER_EFFECT (effect));

      g_object_notify_by_pspec (G_OBJECT (effect), obj_props[PROP_UNSHADED_RECT]);
    }
}
コード例 #9
0
/**
 * shell_grid_desaturate_effect_set_factor:
 * @effect: a #ShellGridDesaturateEffect
 * @factor: the desaturation factor, between 0.0 and 1.0
 *
 * Sets the desaturation factor for @effect, with 0.0 being "do not desaturate"
 * and 1.0 being "fully desaturate"
 */
void
shell_grid_desaturate_effect_set_factor (ShellGridDesaturateEffect *effect,
                                         gdouble                    factor)
{
  g_return_if_fail (SHELL_IS_GRID_DESATURATE_EFFECT (effect));
  g_return_if_fail (factor >= 0.0 && factor <= 1.0);

  if (fabsf (effect->factor - factor) >= 0.00001)
    {
      effect->factor = factor;
      update_factor_uniform (effect);

      clutter_effect_queue_repaint (CLUTTER_EFFECT (effect));

      g_object_notify_by_pspec (G_OBJECT (effect), obj_props[PROP_FACTOR]);
    }
}
コード例 #10
0
ファイル: st-scroll-view.c プロジェクト: aldatsa/Cinnamon
static void
st_scroll_view_dispose (GObject *object)
{
  StScrollViewPrivate *priv = ST_SCROLL_VIEW (object)->priv;

  if (priv->vfade_effect)
    {
      clutter_actor_remove_effect (CLUTTER_ACTOR (object), CLUTTER_EFFECT (priv->vfade_effect));
      priv->vfade_effect = NULL;
    }

  if (priv->vscroll)
    clutter_actor_destroy (priv->vscroll);

  if (priv->hscroll)
    clutter_actor_destroy (priv->hscroll);

  /* For most reliable freeing of memory, an object with signals
   * like StAdjustment should be explicitly disposed. Since we own
   * the adjustments, we take care of that. This also disconnects
   * the signal handlers that we established on creation.
   */
  if (priv->hadjustment)
    {
      g_object_run_dispose (G_OBJECT (priv->hadjustment));
      g_object_unref (priv->hadjustment);
      priv->hadjustment = NULL;
    }

  if (priv->vadjustment)
    {
      g_object_run_dispose (G_OBJECT (priv->vadjustment));
      g_object_unref (priv->vadjustment);
      priv->vadjustment = NULL;
    }

  if (priv->setting_connect_id > 0) {
    g_signal_handler_disconnect (priv->settings, priv->setting_connect_id);
    priv->setting_connect_id = 0;
  }

  g_signal_handlers_disconnect_by_func (ST_SCROLL_VIEW (object), motion_event_cb, ST_SCROLL_VIEW (object));

  G_OBJECT_CLASS (st_scroll_view_parent_class)->dispose (object);
}
コード例 #11
0
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));
}
コード例 #12
0
ファイル: mex-column.c プロジェクト: ocrete/media-explorer
/**
 * mex_column_add_content:
 *
 * Add an item to the column for the specified content at the specified
 * position.
 */
static void
mex_column_add_content (MexColumn  *column,
                        MexContent *content,
                        guint       position)
{
  MexColumnPrivate *priv = column->priv;
  ClutterActor *box;
  MexShadow *shadow;
  ClutterColor shadow_color = { 0, 0, 0, 128 };
  GList *sibling;

  box = mex_content_box_new ();
  mex_content_view_set_content (MEX_CONTENT_VIEW (box), content);
  mex_content_view_set_context (MEX_CONTENT_VIEW (box), priv->model);

  sibling = g_list_nth (priv->children, position);
  priv->children = g_list_insert_before (priv->children, sibling, box);
  priv->n_items ++;

  /* add shadow */
  shadow = mex_shadow_new ();
  mex_shadow_set_paint_flags (shadow,
                              MEX_TEXTURE_FRAME_TOP
                              | MEX_TEXTURE_FRAME_BOTTOM);
  mex_shadow_set_radius_y (shadow, 25);
  mex_shadow_set_color (shadow, &shadow_color);
  clutter_actor_add_effect_with_name (CLUTTER_ACTOR (box), "shadow",
                                      CLUTTER_EFFECT (shadow));
  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (shadow), FALSE);

  g_signal_connect (box, "notify::open",
                    G_CALLBACK (content_box_open_notify), column);

  /* set important if the column has focus */
  mex_content_box_set_important (MEX_CONTENT_BOX (box), priv->has_focus);

  clutter_actor_set_parent (box, CLUTTER_ACTOR (column));
}
コード例 #13
0
ClutterEffect *
empathy_rounded_effect_new (void)
{
  return CLUTTER_EFFECT (
    g_object_new (EMPATHY_TYPE_ROUNDED_EFFECT, NULL));
}
コード例 #14
0
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;
}