コード例 #1
0
/* Sort drop action targets */
static gint _xfdashboard_drag_action_sort_targets_callback(gconstpointer inLeft, gconstpointer inRight)
{
	ClutterActor		*actor1, *actor2;
	gfloat				depth1, depth2;
	gfloat				x1, y1, w1, h1;
	gfloat				x2, y2, w2, h2;
	ClutterActorBox		*box1, *box2;
	gint				numberPoint1, numberPoint2;

	g_return_val_if_fail(XFDASHBOARD_IS_DROP_ACTION(inLeft) && XFDASHBOARD_IS_DROP_ACTION(inRight), 0);

	actor1=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(inLeft));
	actor2=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(inRight));

	/* Return -1 if actor in inLeft should be inserted before actor in inRight
	 * and return 1 if otherwise. If both actors can be handled equal then
	 * return 0. But how to decide?
	 * The actor with higher z-depth should be inserted before. If both actors
	 * have equal z-depth then the actor with the most edge points within the
	 * other actor (overlap) should be inserted before. Edge points are:
	 * [left,top], [right,top], [left,bottom] and [right, bottom].
	*/
	depth1=clutter_actor_get_z_position(actor1);
	depth2=clutter_actor_get_z_position(actor2);
	if(depth1>depth2) return(-1);
		else if(depth1<depth2) return(1);

	clutter_actor_get_transformed_position(actor1, &x1, &y1);
	clutter_actor_get_transformed_size(actor1, &w1, &h1);
	box1=clutter_actor_box_new(x1, y1, x1+w1, y1+h1);

	clutter_actor_get_transformed_position(actor2, &x2, &y2);
	clutter_actor_get_transformed_size(actor2, &w2, &h2);
	box2=clutter_actor_box_new(x2, y2, x2+w2, y2+h2);

	numberPoint1 =(clutter_actor_box_contains(box1, x2, y2) ? 1 : 0);
	numberPoint1+=(clutter_actor_box_contains(box1, x2+w2, y2) ? 1 : 0);
	numberPoint1+=(clutter_actor_box_contains(box1, x2, y2+h2) ? 1 : 0);
	numberPoint1+=(clutter_actor_box_contains(box1, x2+w2, y2+h2) ? 1 : 0);

	numberPoint2 =(clutter_actor_box_contains(box2, x1, y1) ? 1 : 0);
	numberPoint2+=(clutter_actor_box_contains(box2, x1+w1, y1) ? 1 : 0);
	numberPoint2+=(clutter_actor_box_contains(box2, x1, y1+h1) ? 1 : 0);
	numberPoint2+=(clutter_actor_box_contains(box2, x1+w1, y1+h1) ? 1 : 0);

	clutter_actor_box_free(box1);
	clutter_actor_box_free(box2);

	/* Return result */
	if(numberPoint1>numberPoint2) return(1);
		else if(numberPoint2>numberPoint1) return(-1);
	return(0);
}
コード例 #2
0
/* Find drop target at position */
static XfdashboardDropAction* _xfdashboard_drag_action_find_drop_traget_at_coord(XfdashboardDragAction *self,
																					gfloat inStageX,
																					gfloat inStageY)
{
	XfdashboardDragActionPrivate	*priv;
	GSList							*list;

	g_return_val_if_fail(XFDASHBOARD_IS_DRAG_ACTION(self), NULL);

	priv=self->priv;

	/* Iterate through list and return first drop target in list
	 * where coordinates fit in
	 */
	for(list=priv->targets; list; list=g_slist_next(list))
	{
		ClutterActorMeta			*actorMeta=CLUTTER_ACTOR_META(list->data);
		ClutterActor				*actor=clutter_actor_meta_get_actor(actorMeta);
		gfloat						x, y, w, h;

		/* Get position and size of actor in stage coordinates */
		clutter_actor_get_transformed_position(actor, &x, &y);
		clutter_actor_get_transformed_size(actor, &w, &h);

		/* If given stage coordinates fit in actor we found it */
		if(inStageX>=x && inStageX<(x+w) &&
			inStageY>=y && inStageY<(y+h))
		{
			return(XFDASHBOARD_DROP_ACTION(actorMeta));
		}
	}

	/* If we get here no drop target was found */
	return(NULL);
}
コード例 #3
0
/* Pointer left actor with tooltip */
static gboolean _xfdashboard_tooltip_action_on_leave_event(XfdashboardTooltipAction *self,
															ClutterEvent *inEvent,
															gpointer inUserData)
{
	XfdashboardTooltipActionPrivate		*priv;
	ClutterActor						*actor;
	ClutterActor						*stage;
	ClutterActor						*actorMeta;

	g_return_val_if_fail(XFDASHBOARD_IS_TOOLTIP_ACTION(self), CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(CLUTTER_IS_ACTOR(inUserData), CLUTTER_EVENT_PROPAGATE);

	priv=self->priv;
	actor=CLUTTER_ACTOR(inUserData);

	/* Get current actor this action belongs to */
	actorMeta=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(self));

	/* Release all sources and signal handler (except for enter event) */
	if(priv->motionSignalID!=0)
	{
		if(actorMeta) g_signal_handler_disconnect(actorMeta, priv->motionSignalID);
		priv->motionSignalID=0;
	}

	if(priv->leaveSignalID!=0)
	{
		if(actorMeta) g_signal_handler_disconnect(actorMeta, priv->leaveSignalID);
		priv->leaveSignalID=0;
	}

	if(priv->captureSignalID)
	{
		if(priv->captureSignalActor) g_signal_handler_disconnect(priv->captureSignalActor, priv->captureSignalID);
		priv->captureSignalActor=NULL;
		priv->captureSignalID=0;
	}

	if(priv->timeoutSourceID!=0)
	{
		g_source_remove(priv->timeoutSourceID);
		priv->timeoutSourceID=0;
	}

	/* Clear last actor we remembered if it is pointing to this actor */
	if(_xfdashboard_tooltip_last_event_actor==actor)
	{
		_xfdashboard_tooltip_last_event_actor=NULL;
	}

	/* Hide tooltip now */
	stage=clutter_actor_get_stage(actor);
	if(stage && XFDASHBOARD_IS_STAGE(stage))
	{
		g_signal_emit_by_name(stage, "hide-tooltip", self, NULL);
		priv->isVisible=FALSE;
	}

	return(CLUTTER_EVENT_PROPAGATE);
}
コード例 #4
0
ファイル: mx-fade-effect.c プロジェクト: 3v1n0/mx
static gboolean
mx_fade_effect_pre_paint (ClutterEffect *effect)
{
  MxFadeEffectPrivate *priv = MX_FADE_EFFECT (effect)->priv;

  if (!priv->freeze_update)
    {
      return CLUTTER_EFFECT_CLASS (mx_fade_effect_parent_class)->
        pre_paint (effect);
    }
  else
    {
      ClutterActorBox box;
      ClutterActor *actor =
        clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));

      /* Store the stage coordinates of the actor for when we post-paint */
      clutter_actor_get_paint_box (actor, &box);
      clutter_actor_box_get_origin (&box, &priv->x_offset, &priv->y_offset);

      /* Connect to the paint signal so we can block it */
      priv->blocked_id =
        g_signal_connect (actor, "paint",
                          G_CALLBACK (mx_fade_effect_paint_cb), effect);

      return TRUE;
    }
}
コード例 #5
0
ファイル: click-action.c プロジェクト: gmc-holle/xfdashboard
/* Emit "long-press" signal */
static gboolean _xfdashboard_click_action_emit_long_press(gpointer inUserData)
{
    XfdashboardClickAction			*self;
    XfdashboardClickActionPrivate	*priv;
    ClutterActor					*actor;
    gboolean						result;

    g_return_val_if_fail(XFDASHBOARD_IS_CLICK_ACTION(inUserData), FALSE);

    self=XFDASHBOARD_CLICK_ACTION(inUserData);
    priv=self->priv;

    /* Reset variables */
    priv->longPressID=0;

    /* Emit signal */
    actor=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(inUserData));
    g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_PRESS], 0, actor, CLUTTER_LONG_PRESS_ACTIVATE, &result);

    /* Disconnect signal handlers */
    if(priv->captureID!=0)
    {
        g_signal_handler_disconnect(priv->stage, priv->captureID);
        priv->captureID=0;
    }

    /* Reset state of this action */
    _xfdashboard_click_action_set_pressed(self, FALSE);
    _xfdashboard_click_action_set_held(self, FALSE);

    /* Event handled */
    return(FALSE);
}
コード例 #6
0
ファイル: click-action.c プロジェクト: gmc-holle/xfdashboard
/* Set press state */
static void _xfdashboard_click_action_set_pressed(XfdashboardClickAction *self, gboolean isPressed)
{
    XfdashboardClickActionPrivate	*priv;
    ClutterActor					*actor;

    g_return_if_fail(XFDASHBOARD_IS_CLICK_ACTION(self));

    priv=self->priv;

    /* Set value if changed */
    isPressed=!!isPressed;

    if(priv->isPressed!=isPressed)
    {
        /* Set value */
        priv->isPressed=isPressed;

        /* Style state */
        actor=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(self));
        if(XFDASHBOARD_IS_ACTOR(actor))
        {
            if(priv->isPressed) xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(actor), "pressed");
            else xfdashboard_stylable_remove_pseudo_class(XFDASHBOARD_STYLABLE(actor), "pressed");
        }

        /* Notify about property change */
        g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClickActionProperties[PROP_PRESSED]);
    }
}
コード例 #7
0
ファイル: mx-fade-effect.c プロジェクト: 3v1n0/mx
static void
mx_fade_effect_post_paint (ClutterEffect *effect)
{
  MxFadeEffectPrivate *priv = MX_FADE_EFFECT (effect)->priv;

  if (!priv->freeze_update)
    CLUTTER_EFFECT_CLASS (mx_fade_effect_parent_class)->post_paint (effect);
  else
    {
      CoglMatrix modelview;
      ClutterActor *actor, *stage;

      actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
      stage = clutter_actor_get_stage (actor);

      /* Set up the draw matrix so we draw the offscreen texture at the
       * absolute coordinates of the actor-box. We need to do this to
       * avoid transforming by the actor matrix twice, as when it's drawn
       * into the offscreen surface, it'll already be transformed.
       */
      cogl_push_matrix ();

      cogl_matrix_init_identity (&modelview);
      CLUTTER_ACTOR_CLASS (G_OBJECT_GET_CLASS (stage))->
        apply_transform (stage, &modelview);
      cogl_matrix_translate (&modelview, priv->x_offset, priv->y_offset, 0.f);
      cogl_set_modelview_matrix (&modelview);

      clutter_offscreen_effect_paint_target (CLUTTER_OFFSCREEN_EFFECT (effect));

      cogl_pop_matrix ();
    }
}
コード例 #8
0
ファイル: click-action.c プロジェクト: gmc-holle/xfdashboard
/* Query if long-press events should be handled and signals emitted */
static void _xfdashboard_click_action_query_long_press(XfdashboardClickAction *self)
{
    XfdashboardClickActionPrivate	*priv;
    ClutterActor					*actor;
    gboolean						result;
    gint							timeout;

    g_return_if_fail(XFDASHBOARD_IS_CLICK_ACTION(self));

    priv=self->priv;
    result=FALSE;

    /* If no duration was set get default one from settings */
    if(priv->longPressDuration<0)
    {
        ClutterSettings				*settings=clutter_settings_get_default();

        g_object_get(settings, "long-press-duration", &timeout, NULL);
    }
    else timeout=priv->longPressDuration;

    /* Emit signal to determine if long-press should be supported */
    actor=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(self));
    g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_PRESS], 0, actor, CLUTTER_LONG_PRESS_QUERY, &result);

    if(result)
    {
        priv->longPressID=clutter_threads_add_timeout(timeout,
                          _xfdashboard_click_action_emit_long_press,
                          self);
    }
}
コード例 #9
0
ファイル: clutter-actor-meta.c プロジェクト: nobled/clutter
static void
clutter_actor_meta_get_property (GObject    *gobject,
                                 guint       prop_id,
                                 GValue     *value,
                                 GParamSpec *pspec)
{
  ClutterActorMeta *meta = CLUTTER_ACTOR_META (gobject);

  switch (prop_id)
    {
    case PROP_ACTOR:
      g_value_set_object (value, meta->priv->actor);
      break;

    case PROP_NAME:
      g_value_set_string (value, meta->priv->name);
      break;

    case PROP_ENABLED:
      g_value_set_boolean (value, meta->priv->is_enabled);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
      break;
    }
}
コード例 #10
0
ファイル: clutter-drag-action.c プロジェクト: nobled/clutter
static void
clutter_drag_action_dispose (GObject *gobject)
{
  ClutterDragActionPrivate *priv = CLUTTER_DRAG_ACTION (gobject)->priv;

  if (priv->capture_id != 0)
    {
      if (priv->stage != NULL)
        g_signal_handler_disconnect (priv->stage, priv->capture_id);

      priv->capture_id = 0;
      priv->stage = NULL;
    }

  if (priv->button_press_id != 0)
    {
      ClutterActor *actor;

      actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject));
      g_signal_handler_disconnect (actor, priv->button_press_id);
      priv->button_press_id = 0;
    }

  G_OBJECT_CLASS (clutter_drag_action_parent_class)->dispose (gobject);
}
コード例 #11
0
ファイル: clutter-click-action.c プロジェクト: ebassi/clutter
static inline void
click_action_query_long_press (ClutterClickAction *action)
{
  ClutterClickActionPrivate *priv = action->priv;
  ClutterActor *actor;
  gboolean result = FALSE;
  gint timeout;

  if (priv->long_press_duration < 0)
    {
      ClutterSettings *settings = clutter_settings_get_default ();

      g_object_get (settings,
                    "long-press-duration", &timeout,
                    NULL);
    }
  else
    timeout = priv->long_press_duration;

  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));

  g_signal_emit (action, click_signals[LONG_PRESS], 0,
                 actor,
                 CLUTTER_LONG_PRESS_QUERY,
                 &result);

  if (result)
    {
      priv->long_press_id =
        clutter_threads_add_timeout (timeout,
                                     click_action_emit_long_press,
                                     action);
    }
}
コード例 #12
0
ファイル: test-pick.c プロジェクト: spatulasnout/clutter
static void
shader_paint (ClutterEffect           *effect,
              ClutterEffectPaintFlags  flags)
{
  ClutterShaderEffect *shader = CLUTTER_SHADER_EFFECT (effect);
  float tex_width;
  ClutterActor *actor =
    clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));

  if (g_test_verbose ())
    g_debug ("shader_paint");

  clutter_shader_effect_set_shader_source (shader,
    "uniform sampler2D tex;\n"
    "uniform float step;\n"
    "void main (void)\n"
    "{\n"
    "  gl_FragColor = texture2D(tex, vec2 (gl_TexCoord[0].s + step,\n"
    "                                      gl_TexCoord[0].t));\n"
    "}\n");

  tex_width = clutter_actor_get_width (actor);

  clutter_shader_effect_set_uniform (shader, "tex", G_TYPE_INT, 1, 0);
  clutter_shader_effect_set_uniform (shader, "step", G_TYPE_FLOAT, 1,
                                     SHIFT_STEP / tex_width);

  CLUTTER_EFFECT_CLASS (shift_effect_parent_class)->paint (effect, flags);
}
コード例 #13
0
static void
empathy_rounded_effect_paint (ClutterEffect *effect,
    ClutterEffectPaintFlags flags)
{
  EmpathyRoundedEffect *self = EMPATHY_ROUNDED_EFFECT (effect);
  ClutterActor *actor;
  ClutterActorBox allocation = { 0, };
  gfloat width, height;

  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (self));
  clutter_actor_get_allocation_box (actor, &allocation);
  clutter_actor_box_get_size (&allocation, &width, &height);

  cogl_path_new ();

  /* Create and store a path describing a rounded rectangle. The small
   * size of the preview window makes the radius of the rounded corners
   * very small too, so we can safely use a very coarse angle step
   * without loosing rendering accuracy. It also significantly reduces
   * the time spent in the underlying internal cogl path functions */
  cogl_path_round_rectangle (0, 0, width, height, height / 16., 15);

  cogl_clip_push_from_path ();

  /* Flip */
  cogl_push_matrix ();
  cogl_translate (width, 0, 0);
  cogl_scale (-1, 1, 1);

  clutter_actor_continue_paint (actor);

  cogl_pop_matrix ();
  cogl_clip_pop ();
}
コード例 #14
0
ファイル: clutter-click-action.c プロジェクト: ebassi/clutter
static void
clutter_click_action_dispose (GObject *gobject)
{
  ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;

  if (priv->event_id)
    {
      g_signal_handler_disconnect (clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject)),
                                   priv->event_id);
      priv->event_id = 0;
    }

  if (priv->capture_id)
    {
      g_signal_handler_disconnect (priv->stage, priv->capture_id);
      priv->capture_id = 0;
    }

  if (priv->long_press_id)
    {
      g_source_remove (priv->long_press_id);
      priv->long_press_id = 0;
    }

  G_OBJECT_CLASS (clutter_click_action_parent_class)->dispose (gobject);
}
コード例 #15
0
static void
mx_label_fade_started_cb (ClutterTimeline *timeline,
                          MxLabel         *label)
{
  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (label->priv->fade_effect),
                                  TRUE);
}
コード例 #16
0
static gboolean
actor_captured_event_cb (ClutterActor *actor,
                         ClutterEvent *event,
                         ClutterGestureAction *action)
{
  ClutterGestureActionPrivate *priv = action->priv;
  GesturePoint *point G_GNUC_UNUSED;

  if ((clutter_event_type (event) != CLUTTER_BUTTON_PRESS) &&
      (clutter_event_type (event) != CLUTTER_TOUCH_BEGIN))
    return CLUTTER_EVENT_PROPAGATE;

  if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action)))
    return CLUTTER_EVENT_PROPAGATE;

  point = gesture_register_point (action, event);

  if (priv->stage == NULL)
    priv->stage = clutter_actor_get_stage (actor);

  if (priv->stage_capture_id == 0)
    priv->stage_capture_id =
      g_signal_connect_after (priv->stage, "captured-event",
                              G_CALLBACK (stage_captured_event_cb),
                              action);

  /* Start the gesture immediately if the gesture has no
   * _TRIGGER_EDGE_AFTER drag threshold. */
  if ((priv->points->len >= priv->requested_nb_points) &&
      (priv->edge != CLUTTER_GESTURE_TRIGGER_EDGE_AFTER))
    begin_gesture (action, actor);

  return CLUTTER_EVENT_PROPAGATE;
}
コード例 #17
0
static void
shell_grid_desaturate_effect_paint_target (ClutterOffscreenEffect *effect)
{
  ShellGridDesaturateEffect *self = SHELL_GRID_DESATURATE_EFFECT (effect);
  ClutterActor *actor;
  CoglHandle texture;
  guint8 paint_opacity;

  texture = clutter_offscreen_effect_get_texture (effect);
  cogl_pipeline_set_layer_texture (self->pipeline, 0, texture);

  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
  paint_opacity = clutter_actor_get_paint_opacity (actor);

  cogl_pipeline_set_color4ub (self->pipeline,
                              paint_opacity,
                              paint_opacity,
                              paint_opacity,
                              paint_opacity);
  cogl_push_source (self->pipeline);

  cogl_rectangle (0, 0,
                  cogl_texture_get_width (texture),
                  cogl_texture_get_height (texture));

  cogl_pop_source ();
}
コード例 #18
0
ファイル: mex-tile.c プロジェクト: frankopt/media-explorer
static void
mex_tile_init (MexTile *self)
{
  MexTilePrivate *priv = self->priv = TILE_PRIVATE (self);
  const ClutterColor opaque = { 0x00, 0x00, 0x00, 0x00 };
  ClutterEffect *fade;

  /* create a template material for the header background from which cheap
   * copies can be made for each instance */
  if (G_UNLIKELY (!template_material))
    template_material = cogl_material_new ();

  priv->material = cogl_material_copy (template_material);


  /* layout for primary and secondary labels */
  priv->box_layout = mx_box_layout_new ();
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (priv->box_layout), 12);

  /* add fade effect to the box layout */
  fade = (ClutterEffect*) mx_fade_effect_new ();
  mx_fade_effect_set_border (MX_FADE_EFFECT (fade), 0, 50, 0, 0);
  mx_fade_effect_set_color (MX_FADE_EFFECT (fade), &opaque);
  clutter_actor_add_effect_with_name (priv->box_layout, "fade", fade);
  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (fade), TRUE);

  clutter_actor_push_internal (CLUTTER_ACTOR (self));
  clutter_actor_set_parent (priv->box_layout, CLUTTER_ACTOR (self));
  clutter_actor_pop_internal (CLUTTER_ACTOR (self));


  priv->label = clutter_text_new ();
  priv->secondary_label = clutter_text_new ();
  clutter_actor_set_opacity (priv->secondary_label, 128);

  clutter_container_add (CLUTTER_CONTAINER (priv->box_layout), priv->label,
                         priv->secondary_label, NULL);

  priv->header_visible = TRUE;

  priv->timeline = clutter_timeline_new (DURATION);
  priv->important_alpha =
    clutter_alpha_new_full (priv->timeline, CLUTTER_EASE_OUT_QUAD);
  g_signal_connect_object (priv->timeline, "new-frame",
                           G_CALLBACK (mex_tile_important_new_frame_cb), self,
                           0);
  g_signal_connect_object (priv->timeline, "completed",
                           G_CALLBACK (mex_tile_timeline_completed_cb), self,
                           0);

  g_signal_connect (self, "style-changed",
                    G_CALLBACK (mex_tile_style_changed_cb), NULL);

  g_signal_connect (self, "actor-added",
                    G_CALLBACK (mex_tile_actor_added), NULL);
  g_signal_connect (self, "actor-removed",
                    G_CALLBACK (mex_tile_actor_removed), NULL);
}
コード例 #19
0
/**
 * clutter_align_constraint_set_source:
 * @align: a #ClutterAlignConstraint
 * @source: (allow-none): a #ClutterActor, or %NULL to unset the source
 *
 * Sets the source of the alignment constraint
 *
 * Since: 1.4
 */
