2006-08-28 13:11:15 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Jorn Baayen <jorn@openedhand.com>
|
2006-09-08 16:52:38 -04:00
|
|
|
* Emmanuele Bassi <ebassi@openedhand.com>
|
2006-08-28 13:11:15 -04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-alpha
|
|
|
|
* @short_description: A class for calculating an alpha value as a function
|
|
|
|
* of time.
|
|
|
|
*
|
|
|
|
* #ClutterAlpha is a class for calculating an alpha value as a function
|
|
|
|
* of time.
|
2006-09-08 16:52:38 -04:00
|
|
|
*
|
|
|
|
* When you create a #ClutterAlpha object you should attach a #ClutterTimeline
|
|
|
|
* to it, to be used as a time source. You need to supply the alpha
|
|
|
|
* function to be invoked at each timeline "tick"; some common alpha functions
|
|
|
|
* are available.
|
2006-08-28 13:11:15 -04:00
|
|
|
*/
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
#include "config.h"
|
2006-08-28 13:11:15 -04:00
|
|
|
|
|
|
|
#include "clutter-alpha.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-marshal.h"
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
G_DEFINE_TYPE (ClutterAlpha,
|
|
|
|
clutter_alpha,
|
|
|
|
G_TYPE_INITIALLY_UNOWNED);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
struct _ClutterAlphaPrivate
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
|
|
|
ClutterTimeline *timeline;
|
2006-09-08 16:52:38 -04:00
|
|
|
|
|
|
|
guint32 alpha;
|
|
|
|
|
2006-08-28 13:11:15 -04:00
|
|
|
ClutterAlphaFunc func;
|
2006-09-08 16:52:38 -04:00
|
|
|
gpointer data;
|
|
|
|
GDestroyNotify destroy;
|
|
|
|
|
|
|
|
gint delay;
|
|
|
|
guint is_paused : 1;
|
2006-08-28 13:11:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2006-09-08 16:52:38 -04:00
|
|
|
|
2006-08-28 13:11:15 -04:00
|
|
|
PROP_TIMELINE,
|
2006-09-08 16:52:38 -04:00
|
|
|
PROP_DELAY,
|
|
|
|
PROP_IS_PAUSED,
|
2006-08-28 13:11:15 -04:00
|
|
|
PROP_ALPHA
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Alpha funcs */
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
/**
|
|
|
|
* clutter_alpha_ramp_inc_func:
|
|
|
|
* @alpha: a #ClutterAlpha
|
|
|
|
* @data: user data (ignored)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
2006-08-28 13:11:15 -04:00
|
|
|
guint32
|
2006-09-08 16:52:38 -04:00
|
|
|
clutter_alpha_ramp_inc_func (ClutterAlpha *alpha,
|
|
|
|
gpointer data)
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterTimeline *timeline;
|
|
|
|
gint current_frame_num, nframes;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), 0);
|
|
|
|
|
|
|
|
timeline = clutter_alpha_get_timeline (alpha);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
current_frame_num = clutter_timeline_get_current_frame (timeline);
|
|
|
|
nframes = clutter_timeline_get_n_frames (timeline);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
return (current_frame_num * CLUTTER_ALPHA_MAX) / nframes;
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
/**
|
|
|
|
* clutter_alpha_ramp_dec_func:
|
|
|
|
* @alpha: a #ClutterAlpha
|
|
|
|
* @data: user data (ignored)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
2006-08-28 13:11:15 -04:00
|
|
|
guint32
|
2006-09-08 16:52:38 -04:00
|
|
|
clutter_alpha_ramp_dec_func (ClutterAlpha *alpha,
|
|
|
|
gpointer data)
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterTimeline *timeline;
|
|
|
|
gint current_frame_num, nframes;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), 0);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
timeline = clutter_alpha_get_timeline (alpha);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
current_frame_num = clutter_timeline_get_current_frame (timeline);
|
|
|
|
nframes = clutter_timeline_get_n_frames (timeline);
|
|
|
|
|
|
|
|
return ((nframes - current_frame_num) * CLUTTER_ALPHA_MAX) / nframes;
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
/**
|
|
|
|
* clutter_alpha_ramp_func:
|
|
|
|
* @alpha: a #ClutterAlpha
|
|
|
|
* @data: user data (ignored)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
2006-08-28 13:11:15 -04:00
|
|
|
guint32
|
2006-09-08 16:52:38 -04:00
|
|
|
clutter_alpha_ramp_func (ClutterAlpha *alpha,
|
|
|
|
gpointer data)
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterTimeline *timeline;
|
|
|
|
gint current_frame_num, nframes;
|
|
|
|
guint32 retval;
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), 0);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
timeline = clutter_alpha_get_timeline (alpha);
|
|
|
|
|
|
|
|
current_frame_num = clutter_timeline_get_current_frame (timeline);
|
|
|
|
nframes = clutter_timeline_get_n_frames (timeline);
|
|
|
|
|
|
|
|
if (current_frame_num > (nframes / 2))
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
retval = (nframes - current_frame_num) * CLUTTER_ALPHA_MAX;
|
|
|
|
retval = retval / (nframes / 2);
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
retval = current_frame_num * CLUTTER_ALPHA_MAX;
|
|
|
|
retval = retval / (nframes / 2);
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
2006-09-08 16:52:38 -04:00
|
|
|
|
|
|
|
return retval;
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Object */
|
|
|
|
|
|
|
|
static void
|
|
|
|
timeline_new_frame_cb (ClutterTimeline *timeline,
|
|
|
|
guint current_frame_num,
|
|
|
|
ClutterAlpha *alpha)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterAlphaPrivate *priv = alpha->priv;
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
if (priv->is_paused)
|
|
|
|
return;
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
if ((priv->delay != -1) && (current_frame_num < priv->delay))
|
|
|
|
return;
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
/* Update alpha value */
|
|
|
|
if (priv->func)
|
|
|
|
{
|
|
|
|
g_object_ref (alpha);
|
|
|
|
|
|
|
|
priv->alpha = priv->func (alpha, priv->data);
|
|
|
|
g_object_notify (G_OBJECT (alpha), "alpha");
|
|
|
|
|
|
|
|
g_object_unref (alpha);
|
|
|
|
}
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_alpha_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterAlpha *alpha = CLUTTER_ALPHA (object);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_TIMELINE:
|
|
|
|
clutter_alpha_set_timeline (alpha, g_value_get_object (value));
|
|
|
|
break;
|
2006-09-08 16:52:38 -04:00
|
|
|
case PROP_DELAY:
|
|
|
|
alpha->priv->delay = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_IS_PAUSED:
|
|
|
|
alpha->priv->is_paused = g_value_get_boolean (value);
|
2006-08-28 13:11:15 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_alpha_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterAlphaPrivate *priv;
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
priv = CLUTTER_ALPHA (object)->priv;
|
2006-08-28 13:11:15 -04:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_TIMELINE:
|
|
|
|
g_value_set_object (value, priv->timeline);
|
|
|
|
break;
|
|
|
|
case PROP_ALPHA:
|
2006-08-29 Jorn Baayen <jorn@openedhand.com>
* clutter/clutter-behaviour.c: (_clutter_behaviour_finalize),
(_clutter_behaviour_set_property),
(_clutter_behaviour_get_property), (clutter_behaviour_class_init),
(clutter_behaviour_init), (clutter_behaviour_apply),
(clutter_behaviour_remove), (clutter_behaviour_remove_all),
(clutter_behaviour_actors_foreach):
* clutter/clutter-behaviour.h:
* clutter/clutter-behaviours.c:
(clutter_behaviour_property_change),
(clutter_behaviour_opacity_dispose),
(clutter_behaviour_opacity_finalize),
(clutter_behaviour_opacity_class_init),
(clutter_behaviour_opacity_init):
* clutter/clutter-behaviours.h:
* clutter/clutter-marshal.list:
* examples/behave.c: (main):
Behaviours track generic GObject properties.
* clutter/clutter-video-texture.h:
Remove signal prototypes - they are already specified in
clutter-media.h.
2006-08-29 09:20:29 -04:00
|
|
|
g_value_set_uint (value, priv->alpha);
|
2006-08-28 13:11:15 -04:00
|
|
|
break;
|
2006-09-08 16:52:38 -04:00
|
|
|
case PROP_DELAY:
|
|
|
|
g_value_set_int (value, priv->delay);
|
|
|
|
break;
|
|
|
|
case PROP_IS_PAUSED:
|
|
|
|
g_value_set_boolean (value, priv->is_paused);
|
|
|
|
break;
|
2006-08-28 13:11:15 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_alpha_finalize (GObject *object)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterAlphaPrivate *priv = CLUTTER_ALPHA (object)->priv;
|
|
|
|
|
|
|
|
if (priv->destroy)
|
|
|
|
{
|
|
|
|
priv->destroy (priv->data);
|
|
|
|
|
|
|
|
priv->data = NULL;
|
|
|
|
priv->destroy = NULL;
|
|
|
|
priv->func = NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-28 13:11:15 -04:00
|
|
|
G_OBJECT_CLASS (clutter_alpha_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_alpha_dispose (GObject *object)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterAlpha *self = CLUTTER_ALPHA (object);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
|
|
|
clutter_alpha_set_timeline (self, NULL);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_alpha_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_alpha_class_init (ClutterAlphaClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
|
|
|
object_class->set_property = clutter_alpha_set_property;
|
|
|
|
object_class->get_property = clutter_alpha_get_property;
|
|
|
|
object_class->finalize = clutter_alpha_finalize;
|
|
|
|
object_class->dispose = clutter_alpha_dispose;
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (ClutterAlphaPrivate));
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
/**
|
|
|
|
* ClutterAlpha:timeline
|
|
|
|
*
|
|
|
|
* The #ClutterTimeline object to be used when calculating
|
|
|
|
* the alpha value.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_TIMELINE,
|
|
|
|
g_param_spec_object ("timeline",
|
|
|
|
"Timeline",
|
|
|
|
"Timeline",
|
|
|
|
CLUTTER_TYPE_TIMELINE,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
/**
|
|
|
|
* ClutterAlpha:alpha
|
|
|
|
*
|
|
|
|
* The last computed value of the alpha function.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_ALPHA,
|
|
|
|
g_param_spec_uint ("alpha",
|
|
|
|
"Alpha",
|
|
|
|
"Alpha value",
|
|
|
|
CLUTTER_ALPHA_MIN,
|
|
|
|
CLUTTER_ALPHA_MAX,
|
|
|
|
CLUTTER_ALPHA_MIN,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
/**
|
|
|
|
* ClutterAlpha:delay
|
|
|
|
*
|
|
|
|
* The number of frames that should be skipped before
|
|
|
|
* starting the calculation of the alpha function.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_DELAY,
|
|
|
|
g_param_spec_int ("delay",
|
|
|
|
"Delay",
|
|
|
|
"The number of frames that should be skipped "
|
|
|
|
"before computing the alpha function",
|
|
|
|
0,
|
|
|
|
G_MAXINT,
|
|
|
|
0,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
/**
|
|
|
|
* ClutterAlpha:is-paused
|
|
|
|
*
|
|
|
|
* Whether the #ClutterAlpha should be paused or not;
|
|
|
|
* the timeline bound to the #ClutterAlpha object will
|
|
|
|
* continue to run.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_IS_PAUSED,
|
|
|
|
g_param_spec_boolean ("is-paused",
|
|
|
|
"Is Paused",
|
|
|
|
"Whether the alpha should be paused or not",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE));
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_alpha_init (ClutterAlpha *self)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
|
|
|
CLUTTER_TYPE_ALPHA,
|
|
|
|
ClutterAlphaPrivate);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
|
|
|
self->priv->func = CLUTTER_ALPHA_RAMP_INC;
|
2006-09-08 16:52:38 -04:00
|
|
|
|
|
|
|
self->priv->delay = -1;
|
|
|
|
self->priv->is_paused = FALSE;
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-09-08 16:52:38 -04:00
|
|
|
* clutter_alpha_get_value:
|
2006-08-28 13:11:15 -04:00
|
|
|
* @alpha: A #ClutterAlpha
|
|
|
|
*
|
|
|
|
* Query the current alpha value.
|
|
|
|
*
|
2006-09-08 16:52:38 -04:00
|
|
|
* Return value: The current alpha value for the alpha
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
2006-08-28 13:11:15 -04:00
|
|
|
*/
|
2006-09-08 16:52:38 -04:00
|
|
|
guint32
|
|
|
|
clutter_alpha_get_value (ClutterAlpha *alpha)
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), FALSE);
|
|
|
|
|
|
|
|
return alpha->priv->alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_alpha_set_func:
|
|
|
|
* @alpha: A #ClutterAlpha
|
|
|
|
* @func: A #ClutterAlphaAlphaFunc
|
2006-09-08 16:52:38 -04:00
|
|
|
* @data: the data to be passed to func or %NULL
|
|
|
|
* @destroy: the function to be called when removing the previous
|
|
|
|
* alpha function or %NULL
|
2006-08-28 13:11:15 -04:00
|
|
|
*
|
2006-09-08 16:52:38 -04:00
|
|
|
* Since: 0.2
|
2006-08-28 13:11:15 -04:00
|
|
|
*/
|
|
|
|
void
|
2006-09-08 16:52:38 -04:00
|
|
|
clutter_alpha_set_func (ClutterAlpha *alpha,
|
|
|
|
ClutterAlphaFunc func,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify destroy)
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterAlphaPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
|
|
|
g_return_if_fail (func != NULL);
|
|
|
|
|
|
|
|
priv = alpha->priv;
|
|
|
|
|
|
|
|
if (priv->destroy)
|
|
|
|
{
|
|
|
|
priv->destroy (priv->data);
|
|
|
|
priv->destroy = NULL;
|
|
|
|
priv->data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->func = func;
|
|
|
|
priv->data = data;
|
|
|
|
priv->destroy = destroy;
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_alpha_set_timeline:
|
|
|
|
* @alpha: A #ClutterAlpha
|
2006-09-08 16:52:38 -04:00
|
|
|
* @timeline: A #ClutterTimeline or %NULL to unset the timeline
|
2006-08-28 13:11:15 -04:00
|
|
|
*
|
2006-09-08 16:52:38 -04:00
|
|
|
* Binds @timeline to @alpha. Since an alpha is a function of time,
|
|
|
|
* @timeline will be used to compute the alpha each time the "new-frame"
|
|
|
|
* signal of @timeline is emitted.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
2006-08-28 13:11:15 -04:00
|
|
|
*/
|
|
|
|
void
|
2006-09-08 16:52:38 -04:00
|
|
|
clutter_alpha_set_timeline (ClutterAlpha *alpha,
|
2006-08-28 13:11:15 -04:00
|
|
|
ClutterTimeline *timeline)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterAlphaPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
|
|
|
g_return_if_fail (timeline == NULL || CLUTTER_IS_TIMELINE (timeline));
|
|
|
|
|
|
|
|
priv = alpha->priv;
|
|
|
|
|
|
|
|
g_object_ref (alpha);
|
|
|
|
|
|
|
|
if (priv->timeline)
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
g_signal_handlers_disconnect_by_func (priv->timeline,
|
|
|
|
timeline_new_frame_cb,
|
|
|
|
alpha);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
g_object_unref (priv->timeline);
|
|
|
|
priv->timeline = NULL;
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (timeline)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
priv->timeline = g_object_ref (timeline);
|
2006-08-28 13:11:15 -04:00
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
g_signal_connect (priv->timeline, "new-frame",
|
|
|
|
G_CALLBACK (timeline_new_frame_cb),
|
|
|
|
alpha);
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
2006-09-08 16:52:38 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (alpha), "timeline");
|
|
|
|
|
|
|
|
g_object_unref (alpha);
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_alpha_get_timeline:
|
|
|
|
* @alpha: A #ClutterAlpha
|
|
|
|
*
|
2006-09-08 16:52:38 -04:00
|
|
|
* Gets the #ClutterTimeline object bound to @alpha.
|
|
|
|
*
|
|
|
|
* Return value: The #ClutterTimeline bount to @alpa or %NULL.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
2006-08-28 13:11:15 -04:00
|
|
|
*/
|
|
|
|
ClutterTimeline *
|
|
|
|
clutter_alpha_get_timeline (ClutterAlpha *alpha)
|
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), NULL);
|
|
|
|
|
2006-08-28 13:11:15 -04:00
|
|
|
return alpha->priv->timeline;
|
|
|
|
}
|
|
|
|
|
2006-09-08 16:52:38 -04:00
|
|
|
/**
|
|
|
|
* clutter_alpha_get_delay:
|
|
|
|
* @alpha: a #ClutterAlpha
|
|
|
|
*
|
|
|
|
* Gets the delay used by @alpha. See clutter_alpha_set_delay().
|
|
|
|
*
|
|
|
|
* Return value: the number of frames to wait, or -1
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
clutter_alpha_get_delay (ClutterAlpha *alpha)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), -1);
|
|
|
|
|
|
|
|
return alpha->priv->delay;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_alpha_set_delay:
|
|
|
|
* @alpha: a #ClutterAlpha
|
|
|
|
* @delay: the number of frames to wait or -1 for no delay
|
|
|
|
*
|
|
|
|
* Sets the number of timeline frames to wait before starting to
|
|
|
|
* compute the alpha value.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_alpha_set_delay (ClutterAlpha *alpha,
|
|
|
|
gint delay)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
|
|
|
|
|
|
|
if (alpha->priv->delay != delay)
|
|
|
|
{
|
|
|
|
g_object_ref (alpha);
|
|
|
|
|
|
|
|
alpha->priv->delay = delay;
|
|
|
|
g_object_notify (G_OBJECT (alpha), "delay");
|
|
|
|
|
|
|
|
g_object_unref (alpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_alpha_get_is_paused:
|
|
|
|
* @alpha: a #ClutterAlpha
|
|
|
|
*
|
|
|
|
* Gets whether @alpha is in paused state or not.
|
|
|
|
* See clutter_alpha_set_is_paused().
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if @alpha is paused
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_alpha_get_is_paused (ClutterAlpha *alpha)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), FALSE);
|
|
|
|
|
|
|
|
return alpha->priv->is_paused;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_alpha_set_is_paused:
|
|
|
|
* @alpha: a #ClutterAlpha
|
|
|
|
* @is_paused: %TRUE to pause the alpha
|
|
|
|
*
|
|
|
|
* Pauses the calculation of the alpha value of @alpha. This is
|
|
|
|
* independent of the running state of the #ClutterTimeline bount
|
|
|
|
* to @alpha.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_alpha_set_is_paused (ClutterAlpha *alpha,
|
|
|
|
gboolean is_paused)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
|
|
|
|
|
|
|
if (alpha->priv->is_paused != is_paused)
|
|
|
|
{
|
|
|
|
g_object_ref (alpha);
|
|
|
|
|
|
|
|
alpha->priv->is_paused = is_paused;
|
|
|
|
g_object_notify (G_OBJECT (alpha), "is-paused");
|
|
|
|
|
|
|
|
g_object_unref (alpha);
|
|
|
|
}
|
|
|
|
}
|
2006-08-28 13:11:15 -04:00
|
|
|
/**
|
|
|
|
* clutter_alpha_new:
|
2006-09-08 16:52:38 -04:00
|
|
|
* @timeline: a #ClutterTimeline or %NULL
|
|
|
|
* @func: a #ClutterAlphaFunc alpha function
|
|
|
|
* @data: data to be passed to func, or %NULL
|
2006-08-28 13:11:15 -04:00
|
|
|
*
|
2006-09-08 16:52:38 -04:00
|
|
|
* Creates a new #ClutterAlpha instance, using @timeline as the time
|
|
|
|
* source and @func as the function to compute the alpha(t) value.
|
2006-08-28 13:11:15 -04:00
|
|
|
*
|
2006-09-08 16:52:38 -04:00
|
|
|
* Return value: a new #ClutterAlpha
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
2006-08-28 13:11:15 -04:00
|
|
|
*/
|
2006-09-08 16:52:38 -04:00
|
|
|
ClutterAlpha *
|
|
|
|
clutter_alpha_new (ClutterTimeline *timeline,
|
|
|
|
ClutterAlphaFunc func,
|
|
|
|
gpointer data)
|
2006-08-28 13:11:15 -04:00
|
|
|
{
|
2006-09-08 16:52:38 -04:00
|
|
|
return clutter_alpha_new_full (timeline, func, data, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_alpha_new_full:
|
|
|
|
* @timeline: #ClutterTimeline or %NULL
|
|
|
|
* @func: a #ClutterAlphaFunc
|
|
|
|
* @data: data to be passed to func
|
|
|
|
* @destroy: function to be called when removing the alpha function
|
|
|
|
*
|
|
|
|
* Creates a new #ClutterAlpha instance, using @timeline as the
|
|
|
|
* time source and @func as the function to compute the alpha(t)
|
|
|
|
* value.
|
|
|
|
*
|
|
|
|
* You should use this constructor in bindings or if you want to
|
|
|
|
* let the #ClutterAlpha object control the lifetime of @data.
|
|
|
|
*
|
|
|
|
* Return value: the newly created #ClutterAlpha instance
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
ClutterAlpha *
|
|
|
|
clutter_alpha_new_full (ClutterTimeline *timeline,
|
|
|
|
ClutterAlphaFunc func,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify destroy)
|
|
|
|
{
|
|
|
|
ClutterAlpha *retval;
|
|
|
|
|
|
|
|
g_return_val_if_fail (timeline == NULL || CLUTTER_IS_TIMELINE (timeline), NULL);
|
|
|
|
g_return_val_if_fail (func != NULL, NULL);
|
|
|
|
|
|
|
|
retval = g_object_new (CLUTTER_TYPE_ALPHA,
|
|
|
|
"timeline", timeline,
|
|
|
|
NULL);
|
|
|
|
clutter_alpha_set_func (retval, func, data, destroy);
|
|
|
|
|
|
|
|
return retval;
|
2006-08-28 13:11:15 -04:00
|
|
|
}
|