コード例 #1
0
/**
 * clutter_behaviour_ellipse_new:
 * @alpha: (allow-none): a #ClutterAlpha instance, or %NULL
 * @x: x coordinace of the center
 * @y: y coordiance of the center
 * @width: width of the ellipse
 * @height: height of the ellipse
 * @direction: #ClutterRotateDirection of rotation
 * @start: angle in degrees at which movement starts, between 0 and 360
 * @end: angle in degrees at which movement ends, between 0 and 360
 *
 * Creates a behaviour that drives actors along an elliptical path with
 * given center, width and height; the movement starts at @start
 * degrees (with 0 corresponding to 12 o'clock) and ends at @end
 * degrees. Angles greated than 360 degrees get clamped to the canonical
 * interval <0, 360); if @start is equal to @end, the behaviour will
 * rotate by exacly 360 degrees.
 *
 * If @alpha is not %NULL, the #ClutterBehaviour will take ownership
 * of the #ClutterAlpha instance. In the case when @alpha is %NULL,
 * it can be set later with clutter_behaviour_set_alpha().
 *
 * Return value: the newly created #ClutterBehaviourEllipse
 *
 * Since: 0.4
 */
ClutterBehaviour *
clutter_behaviour_ellipse_new (ClutterAlpha           *alpha,
                               gint                    x,
                               gint                    y,
                               gint                    width,
                               gint                    height,
                               ClutterRotateDirection  direction,
                               gdouble                 start,
                               gdouble                 end)
{
    ClutterKnot center;

    g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);

    center.x = x;
    center.y = y;

    return g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE,
                         "alpha", alpha,
                         "center", &center,
                         "width", width,
                         "height", height,
                         "direction", direction,
                         "angle-start", start,
                         "angle-end", end,
                         NULL);
}
コード例 #2
0
ファイル: clutter-alpha.c プロジェクト: ebassi/clutter
/**
 * clutter_alpha_get_timeline:
 * @alpha: A #ClutterAlpha
 *
 * Gets the #ClutterTimeline bound to @alpha.
 *
 * Return value: (transfer none): a #ClutterTimeline instance
 *
 * Since: 0.2
 *
 * Deprecated: 1.12
 */
ClutterTimeline *
clutter_alpha_get_timeline (ClutterAlpha *alpha)
{
  g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), NULL);

  return alpha->priv->timeline;
}
コード例 #3
0
ファイル: clutter-alpha.c プロジェクト: ebassi/clutter
/**
 * clutter_alpha_get_mode:
 * @alpha: a #ClutterAlpha
 *
 * Retrieves the #ClutterAnimationMode used by @alpha.
 *
 * Return value: the animation mode
 *
 * Since: 1.0
 *
 * Deprecated: 1.12
 */
gulong
clutter_alpha_get_mode (ClutterAlpha *alpha)
{
  g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), CLUTTER_CUSTOM_MODE);

  return alpha->priv->mode;
}
コード例 #4
0
ファイル: clutter-alpha.c プロジェクト: ebassi/clutter
/**
 * clutter_alpha_set_timeline:
 * @alpha: A #ClutterAlpha
 * @timeline: A #ClutterTimeline
 *
 * Binds @alpha to @timeline.
 *
 * Since: 0.2
 *
 * Deprecated: 1.12
 */
void
clutter_alpha_set_timeline (ClutterAlpha    *alpha,
                            ClutterTimeline *timeline)
{
  ClutterAlphaPrivate *priv;

  g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
  g_return_if_fail (timeline == NULL || CLUTTER_IS_TIMELINE (timeline));
  
  priv = alpha->priv;

  if (priv->timeline == timeline)
    return;

  if (priv->timeline)
    {
      g_signal_handlers_disconnect_by_func (priv->timeline,
                                            timeline_new_frame_cb,
                                            alpha);

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

  if (timeline)
    {
      priv->timeline = g_object_ref (timeline);

      g_signal_connect (priv->timeline, "new-frame",
                        G_CALLBACK (timeline_new_frame_cb),
                        alpha);
    }

  g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_TIMELINE]);
}
コード例 #5
0
ファイル: clutter-alpha.c プロジェクト: ebassi/clutter
/**
 * clutter_alpha_set_func:
 * @alpha: A #ClutterAlpha
 * @func: A #ClutterAlphaFunc
 * @data: user data to be passed to the alpha function, or %NULL
 * @destroy: notify function used when disposing the alpha function
 *
 * Sets the #ClutterAlphaFunc function used to compute
 * the alpha value at each frame of the #ClutterTimeline
 * bound to @alpha.
 *
 * This function will not register @func as a global alpha function.
 *
 * Since: 0.2
 *
 * Deprecated: 1.12
 */