void
clutter_align_constraint_set_source (ClutterAlignConstraint *align,
                                     ClutterActor           *source)
{
  ClutterActor *old_source, *actor;
  ClutterActorMeta *meta;

  g_return_if_fail (CLUTTER_IS_ALIGN_CONSTRAINT (align));
  g_return_if_fail (source == NULL || CLUTTER_IS_ACTOR (source));

  if (align->source == source)
    return;

  meta = CLUTTER_ACTOR_META (align);
  actor = clutter_actor_meta_get_actor (meta);
  if (actor != NULL && source != NULL)
    {
      if (clutter_actor_contains (actor, source))
        {
          g_warning (G_STRLOC ": The source actor '%s' is contained "
                     "by the actor '%s' associated to the constraint "
                     "'%s'",
                     _clutter_actor_get_debug_name (source),
                     _clutter_actor_get_debug_name (actor),
                     _clutter_actor_meta_get_debug_name (meta));
          return;
        }
    }

  old_source = align->source;
  if (old_source != NULL)
    {
      g_signal_handlers_disconnect_by_func (old_source,
                                            G_CALLBACK (source_destroyed),
                                            align);
      g_signal_handlers_disconnect_by_func (old_source,
                                            G_CALLBACK (source_position_changed),
                                            align);
    }

  align->source = source;
  if (align->source != NULL)
    {
      g_signal_connect (align->source, "allocation-changed",
                        G_CALLBACK (source_position_changed),
                        align);
      g_signal_connect (align->source, "destroy",
                        G_CALLBACK (source_destroyed),
                        align);

      if (align->actor != NULL)
        clutter_actor_queue_relayout (align->actor);
    }

  g_object_notify_by_pspec (G_OBJECT (align), obj_props[PROP_SOURCE]);
}
コード例 #20
0
/**
 * clutter_bind_constraint_set_source:
 * @constraint: a #ClutterBindConstraint
 * @source: (allow-none): a #ClutterActor, or %NULL to unset the source
 *
 * Sets the source #ClutterActor for the constraint
 *
 * Since: 1.4
 */