void
clutter_alpha_set_func (ClutterAlpha    *alpha,
		        ClutterAlphaFunc func,
                        gpointer         data,
                        GDestroyNotify   destroy)
{
  ClutterAlphaPrivate *priv;

  g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
  g_return_if_fail (func != NULL);

  priv = alpha->priv;

  if (priv->notify != NULL)
    {
      priv->notify (priv->user_data);
    }
  else if (priv->closure != NULL)
    {
      g_closure_unref (priv->closure);
      priv->closure = NULL;
    }

  priv->func = func;
  priv->user_data = data;
  priv->notify = destroy;

  priv->mode = CLUTTER_CUSTOM_MODE;

  g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_MODE]);
}
コード例 #6
0
ファイル: clutter-alpha.c プロジェクト: ebassi/clutter
/**
 * clutter_alpha_set_closure:
 * @alpha: A #ClutterAlpha
 * @closure: A #GClosure
 *
 * Sets the #GClosure used to compute the alpha value at each
 * frame of the #ClutterTimeline bound to @alpha.
 *
 * Since: 0.8
 *
 * Deprecated: 1.12
 */
void
clutter_alpha_set_closure (ClutterAlpha *alpha,
                           GClosure     *closure)
{
  ClutterAlphaPrivate *priv;

  g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
  g_return_if_fail (closure != NULL);

  priv = alpha->priv;

  clutter_alpha_set_closure_internal (alpha, closure);

  priv->mode = CLUTTER_CUSTOM_MODE;
  g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_MODE]);
}
コード例 #7
0
/**
 * clutter_behaviour_rotate_new:
 * @alpha: (allow-none): a #ClutterAlpha instance, or %NULL
 * @axis: the rotation axis
 * @direction: the rotation direction
 * @angle_start: the starting angle in degrees, between 0 and 360.
 * @angle_end: the final angle in degrees, between 0 and 360.
 *
 * Creates a new #ClutterBehaviourRotate. This behaviour will rotate actors
 * bound to it on @axis, following @direction, between @angle_start and
 * @angle_end. Angles >= 360 degrees will be clamped to the canonical interval
 * <0, 360), if angle_start == angle_end, the behaviour will carry out a
 * single rotation of 360 degrees.
 *
 * If @alpha is not %NULL, the #ClutterBehaviour will take ownership
 * of the #ClutterAlpha instance. In the case when @alpha is %NULL,
 * it can be set later with clutter_behaviour_set_alpha().
 *
 * Return value: the newly created #ClutterBehaviourRotate.
 *
 * Since: 0.4
 */
ClutterBehaviour *
clutter_behaviour_rotate_new (ClutterAlpha           *alpha,
                              ClutterRotateAxis       axis,
                              ClutterRotateDirection  direction,
                              gdouble                 angle_start,
                              gdouble                 angle_end)
{
  g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);

  return g_object_new (CLUTTER_TYPE_BEHAVIOUR_ROTATE,
                       "alpha", alpha,
                       "axis", axis,
                       "direction", direction,
                       "angle-start", angle_start,
                       "angle-end", angle_end,
                       NULL);
}
コード例 #8
0
/**
 * clutter_behaviour_set_alpha:
 * @behave: a #ClutterBehaviour
 * @alpha: a #ClutterAlpha or %NULL to unset a previously set alpha
 *
 * Binds @alpha to a #ClutterBehaviour. The #ClutterAlpha object
 * is what makes a behaviour work: for each tick of the timeline
 * used by #ClutterAlpha a new value of the alpha parameter is
 * computed by the alpha function; the value should be used by
 * the #ClutterBehaviour to update one or more properties of the
 * actors to which the behaviour applies.
 *
 * If @alpha is not %NULL, the #ClutterBehaviour will take ownership
 * of the #ClutterAlpha instance.
 *
 * Since: 0.2
 */