void
clutter_bind_constraint_set_source (ClutterBindConstraint *constraint,
                                    ClutterActor          *source)
{
  ClutterActor *old_source, *actor;
  ClutterActorMeta *meta;

  g_return_if_fail (CLUTTER_IS_BIND_CONSTRAINT (constraint));
  g_return_if_fail (source == NULL || CLUTTER_IS_ACTOR (source));

  if (constraint->source == source)
    return;

  meta = CLUTTER_ACTOR_META (constraint);
  actor = clutter_actor_meta_get_actor (meta);
  if (source != NULL && actor != NULL)
    {
      if (clutter_actor_contains (actor, source))
        {
          g_warning (G_STRLOC ": The source actor '%s' is contained "
                     "by the actor '%s' associated to the constraint "
                     "'%s'",
                     _clutter_actor_get_debug_name (source),
                     _clutter_actor_get_debug_name (actor),
                     _clutter_actor_meta_get_debug_name (meta));
          return;
        }
    }

  old_source = constraint->source;
  if (old_source != NULL)
    {
      g_signal_handlers_disconnect_by_func (old_source,
                                            G_CALLBACK (source_destroyed),
                                            constraint);
      g_signal_handlers_disconnect_by_func (old_source,
                                            G_CALLBACK (source_queue_relayout),
                                            constraint);
    }

  constraint->source = source;
  if (constraint->source != NULL)
    {
      g_signal_connect (constraint->source, "queue-relayout",
                        G_CALLBACK (source_queue_relayout),
                        constraint);
      g_signal_connect (constraint->source, "destroy",
                        G_CALLBACK (source_destroyed),
                        constraint);

      if (constraint->actor != NULL)
        clutter_actor_queue_relayout (constraint->actor);
    }

  g_object_notify_by_pspec (G_OBJECT (constraint), obj_props[PROP_SOURCE]);
}
コード例 #21
0
static void
mx_label_fade_completed_cb (ClutterTimeline *timeline,
                            MxLabel         *label)
{
  MxLabelPrivate *priv = label->priv;

  if (!priv->label_should_fade)
    clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (priv->fade_effect),
                                    FALSE);
}
コード例 #22
0
static gboolean
shell_grid_desaturate_effect_pre_paint (ClutterEffect *effect)
{
  ShellGridDesaturateEffect *self = SHELL_GRID_DESATURATE_EFFECT (effect);
  ClutterEffectClass *parent_class;

  if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
    return FALSE;

  if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
    {
      /* if we don't have support for GLSL shaders then we
       * forcibly disable the ActorMeta
       */
      g_warning ("Unable to use the ShaderEffect: the graphics hardware "
                 "or the current GL driver does not implement support "
                 "for the GLSL shading language.");
      clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE);
      return FALSE;
    }

  parent_class = CLUTTER_EFFECT_CLASS (shell_grid_desaturate_effect_parent_class);
  if (parent_class->pre_paint (effect))
    {
      ClutterOffscreenEffect *offscreen_effect =
        CLUTTER_OFFSCREEN_EFFECT (effect);
      CoglHandle texture;

      texture = clutter_offscreen_effect_get_texture (offscreen_effect);
      self->tex_width = cogl_texture_get_width (texture);
      self->tex_height = cogl_texture_get_height (texture);

      if (self->unshaded_uniform_dirty)
        update_unshaded_uniform (self);

      cogl_pipeline_set_layer_texture (self->pipeline, 0, texture);

      return TRUE;
    }
  else
    return FALSE;
}
コード例 #23
0
static gboolean
shell_anamorphosis_effect_pre_paint (ClutterEffect *effect)
{
  ShellAnamorphosisEffect *self = SHELL_ANAMORPHOSIS_EFFECT (effect);
  ShellAnamorphosisEffectPrivate *priv = shell_anamorphosis_effect_get_instance_private (self);

  if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
    return FALSE;

  /* If we're not doing any bending, we're not needed. */

  if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
    {
      /* if we don't have support for GLSL shaders then we
       * forcibly disable the ActorMeta
       */
      g_warning ("Unable to use the ShellAnamorphosisEffect: the "
                 "graphics hardware or the current GL driver does not "
                 "implement support for the GLSL shading language. The "
                 "effect will be disabled.");
      clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE);
      return FALSE;
    }

  if (!CLUTTER_EFFECT_CLASS (shell_anamorphosis_effect_parent_class)->pre_paint (effect))
    return FALSE;

  ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (effect);
  CoglObject *texture;

  texture = clutter_offscreen_effect_get_texture (offscreen_effect);
  cogl_pipeline_set_layer_texture (priv->pipeline, 0, texture);

  priv->tex_width = cogl_texture_get_width (texture);
  priv->tex_height = cogl_texture_get_height (texture);

  cogl_pipeline_set_uniform_1i (priv->pipeline, priv->tex_width_uniform, priv->tex_width);
  cogl_pipeline_set_uniform_1i (priv->pipeline, priv->tex_height_uniform, priv->tex_height);

  return TRUE;
}
コード例 #24
0
static void
on_vadjustment_changed (StAdjustment *adjustment,
                        ClutterEffect *effect)
{
  gdouble value, lower, upper, page_size;
  gboolean needs_fade;

  st_adjustment_get_values (adjustment, &value, &lower, &upper, NULL, NULL, &page_size);
  needs_fade = (value > lower + 0.1) || (value < upper - page_size - 0.1);

  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), needs_fade);
}
コード例 #25
0
ファイル: clutter-actor-meta.c プロジェクト: nobled/clutter
static void
clutter_actor_meta_finalize (GObject *gobject)
{
  ClutterActorMetaPrivate *priv = CLUTTER_ACTOR_META (gobject)->priv;

  if (priv->destroy_id != 0 && priv->actor != NULL)
    g_signal_handler_disconnect (priv->actor, priv->destroy_id);

  g_free (priv->name);

  G_OBJECT_CLASS (clutter_actor_meta_parent_class)->finalize (gobject);
}
コード例 #26
0
ファイル: mx-fade-effect.c プロジェクト: 3v1n0/mx
static void
mx_fade_effect_paint_target (ClutterOffscreenEffect *effect)
{
  guint8 opacity;
  CoglColor color;
  ClutterActor *actor;

  CoglMaterial *material = clutter_offscreen_effect_get_target (effect);
  MxFadeEffect *self = MX_FADE_EFFECT (effect);
  MxFadeEffectPrivate *priv = self->priv;

  if (priv->update_vbo)
    mx_fade_effect_update_vbo (self);

  if (!priv->vbo || !priv->indices || !material)
    return;

  /* Set the blend string if the material has changed so we can blend with
   * the paint opacity.
   */
  if (material != priv->old_material)
    {
      GError *error = NULL;
      priv->old_material = material;

      if (!cogl_material_set_layer_combine (material, 1,
                                            "RGBA = MODULATE(PREVIOUS,CONSTANT)", &error))
        {
          g_warning (G_STRLOC ": Error setting layer combine blend string: %s",
                     error->message);
          g_error_free (error);
        }
    }

  /* Set the layer-combine constant so the texture is blended with the paint
   * opacity when painted.
   */
  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
  opacity = clutter_actor_get_paint_opacity (actor);
  cogl_color_init_from_4ub (&color, opacity, opacity, opacity, opacity);
  cogl_material_set_layer_combine_constant (material, 1, &color);

  /* Draw the texture */
  cogl_set_source (material);
  cogl_vertex_buffer_draw_elements (priv->vbo,
                                    COGL_VERTICES_MODE_TRIANGLES,
                                    priv->indices,
                                    0,
                                    (priv->n_quads * 4) - 1,
                                    0,
                                    priv->n_quads * 6);
}
コード例 #27
0
static gboolean
st_scroll_view_fade_pre_paint (ClutterEffect *effect)
{
  StScrollViewFade *self = ST_SCROLL_VIEW_FADE (effect);
  ClutterEffectClass *parent_class;

  if (self->shader == COGL_INVALID_HANDLE)
    return FALSE;

  if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
    return FALSE;

  if (self->actor == NULL)
    return FALSE;

  if (self->program == COGL_INVALID_HANDLE)
    self->program = cogl_create_program ();

  if (!self->is_attached)
    {
      g_assert (self->shader != COGL_INVALID_HANDLE);
      g_assert (self->program != COGL_INVALID_HANDLE);

      cogl_program_attach_shader (self->program, self->shader);
      cogl_program_link (self->program);

      cogl_handle_unref (self->shader);

      self->is_attached = TRUE;

      self->tex_uniform =
        cogl_program_get_uniform_location (self->program, "tex");
      self->height_uniform =
        cogl_program_get_uniform_location (self->program, "height");
      self->width_uniform =
        cogl_program_get_uniform_location (self->program, "width");
      self->scrollbar_width_uniform =
        cogl_program_get_uniform_location (self->program, "scrollbar_width");
      self->scrollbar_height_uniform =
        cogl_program_get_uniform_location (self->program, "scrollbar_height");
      self->rtl_uniform =
        cogl_program_get_uniform_location (self->program, "rtl");
      self->offset_top_uniform =
        cogl_program_get_uniform_location (self->program, "offset_top");
      self->offset_bottom_uniform =
        cogl_program_get_uniform_location (self->program, "offset_bottom");
    }

  parent_class = CLUTTER_EFFECT_CLASS (st_scroll_view_fade_parent_class);
  return parent_class->pre_paint (effect);
}
コード例 #28
0
static MxFocusable *
_accept_focus (MxFocusable *focusable,
               MxFocusHint  hint)
{
  MexActionButtonPrivate *priv = MEX_ACTION_BUTTON (focusable)->priv;
  MxFocusableIface *iface;

  priv->has_focus = TRUE;

  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (priv->shadow), TRUE);

  iface = g_type_interface_peek_parent (MX_FOCUSABLE_GET_INTERFACE (focusable));
  return iface->accept_focus (focusable, hint);
}
コード例 #29
0
ファイル: clutter-pan-action.c プロジェクト: UIKit0/clutter
static void
on_deceleration_stopped (ClutterTimeline           *timeline,
                         gboolean                   is_finished,
                         ClutterPanAction *self)
{
  ClutterPanActionPrivate *priv = self->priv;
  ClutterActor *actor;

  g_object_unref (timeline);
  priv->deceleration_timeline = NULL;

  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (self));
  emit_pan_stopped (self, actor);
}
コード例 #30
0
/**
 * clutter_gesture_action_set_n_touch_points:
 * @action: a #ClutterGestureAction
 * @nb_points: a number of points
 *
 * Sets the number of points needed to trigger the gesture.
 *
 * Since: 1.12
 */