void
clutter_behaviour_set_alpha (ClutterBehaviour *behave,
			     ClutterAlpha     *alpha)
{
  ClutterBehaviourPrivate *priv;

  g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave));
  g_return_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha));

  priv = behave->priv;

  if (priv->alpha == alpha)
    return;

  if (priv->notify_id)
    {
      CLUTTER_NOTE (BEHAVIOUR, "removing previous notify-id (%d)",
                    priv->notify_id);

      g_signal_handler_disconnect (priv->alpha, priv->notify_id);
      priv->notify_id = 0;
    }

  if (priv->alpha != NULL)
    {
      CLUTTER_NOTE (BEHAVIOUR, "removing previous alpha object");

      g_object_unref (priv->alpha);
      priv->alpha = NULL;
    }

  if (alpha != NULL)
    {
      priv->alpha = g_object_ref_sink (alpha);

      priv->notify_id = g_signal_connect (priv->alpha, "notify::alpha",
                                          G_CALLBACK(notify_cb),
                                          behave);
      
      CLUTTER_NOTE (BEHAVIOUR, "setting new alpha object (%p, notify:%d)",
                    priv->alpha, priv->notify_id);
    }

  g_object_notify_by_pspec (G_OBJECT (behave), obj_props[PROP_ALPHA]);
}
コード例 #9
0
ファイル: clutter-alpha.c プロジェクト: ebassi/clutter
/**
 * clutter_alpha_get_alpha:
 * @alpha: A #ClutterAlpha
 *
 * Query the current alpha value.
 *
 * Return Value: The current alpha value for the alpha
 *
 * Since: 0.2
 *
 * Deprecated: 1.12
 */
gdouble
clutter_alpha_get_alpha (ClutterAlpha *alpha)
{
  ClutterAlphaPrivate *priv;
  gdouble retval = 0;

  g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), 0);

  priv = alpha->priv;

  if (G_LIKELY (priv->func))
    {
      return priv->func (alpha, priv->user_data);
    }
  else if (priv->closure)
    {
      GValue params = G_VALUE_INIT;
      GValue result_value = G_VALUE_INIT;

      g_object_ref (alpha);

      g_value_init (&result_value, G_TYPE_DOUBLE);

      g_value_init (&params, CLUTTER_TYPE_ALPHA);
      g_value_set_object (&params, alpha);

      g_closure_invoke (priv->closure, &result_value, 1, &params, NULL);

      retval = g_value_get_double (&result_value);

      g_value_unset (&result_value);
      g_value_unset (&params);

      g_object_unref (alpha);
    }

  return retval;
}
コード例 #10
0
ファイル: clutter-alpha.c プロジェクト: ebassi/clutter
/**
 * clutter_alpha_set_mode:
 * @alpha: a #ClutterAlpha
 * @mode: a #ClutterAnimationMode
 *
 * Sets the progress function of @alpha using the symbolic value
 * of @mode, as taken by the #ClutterAnimationMode enumeration or
 * using the value returned by clutter_alpha_register_func().
 *
 * Since: 1.0
 *
 * Deprecated: 1.12
 */
void
clutter_alpha_set_mode (ClutterAlpha *alpha,
                        gulong        mode)
{
  ClutterAlphaPrivate *priv;

  g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
  g_return_if_fail (mode != CLUTTER_ANIMATION_LAST);

  priv = alpha->priv;

  if (mode == CLUTTER_CUSTOM_MODE)
    {
      priv->mode = mode;
    }
  else if (mode < CLUTTER_ANIMATION_LAST)
    {
      if (priv->mode == mode)
        return;

      /* sanity check to avoid getting an out of sync
       * enum/function mapping
       */
      g_assert (clutter_get_easing_func_for_mode (mode) != NULL);

      clutter_alpha_set_closure_internal (alpha, NULL);

      priv->mode = mode;

      CLUTTER_NOTE (ANIMATION, "New easing mode '%s'[%lu]\n",
                    clutter_get_easing_name_for_mode (priv->mode),
                    priv->mode);

      priv->func = clutter_alpha_easing_func;
      priv->user_data = NULL;
      priv->notify = NULL;
    }
  else if (mode > CLUTTER_ANIMATION_LAST)
    {
      AlphaData *alpha_data = NULL;
      gulong real_index = 0;

      if (priv->mode == mode)
        return;

      if (G_UNLIKELY (clutter_alphas == NULL))
        {
          g_warning ("No alpha functions defined for ClutterAlpha to use. "
                     "Use clutter_alpha_register_func() to register an "
                     "alpha function.");
          return;
        }

      real_index = mode - CLUTTER_ANIMATION_LAST - 1;

      alpha_data = g_ptr_array_index (clutter_alphas, real_index);
      if (G_UNLIKELY (alpha_data == NULL))
        {
          g_warning ("No alpha function registered for mode %lu.",
                     mode);
          return;
        }

      if (alpha_data->closure_set)
        clutter_alpha_set_closure (alpha, alpha_data->closure);
      else
        {
          clutter_alpha_set_closure_internal (alpha, NULL);

          priv->func = alpha_data->func;
          priv->user_data = alpha_data->data;
          priv->notify = NULL;
        }

      priv->mode = mode;
    }
  else
    g_assert_not_reached ();

  g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_MODE]);
}