void
clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
                                           gint                  nb_points)
{
  ClutterGestureActionPrivate *priv;

  g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
  g_return_if_fail (nb_points >= 1);

  priv = action->priv;

  if (priv->requested_nb_points == nb_points)
    return;

  priv->requested_nb_points = nb_points;

  if (priv->in_gesture)
    {
      if (priv->points->len < priv->requested_nb_points)
        cancel_gesture (action);
    }
  else if (priv->edge == CLUTTER_GESTURE_TRIGGER_EDGE_AFTER)
    {
      if (priv->points->len >= priv->requested_nb_points)
        {
          ClutterActor *actor =
            clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));
          gint i;
          float threshold_x, threshold_y;

          clutter_gesture_action_get_threshold_trigger_distance (action, &threshold_x, &threshold_y);

          for (i = 0; i < priv->points->len; i++)
            {
              GesturePoint *point = &g_array_index (priv->points, GesturePoint, i);

              if ((fabsf (point->press_y - point->last_motion_y) >= threshold_y) ||
                  (fabsf (point->press_x - point->last_motion_x) >= threshold_x))
                {
                  begin_gesture (action, actor);
                  break;
                }
            }
        }
    }

  g_object_notify_by_pspec (G_OBJECT (action),
                            gesture_props[PROP_N_TOUCH_POINTS]);
}